babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853
  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: string | ArrayBuffer | (string | ArrayBuffer)[], 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: ArrayBuffer, 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. * Multiply the Vector2 coordinates by scale
  2111. * @param scale defines the scaling factor
  2112. * @returns the current updated Vector2
  2113. */
  2114. scaleInPlace(scale: number): Vector2;
  2115. /**
  2116. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2117. * @param scale defines the scaling factor
  2118. * @returns a new Vector2
  2119. */
  2120. scale(scale: number): Vector2;
  2121. /**
  2122. * Scale the current Vector2 values by a factor to a given Vector2
  2123. * @param scale defines the scale factor
  2124. * @param result defines the Vector2 object where to store the result
  2125. * @returns the unmodified current Vector2
  2126. */
  2127. scaleToRef(scale: number, result: Vector2): Vector2;
  2128. /**
  2129. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2130. * @param scale defines the scale factor
  2131. * @param result defines the Vector2 object where to store the result
  2132. * @returns the unmodified current Vector2
  2133. */
  2134. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2135. /**
  2136. * Gets a boolean if two vectors are equals
  2137. * @param otherVector defines the other vector
  2138. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2139. */
  2140. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2141. /**
  2142. * Gets a boolean if two vectors are equals (using an epsilon value)
  2143. * @param otherVector defines the other vector
  2144. * @param epsilon defines the minimal distance to consider equality
  2145. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2146. */
  2147. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2148. /**
  2149. * Gets a new Vector2 from current Vector2 floored values
  2150. * @returns a new Vector2
  2151. */
  2152. floor(): Vector2;
  2153. /**
  2154. * Gets a new Vector2 from current Vector2 floored values
  2155. * @returns a new Vector2
  2156. */
  2157. fract(): Vector2;
  2158. /**
  2159. * Gets the length of the vector
  2160. * @returns the vector length (float)
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Gets the vector squared length
  2165. * @returns the vector squared length (float)
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalize the vector
  2170. * @returns the current updated Vector2
  2171. */
  2172. normalize(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 copied from the Vector2
  2175. * @returns a new Vector2
  2176. */
  2177. clone(): Vector2;
  2178. /**
  2179. * Gets a new Vector2(0, 0)
  2180. * @returns a new Vector2
  2181. */
  2182. static Zero(): Vector2;
  2183. /**
  2184. * Gets a new Vector2(1, 1)
  2185. * @returns a new Vector2
  2186. */
  2187. static One(): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set from the given index element of the given array
  2190. * @param array defines the data source
  2191. * @param offset defines the offset in the data source
  2192. * @returns a new Vector2
  2193. */
  2194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2195. /**
  2196. * Sets "result" from the given index element of the given array
  2197. * @param array defines the data source
  2198. * @param offset defines the offset in the data source
  2199. * @param result defines the target vector
  2200. */
  2201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2202. /**
  2203. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2204. * @param value1 defines 1st point of control
  2205. * @param value2 defines 2nd point of control
  2206. * @param value3 defines 3rd point of control
  2207. * @param value4 defines 4th point of control
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * 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".
  2214. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2215. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2216. * @param value defines the value to clamp
  2217. * @param min defines the lower limit
  2218. * @param max defines the upper limit
  2219. * @returns a new Vector2
  2220. */
  2221. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2222. /**
  2223. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2224. * @param value1 defines the 1st control point
  2225. * @param tangent1 defines the outgoing tangent
  2226. * @param value2 defines the 2nd control point
  2227. * @param tangent2 defines the incoming tangent
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2234. * @param start defines the start vector
  2235. * @param end defines the end vector
  2236. * @param amount defines the interpolation factor
  2237. * @returns a new Vector2
  2238. */
  2239. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2240. /**
  2241. * Gets the dot product of the vector "left" and the vector "right"
  2242. * @param left defines first vector
  2243. * @param right defines second vector
  2244. * @returns the dot product (float)
  2245. */
  2246. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2247. /**
  2248. * Returns a new Vector2 equal to the normalized given vector
  2249. * @param vector defines the vector to normalize
  2250. * @returns a new Vector2
  2251. */
  2252. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2255. * @param left defines 1st vector
  2256. * @param right defines 2nd vector
  2257. * @returns a new Vector2
  2258. */
  2259. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2260. /**
  2261. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2262. * @param left defines 1st vector
  2263. * @param right defines 2nd vector
  2264. * @returns a new Vector2
  2265. */
  2266. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2267. /**
  2268. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2269. * @param vector defines the vector to transform
  2270. * @param transformation defines the matrix to apply
  2271. * @returns a new Vector2
  2272. */
  2273. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2274. /**
  2275. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2276. * @param vector defines the vector to transform
  2277. * @param transformation defines the matrix to apply
  2278. * @param result defines the target vector
  2279. */
  2280. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2281. /**
  2282. * Determines if a given vector is included in a triangle
  2283. * @param p defines the vector to test
  2284. * @param p0 defines 1st triangle point
  2285. * @param p1 defines 2nd triangle point
  2286. * @param p2 defines 3rd triangle point
  2287. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2288. */
  2289. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2290. /**
  2291. * Gets the distance between the vectors "value1" and "value2"
  2292. * @param value1 defines first vector
  2293. * @param value2 defines second vector
  2294. * @returns the distance between vectors
  2295. */
  2296. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2297. /**
  2298. * Returns the squared distance between the vectors "value1" and "value2"
  2299. * @param value1 defines first vector
  2300. * @param value2 defines second vector
  2301. * @returns the squared distance between vectors
  2302. */
  2303. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2304. /**
  2305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2306. * @param value1 defines first vector
  2307. * @param value2 defines second vector
  2308. * @returns a new Vector2
  2309. */
  2310. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2311. /**
  2312. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2313. * @param p defines the middle point
  2314. * @param segA defines one point of the segment
  2315. * @param segB defines the other point of the segment
  2316. * @returns the shortest distance
  2317. */
  2318. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2319. }
  2320. /**
  2321. * Class used to store (x,y,z) vector representation
  2322. * A Vector3 is the main object used in 3D geometry
  2323. * It can represent etiher the coordinates of a point the space, either a direction
  2324. * Reminder: js uses a left handed forward facing system
  2325. */
  2326. export class Vector3 {
  2327. /**
  2328. * Defines the first coordinates (on X axis)
  2329. */
  2330. x: number;
  2331. /**
  2332. * Defines the second coordinates (on Y axis)
  2333. */
  2334. y: number;
  2335. /**
  2336. * Defines the third coordinates (on Z axis)
  2337. */
  2338. z: number;
  2339. private static _UpReadOnly;
  2340. private static _ZeroReadOnly;
  2341. /**
  2342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2343. * @param x defines the first coordinates (on X axis)
  2344. * @param y defines the second coordinates (on Y axis)
  2345. * @param z defines the third coordinates (on Z axis)
  2346. */
  2347. constructor(
  2348. /**
  2349. * Defines the first coordinates (on X axis)
  2350. */
  2351. x?: number,
  2352. /**
  2353. * Defines the second coordinates (on Y axis)
  2354. */
  2355. y?: number,
  2356. /**
  2357. * Defines the third coordinates (on Z axis)
  2358. */
  2359. z?: number);
  2360. /**
  2361. * Creates a string representation of the Vector3
  2362. * @returns a string with the Vector3 coordinates.
  2363. */
  2364. toString(): string;
  2365. /**
  2366. * Gets the class name
  2367. * @returns the string "Vector3"
  2368. */
  2369. getClassName(): string;
  2370. /**
  2371. * Creates the Vector3 hash code
  2372. * @returns a number which tends to be unique between Vector3 instances
  2373. */
  2374. getHashCode(): number;
  2375. /**
  2376. * Creates an array containing three elements : the coordinates of the Vector3
  2377. * @returns a new array of numbers
  2378. */
  2379. asArray(): number[];
  2380. /**
  2381. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2382. * @param array defines the destination array
  2383. * @param index defines the offset in the destination array
  2384. * @returns the current Vector3
  2385. */
  2386. toArray(array: FloatArray, index?: number): Vector3;
  2387. /**
  2388. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2389. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2390. */
  2391. toQuaternion(): Quaternion;
  2392. /**
  2393. * Adds the given vector to the current Vector3
  2394. * @param otherVector defines the second operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2398. /**
  2399. * Adds the given coordinates to the current Vector3
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2406. /**
  2407. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Subtract the given vector from the current Vector3
  2421. * @param otherVector defines the second operand
  2422. * @returns the current updated Vector3
  2423. */
  2424. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2425. /**
  2426. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2427. * @param otherVector defines the second operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2433. * @param otherVector defines the second operand
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns the resulting Vector3
  2444. */
  2445. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2446. /**
  2447. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @param result defines the Vector3 object where to store the result
  2452. * @returns the current Vector3
  2453. */
  2454. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2455. /**
  2456. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2457. * @returns a new Vector3
  2458. */
  2459. negate(): Vector3;
  2460. /**
  2461. * Negate this vector in place
  2462. * @returns this
  2463. */
  2464. negateInPlace(): Vector3;
  2465. /**
  2466. * Multiplies the Vector3 coordinates by the float "scale"
  2467. * @param scale defines the multiplier factor
  2468. * @returns the current updated Vector3
  2469. */
  2470. scaleInPlace(scale: number): Vector3;
  2471. /**
  2472. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2473. * @param scale defines the multiplier factor
  2474. * @returns a new Vector3
  2475. */
  2476. scale(scale: number): Vector3;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2479. * @param scale defines the multiplier factor
  2480. * @param result defines the Vector3 object where to store the result
  2481. * @returns the current Vector3
  2482. */
  2483. scaleToRef(scale: number, result: Vector3): Vector3;
  2484. /**
  2485. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2486. * @param scale defines the scale factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the unmodified current Vector3
  2489. */
  2490. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2493. * @param otherVector defines the second operand
  2494. * @returns true if both vectors are equals
  2495. */
  2496. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2497. /**
  2498. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2499. * @param otherVector defines the second operand
  2500. * @param epsilon defines the minimal distance to define values as equals
  2501. * @returns true if both vectors are distant less than epsilon
  2502. */
  2503. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 coordinates equals the given floats
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns true if both vectors are equals
  2510. */
  2511. equalsToFloats(x: number, y: number, z: number): boolean;
  2512. /**
  2513. * Multiplies the current Vector3 coordinates by the given ones
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2533. * @param x defines the x coordinate of the operand
  2534. * @param y defines the y coordinate of the operand
  2535. * @param z defines the z coordinate of the operand
  2536. * @returns the new Vector3
  2537. */
  2538. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2539. /**
  2540. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2541. * @param otherVector defines the second operand
  2542. * @returns the new Vector3
  2543. */
  2544. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones.
  2554. * @param otherVector defines the second operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. divideInPlace(otherVector: Vector3): Vector3;
  2558. /**
  2559. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2560. * @param other defines the second operand
  2561. * @returns the current updated Vector3
  2562. */
  2563. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2566. * @param other defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2572. * @param x defines the x coordinate of the operand
  2573. * @param y defines the y coordinate of the operand
  2574. * @param z defines the z coordinate of the operand
  2575. * @returns the current updated Vector3
  2576. */
  2577. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2578. /**
  2579. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2580. * @param x defines the x coordinate of the operand
  2581. * @param y defines the y coordinate of the operand
  2582. * @param z defines the z coordinate of the operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2586. /**
  2587. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2588. * Check if is non uniform within a certain amount of decimal places to account for this
  2589. * @param epsilon the amount the values can differ
  2590. * @returns if the the vector is non uniform to a certain number of decimal places
  2591. */
  2592. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2593. /**
  2594. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2595. */
  2596. get isNonUniform(): boolean;
  2597. /**
  2598. * Gets a new Vector3 from current Vector3 floored values
  2599. * @returns a new Vector3
  2600. */
  2601. floor(): Vector3;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. fract(): Vector3;
  2607. /**
  2608. * Gets the length of the Vector3
  2609. * @returns the length of the Vector3
  2610. */
  2611. length(): number;
  2612. /**
  2613. * Gets the squared length of the Vector3
  2614. * @returns squared length of the Vector3
  2615. */
  2616. lengthSquared(): number;
  2617. /**
  2618. * Normalize the current Vector3.
  2619. * Please note that this is an in place operation.
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalize(): Vector3;
  2623. /**
  2624. * Reorders the x y z properties of the vector in place
  2625. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2626. * @returns the current updated vector
  2627. */
  2628. reorderInPlace(order: string): this;
  2629. /**
  2630. * Rotates the vector around 0,0,0 by a quaternion
  2631. * @param quaternion the rotation quaternion
  2632. * @param result vector to store the result
  2633. * @returns the resulting vector
  2634. */
  2635. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2636. /**
  2637. * Rotates a vector around a given point
  2638. * @param quaternion the rotation quaternion
  2639. * @param point the point to rotate around
  2640. * @param result vector to store the result
  2641. * @returns the resulting vector
  2642. */
  2643. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2644. /**
  2645. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2646. * The cross product is then orthogonal to both current and "other"
  2647. * @param other defines the right operand
  2648. * @returns the cross product
  2649. */
  2650. cross(other: Vector3): Vector3;
  2651. /**
  2652. * Normalize the current Vector3 with the given input length.
  2653. * Please note that this is an in place operation.
  2654. * @param len the length of the vector
  2655. * @returns the current updated Vector3
  2656. */
  2657. normalizeFromLength(len: number): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 to a new vector
  2660. * @returns the new Vector3
  2661. */
  2662. normalizeToNew(): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to the reference
  2665. * @param reference define the Vector3 to update
  2666. * @returns the updated Vector3
  2667. */
  2668. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2669. /**
  2670. * Creates a new Vector3 copied from the current Vector3
  2671. * @returns the new Vector3
  2672. */
  2673. clone(): Vector3;
  2674. /**
  2675. * Copies the given vector coordinates to the current Vector3 ones
  2676. * @param source defines the source Vector3
  2677. * @returns the current updated Vector3
  2678. */
  2679. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Copies the given floats to the current Vector3 coordinates
  2682. * @param x defines the x coordinate of the operand
  2683. * @param y defines the y coordinate of the operand
  2684. * @param z defines the z coordinate of the operand
  2685. * @returns the current updated Vector3
  2686. */
  2687. copyFromFloats(x: number, y: number, z: number): Vector3;
  2688. /**
  2689. * Copies the given floats to the current Vector3 coordinates
  2690. * @param x defines the x coordinate of the operand
  2691. * @param y defines the y coordinate of the operand
  2692. * @param z defines the z coordinate of the operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. set(x: number, y: number, z: number): Vector3;
  2696. /**
  2697. * Copies the given float to the current Vector3 coordinates
  2698. * @param v defines the x, y and z coordinates of the operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. setAll(v: number): Vector3;
  2702. /**
  2703. * Get the clip factor between two vectors
  2704. * @param vector0 defines the first operand
  2705. * @param vector1 defines the second operand
  2706. * @param axis defines the axis to use
  2707. * @param size defines the size along the axis
  2708. * @returns the clip factor
  2709. */
  2710. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2711. /**
  2712. * Get angle between two vectors
  2713. * @param vector0 angle between vector0 and vector1
  2714. * @param vector1 angle between vector0 and vector1
  2715. * @param normal direction of the normal
  2716. * @return the angle between vector0 and vector1
  2717. */
  2718. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2719. /**
  2720. * Returns a new Vector3 set from the index "offset" of the given array
  2721. * @param array defines the source array
  2722. * @param offset defines the offset in the source array
  2723. * @returns the new Vector3
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. * @deprecated Please use FromArray instead.
  2732. */
  2733. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2734. /**
  2735. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2736. * @param array defines the source array
  2737. * @param offset defines the offset in the source array
  2738. * @param result defines the Vector3 where to store the result
  2739. */
  2740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. * @deprecated Please use FromArrayToRef instead.
  2747. */
  2748. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2749. /**
  2750. * Sets the given vector "result" with the given floats.
  2751. * @param x defines the x coordinate of the source
  2752. * @param y defines the y coordinate of the source
  2753. * @param z defines the z coordinate of the source
  2754. * @param result defines the Vector3 where to store the result
  2755. */
  2756. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2759. * @returns a new empty Vector3
  2760. */
  2761. static Zero(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2764. * @returns a new unit Vector3
  2765. */
  2766. static One(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2769. * @returns a new up Vector3
  2770. */
  2771. static Up(): Vector3;
  2772. /**
  2773. * Gets a up Vector3 that must not be updated
  2774. */
  2775. static get UpReadOnly(): DeepImmutable<Vector3>;
  2776. /**
  2777. * Gets a zero Vector3 that must not be updated
  2778. */
  2779. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2780. /**
  2781. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2782. * @returns a new down Vector3
  2783. */
  2784. static Down(): Vector3;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2787. * @returns a new forward Vector3
  2788. */
  2789. static Forward(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Backward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2797. * @returns a new right Vector3
  2798. */
  2799. static Right(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2802. * @returns a new left Vector3
  2803. */
  2804. static Left(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2807. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the transformed Vector3
  2811. */
  2812. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2815. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2823. * This method computes tranformed coordinates only, not transformed direction vectors
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2834. * @param vector defines the Vector3 to transform
  2835. * @param transformation defines the transformation matrix
  2836. * @returns the new Vector3
  2837. */
  2838. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2839. /**
  2840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2841. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2842. * @param vector defines the Vector3 to transform
  2843. * @param transformation defines the transformation matrix
  2844. * @param result defines the Vector3 where to store the result
  2845. */
  2846. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2847. /**
  2848. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2849. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2850. * @param x define the x coordinate of the source vector
  2851. * @param y define the y coordinate of the source vector
  2852. * @param z define the z coordinate of the source vector
  2853. * @param transformation defines the transformation matrix
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2857. /**
  2858. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2859. * @param value1 defines the first control point
  2860. * @param value2 defines the second control point
  2861. * @param value3 defines the third control point
  2862. * @param value4 defines the fourth control point
  2863. * @param amount defines the amount on the spline to use
  2864. * @returns the new Vector3
  2865. */
  2866. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2867. /**
  2868. * 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"
  2869. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2870. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2871. * @param value defines the current value
  2872. * @param min defines the lower range value
  2873. * @param max defines the upper range value
  2874. * @returns the new Vector3
  2875. */
  2876. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * 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"
  2879. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2880. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2881. * @param value defines the current value
  2882. * @param min defines the lower range value
  2883. * @param max defines the upper range value
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2887. /**
  2888. * Checks if a given vector is inside a specific range
  2889. * @param v defines the vector to test
  2890. * @param min defines the minimum range
  2891. * @param max defines the maximum range
  2892. */
  2893. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2894. /**
  2895. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2896. * @param value1 defines the first control point
  2897. * @param tangent1 defines the first tangent vector
  2898. * @param value2 defines the second control point
  2899. * @param tangent2 defines the second tangent vector
  2900. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2901. * @returns the new Vector3
  2902. */
  2903. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2904. /**
  2905. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2906. * @param start defines the start value
  2907. * @param end defines the end value
  2908. * @param amount max defines amount between both (between 0 and 1)
  2909. * @returns the new Vector3
  2910. */
  2911. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2914. * @param start defines the start value
  2915. * @param end defines the end value
  2916. * @param amount max defines amount between both (between 0 and 1)
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2920. /**
  2921. * Returns the dot product (float) between the vectors "left" and "right"
  2922. * @param left defines the left operand
  2923. * @param right defines the right operand
  2924. * @returns the dot product
  2925. */
  2926. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2929. * The cross product is then orthogonal to both "left" and "right"
  2930. * @param left defines the left operand
  2931. * @param right defines the right operand
  2932. * @returns the cross product
  2933. */
  2934. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * Sets the given vector "result" with the cross product of "left" and "right"
  2937. * The cross product is then orthogonal to both "left" and "right"
  2938. * @param left defines the left operand
  2939. * @param right defines the right operand
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2943. /**
  2944. * Returns a new Vector3 as the normalization of the given vector
  2945. * @param vector defines the Vector3 to normalize
  2946. * @returns the new Vector3
  2947. */
  2948. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" with the normalization of the given first vector
  2951. * @param vector defines the Vector3 to normalize
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2955. /**
  2956. * Project a Vector3 onto screen space
  2957. * @param vector defines the Vector3 to project
  2958. * @param world defines the world matrix to use
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @param viewport defines the screen viewport to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2964. /** @hidden */
  2965. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param transform defines the transform (view x projection) matrix to use
  2973. * @returns the new Vector3
  2974. */
  2975. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2976. /**
  2977. * Unproject from screen space to object space
  2978. * @param source defines the screen space Vector3 to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @returns the new Vector3
  2985. */
  2986. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Unproject from screen space to object space
  2989. * @param source defines the screen space Vector3 to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Unproject from screen space to object space
  3000. * @param sourceX defines the screen space x coordinate to use
  3001. * @param sourceY defines the screen space y coordinate to use
  3002. * @param sourceZ defines the screen space z coordinate to use
  3003. * @param viewportWidth defines the current width of the viewport
  3004. * @param viewportHeight defines the current height of the viewport
  3005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3006. * @param view defines the view matrix to use
  3007. * @param projection defines the projection matrix to use
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Gets the minimal coordinate values between two Vector3
  3013. * @param left defines the first operand
  3014. * @param right defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Gets the maximal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Returns the distance between the vectors "value1" and "value2"
  3027. * @param value1 defines the first operand
  3028. * @param value2 defines the second operand
  3029. * @returns the distance
  3030. */
  3031. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3032. /**
  3033. * Returns the squared distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the squared distance
  3037. */
  3038. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns a new Vector3 located at the center between "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the new Vector3
  3044. */
  3045. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3046. /**
  3047. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3048. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3049. * to something in order to rotate it from its local system to the given target system
  3050. * Note: axis1, axis2 and axis3 are normalized during this operation
  3051. * @param axis1 defines the first axis
  3052. * @param axis2 defines the second axis
  3053. * @param axis3 defines the third axis
  3054. * @returns a new Vector3
  3055. */
  3056. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3059. * @param axis1 defines the first axis
  3060. * @param axis2 defines the second axis
  3061. * @param axis3 defines the third axis
  3062. * @param ref defines the Vector3 where to store the result
  3063. */
  3064. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3065. }
  3066. /**
  3067. * Vector4 class created for EulerAngle class conversion to Quaternion
  3068. */
  3069. export class Vector4 {
  3070. /** x value of the vector */
  3071. x: number;
  3072. /** y value of the vector */
  3073. y: number;
  3074. /** z value of the vector */
  3075. z: number;
  3076. /** w value of the vector */
  3077. w: number;
  3078. /**
  3079. * Creates a Vector4 object from the given floats.
  3080. * @param x x value of the vector
  3081. * @param y y value of the vector
  3082. * @param z z value of the vector
  3083. * @param w w value of the vector
  3084. */
  3085. constructor(
  3086. /** x value of the vector */
  3087. x: number,
  3088. /** y value of the vector */
  3089. y: number,
  3090. /** z value of the vector */
  3091. z: number,
  3092. /** w value of the vector */
  3093. w: number);
  3094. /**
  3095. * Returns the string with the Vector4 coordinates.
  3096. * @returns a string containing all the vector values
  3097. */
  3098. toString(): string;
  3099. /**
  3100. * Returns the string "Vector4".
  3101. * @returns "Vector4"
  3102. */
  3103. getClassName(): string;
  3104. /**
  3105. * Returns the Vector4 hash code.
  3106. * @returns a unique hash code
  3107. */
  3108. getHashCode(): number;
  3109. /**
  3110. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3111. * @returns the resulting array
  3112. */
  3113. asArray(): number[];
  3114. /**
  3115. * Populates the given array from the given index with the Vector4 coordinates.
  3116. * @param array array to populate
  3117. * @param index index of the array to start at (default: 0)
  3118. * @returns the Vector4.
  3119. */
  3120. toArray(array: FloatArray, index?: number): Vector4;
  3121. /**
  3122. * Adds the given vector to the current Vector4.
  3123. * @param otherVector the vector to add
  3124. * @returns the updated Vector4.
  3125. */
  3126. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3127. /**
  3128. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3129. * @param otherVector the vector to add
  3130. * @returns the resulting vector
  3131. */
  3132. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3135. * @param otherVector the vector to add
  3136. * @param result the vector to store the result
  3137. * @returns the current Vector4.
  3138. */
  3139. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3140. /**
  3141. * Subtract in place the given vector from the current Vector4.
  3142. * @param otherVector the vector to subtract
  3143. * @returns the updated Vector4.
  3144. */
  3145. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3146. /**
  3147. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3148. * @param otherVector the vector to add
  3149. * @returns the new vector with the result
  3150. */
  3151. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3152. /**
  3153. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3154. * @param otherVector the vector to subtract
  3155. * @param result the vector to store the result
  3156. * @returns the current Vector4.
  3157. */
  3158. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3159. /**
  3160. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3161. */
  3162. /**
  3163. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @returns new vector containing the result
  3169. */
  3170. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3171. /**
  3172. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3173. * @param x value to subtract
  3174. * @param y value to subtract
  3175. * @param z value to subtract
  3176. * @param w value to subtract
  3177. * @param result the vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3181. /**
  3182. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3183. * @returns a new vector with the negated values
  3184. */
  3185. negate(): Vector4;
  3186. /**
  3187. * Multiplies the current Vector4 coordinates by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns the updated Vector4.
  3190. */
  3191. scaleInPlace(scale: number): Vector4;
  3192. /**
  3193. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @returns a new vector with the result
  3196. */
  3197. scale(scale: number): Vector4;
  3198. /**
  3199. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3200. * @param scale the number to scale with
  3201. * @param result a vector to store the result in
  3202. * @returns the current Vector4.
  3203. */
  3204. scaleToRef(scale: number, result: Vector4): Vector4;
  3205. /**
  3206. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3207. * @param scale defines the scale factor
  3208. * @param result defines the Vector4 object where to store the result
  3209. * @returns the unmodified current Vector4
  3210. */
  3211. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3214. * @param otherVector the vector to compare against
  3215. * @returns true if they are equal
  3216. */
  3217. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3218. /**
  3219. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3220. * @param otherVector vector to compare against
  3221. * @param epsilon (Default: very small number)
  3222. * @returns true if they are equal
  3223. */
  3224. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3225. /**
  3226. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3227. * @param x x value to compare against
  3228. * @param y y value to compare against
  3229. * @param z z value to compare against
  3230. * @param w w value to compare against
  3231. * @returns true if equal
  3232. */
  3233. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3234. /**
  3235. * Multiplies in place the current Vector4 by the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns the updated Vector4.
  3238. */
  3239. multiplyInPlace(otherVector: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @returns resulting new vector
  3244. */
  3245. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3248. * @param otherVector vector to multiple with
  3249. * @param result vector to store the result
  3250. * @returns the current Vector4.
  3251. */
  3252. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3255. * @param x x value multiply with
  3256. * @param y y value multiply with
  3257. * @param z z value multiply with
  3258. * @param w w value multiply with
  3259. * @returns resulting new vector
  3260. */
  3261. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @returns resulting new vector
  3266. */
  3267. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3270. * @param otherVector vector to devide with
  3271. * @param result vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Divides the current Vector3 coordinates by the given ones.
  3277. * @param otherVector vector to devide with
  3278. * @returns the updated Vector3.
  3279. */
  3280. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3289. * @param other defines the second operand
  3290. * @returns the current updated Vector4
  3291. */
  3292. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3293. /**
  3294. * Gets a new Vector4 from current Vector4 floored values
  3295. * @returns a new Vector4
  3296. */
  3297. floor(): Vector4;
  3298. /**
  3299. * Gets a new Vector4 from current Vector3 floored values
  3300. * @returns a new Vector4
  3301. */
  3302. fract(): Vector4;
  3303. /**
  3304. * Returns the Vector4 length (float).
  3305. * @returns the length
  3306. */
  3307. length(): number;
  3308. /**
  3309. * Returns the Vector4 squared length (float).
  3310. * @returns the length squared
  3311. */
  3312. lengthSquared(): number;
  3313. /**
  3314. * Normalizes in place the Vector4.
  3315. * @returns the updated Vector4.
  3316. */
  3317. normalize(): Vector4;
  3318. /**
  3319. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3320. * @returns this converted to a new vector3
  3321. */
  3322. toVector3(): Vector3;
  3323. /**
  3324. * Returns a new Vector4 copied from the current one.
  3325. * @returns the new cloned vector
  3326. */
  3327. clone(): Vector4;
  3328. /**
  3329. * Updates the current Vector4 with the given one coordinates.
  3330. * @param source the source vector to copy from
  3331. * @returns the updated Vector4.
  3332. */
  3333. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Updates the current Vector4 coordinates with the given floats.
  3336. * @param x float to copy from
  3337. * @param y float to copy from
  3338. * @param z float to copy from
  3339. * @param w float to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to set from
  3346. * @param y float to set from
  3347. * @param z float to set from
  3348. * @param w float to set from
  3349. * @returns the updated Vector4.
  3350. */
  3351. set(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Copies the given float to the current Vector3 coordinates
  3354. * @param v defines the x, y, z and w coordinates of the operand
  3355. * @returns the current updated Vector3
  3356. */
  3357. setAll(v: number): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set from the starting index of the given array.
  3360. * @param array the array to pull values from
  3361. * @param offset the offset into the array to start at
  3362. * @returns the new vector
  3363. */
  3364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3365. /**
  3366. * Updates the given vector "result" from the starting index of the given array.
  3367. * @param array the array to pull values from
  3368. * @param offset the offset into the array to start at
  3369. * @param result the vector to store the result in
  3370. */
  3371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3372. /**
  3373. * Updates the given vector "result" from the starting index of the given Float32Array.
  3374. * @param array the array to pull values from
  3375. * @param offset the offset into the array to start at
  3376. * @param result the vector to store the result in
  3377. */
  3378. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3379. /**
  3380. * Updates the given vector "result" coordinates from the given floats.
  3381. * @param x float to set from
  3382. * @param y float to set from
  3383. * @param z float to set from
  3384. * @param w float to set from
  3385. * @param result the vector to the floats in
  3386. */
  3387. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3388. /**
  3389. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3390. * @returns the new vector
  3391. */
  3392. static Zero(): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3395. * @returns the new vector
  3396. */
  3397. static One(): Vector4;
  3398. /**
  3399. * Returns a new normalized Vector4 from the given one.
  3400. * @param vector the vector to normalize
  3401. * @returns the vector
  3402. */
  3403. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the given vector "result" from the normalization of the given one.
  3406. * @param vector the vector to normalize
  3407. * @param result the vector to store the result in
  3408. */
  3409. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3410. /**
  3411. * Returns a vector with the minimum values from the left and right vectors
  3412. * @param left left vector to minimize
  3413. * @param right right vector to minimize
  3414. * @returns a new vector with the minimum of the left and right vector values
  3415. */
  3416. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a vector with the maximum values from the left and right vectors
  3419. * @param left left vector to maximize
  3420. * @param right right vector to maximize
  3421. * @returns a new vector with the maximum of the left and right vector values
  3422. */
  3423. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns the distance (float) between the vectors "value1" and "value2".
  3426. * @param value1 value to calulate the distance between
  3427. * @param value2 value to calulate the distance between
  3428. * @return the distance between the two vectors
  3429. */
  3430. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3431. /**
  3432. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3433. * @param value1 value to calulate the distance between
  3434. * @param value2 value to calulate the distance between
  3435. * @return the distance between the two vectors squared
  3436. */
  3437. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3438. /**
  3439. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3440. * @param value1 value to calulate the center between
  3441. * @param value2 value to calulate the center between
  3442. * @return the center between the two vectors
  3443. */
  3444. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3447. * This methods computes transformed normalized direction vectors only.
  3448. * @param vector the vector to transform
  3449. * @param transformation the transformation matrix to apply
  3450. * @returns the new vector
  3451. */
  3452. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3453. /**
  3454. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3455. * This methods computes transformed normalized direction vectors only.
  3456. * @param vector the vector to transform
  3457. * @param transformation the transformation matrix to apply
  3458. * @param result the vector to store the result in
  3459. */
  3460. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3461. /**
  3462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param x value to transform
  3465. * @param y value to transform
  3466. * @param z value to transform
  3467. * @param w value to transform
  3468. * @param transformation the transformation matrix to apply
  3469. * @param result the vector to store the results in
  3470. */
  3471. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3472. /**
  3473. * Creates a new Vector4 from a Vector3
  3474. * @param source defines the source data
  3475. * @param w defines the 4th component (default is 0)
  3476. * @returns a new Vector4
  3477. */
  3478. static FromVector3(source: Vector3, w?: number): Vector4;
  3479. }
  3480. /**
  3481. * Class used to store quaternion data
  3482. * @see https://en.wikipedia.org/wiki/Quaternion
  3483. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3484. */
  3485. export class Quaternion {
  3486. /** defines the first component (0 by default) */
  3487. x: number;
  3488. /** defines the second component (0 by default) */
  3489. y: number;
  3490. /** defines the third component (0 by default) */
  3491. z: number;
  3492. /** defines the fourth component (1.0 by default) */
  3493. w: number;
  3494. /**
  3495. * Creates a new Quaternion from the given floats
  3496. * @param x defines the first component (0 by default)
  3497. * @param y defines the second component (0 by default)
  3498. * @param z defines the third component (0 by default)
  3499. * @param w defines the fourth component (1.0 by default)
  3500. */
  3501. constructor(
  3502. /** defines the first component (0 by default) */
  3503. x?: number,
  3504. /** defines the second component (0 by default) */
  3505. y?: number,
  3506. /** defines the third component (0 by default) */
  3507. z?: number,
  3508. /** defines the fourth component (1.0 by default) */
  3509. w?: number);
  3510. /**
  3511. * Gets a string representation for the current quaternion
  3512. * @returns a string with the Quaternion coordinates
  3513. */
  3514. toString(): string;
  3515. /**
  3516. * Gets the class name of the quaternion
  3517. * @returns the string "Quaternion"
  3518. */
  3519. getClassName(): string;
  3520. /**
  3521. * Gets a hash code for this quaternion
  3522. * @returns the quaternion hash code
  3523. */
  3524. getHashCode(): number;
  3525. /**
  3526. * Copy the quaternion to an array
  3527. * @returns a new array populated with 4 elements from the quaternion coordinates
  3528. */
  3529. asArray(): number[];
  3530. /**
  3531. * Check if two quaternions are equals
  3532. * @param otherQuaternion defines the second operand
  3533. * @return true if the current quaternion and the given one coordinates are strictly equals
  3534. */
  3535. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3536. /**
  3537. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3538. * @param otherQuaternion defines the other quaternion
  3539. * @param epsilon defines the minimal distance to consider equality
  3540. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3541. */
  3542. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3543. /**
  3544. * Clone the current quaternion
  3545. * @returns a new quaternion copied from the current one
  3546. */
  3547. clone(): Quaternion;
  3548. /**
  3549. * Copy a quaternion to the current one
  3550. * @param other defines the other quaternion
  3551. * @returns the updated current quaternion
  3552. */
  3553. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Updates the current quaternion with the given float coordinates
  3556. * @param x defines the x coordinate
  3557. * @param y defines the y coordinate
  3558. * @param z defines the z coordinate
  3559. * @param w defines the w coordinate
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3563. /**
  3564. * Updates the current quaternion from the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. set(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Adds two quaternions
  3574. * @param other defines the second operand
  3575. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3576. */
  3577. add(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Add a quaternion to the current one
  3580. * @param other defines the quaternion to add
  3581. * @returns the current quaternion
  3582. */
  3583. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3584. /**
  3585. * Subtract two quaternions
  3586. * @param other defines the second operand
  3587. * @returns a new quaternion as the subtraction result of the given one from the current one
  3588. */
  3589. subtract(other: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3594. */
  3595. scale(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies in place the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns the current modified quaternion
  3607. */
  3608. scaleInPlace(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies two quaternions
  3618. * @param q1 defines the second operand
  3619. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3620. */
  3621. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3624. * @param q1 defines the second operand
  3625. * @param result defines the target quaternion
  3626. * @returns the current quaternion
  3627. */
  3628. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3629. /**
  3630. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3631. * @param q1 defines the second operand
  3632. * @returns the currentupdated quaternion
  3633. */
  3634. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3637. * @param ref defines the target quaternion
  3638. * @returns the current quaternion
  3639. */
  3640. conjugateToRef(ref: Quaternion): Quaternion;
  3641. /**
  3642. * Conjugates in place (1-q) the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. conjugateInPlace(): Quaternion;
  3646. /**
  3647. * Conjugates in place (1-q) the current quaternion
  3648. * @returns a new quaternion
  3649. */
  3650. conjugate(): Quaternion;
  3651. /**
  3652. * Gets length of current quaternion
  3653. * @returns the quaternion length (float)
  3654. */
  3655. length(): number;
  3656. /**
  3657. * Normalize in place the current quaternion
  3658. * @returns the current updated quaternion
  3659. */
  3660. normalize(): Quaternion;
  3661. /**
  3662. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3663. * @param order is a reserved parameter and is ignore for now
  3664. * @returns a new Vector3 containing the Euler angles
  3665. */
  3666. toEulerAngles(order?: string): Vector3;
  3667. /**
  3668. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3669. * @param result defines the vector which will be filled with the Euler angles
  3670. * @param order is a reserved parameter and is ignore for now
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toEulerAnglesToRef(result: Vector3): Quaternion;
  3674. /**
  3675. * Updates the given rotation matrix with the current quaternion values
  3676. * @param result defines the target matrix
  3677. * @returns the current unchanged quaternion
  3678. */
  3679. toRotationMatrix(result: Matrix): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given rotation matrix values
  3682. * @param matrix defines the source matrix
  3683. * @returns the current updated quaternion
  3684. */
  3685. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Creates a new quaternion from a rotation matrix
  3688. * @param matrix defines the source matrix
  3689. * @returns a new quaternion created from the given rotation matrix values
  3690. */
  3691. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3692. /**
  3693. * Updates the given quaternion with the given rotation matrix values
  3694. * @param matrix defines the source matrix
  3695. * @param result defines the target quaternion
  3696. */
  3697. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3698. /**
  3699. * Returns the dot product (float) between the quaternions "left" and "right"
  3700. * @param left defines the left operand
  3701. * @param right defines the right operand
  3702. * @returns the dot product
  3703. */
  3704. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3705. /**
  3706. * Checks if the two quaternions are close to each other
  3707. * @param quat0 defines the first quaternion to check
  3708. * @param quat1 defines the second quaternion to check
  3709. * @returns true if the two quaternions are close to each other
  3710. */
  3711. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3712. /**
  3713. * Creates an empty quaternion
  3714. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3715. */
  3716. static Zero(): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @returns a new quaternion as the inverted current quaternion
  3721. */
  3722. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Inverse a given quaternion
  3725. * @param q defines the source quaternion
  3726. * @param result the quaternion the result will be stored in
  3727. * @returns the result quaternion
  3728. */
  3729. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3730. /**
  3731. * Creates an identity quaternion
  3732. * @returns the identity quaternion
  3733. */
  3734. static Identity(): Quaternion;
  3735. /**
  3736. * Gets a boolean indicating if the given quaternion is identity
  3737. * @param quaternion defines the quaternion to check
  3738. * @returns true if the quaternion is identity
  3739. */
  3740. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Creates a quaternion from a rotation around an axis
  3743. * @param axis defines the axis to use
  3744. * @param angle defines the angle to use
  3745. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3746. */
  3747. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3748. /**
  3749. * Creates a rotation around an axis and stores it into the given quaternion
  3750. * @param axis defines the axis to use
  3751. * @param angle defines the angle to use
  3752. * @param result defines the target quaternion
  3753. * @returns the target quaternion
  3754. */
  3755. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Creates a new quaternion from data stored into an array
  3758. * @param array defines the data source
  3759. * @param offset defines the offset in the source array where the data starts
  3760. * @returns a new quaternion
  3761. */
  3762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @returns the new Quaternion
  3769. */
  3770. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3771. /**
  3772. * Updates a quaternion from Euler rotation angles
  3773. * @param x Pitch
  3774. * @param y Yaw
  3775. * @param z Roll
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3780. /**
  3781. * Create a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @returns the new Quaternion
  3784. */
  3785. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3786. /**
  3787. * Updates a quaternion from Euler rotation vector
  3788. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3789. * @param result the quaternion to store the result
  3790. * @returns the updated quaternion
  3791. */
  3792. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3793. /**
  3794. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @returns the new quaternion
  3799. */
  3800. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3801. /**
  3802. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3803. * @param yaw defines the rotation around Y axis
  3804. * @param pitch defines the rotation around X axis
  3805. * @param roll defines the rotation around Z axis
  3806. * @param result defines the target quaternion
  3807. */
  3808. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3817. /**
  3818. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3819. * @param alpha defines the rotation around first axis
  3820. * @param beta defines the rotation around second axis
  3821. * @param gamma defines the rotation around third axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3825. /**
  3826. * 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)
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3833. /**
  3834. * 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
  3835. * @param axis1 defines the first axis
  3836. * @param axis2 defines the second axis
  3837. * @param axis3 defines the third axis
  3838. * @param ref defines the target quaternion
  3839. */
  3840. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3841. /**
  3842. * Interpolates between two quaternions
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @returns the new interpolated quaternion
  3847. */
  3848. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3849. /**
  3850. * Interpolates between two quaternions and stores it into a target quaternion
  3851. * @param left defines first quaternion
  3852. * @param right defines second quaternion
  3853. * @param amount defines the gradient to use
  3854. * @param result defines the target quaternion
  3855. */
  3856. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3857. /**
  3858. * Interpolate between two quaternions using Hermite interpolation
  3859. * @param value1 defines first quaternion
  3860. * @param tangent1 defines the incoming tangent
  3861. * @param value2 defines second quaternion
  3862. * @param tangent2 defines the outgoing tangent
  3863. * @param amount defines the target quaternion
  3864. * @returns the new interpolated quaternion
  3865. */
  3866. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3867. }
  3868. /**
  3869. * Class used to store matrix data (4x4)
  3870. */
  3871. export class Matrix {
  3872. private static _updateFlagSeed;
  3873. private static _identityReadOnly;
  3874. private _isIdentity;
  3875. private _isIdentityDirty;
  3876. private _isIdentity3x2;
  3877. private _isIdentity3x2Dirty;
  3878. /**
  3879. * Gets the update flag of the matrix which is an unique number for the matrix.
  3880. * It will be incremented every time the matrix data change.
  3881. * You can use it to speed the comparison between two versions of the same matrix.
  3882. */
  3883. updateFlag: number;
  3884. private readonly _m;
  3885. /**
  3886. * Gets the internal data of the matrix
  3887. */
  3888. get m(): DeepImmutable<Float32Array>;
  3889. /** @hidden */
  3890. _markAsUpdated(): void;
  3891. /** @hidden */
  3892. private _updateIdentityStatus;
  3893. /**
  3894. * Creates an empty matrix (filled with zeros)
  3895. */
  3896. constructor();
  3897. /**
  3898. * Check if the current matrix is identity
  3899. * @returns true is the matrix is the identity matrix
  3900. */
  3901. isIdentity(): boolean;
  3902. /**
  3903. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3904. * @returns true is the matrix is the identity matrix
  3905. */
  3906. isIdentityAs3x2(): boolean;
  3907. /**
  3908. * Gets the determinant of the matrix
  3909. * @returns the matrix determinant
  3910. */
  3911. determinant(): number;
  3912. /**
  3913. * Returns the matrix as a Float32Array
  3914. * @returns the matrix underlying array
  3915. */
  3916. toArray(): DeepImmutable<Float32Array>;
  3917. /**
  3918. * Returns the matrix as a Float32Array
  3919. * @returns the matrix underlying array.
  3920. */
  3921. asArray(): DeepImmutable<Float32Array>;
  3922. /**
  3923. * Inverts the current matrix in place
  3924. * @returns the current inverted matrix
  3925. */
  3926. invert(): Matrix;
  3927. /**
  3928. * Sets all the matrix elements to zero
  3929. * @returns the current matrix
  3930. */
  3931. reset(): Matrix;
  3932. /**
  3933. * Adds the current matrix with a second one
  3934. * @param other defines the matrix to add
  3935. * @returns a new matrix as the addition of the current matrix and the given one
  3936. */
  3937. add(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3940. * @param other defines the matrix to add
  3941. * @param result defines the target matrix
  3942. * @returns the current matrix
  3943. */
  3944. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3945. /**
  3946. * Adds in place the given matrix to the current matrix
  3947. * @param other defines the second operand
  3948. * @returns the current updated matrix
  3949. */
  3950. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3951. /**
  3952. * Sets the given matrix to the current inverted Matrix
  3953. * @param other defines the target matrix
  3954. * @returns the unmodified current matrix
  3955. */
  3956. invertToRef(other: Matrix): Matrix;
  3957. /**
  3958. * add a value at the specified position in the current Matrix
  3959. * @param index the index of the value within the matrix. between 0 and 15.
  3960. * @param value the value to be added
  3961. * @returns the current updated matrix
  3962. */
  3963. addAtIndex(index: number, value: number): Matrix;
  3964. /**
  3965. * mutiply the specified position in the current Matrix by a value
  3966. * @param index the index of the value within the matrix. between 0 and 15.
  3967. * @param value the value to be added
  3968. * @returns the current updated matrix
  3969. */
  3970. multiplyAtIndex(index: number, value: number): Matrix;
  3971. /**
  3972. * Inserts the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Adds the translation vector (using 3 floats) in the current matrix
  3981. * @param x defines the 1st component of the translation
  3982. * @param y defines the 2nd component of the translation
  3983. * @param z defines the 3rd component of the translation
  3984. * @returns the current updated matrix
  3985. */
  3986. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector in the current matrix
  3989. * @param vector3 defines the translation to insert
  3990. * @returns the current updated matrix
  3991. */
  3992. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3993. /**
  3994. * Gets the translation value of the current matrix
  3995. * @returns a new Vector3 as the extracted translation from the matrix
  3996. */
  3997. getTranslation(): Vector3;
  3998. /**
  3999. * Fill a Vector3 with the extracted translation from the matrix
  4000. * @param result defines the Vector3 where to store the translation
  4001. * @returns the current matrix
  4002. */
  4003. getTranslationToRef(result: Vector3): Matrix;
  4004. /**
  4005. * Remove rotation and scaling part from the matrix
  4006. * @returns the updated matrix
  4007. */
  4008. removeRotationAndScaling(): Matrix;
  4009. /**
  4010. * Multiply two matrices
  4011. * @param other defines the second operand
  4012. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4013. */
  4014. multiply(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Copy the current matrix from the given one
  4017. * @param other defines the source matrix
  4018. * @returns the current updated matrix
  4019. */
  4020. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4021. /**
  4022. * Populates the given array from the starting index with the current matrix values
  4023. * @param array defines the target array
  4024. * @param offset defines the offset in the target array where to start storing values
  4025. * @returns the current matrix
  4026. */
  4027. copyToArray(array: Float32Array, offset?: number): Matrix;
  4028. /**
  4029. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4030. * @param other defines the second operand
  4031. * @param result defines the matrix where to store the multiplication
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4035. /**
  4036. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4037. * @param other defines the second operand
  4038. * @param result defines the array where to store the multiplication
  4039. * @param offset defines the offset in the target array where to start storing values
  4040. * @returns the current matrix
  4041. */
  4042. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4043. /**
  4044. * Check equality between this matrix and a second one
  4045. * @param value defines the second matrix to compare
  4046. * @returns true is the current matrix and the given one values are strictly equal
  4047. */
  4048. equals(value: DeepImmutable<Matrix>): boolean;
  4049. /**
  4050. * Clone the current matrix
  4051. * @returns a new matrix from the current matrix
  4052. */
  4053. clone(): Matrix;
  4054. /**
  4055. * Returns the name of the current matrix class
  4056. * @returns the string "Matrix"
  4057. */
  4058. getClassName(): string;
  4059. /**
  4060. * Gets the hash code of the current matrix
  4061. * @returns the hash code
  4062. */
  4063. getHashCode(): number;
  4064. /**
  4065. * Decomposes the current Matrix into a translation, rotation and scaling components
  4066. * @param scale defines the scale vector3 given as a reference to update
  4067. * @param rotation defines the rotation quaternion given as a reference to update
  4068. * @param translation defines the translation vector3 given as a reference to update
  4069. * @returns true if operation was successful
  4070. */
  4071. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4072. /**
  4073. * Gets specific row of the matrix
  4074. * @param index defines the number of the row to get
  4075. * @returns the index-th row of the current matrix as a new Vector4
  4076. */
  4077. getRow(index: number): Nullable<Vector4>;
  4078. /**
  4079. * Sets the index-th row of the current matrix to the vector4 values
  4080. * @param index defines the number of the row to set
  4081. * @param row defines the target vector4
  4082. * @returns the updated current matrix
  4083. */
  4084. setRow(index: number, row: Vector4): Matrix;
  4085. /**
  4086. * Compute the transpose of the matrix
  4087. * @returns the new transposed matrix
  4088. */
  4089. transpose(): Matrix;
  4090. /**
  4091. * Compute the transpose of the matrix and store it in a given matrix
  4092. * @param result defines the target matrix
  4093. * @returns the current matrix
  4094. */
  4095. transposeToRef(result: Matrix): Matrix;
  4096. /**
  4097. * Sets the index-th row of the current matrix with the given 4 x float values
  4098. * @param index defines the row index
  4099. * @param x defines the x component to set
  4100. * @param y defines the y component to set
  4101. * @param z defines the z component to set
  4102. * @param w defines the w component to set
  4103. * @returns the updated current matrix
  4104. */
  4105. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4106. /**
  4107. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4108. * @param scale defines the scale factor
  4109. * @returns a new matrix
  4110. */
  4111. scale(scale: number): Matrix;
  4112. /**
  4113. * Scale the current matrix values by a factor to a given result matrix
  4114. * @param scale defines the scale factor
  4115. * @param result defines the matrix to store the result
  4116. * @returns the current matrix
  4117. */
  4118. scaleToRef(scale: number, result: Matrix): Matrix;
  4119. /**
  4120. * Scale the current matrix values by a factor and add the result to a given matrix
  4121. * @param scale defines the scale factor
  4122. * @param result defines the Matrix to store the result
  4123. * @returns the current matrix
  4124. */
  4125. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4126. /**
  4127. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4128. * @param ref matrix to store the result
  4129. */
  4130. toNormalMatrix(ref: Matrix): void;
  4131. /**
  4132. * Gets only rotation part of the current matrix
  4133. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4134. */
  4135. getRotationMatrix(): Matrix;
  4136. /**
  4137. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4138. * @param result defines the target matrix to store data to
  4139. * @returns the current matrix
  4140. */
  4141. getRotationMatrixToRef(result: Matrix): Matrix;
  4142. /**
  4143. * Toggles model matrix from being right handed to left handed in place and vice versa
  4144. */
  4145. toggleModelMatrixHandInPlace(): void;
  4146. /**
  4147. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4148. */
  4149. toggleProjectionMatrixHandInPlace(): void;
  4150. /**
  4151. * Creates a matrix from an array
  4152. * @param array defines the source array
  4153. * @param offset defines an offset in the source array
  4154. * @returns a new Matrix set from the starting index of the given array
  4155. */
  4156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4157. /**
  4158. * Copy the content of an array into a given matrix
  4159. * @param array defines the source array
  4160. * @param offset defines an offset in the source array
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4164. /**
  4165. * Stores an array into a matrix after having multiplied each component by a given factor
  4166. * @param array defines the source array
  4167. * @param offset defines the offset in the source array
  4168. * @param scale defines the scaling factor
  4169. * @param result defines the target matrix
  4170. */
  4171. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4172. /**
  4173. * Gets an identity matrix that must not be updated
  4174. */
  4175. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4176. /**
  4177. * Stores a list of values (16) inside a given matrix
  4178. * @param initialM11 defines 1st value of 1st row
  4179. * @param initialM12 defines 2nd value of 1st row
  4180. * @param initialM13 defines 3rd value of 1st row
  4181. * @param initialM14 defines 4th value of 1st row
  4182. * @param initialM21 defines 1st value of 2nd row
  4183. * @param initialM22 defines 2nd value of 2nd row
  4184. * @param initialM23 defines 3rd value of 2nd row
  4185. * @param initialM24 defines 4th value of 2nd row
  4186. * @param initialM31 defines 1st value of 3rd row
  4187. * @param initialM32 defines 2nd value of 3rd row
  4188. * @param initialM33 defines 3rd value of 3rd row
  4189. * @param initialM34 defines 4th value of 3rd row
  4190. * @param initialM41 defines 1st value of 4th row
  4191. * @param initialM42 defines 2nd value of 4th row
  4192. * @param initialM43 defines 3rd value of 4th row
  4193. * @param initialM44 defines 4th value of 4th row
  4194. * @param result defines the target matrix
  4195. */
  4196. 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;
  4197. /**
  4198. * Creates new matrix from a list of values (16)
  4199. * @param initialM11 defines 1st value of 1st row
  4200. * @param initialM12 defines 2nd value of 1st row
  4201. * @param initialM13 defines 3rd value of 1st row
  4202. * @param initialM14 defines 4th value of 1st row
  4203. * @param initialM21 defines 1st value of 2nd row
  4204. * @param initialM22 defines 2nd value of 2nd row
  4205. * @param initialM23 defines 3rd value of 2nd row
  4206. * @param initialM24 defines 4th value of 2nd row
  4207. * @param initialM31 defines 1st value of 3rd row
  4208. * @param initialM32 defines 2nd value of 3rd row
  4209. * @param initialM33 defines 3rd value of 3rd row
  4210. * @param initialM34 defines 4th value of 3rd row
  4211. * @param initialM41 defines 1st value of 4th row
  4212. * @param initialM42 defines 2nd value of 4th row
  4213. * @param initialM43 defines 3rd value of 4th row
  4214. * @param initialM44 defines 4th value of 4th row
  4215. * @returns the new matrix
  4216. */
  4217. 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;
  4218. /**
  4219. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @returns a new matrix
  4224. */
  4225. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4226. /**
  4227. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4228. * @param scale defines the scale vector3
  4229. * @param rotation defines the rotation quaternion
  4230. * @param translation defines the translation vector3
  4231. * @param result defines the target matrix
  4232. */
  4233. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4234. /**
  4235. * Creates a new identity matrix
  4236. * @returns a new identity matrix
  4237. */
  4238. static Identity(): Matrix;
  4239. /**
  4240. * Creates a new identity matrix and stores the result in a given matrix
  4241. * @param result defines the target matrix
  4242. */
  4243. static IdentityToRef(result: Matrix): void;
  4244. /**
  4245. * Creates a new zero matrix
  4246. * @returns a new zero matrix
  4247. */
  4248. static Zero(): Matrix;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the X axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationX(angle: number): Matrix;
  4255. /**
  4256. * Creates a new matrix as the invert of a given matrix
  4257. * @param source defines the source matrix
  4258. * @returns the new matrix
  4259. */
  4260. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4263. * @param angle defines the angle (in radians) to use
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationXToRef(angle: number, result: Matrix): void;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis
  4269. * @param angle defines the angle (in radians) to use
  4270. * @return the new matrix
  4271. */
  4272. static RotationY(angle: number): Matrix;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4275. * @param angle defines the angle (in radians) to use
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationYToRef(angle: number, result: Matrix): void;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationZ(angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4287. * @param angle defines the angle (in radians) to use
  4288. * @param result defines the target matrix
  4289. */
  4290. static RotationZToRef(angle: number, result: Matrix): void;
  4291. /**
  4292. * Creates a new rotation matrix for "angle" radians around the given axis
  4293. * @param axis defines the axis to use
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4300. * @param axis defines the axis to use
  4301. * @param angle defines the angle (in radians) to use
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4305. /**
  4306. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4307. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4308. * @param from defines the vector to align
  4309. * @param to defines the vector to align to
  4310. * @param result defines the target matrix
  4311. */
  4312. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4313. /**
  4314. * Creates a rotation matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @returns the new rotation matrix
  4319. */
  4320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4321. /**
  4322. * Creates a rotation matrix and stores it in a given matrix
  4323. * @param yaw defines the yaw angle in radians (Y axis)
  4324. * @param pitch defines the pitch angle in radians (X axis)
  4325. * @param roll defines the roll angle in radians (X axis)
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4329. /**
  4330. * Creates a scaling matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @returns the new matrix
  4335. */
  4336. static Scaling(x: number, y: number, z: number): Matrix;
  4337. /**
  4338. * Creates a scaling matrix and stores it in a given matrix
  4339. * @param x defines the scale factor on X axis
  4340. * @param y defines the scale factor on Y axis
  4341. * @param z defines the scale factor on Z axis
  4342. * @param result defines the target matrix
  4343. */
  4344. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4345. /**
  4346. * Creates a translation matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Translation(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a translation matrix and stores it in a given matrix
  4355. * @param x defines the translation on X axis
  4356. * @param y defines the translation on Y axis
  4357. * @param z defines the translationon Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @returns the new matrix
  4367. */
  4368. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4369. /**
  4370. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4371. * @param startValue defines the start value
  4372. * @param endValue defines the end value
  4373. * @param gradient defines the gradient factor
  4374. * @param result defines the Matrix object where to store data
  4375. */
  4376. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4377. /**
  4378. * Builds a new matrix whose values are computed by:
  4379. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4380. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4381. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4382. * @param startValue defines the first matrix
  4383. * @param endValue defines the second matrix
  4384. * @param gradient defines the gradient between the two matrices
  4385. * @returns the new matrix
  4386. */
  4387. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4388. /**
  4389. * Update a matrix to values which are computed by:
  4390. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4391. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4392. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4393. * @param startValue defines the first matrix
  4394. * @param endValue defines the second matrix
  4395. * @param gradient defines the gradient between the two matrices
  4396. * @param result defines the target matrix
  4397. */
  4398. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4399. /**
  4400. * 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"
  4401. * This function works in left handed mode
  4402. * @param eye defines the final position of the entity
  4403. * @param target defines where the entity should look at
  4404. * @param up defines the up vector for the entity
  4405. * @returns the new matrix
  4406. */
  4407. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4408. /**
  4409. * 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".
  4410. * This function works in left handed mode
  4411. * @param eye defines the final position of the entity
  4412. * @param target defines where the entity should look at
  4413. * @param up defines the up vector for the entity
  4414. * @param result defines the target matrix
  4415. */
  4416. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4417. /**
  4418. * 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"
  4419. * This function works in right handed mode
  4420. * @param eye defines the final position of the entity
  4421. * @param target defines where the entity should look at
  4422. * @param up defines the up vector for the entity
  4423. * @returns the new matrix
  4424. */
  4425. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4426. /**
  4427. * 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".
  4428. * This function works in right handed mode
  4429. * @param eye defines the final position of the entity
  4430. * @param target defines where the entity should look at
  4431. * @param up defines the up vector for the entity
  4432. * @param result defines the target matrix
  4433. */
  4434. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4435. /**
  4436. * Create a left-handed orthographic projection matrix
  4437. * @param width defines the viewport width
  4438. * @param height defines the viewport height
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @returns a new matrix as a left-handed orthographic projection matrix
  4442. */
  4443. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4444. /**
  4445. * Store a left-handed orthographic projection to a given matrix
  4446. * @param width defines the viewport width
  4447. * @param height defines the viewport height
  4448. * @param znear defines the near clip plane
  4449. * @param zfar defines the far clip plane
  4450. * @param result defines the target matrix
  4451. */
  4452. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4453. /**
  4454. * Create a left-handed orthographic projection matrix
  4455. * @param left defines the viewport left coordinate
  4456. * @param right defines the viewport right coordinate
  4457. * @param bottom defines the viewport bottom coordinate
  4458. * @param top defines the viewport top coordinate
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Stores a left-handed orthographic projection into a given matrix
  4466. * @param left defines the viewport left coordinate
  4467. * @param right defines the viewport right coordinate
  4468. * @param bottom defines the viewport bottom coordinate
  4469. * @param top defines the viewport top coordinate
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @param result defines the target matrix
  4473. */
  4474. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4475. /**
  4476. * Creates a right-handed orthographic projection matrix
  4477. * @param left defines the viewport left coordinate
  4478. * @param right defines the viewport right coordinate
  4479. * @param bottom defines the viewport bottom coordinate
  4480. * @param top defines the viewport top coordinate
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed orthographic projection matrix
  4484. */
  4485. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed orthographic projection into a given matrix
  4488. * @param left defines the viewport left coordinate
  4489. * @param right defines the viewport right coordinate
  4490. * @param bottom defines the viewport bottom coordinate
  4491. * @param top defines the viewport top coordinate
  4492. * @param znear defines the near clip plane
  4493. * @param zfar defines the far clip plane
  4494. * @param result defines the target matrix
  4495. */
  4496. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4497. /**
  4498. * Creates a left-handed perspective projection matrix
  4499. * @param width defines the viewport width
  4500. * @param height defines the viewport height
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a left-handed perspective projection matrix
  4504. */
  4505. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Creates a left-handed perspective projection matrix
  4508. * @param fov defines the horizontal field of view
  4509. * @param aspect defines the aspect ratio
  4510. * @param znear defines the near clip plane
  4511. * @param zfar defines the far clip plane
  4512. * @returns a new matrix as a left-handed perspective projection matrix
  4513. */
  4514. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4515. /**
  4516. * Stores a left-handed perspective projection into a given matrix
  4517. * @param fov defines the horizontal field of view
  4518. * @param aspect defines the aspect ratio
  4519. * @param znear defines the near clip plane
  4520. * @param zfar defines the far clip plane
  4521. * @param result defines the target matrix
  4522. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4523. */
  4524. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4525. /**
  4526. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4527. * @param fov defines the horizontal field of view
  4528. * @param aspect defines the aspect ratio
  4529. * @param znear defines the near clip plane
  4530. * @param zfar not used as infinity is used as far clip
  4531. * @param result defines the target matrix
  4532. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4533. */
  4534. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4535. /**
  4536. * Creates a right-handed perspective projection matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @returns a new matrix as a right-handed perspective projection matrix
  4542. */
  4543. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4544. /**
  4545. * Stores a right-handed perspective projection into a given matrix
  4546. * @param fov defines the horizontal field of view
  4547. * @param aspect defines the aspect ratio
  4548. * @param znear defines the near clip plane
  4549. * @param zfar defines the far clip plane
  4550. * @param result defines the target matrix
  4551. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4552. */
  4553. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4554. /**
  4555. * Stores a right-handed perspective projection into a given matrix
  4556. * @param fov defines the horizontal field of view
  4557. * @param aspect defines the aspect ratio
  4558. * @param znear defines the near clip plane
  4559. * @param zfar not used as infinity is used as far clip
  4560. * @param result defines the target matrix
  4561. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4562. */
  4563. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4564. /**
  4565. * Stores a perspective projection for WebVR info a given matrix
  4566. * @param fov defines the field of view
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @param result defines the target matrix
  4570. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4571. */
  4572. static PerspectiveFovWebVRToRef(fov: {
  4573. upDegrees: number;
  4574. downDegrees: number;
  4575. leftDegrees: number;
  4576. rightDegrees: number;
  4577. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4578. /**
  4579. * Computes a complete transformation matrix
  4580. * @param viewport defines the viewport to use
  4581. * @param world defines the world matrix
  4582. * @param view defines the view matrix
  4583. * @param projection defines the projection matrix
  4584. * @param zmin defines the near clip plane
  4585. * @param zmax defines the far clip plane
  4586. * @returns the transformation matrix
  4587. */
  4588. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4589. /**
  4590. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4597. * @param matrix defines the matrix to use
  4598. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4599. */
  4600. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4601. /**
  4602. * Compute the transpose of a given matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @returns the new matrix
  4605. */
  4606. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4607. /**
  4608. * Compute the transpose of a matrix and store it in a target matrix
  4609. * @param matrix defines the matrix to transpose
  4610. * @param result defines the target matrix
  4611. */
  4612. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @returns a new matrix
  4617. */
  4618. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4619. /**
  4620. * Computes a reflection matrix from a plane
  4621. * @param plane defines the reflection plane
  4622. * @param result defines the target matrix
  4623. */
  4624. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4625. /**
  4626. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4627. * @param xaxis defines the value of the 1st axis
  4628. * @param yaxis defines the value of the 2nd axis
  4629. * @param zaxis defines the value of the 3rd axis
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4635. * @param quat defines the quaternion to use
  4636. * @param result defines the target matrix
  4637. */
  4638. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4639. }
  4640. /**
  4641. * @hidden
  4642. */
  4643. export class TmpVectors {
  4644. static Vector2: Vector2[];
  4645. static Vector3: Vector3[];
  4646. static Vector4: Vector4[];
  4647. static Quaternion: Quaternion[];
  4648. static Matrix: Matrix[];
  4649. }
  4650. }
  4651. declare module "babylonjs/Maths/math.path" {
  4652. import { DeepImmutable, Nullable } from "babylonjs/types";
  4653. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4654. /**
  4655. * Defines potential orientation for back face culling
  4656. */
  4657. export enum Orientation {
  4658. /**
  4659. * Clockwise
  4660. */
  4661. CW = 0,
  4662. /** Counter clockwise */
  4663. CCW = 1
  4664. }
  4665. /** Class used to represent a Bezier curve */
  4666. export class BezierCurve {
  4667. /**
  4668. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4669. * @param t defines the time
  4670. * @param x1 defines the left coordinate on X axis
  4671. * @param y1 defines the left coordinate on Y axis
  4672. * @param x2 defines the right coordinate on X axis
  4673. * @param y2 defines the right coordinate on Y axis
  4674. * @returns the interpolated value
  4675. */
  4676. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4677. }
  4678. /**
  4679. * Defines angle representation
  4680. */
  4681. export class Angle {
  4682. private _radians;
  4683. /**
  4684. * Creates an Angle object of "radians" radians (float).
  4685. * @param radians the angle in radians
  4686. */
  4687. constructor(radians: number);
  4688. /**
  4689. * Get value in degrees
  4690. * @returns the Angle value in degrees (float)
  4691. */
  4692. degrees(): number;
  4693. /**
  4694. * Get value in radians
  4695. * @returns the Angle value in radians (float)
  4696. */
  4697. radians(): number;
  4698. /**
  4699. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4700. * @param a defines first vector
  4701. * @param b defines second vector
  4702. * @returns a new Angle
  4703. */
  4704. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4705. /**
  4706. * Gets a new Angle object from the given float in radians
  4707. * @param radians defines the angle value in radians
  4708. * @returns a new Angle
  4709. */
  4710. static FromRadians(radians: number): Angle;
  4711. /**
  4712. * Gets a new Angle object from the given float in degrees
  4713. * @param degrees defines the angle value in degrees
  4714. * @returns a new Angle
  4715. */
  4716. static FromDegrees(degrees: number): Angle;
  4717. }
  4718. /**
  4719. * This represents an arc in a 2d space.
  4720. */
  4721. export class Arc2 {
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2;
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2;
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2;
  4728. /**
  4729. * Defines the center point of the arc.
  4730. */
  4731. centerPoint: Vector2;
  4732. /**
  4733. * Defines the radius of the arc.
  4734. */
  4735. radius: number;
  4736. /**
  4737. * Defines the angle of the arc (from mid point to end point).
  4738. */
  4739. angle: Angle;
  4740. /**
  4741. * Defines the start angle of the arc (from start point to middle point).
  4742. */
  4743. startAngle: Angle;
  4744. /**
  4745. * Defines the orientation of the arc (clock wise/counter clock wise).
  4746. */
  4747. orientation: Orientation;
  4748. /**
  4749. * Creates an Arc object from the three given points : start, middle and end.
  4750. * @param startPoint Defines the start point of the arc
  4751. * @param midPoint Defines the midlle point of the arc
  4752. * @param endPoint Defines the end point of the arc
  4753. */
  4754. constructor(
  4755. /** Defines the start point of the arc */
  4756. startPoint: Vector2,
  4757. /** Defines the mid point of the arc */
  4758. midPoint: Vector2,
  4759. /** Defines the end point of the arc */
  4760. endPoint: Vector2);
  4761. }
  4762. /**
  4763. * Represents a 2D path made up of multiple 2D points
  4764. */
  4765. export class Path2 {
  4766. private _points;
  4767. private _length;
  4768. /**
  4769. * If the path start and end point are the same
  4770. */
  4771. closed: boolean;
  4772. /**
  4773. * Creates a Path2 object from the starting 2D coordinates x and y.
  4774. * @param x the starting points x value
  4775. * @param y the starting points y value
  4776. */
  4777. constructor(x: number, y: number);
  4778. /**
  4779. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4780. * @param x the added points x value
  4781. * @param y the added points y value
  4782. * @returns the updated Path2.
  4783. */
  4784. addLineTo(x: number, y: number): Path2;
  4785. /**
  4786. * 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.
  4787. * @param midX middle point x value
  4788. * @param midY middle point y value
  4789. * @param endX end point x value
  4790. * @param endY end point y value
  4791. * @param numberOfSegments (default: 36)
  4792. * @returns the updated Path2.
  4793. */
  4794. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4795. /**
  4796. * Closes the Path2.
  4797. * @returns the Path2.
  4798. */
  4799. close(): Path2;
  4800. /**
  4801. * Gets the sum of the distance between each sequential point in the path
  4802. * @returns the Path2 total length (float).
  4803. */
  4804. length(): number;
  4805. /**
  4806. * Gets the points which construct the path
  4807. * @returns the Path2 internal array of points.
  4808. */
  4809. getPoints(): Vector2[];
  4810. /**
  4811. * Retreives the point at the distance aways from the starting point
  4812. * @param normalizedLengthPosition the length along the path to retreive the point from
  4813. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4814. */
  4815. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4816. /**
  4817. * Creates a new path starting from an x and y position
  4818. * @param x starting x value
  4819. * @param y starting y value
  4820. * @returns a new Path2 starting at the coordinates (x, y).
  4821. */
  4822. static StartingAt(x: number, y: number): Path2;
  4823. }
  4824. /**
  4825. * Represents a 3D path made up of multiple 3D points
  4826. */
  4827. export class Path3D {
  4828. /**
  4829. * an array of Vector3, the curve axis of the Path3D
  4830. */
  4831. path: Vector3[];
  4832. private _curve;
  4833. private _distances;
  4834. private _tangents;
  4835. private _normals;
  4836. private _binormals;
  4837. private _raw;
  4838. private _alignTangentsWithPath;
  4839. private readonly _pointAtData;
  4840. /**
  4841. * new Path3D(path, normal, raw)
  4842. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4843. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4844. * @param path an array of Vector3, the curve axis of the Path3D
  4845. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4846. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4847. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4848. */
  4849. constructor(
  4850. /**
  4851. * an array of Vector3, the curve axis of the Path3D
  4852. */
  4853. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4854. /**
  4855. * Returns the Path3D array of successive Vector3 designing its curve.
  4856. * @returns the Path3D array of successive Vector3 designing its curve.
  4857. */
  4858. getCurve(): Vector3[];
  4859. /**
  4860. * Returns the Path3D array of successive Vector3 designing its curve.
  4861. * @returns the Path3D array of successive Vector3 designing its curve.
  4862. */
  4863. getPoints(): Vector3[];
  4864. /**
  4865. * @returns the computed length (float) of the path.
  4866. */
  4867. length(): number;
  4868. /**
  4869. * Returns an array populated with tangent vectors on each Path3D curve point.
  4870. * @returns an array populated with tangent vectors on each Path3D curve point.
  4871. */
  4872. getTangents(): Vector3[];
  4873. /**
  4874. * Returns an array populated with normal vectors on each Path3D curve point.
  4875. * @returns an array populated with normal vectors on each Path3D curve point.
  4876. */
  4877. getNormals(): Vector3[];
  4878. /**
  4879. * Returns an array populated with binormal vectors on each Path3D curve point.
  4880. * @returns an array populated with binormal vectors on each Path3D curve point.
  4881. */
  4882. getBinormals(): Vector3[];
  4883. /**
  4884. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4885. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4886. */
  4887. getDistances(): number[];
  4888. /**
  4889. * Returns an interpolated point along this path
  4890. * @param position the position of the point along this path, from 0.0 to 1.0
  4891. * @returns a new Vector3 as the point
  4892. */
  4893. getPointAt(position: number): Vector3;
  4894. /**
  4895. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4896. * @param position the position of the point along this path, from 0.0 to 1.0
  4897. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4898. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4899. */
  4900. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4901. /**
  4902. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4903. * @param position the position of the point along this path, from 0.0 to 1.0
  4904. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4905. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4906. */
  4907. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4908. /**
  4909. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4912. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4913. */
  4914. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4915. /**
  4916. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4917. * @param position the position of the point along this path, from 0.0 to 1.0
  4918. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4919. */
  4920. getDistanceAt(position: number): number;
  4921. /**
  4922. * Returns the array index of the previous point of an interpolated point along this path
  4923. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4924. * @returns the array index
  4925. */
  4926. getPreviousPointIndexAt(position: number): number;
  4927. /**
  4928. * 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)
  4929. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4930. * @returns the sub position
  4931. */
  4932. getSubPositionAt(position: number): number;
  4933. /**
  4934. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4935. * @param target the vector of which to get the closest position to
  4936. * @returns the position of the closest virtual point on this path to the target vector
  4937. */
  4938. getClosestPositionTo(target: Vector3): number;
  4939. /**
  4940. * Returns a sub path (slice) of this path
  4941. * @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
  4942. * @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
  4943. * @returns a sub path (slice) of this path
  4944. */
  4945. slice(start?: number, end?: number): Path3D;
  4946. /**
  4947. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4948. * @param path path which all values are copied into the curves points
  4949. * @param firstNormal which should be projected onto the curve
  4950. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4951. * @returns the same object updated.
  4952. */
  4953. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4954. private _compute;
  4955. private _getFirstNonNullVector;
  4956. private _getLastNonNullVector;
  4957. private _normalVector;
  4958. /**
  4959. * Updates the point at data for an interpolated point along this curve
  4960. * @param position the position of the point along this curve, from 0.0 to 1.0
  4961. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4962. * @returns the (updated) point at data
  4963. */
  4964. private _updatePointAtData;
  4965. /**
  4966. * Updates the point at data from the specified parameters
  4967. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4968. * @param point the interpolated point
  4969. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4970. */
  4971. private _setPointAtData;
  4972. /**
  4973. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4974. */
  4975. private _updateInterpolationMatrix;
  4976. }
  4977. /**
  4978. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4979. * A Curve3 is designed from a series of successive Vector3.
  4980. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4981. */
  4982. export class Curve3 {
  4983. private _points;
  4984. private _length;
  4985. /**
  4986. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4987. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4988. * @param v1 (Vector3) the control point
  4989. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4996. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4997. * @param v1 (Vector3) the first control point
  4998. * @param v2 (Vector3) the second control point
  4999. * @param v3 (Vector3) the end point of the Cubic Bezier
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5006. * @param p1 (Vector3) the origin point of the Hermite Spline
  5007. * @param t1 (Vector3) the tangent vector at the origin point
  5008. * @param p2 (Vector3) the end point of the Hermite Spline
  5009. * @param t2 (Vector3) the tangent vector at the end point
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a CatmullRom Spline curve :
  5016. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5017. * @param nbPoints (integer) the wanted number of points between each curve control points
  5018. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5022. /**
  5023. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5024. * A Curve3 is designed from a series of successive Vector3.
  5025. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5026. * @param points points which make up the curve
  5027. */
  5028. constructor(points: Vector3[]);
  5029. /**
  5030. * @returns the Curve3 stored array of successive Vector3
  5031. */
  5032. getPoints(): Vector3[];
  5033. /**
  5034. * @returns the computed length (float) of the curve.
  5035. */
  5036. length(): number;
  5037. /**
  5038. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5039. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5040. * curveA and curveB keep unchanged.
  5041. * @param curve the curve to continue from this curve
  5042. * @returns the newly constructed curve
  5043. */
  5044. continue(curve: DeepImmutable<Curve3>): Curve3;
  5045. private _computeLength;
  5046. }
  5047. }
  5048. declare module "babylonjs/Animations/easing" {
  5049. /**
  5050. * This represents the main contract an easing function should follow.
  5051. * Easing functions are used throughout the animation system.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export interface IEasingFunction {
  5055. /**
  5056. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5057. * of the easing function.
  5058. * The link below provides some of the most common examples of easing functions.
  5059. * @see https://easings.net/
  5060. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5061. * @returns the corresponding value on the curve defined by the easing function
  5062. */
  5063. ease(gradient: number): number;
  5064. }
  5065. /**
  5066. * Base class used for every default easing function.
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class EasingFunction implements IEasingFunction {
  5070. /**
  5071. * Interpolation follows the mathematical formula associated with the easing function.
  5072. */
  5073. static readonly EASINGMODE_EASEIN: number;
  5074. /**
  5075. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5076. */
  5077. static readonly EASINGMODE_EASEOUT: number;
  5078. /**
  5079. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5080. */
  5081. static readonly EASINGMODE_EASEINOUT: number;
  5082. private _easingMode;
  5083. /**
  5084. * Sets the easing mode of the current function.
  5085. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5086. */
  5087. setEasingMode(easingMode: number): void;
  5088. /**
  5089. * Gets the current easing mode.
  5090. * @returns the easing mode
  5091. */
  5092. getEasingMode(): number;
  5093. /**
  5094. * @hidden
  5095. */
  5096. easeInCore(gradient: number): number;
  5097. /**
  5098. * Given an input gradient between 0 and 1, this returns the corresponding value
  5099. * of the easing function.
  5100. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5101. * @returns the corresponding value on the curve defined by the easing function
  5102. */
  5103. ease(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a circle shape (see link below).
  5107. * @see https://easings.net/#easeInCirc
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class CircleEase extends EasingFunction implements IEasingFunction {
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a ease back shape (see link below).
  5116. * @see https://easings.net/#easeInBack
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BackEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the amplitude of the function */
  5121. amplitude: number;
  5122. /**
  5123. * Instantiates a back ease easing
  5124. * @see https://easings.net/#easeInBack
  5125. * @param amplitude Defines the amplitude of the function
  5126. */
  5127. constructor(
  5128. /** Defines the amplitude of the function */
  5129. amplitude?: number);
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a bouncing shape (see link below).
  5135. * @see https://easings.net/#easeInBounce
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class BounceEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of bounces */
  5140. bounces: number;
  5141. /** Defines the amplitude of the bounce */
  5142. bounciness: number;
  5143. /**
  5144. * Instantiates a bounce easing
  5145. * @see https://easings.net/#easeInBounce
  5146. * @param bounces Defines the number of bounces
  5147. * @param bounciness Defines the amplitude of the bounce
  5148. */
  5149. constructor(
  5150. /** Defines the number of bounces */
  5151. bounces?: number,
  5152. /** Defines the amplitude of the bounce */
  5153. bounciness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with a power of 3 shape (see link below).
  5159. * @see https://easings.net/#easeInCubic
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class CubicEase extends EasingFunction implements IEasingFunction {
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with an elastic shape (see link below).
  5168. * @see https://easings.net/#easeInElastic
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5172. /** Defines the number of oscillations*/
  5173. oscillations: number;
  5174. /** Defines the amplitude of the oscillations*/
  5175. springiness: number;
  5176. /**
  5177. * Instantiates an elastic easing function
  5178. * @see https://easings.net/#easeInElastic
  5179. * @param oscillations Defines the number of oscillations
  5180. * @param springiness Defines the amplitude of the oscillations
  5181. */
  5182. constructor(
  5183. /** Defines the number of oscillations*/
  5184. oscillations?: number,
  5185. /** Defines the amplitude of the oscillations*/
  5186. springiness?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with an exponential shape (see link below).
  5192. * @see https://easings.net/#easeInExpo
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the exponent of the function */
  5197. exponent: number;
  5198. /**
  5199. * Instantiates an exponential easing function
  5200. * @see https://easings.net/#easeInExpo
  5201. * @param exponent Defines the exponent of the function
  5202. */
  5203. constructor(
  5204. /** Defines the exponent of the function */
  5205. exponent?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class PowerEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the power of the function */
  5216. power: number;
  5217. /**
  5218. * Instantiates an power base easing function
  5219. * @see https://easings.net/#easeInQuad
  5220. * @param power Defines the power of the function
  5221. */
  5222. constructor(
  5223. /** Defines the power of the function */
  5224. power?: number);
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a power of 2 shape (see link below).
  5230. * @see https://easings.net/#easeInQuad
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power of 4 shape (see link below).
  5239. * @see https://easings.net/#easeInQuart
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5243. /** @hidden */
  5244. easeInCore(gradient: number): number;
  5245. }
  5246. /**
  5247. * Easing function with a power of 5 shape (see link below).
  5248. * @see https://easings.net/#easeInQuint
  5249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5250. */
  5251. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a sin shape (see link below).
  5257. * @see https://easings.net/#easeInSine
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class SineEase extends EasingFunction implements IEasingFunction {
  5261. /** @hidden */
  5262. easeInCore(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a bezier shape (see link below).
  5266. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5270. /** Defines the x component of the start tangent in the bezier curve */
  5271. x1: number;
  5272. /** Defines the y component of the start tangent in the bezier curve */
  5273. y1: number;
  5274. /** Defines the x component of the end tangent in the bezier curve */
  5275. x2: number;
  5276. /** Defines the y component of the end tangent in the bezier curve */
  5277. y2: number;
  5278. /**
  5279. * Instantiates a bezier function
  5280. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5281. * @param x1 Defines the x component of the start tangent in the bezier curve
  5282. * @param y1 Defines the y component of the start tangent in the bezier curve
  5283. * @param x2 Defines the x component of the end tangent in the bezier curve
  5284. * @param y2 Defines the y component of the end tangent in the bezier curve
  5285. */
  5286. constructor(
  5287. /** Defines the x component of the start tangent in the bezier curve */
  5288. x1?: number,
  5289. /** Defines the y component of the start tangent in the bezier curve */
  5290. y1?: number,
  5291. /** Defines the x component of the end tangent in the bezier curve */
  5292. x2?: number,
  5293. /** Defines the y component of the end tangent in the bezier curve */
  5294. y2?: number);
  5295. /** @hidden */
  5296. easeInCore(gradient: number): number;
  5297. }
  5298. }
  5299. declare module "babylonjs/Maths/math.color" {
  5300. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5301. /**
  5302. * Class used to hold a RBG color
  5303. */
  5304. export class Color3 {
  5305. /**
  5306. * Defines the red component (between 0 and 1, default is 0)
  5307. */
  5308. r: number;
  5309. /**
  5310. * Defines the green component (between 0 and 1, default is 0)
  5311. */
  5312. g: number;
  5313. /**
  5314. * Defines the blue component (between 0 and 1, default is 0)
  5315. */
  5316. b: number;
  5317. /**
  5318. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5319. * @param r defines the red component (between 0 and 1, default is 0)
  5320. * @param g defines the green component (between 0 and 1, default is 0)
  5321. * @param b defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. constructor(
  5324. /**
  5325. * Defines the red component (between 0 and 1, default is 0)
  5326. */
  5327. r?: number,
  5328. /**
  5329. * Defines the green component (between 0 and 1, default is 0)
  5330. */
  5331. g?: number,
  5332. /**
  5333. * Defines the blue component (between 0 and 1, default is 0)
  5334. */
  5335. b?: number);
  5336. /**
  5337. * Creates a string with the Color3 current values
  5338. * @returns the string representation of the Color3 object
  5339. */
  5340. toString(): string;
  5341. /**
  5342. * Returns the string "Color3"
  5343. * @returns "Color3"
  5344. */
  5345. getClassName(): string;
  5346. /**
  5347. * Compute the Color3 hash code
  5348. * @returns an unique number that can be used to hash Color3 objects
  5349. */
  5350. getHashCode(): number;
  5351. /**
  5352. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5353. * @param array defines the array where to store the r,g,b components
  5354. * @param index defines an optional index in the target array to define where to start storing values
  5355. * @returns the current Color3 object
  5356. */
  5357. toArray(array: FloatArray, index?: number): Color3;
  5358. /**
  5359. * Returns a new Color4 object from the current Color3 and the given alpha
  5360. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5361. * @returns a new Color4 object
  5362. */
  5363. toColor4(alpha?: number): Color4;
  5364. /**
  5365. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5366. * @returns the new array
  5367. */
  5368. asArray(): number[];
  5369. /**
  5370. * Returns the luminance value
  5371. * @returns a float value
  5372. */
  5373. toLuminance(): number;
  5374. /**
  5375. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3 object
  5378. */
  5379. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines the Color3 object where to store the result
  5384. * @returns the current Color3
  5385. */
  5386. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Determines equality between Color3 objects
  5389. * @param otherColor defines the second operand
  5390. * @returns true if the rgb values are equal to the given ones
  5391. */
  5392. equals(otherColor: DeepImmutable<Color3>): boolean;
  5393. /**
  5394. * Determines equality between the current Color3 object and a set of r,b,g values
  5395. * @param r defines the red component to check
  5396. * @param g defines the green component to check
  5397. * @param b defines the blue component to check
  5398. * @returns true if the rgb values are equal to the given ones
  5399. */
  5400. equalsFloats(r: number, g: number, b: number): boolean;
  5401. /**
  5402. * Multiplies in place each rgb value by scale
  5403. * @param scale defines the scaling factor
  5404. * @returns the updated Color3
  5405. */
  5406. scale(scale: number): Color3;
  5407. /**
  5408. * Multiplies the rgb values by scale and stores the result into "result"
  5409. * @param scale defines the scaling factor
  5410. * @param result defines the Color3 object where to store the result
  5411. * @returns the unmodified current Color3
  5412. */
  5413. scaleToRef(scale: number, result: Color3): Color3;
  5414. /**
  5415. * Scale the current Color3 values by a factor and add the result to a given Color3
  5416. * @param scale defines the scale factor
  5417. * @param result defines color to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5421. /**
  5422. * Clamps the rgb values by the min and max values and stores the result into "result"
  5423. * @param min defines minimum clamping value (default is 0)
  5424. * @param max defines maximum clamping value (default is 1)
  5425. * @param result defines color to store the result into
  5426. * @returns the original Color3
  5427. */
  5428. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5429. /**
  5430. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5431. * @param otherColor defines the second operand
  5432. * @returns the new Color3
  5433. */
  5434. add(otherColor: DeepImmutable<Color3>): Color3;
  5435. /**
  5436. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5437. * @param otherColor defines the second operand
  5438. * @param result defines Color3 object to store the result into
  5439. * @returns the unmodified current Color3
  5440. */
  5441. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5442. /**
  5443. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5444. * @param otherColor defines the second operand
  5445. * @returns the new Color3
  5446. */
  5447. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5448. /**
  5449. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5450. * @param otherColor defines the second operand
  5451. * @param result defines Color3 object to store the result into
  5452. * @returns the unmodified current Color3
  5453. */
  5454. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5455. /**
  5456. * Copy the current object
  5457. * @returns a new Color3 copied the current one
  5458. */
  5459. clone(): Color3;
  5460. /**
  5461. * Copies the rgb values from the source in the current Color3
  5462. * @param source defines the source Color3 object
  5463. * @returns the updated Color3 object
  5464. */
  5465. copyFrom(source: DeepImmutable<Color3>): Color3;
  5466. /**
  5467. * Updates the Color3 rgb values from the given floats
  5468. * @param r defines the red component to read from
  5469. * @param g defines the green component to read from
  5470. * @param b defines the blue component to read from
  5471. * @returns the current Color3 object
  5472. */
  5473. copyFromFloats(r: number, g: number, b: number): Color3;
  5474. /**
  5475. * Updates the Color3 rgb values from the given floats
  5476. * @param r defines the red component to read from
  5477. * @param g defines the green component to read from
  5478. * @param b defines the blue component to read from
  5479. * @returns the current Color3 object
  5480. */
  5481. set(r: number, g: number, b: number): Color3;
  5482. /**
  5483. * Compute the Color3 hexadecimal code as a string
  5484. * @returns a string containing the hexadecimal representation of the Color3 object
  5485. */
  5486. toHexString(): string;
  5487. /**
  5488. * Computes a new Color3 converted from the current one to linear space
  5489. * @returns a new Color3 object
  5490. */
  5491. toLinearSpace(): Color3;
  5492. /**
  5493. * Converts current color in rgb space to HSV values
  5494. * @returns a new color3 representing the HSV values
  5495. */
  5496. toHSV(): Color3;
  5497. /**
  5498. * Converts current color in rgb space to HSV values
  5499. * @param result defines the Color3 where to store the HSV values
  5500. */
  5501. toHSVToRef(result: Color3): void;
  5502. /**
  5503. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the linear space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5508. /**
  5509. * Computes a new Color3 converted from the current one to gamma space
  5510. * @returns a new Color3 object
  5511. */
  5512. toGammaSpace(): Color3;
  5513. /**
  5514. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5515. * @param convertedColor defines the Color3 object where to store the gamma space version
  5516. * @returns the unmodified Color3
  5517. */
  5518. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5519. private static _BlackReadOnly;
  5520. /**
  5521. * Convert Hue, saturation and value to a Color3 (RGB)
  5522. * @param hue defines the hue
  5523. * @param saturation defines the saturation
  5524. * @param value defines the value
  5525. * @param result defines the Color3 where to store the RGB values
  5526. */
  5527. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5528. /**
  5529. * Creates a new Color3 from the string containing valid hexadecimal values
  5530. * @param hex defines a string containing valid hexadecimal values
  5531. * @returns a new Color3 object
  5532. */
  5533. static FromHexString(hex: string): Color3;
  5534. /**
  5535. * Creates a new Color3 from the starting index of the given array
  5536. * @param array defines the source array
  5537. * @param offset defines an offset in the source array
  5538. * @returns a new Color3 object
  5539. */
  5540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5541. /**
  5542. * Creates a new Color3 from integer values (< 256)
  5543. * @param r defines the red component to read from (value between 0 and 255)
  5544. * @param g defines the green component to read from (value between 0 and 255)
  5545. * @param b defines the blue component to read from (value between 0 and 255)
  5546. * @returns a new Color3 object
  5547. */
  5548. static FromInts(r: number, g: number, b: number): Color3;
  5549. /**
  5550. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5551. * @param start defines the start Color3 value
  5552. * @param end defines the end Color3 value
  5553. * @param amount defines the gradient value between start and end
  5554. * @returns a new Color3 object
  5555. */
  5556. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5557. /**
  5558. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5559. * @param left defines the start value
  5560. * @param right defines the end value
  5561. * @param amount defines the gradient factor
  5562. * @param result defines the Color3 object where to store the result
  5563. */
  5564. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5565. /**
  5566. * Returns a Color3 value containing a red color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Red(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a green color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Green(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a blue color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Blue(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a black color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Black(): Color3;
  5585. /**
  5586. * Gets a Color3 value containing a black color that must not be updated
  5587. */
  5588. static get BlackReadOnly(): DeepImmutable<Color3>;
  5589. /**
  5590. * Returns a Color3 value containing a white color
  5591. * @returns a new Color3 object
  5592. */
  5593. static White(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a purple color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Purple(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a magenta color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Magenta(): Color3;
  5604. /**
  5605. * Returns a Color3 value containing a yellow color
  5606. * @returns a new Color3 object
  5607. */
  5608. static Yellow(): Color3;
  5609. /**
  5610. * Returns a Color3 value containing a gray color
  5611. * @returns a new Color3 object
  5612. */
  5613. static Gray(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a teal color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Teal(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a random color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Random(): Color3;
  5624. }
  5625. /**
  5626. * Class used to hold a RBGA color
  5627. */
  5628. export class Color4 {
  5629. /**
  5630. * Defines the red component (between 0 and 1, default is 0)
  5631. */
  5632. r: number;
  5633. /**
  5634. * Defines the green component (between 0 and 1, default is 0)
  5635. */
  5636. g: number;
  5637. /**
  5638. * Defines the blue component (between 0 and 1, default is 0)
  5639. */
  5640. b: number;
  5641. /**
  5642. * Defines the alpha component (between 0 and 1, default is 1)
  5643. */
  5644. a: number;
  5645. /**
  5646. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5647. * @param r defines the red component (between 0 and 1, default is 0)
  5648. * @param g defines the green component (between 0 and 1, default is 0)
  5649. * @param b defines the blue component (between 0 and 1, default is 0)
  5650. * @param a defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. constructor(
  5653. /**
  5654. * Defines the red component (between 0 and 1, default is 0)
  5655. */
  5656. r?: number,
  5657. /**
  5658. * Defines the green component (between 0 and 1, default is 0)
  5659. */
  5660. g?: number,
  5661. /**
  5662. * Defines the blue component (between 0 and 1, default is 0)
  5663. */
  5664. b?: number,
  5665. /**
  5666. * Defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. a?: number);
  5669. /**
  5670. * Adds in place the given Color4 values to the current Color4 object
  5671. * @param right defines the second operand
  5672. * @returns the current updated Color4 object
  5673. */
  5674. addInPlace(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5677. * @returns the new array
  5678. */
  5679. asArray(): number[];
  5680. /**
  5681. * Stores from the starting index in the given array the Color4 successive values
  5682. * @param array defines the array where to store the r,g,b components
  5683. * @param index defines an optional index in the target array to define where to start storing values
  5684. * @returns the current Color4 object
  5685. */
  5686. toArray(array: number[], index?: number): Color4;
  5687. /**
  5688. * Determines equality between Color4 objects
  5689. * @param otherColor defines the second operand
  5690. * @returns true if the rgba values are equal to the given ones
  5691. */
  5692. equals(otherColor: DeepImmutable<Color4>): boolean;
  5693. /**
  5694. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5695. * @param right defines the second operand
  5696. * @returns a new Color4 object
  5697. */
  5698. add(right: DeepImmutable<Color4>): Color4;
  5699. /**
  5700. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5701. * @param right defines the second operand
  5702. * @returns a new Color4 object
  5703. */
  5704. subtract(right: DeepImmutable<Color4>): Color4;
  5705. /**
  5706. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5707. * @param right defines the second operand
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the current Color4 object
  5710. */
  5711. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5712. /**
  5713. * Creates a new Color4 with the current Color4 values multiplied by scale
  5714. * @param scale defines the scaling factor to apply
  5715. * @returns a new Color4 object
  5716. */
  5717. scale(scale: number): Color4;
  5718. /**
  5719. * Multiplies the current Color4 values by scale and stores the result in "result"
  5720. * @param scale defines the scaling factor to apply
  5721. * @param result defines the Color4 object where to store the result
  5722. * @returns the current unmodified Color4
  5723. */
  5724. scaleToRef(scale: number, result: Color4): Color4;
  5725. /**
  5726. * Scale the current Color4 values by a factor and add the result to a given Color4
  5727. * @param scale defines the scale factor
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the unmodified current Color4
  5730. */
  5731. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5732. /**
  5733. * Clamps the rgb values by the min and max values and stores the result into "result"
  5734. * @param min defines minimum clamping value (default is 0)
  5735. * @param max defines maximum clamping value (default is 1)
  5736. * @param result defines color to store the result into.
  5737. * @returns the cuurent Color4
  5738. */
  5739. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5740. /**
  5741. * Multipy an Color4 value by another and return a new Color4 object
  5742. * @param color defines the Color4 value to multiply by
  5743. * @returns a new Color4 object
  5744. */
  5745. multiply(color: Color4): Color4;
  5746. /**
  5747. * Multipy a Color4 value by another and push the result in a reference value
  5748. * @param color defines the Color4 value to multiply by
  5749. * @param result defines the Color4 to fill the result in
  5750. * @returns the result Color4
  5751. */
  5752. multiplyToRef(color: Color4, result: Color4): Color4;
  5753. /**
  5754. * Creates a string with the Color4 current values
  5755. * @returns the string representation of the Color4 object
  5756. */
  5757. toString(): string;
  5758. /**
  5759. * Returns the string "Color4"
  5760. * @returns "Color4"
  5761. */
  5762. getClassName(): string;
  5763. /**
  5764. * Compute the Color4 hash code
  5765. * @returns an unique number that can be used to hash Color4 objects
  5766. */
  5767. getHashCode(): number;
  5768. /**
  5769. * Creates a new Color4 copied from the current one
  5770. * @returns a new Color4 object
  5771. */
  5772. clone(): Color4;
  5773. /**
  5774. * Copies the given Color4 values into the current one
  5775. * @param source defines the source Color4 object
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFrom(source: Color4): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Copies the given float values into the current one
  5790. * @param r defines the red component to read from
  5791. * @param g defines the green component to read from
  5792. * @param b defines the blue component to read from
  5793. * @param a defines the alpha component to read from
  5794. * @returns the current updated Color4 object
  5795. */
  5796. set(r: number, g: number, b: number, a: number): Color4;
  5797. /**
  5798. * Compute the Color4 hexadecimal code as a string
  5799. * @returns a string containing the hexadecimal representation of the Color4 object
  5800. */
  5801. toHexString(): string;
  5802. /**
  5803. * Computes a new Color4 converted from the current one to linear space
  5804. * @returns a new Color4 object
  5805. */
  5806. toLinearSpace(): Color4;
  5807. /**
  5808. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5809. * @param convertedColor defines the Color4 object where to store the linear space version
  5810. * @returns the unmodified Color4
  5811. */
  5812. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5813. /**
  5814. * Computes a new Color4 converted from the current one to gamma space
  5815. * @returns a new Color4 object
  5816. */
  5817. toGammaSpace(): Color4;
  5818. /**
  5819. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5820. * @param convertedColor defines the Color4 object where to store the gamma space version
  5821. * @returns the unmodified Color4
  5822. */
  5823. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5824. /**
  5825. * Creates a new Color4 from the string containing valid hexadecimal values
  5826. * @param hex defines a string containing valid hexadecimal values
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromHexString(hex: string): Color4;
  5830. /**
  5831. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @returns a new Color4 object
  5836. */
  5837. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5838. /**
  5839. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5840. * @param left defines the start value
  5841. * @param right defines the end value
  5842. * @param amount defines the gradient factor
  5843. * @param result defines the Color4 object where to store data
  5844. */
  5845. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5846. /**
  5847. * Creates a new Color4 from a Color3 and an alpha value
  5848. * @param color3 defines the source Color3 to read from
  5849. * @param alpha defines the alpha component (1.0 by default)
  5850. * @returns a new Color4 object
  5851. */
  5852. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5853. /**
  5854. * Creates a new Color4 from the starting index element of the given array
  5855. * @param array defines the source array to read from
  5856. * @param offset defines the offset in the source array
  5857. * @returns a new Color4 object
  5858. */
  5859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5860. /**
  5861. * Creates a new Color3 from integer values (< 256)
  5862. * @param r defines the red component to read from (value between 0 and 255)
  5863. * @param g defines the green component to read from (value between 0 and 255)
  5864. * @param b defines the blue component to read from (value between 0 and 255)
  5865. * @param a defines the alpha component to read from (value between 0 and 255)
  5866. * @returns a new Color3 object
  5867. */
  5868. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5869. /**
  5870. * Check the content of a given array and convert it to an array containing RGBA data
  5871. * If the original array was already containing count * 4 values then it is returned directly
  5872. * @param colors defines the array to check
  5873. * @param count defines the number of RGBA data to expect
  5874. * @returns an array containing count * 4 values (RGBA)
  5875. */
  5876. static CheckColors4(colors: number[], count: number): number[];
  5877. }
  5878. /**
  5879. * @hidden
  5880. */
  5881. export class TmpColors {
  5882. static Color3: Color3[];
  5883. static Color4: Color4[];
  5884. }
  5885. }
  5886. declare module "babylonjs/Animations/animationKey" {
  5887. /**
  5888. * Defines an interface which represents an animation key frame
  5889. */
  5890. export interface IAnimationKey {
  5891. /**
  5892. * Frame of the key frame
  5893. */
  5894. frame: number;
  5895. /**
  5896. * Value at the specifies key frame
  5897. */
  5898. value: any;
  5899. /**
  5900. * The input tangent for the cubic hermite spline
  5901. */
  5902. inTangent?: any;
  5903. /**
  5904. * The output tangent for the cubic hermite spline
  5905. */
  5906. outTangent?: any;
  5907. /**
  5908. * The animation interpolation type
  5909. */
  5910. interpolation?: AnimationKeyInterpolation;
  5911. }
  5912. /**
  5913. * Enum for the animation key frame interpolation type
  5914. */
  5915. export enum AnimationKeyInterpolation {
  5916. /**
  5917. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5918. */
  5919. STEP = 1
  5920. }
  5921. }
  5922. declare module "babylonjs/Animations/animationRange" {
  5923. /**
  5924. * Represents the range of an animation
  5925. */
  5926. export class AnimationRange {
  5927. /**The name of the animation range**/
  5928. name: string;
  5929. /**The starting frame of the animation */
  5930. from: number;
  5931. /**The ending frame of the animation*/
  5932. to: number;
  5933. /**
  5934. * Initializes the range of an animation
  5935. * @param name The name of the animation range
  5936. * @param from The starting frame of the animation
  5937. * @param to The ending frame of the animation
  5938. */
  5939. constructor(
  5940. /**The name of the animation range**/
  5941. name: string,
  5942. /**The starting frame of the animation */
  5943. from: number,
  5944. /**The ending frame of the animation*/
  5945. to: number);
  5946. /**
  5947. * Makes a copy of the animation range
  5948. * @returns A copy of the animation range
  5949. */
  5950. clone(): AnimationRange;
  5951. }
  5952. }
  5953. declare module "babylonjs/Animations/animationEvent" {
  5954. /**
  5955. * Composed of a frame, and an action function
  5956. */
  5957. export class AnimationEvent {
  5958. /** The frame for which the event is triggered **/
  5959. frame: number;
  5960. /** The event to perform when triggered **/
  5961. action: (currentFrame: number) => void;
  5962. /** Specifies if the event should be triggered only once**/
  5963. onlyOnce?: boolean | undefined;
  5964. /**
  5965. * Specifies if the animation event is done
  5966. */
  5967. isDone: boolean;
  5968. /**
  5969. * Initializes the animation event
  5970. * @param frame The frame for which the event is triggered
  5971. * @param action The event to perform when triggered
  5972. * @param onlyOnce Specifies if the event should be triggered only once
  5973. */
  5974. constructor(
  5975. /** The frame for which the event is triggered **/
  5976. frame: number,
  5977. /** The event to perform when triggered **/
  5978. action: (currentFrame: number) => void,
  5979. /** Specifies if the event should be triggered only once**/
  5980. onlyOnce?: boolean | undefined);
  5981. /** @hidden */
  5982. _clone(): AnimationEvent;
  5983. }
  5984. }
  5985. declare module "babylonjs/Behaviors/behavior" {
  5986. import { Nullable } from "babylonjs/types";
  5987. /**
  5988. * Interface used to define a behavior
  5989. */
  5990. export interface Behavior<T> {
  5991. /** gets or sets behavior's name */
  5992. name: string;
  5993. /**
  5994. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5995. */
  5996. init(): void;
  5997. /**
  5998. * Called when the behavior is attached to a target
  5999. * @param target defines the target where the behavior is attached to
  6000. */
  6001. attach(target: T): void;
  6002. /**
  6003. * Called when the behavior is detached from its target
  6004. */
  6005. detach(): void;
  6006. }
  6007. /**
  6008. * Interface implemented by classes supporting behaviors
  6009. */
  6010. export interface IBehaviorAware<T> {
  6011. /**
  6012. * Attach a behavior
  6013. * @param behavior defines the behavior to attach
  6014. * @returns the current host
  6015. */
  6016. addBehavior(behavior: Behavior<T>): T;
  6017. /**
  6018. * Remove a behavior from the current object
  6019. * @param behavior defines the behavior to detach
  6020. * @returns the current host
  6021. */
  6022. removeBehavior(behavior: Behavior<T>): T;
  6023. /**
  6024. * Gets a behavior using its name to search
  6025. * @param name defines the name to search
  6026. * @returns the behavior or null if not found
  6027. */
  6028. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Misc/smartArray" {
  6032. /**
  6033. * Defines an array and its length.
  6034. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6035. */
  6036. export interface ISmartArrayLike<T> {
  6037. /**
  6038. * The data of the array.
  6039. */
  6040. data: Array<T>;
  6041. /**
  6042. * The active length of the array.
  6043. */
  6044. length: number;
  6045. }
  6046. /**
  6047. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6048. */
  6049. export class SmartArray<T> implements ISmartArrayLike<T> {
  6050. /**
  6051. * The full set of data from the array.
  6052. */
  6053. data: Array<T>;
  6054. /**
  6055. * The active length of the array.
  6056. */
  6057. length: number;
  6058. protected _id: number;
  6059. /**
  6060. * Instantiates a Smart Array.
  6061. * @param capacity defines the default capacity of the array.
  6062. */
  6063. constructor(capacity: number);
  6064. /**
  6065. * Pushes a value at the end of the active data.
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Iterates over the active data and apply the lambda to them.
  6071. * @param func defines the action to apply on each value.
  6072. */
  6073. forEach(func: (content: T) => void): void;
  6074. /**
  6075. * Sorts the full sets of data.
  6076. * @param compareFn defines the comparison function to apply.
  6077. */
  6078. sort(compareFn: (a: T, b: T) => number): void;
  6079. /**
  6080. * Resets the active data to an empty array.
  6081. */
  6082. reset(): void;
  6083. /**
  6084. * Releases all the data from the array as well as the array.
  6085. */
  6086. dispose(): void;
  6087. /**
  6088. * Concats the active data with a given array.
  6089. * @param array defines the data to concatenate with.
  6090. */
  6091. concat(array: any): void;
  6092. /**
  6093. * Returns the position of a value in the active data.
  6094. * @param value defines the value to find the index for
  6095. * @returns the index if found in the active data otherwise -1
  6096. */
  6097. indexOf(value: T): number;
  6098. /**
  6099. * Returns whether an element is part of the active data.
  6100. * @param value defines the value to look for
  6101. * @returns true if found in the active data otherwise false
  6102. */
  6103. contains(value: T): boolean;
  6104. private static _GlobalId;
  6105. }
  6106. /**
  6107. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6108. * The data in this array can only be present once
  6109. */
  6110. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6111. private _duplicateId;
  6112. /**
  6113. * Pushes a value at the end of the active data.
  6114. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6115. * @param value defines the object to push in the array.
  6116. */
  6117. push(value: T): void;
  6118. /**
  6119. * Pushes a value at the end of the active data.
  6120. * If the data is already present, it won t be added again
  6121. * @param value defines the object to push in the array.
  6122. * @returns true if added false if it was already present
  6123. */
  6124. pushNoDuplicate(value: T): boolean;
  6125. /**
  6126. * Resets the active data to an empty array.
  6127. */
  6128. reset(): void;
  6129. /**
  6130. * Concats the active data with a given array.
  6131. * This ensures no dupplicate will be present in the result.
  6132. * @param array defines the data to concatenate with.
  6133. */
  6134. concatWithNoDuplicate(array: any): void;
  6135. }
  6136. }
  6137. declare module "babylonjs/Cameras/cameraInputsManager" {
  6138. import { Nullable } from "babylonjs/types";
  6139. import { Camera } from "babylonjs/Cameras/camera";
  6140. /**
  6141. * @ignore
  6142. * This is a list of all the different input types that are available in the application.
  6143. * Fo instance: ArcRotateCameraGamepadInput...
  6144. */
  6145. export var CameraInputTypes: {};
  6146. /**
  6147. * This is the contract to implement in order to create a new input class.
  6148. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6149. */
  6150. export interface ICameraInput<TCamera extends Camera> {
  6151. /**
  6152. * Defines the camera the input is attached to.
  6153. */
  6154. camera: Nullable<TCamera>;
  6155. /**
  6156. * Gets the class name of the current intput.
  6157. * @returns the class name
  6158. */
  6159. getClassName(): string;
  6160. /**
  6161. * Get the friendly name associated with the input class.
  6162. * @returns the input friendly name
  6163. */
  6164. getSimpleName(): string;
  6165. /**
  6166. * Attach the input controls to a specific dom element to get the input from.
  6167. * @param element Defines the element the controls should be listened from
  6168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6169. */
  6170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6171. /**
  6172. * Detach the current controls from the specified dom element.
  6173. * @param element Defines the element to stop listening the inputs from
  6174. */
  6175. detachControl(element: Nullable<HTMLElement>): void;
  6176. /**
  6177. * Update the current camera state depending on the inputs that have been used this frame.
  6178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6179. */
  6180. checkInputs?: () => void;
  6181. }
  6182. /**
  6183. * Represents a map of input types to input instance or input index to input instance.
  6184. */
  6185. export interface CameraInputsMap<TCamera extends Camera> {
  6186. /**
  6187. * Accessor to the input by input type.
  6188. */
  6189. [name: string]: ICameraInput<TCamera>;
  6190. /**
  6191. * Accessor to the input by input index.
  6192. */
  6193. [idx: number]: ICameraInput<TCamera>;
  6194. }
  6195. /**
  6196. * This represents the input manager used within a camera.
  6197. * It helps dealing with all the different kind of input attached to a camera.
  6198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6199. */
  6200. export class CameraInputsManager<TCamera extends Camera> {
  6201. /**
  6202. * Defines the list of inputs attahed to the camera.
  6203. */
  6204. attached: CameraInputsMap<TCamera>;
  6205. /**
  6206. * Defines the dom element the camera is collecting inputs from.
  6207. * This is null if the controls have not been attached.
  6208. */
  6209. attachedElement: Nullable<HTMLElement>;
  6210. /**
  6211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6212. */
  6213. noPreventDefault: boolean;
  6214. /**
  6215. * Defined the camera the input manager belongs to.
  6216. */
  6217. camera: TCamera;
  6218. /**
  6219. * Update the current camera state depending on the inputs that have been used this frame.
  6220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6221. */
  6222. checkInputs: () => void;
  6223. /**
  6224. * Instantiate a new Camera Input Manager.
  6225. * @param camera Defines the camera the input manager blongs to
  6226. */
  6227. constructor(camera: TCamera);
  6228. /**
  6229. * Add an input method to a camera
  6230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6231. * @param input camera input method
  6232. */
  6233. add(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Remove a specific input method from a camera
  6236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6237. * @param inputToRemove camera input method
  6238. */
  6239. remove(inputToRemove: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Remove a specific input type from a camera
  6242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6243. * @param inputType the type of the input to remove
  6244. */
  6245. removeByType(inputType: string): void;
  6246. private _addCheckInputs;
  6247. /**
  6248. * Attach the input controls to the currently attached dom element to listen the events from.
  6249. * @param input Defines the input to attach
  6250. */
  6251. attachInput(input: ICameraInput<TCamera>): void;
  6252. /**
  6253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6254. * @param element Defines the dom element to collect the events from
  6255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6256. */
  6257. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6258. /**
  6259. * Detach the current manager inputs controls from a specific dom element.
  6260. * @param element Defines the dom element to collect the events from
  6261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6262. */
  6263. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6264. /**
  6265. * Rebuild the dynamic inputCheck function from the current list of
  6266. * defined inputs in the manager.
  6267. */
  6268. rebuildInputCheck(): void;
  6269. /**
  6270. * Remove all attached input methods from a camera
  6271. */
  6272. clear(): void;
  6273. /**
  6274. * Serialize the current input manager attached to a camera.
  6275. * This ensures than once parsed,
  6276. * the input associated to the camera will be identical to the current ones
  6277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6278. */
  6279. serialize(serializedCamera: any): void;
  6280. /**
  6281. * Parses an input manager serialized JSON to restore the previous list of inputs
  6282. * and states associated to a camera.
  6283. * @param parsedCamera Defines the JSON to parse
  6284. */
  6285. parse(parsedCamera: any): void;
  6286. }
  6287. }
  6288. declare module "babylonjs/Meshes/buffer" {
  6289. import { Nullable, DataArray } from "babylonjs/types";
  6290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6291. /**
  6292. * Class used to store data that will be store in GPU memory
  6293. */
  6294. export class Buffer {
  6295. private _engine;
  6296. private _buffer;
  6297. /** @hidden */
  6298. _data: Nullable<DataArray>;
  6299. private _updatable;
  6300. private _instanced;
  6301. private _divisor;
  6302. /**
  6303. * Gets the byte stride.
  6304. */
  6305. readonly byteStride: number;
  6306. /**
  6307. * Constructor
  6308. * @param engine the engine
  6309. * @param data the data to use for this buffer
  6310. * @param updatable whether the data is updatable
  6311. * @param stride the stride (optional)
  6312. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6313. * @param instanced whether the buffer is instanced (optional)
  6314. * @param useBytes set to true if the stride in in bytes (optional)
  6315. * @param divisor sets an optional divisor for instances (1 by default)
  6316. */
  6317. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6318. /**
  6319. * Create a new VertexBuffer based on the current buffer
  6320. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6321. * @param offset defines offset in the buffer (0 by default)
  6322. * @param size defines the size in floats of attributes (position is 3 for instance)
  6323. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6324. * @param instanced defines if the vertex buffer contains indexed data
  6325. * @param useBytes defines if the offset and stride are in bytes *
  6326. * @param divisor sets an optional divisor for instances (1 by default)
  6327. * @returns the new vertex buffer
  6328. */
  6329. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6330. /**
  6331. * Gets a boolean indicating if the Buffer is updatable?
  6332. * @returns true if the buffer is updatable
  6333. */
  6334. isUpdatable(): boolean;
  6335. /**
  6336. * Gets current buffer's data
  6337. * @returns a DataArray or null
  6338. */
  6339. getData(): Nullable<DataArray>;
  6340. /**
  6341. * Gets underlying native buffer
  6342. * @returns underlying native buffer
  6343. */
  6344. getBuffer(): Nullable<DataBuffer>;
  6345. /**
  6346. * Gets the stride in float32 units (i.e. byte stride / 4).
  6347. * May not be an integer if the byte stride is not divisible by 4.
  6348. * @returns the stride in float32 units
  6349. * @deprecated Please use byteStride instead.
  6350. */
  6351. getStrideSize(): number;
  6352. /**
  6353. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6354. * @param data defines the data to store
  6355. */
  6356. create(data?: Nullable<DataArray>): void;
  6357. /** @hidden */
  6358. _rebuild(): void;
  6359. /**
  6360. * Update current buffer data
  6361. * @param data defines the data to store
  6362. */
  6363. update(data: DataArray): void;
  6364. /**
  6365. * Updates the data directly.
  6366. * @param data the new data
  6367. * @param offset the new offset
  6368. * @param vertexCount the vertex count (optional)
  6369. * @param useBytes set to true if the offset is in bytes
  6370. */
  6371. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6372. /**
  6373. * Release all resources
  6374. */
  6375. dispose(): void;
  6376. }
  6377. /**
  6378. * Specialized buffer used to store vertex data
  6379. */
  6380. export class VertexBuffer {
  6381. /** @hidden */
  6382. _buffer: Buffer;
  6383. private _kind;
  6384. private _size;
  6385. private _ownsBuffer;
  6386. private _instanced;
  6387. private _instanceDivisor;
  6388. /**
  6389. * The byte type.
  6390. */
  6391. static readonly BYTE: number;
  6392. /**
  6393. * The unsigned byte type.
  6394. */
  6395. static readonly UNSIGNED_BYTE: number;
  6396. /**
  6397. * The short type.
  6398. */
  6399. static readonly SHORT: number;
  6400. /**
  6401. * The unsigned short type.
  6402. */
  6403. static readonly UNSIGNED_SHORT: number;
  6404. /**
  6405. * The integer type.
  6406. */
  6407. static readonly INT: number;
  6408. /**
  6409. * The unsigned integer type.
  6410. */
  6411. static readonly UNSIGNED_INT: number;
  6412. /**
  6413. * The float type.
  6414. */
  6415. static readonly FLOAT: number;
  6416. /**
  6417. * Gets or sets the instance divisor when in instanced mode
  6418. */
  6419. get instanceDivisor(): number;
  6420. set instanceDivisor(value: number);
  6421. /**
  6422. * Gets the byte stride.
  6423. */
  6424. readonly byteStride: number;
  6425. /**
  6426. * Gets the byte offset.
  6427. */
  6428. readonly byteOffset: number;
  6429. /**
  6430. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6431. */
  6432. readonly normalized: boolean;
  6433. /**
  6434. * Gets the data type of each component in the array.
  6435. */
  6436. readonly type: number;
  6437. /**
  6438. * Constructor
  6439. * @param engine the engine
  6440. * @param data the data to use for this vertex buffer
  6441. * @param kind the vertex buffer kind
  6442. * @param updatable whether the data is updatable
  6443. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6444. * @param stride the stride (optional)
  6445. * @param instanced whether the buffer is instanced (optional)
  6446. * @param offset the offset of the data (optional)
  6447. * @param size the number of components (optional)
  6448. * @param type the type of the component (optional)
  6449. * @param normalized whether the data contains normalized data (optional)
  6450. * @param useBytes set to true if stride and offset are in bytes (optional)
  6451. * @param divisor defines the instance divisor to use (1 by default)
  6452. */
  6453. 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);
  6454. /** @hidden */
  6455. _rebuild(): void;
  6456. /**
  6457. * Returns the kind of the VertexBuffer (string)
  6458. * @returns a string
  6459. */
  6460. getKind(): string;
  6461. /**
  6462. * Gets a boolean indicating if the VertexBuffer is updatable?
  6463. * @returns true if the buffer is updatable
  6464. */
  6465. isUpdatable(): boolean;
  6466. /**
  6467. * Gets current buffer's data
  6468. * @returns a DataArray or null
  6469. */
  6470. getData(): Nullable<DataArray>;
  6471. /**
  6472. * Gets underlying native buffer
  6473. * @returns underlying native buffer
  6474. */
  6475. getBuffer(): Nullable<DataBuffer>;
  6476. /**
  6477. * Gets the stride in float32 units (i.e. byte stride / 4).
  6478. * May not be an integer if the byte stride is not divisible by 4.
  6479. * @returns the stride in float32 units
  6480. * @deprecated Please use byteStride instead.
  6481. */
  6482. getStrideSize(): number;
  6483. /**
  6484. * Returns the offset as a multiple of the type byte length.
  6485. * @returns the offset in bytes
  6486. * @deprecated Please use byteOffset instead.
  6487. */
  6488. getOffset(): number;
  6489. /**
  6490. * Returns the number of components per vertex attribute (integer)
  6491. * @returns the size in float
  6492. */
  6493. getSize(): number;
  6494. /**
  6495. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6496. * @returns true if this buffer is instanced
  6497. */
  6498. getIsInstanced(): boolean;
  6499. /**
  6500. * Returns the instancing divisor, zero for non-instanced (integer).
  6501. * @returns a number
  6502. */
  6503. getInstanceDivisor(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: DataArray): void;
  6509. /**
  6510. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6511. * This function will create a new buffer if the current one is not updatable
  6512. * @param data defines the data to store
  6513. */
  6514. update(data: DataArray): void;
  6515. /**
  6516. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6517. * Returns the directly updated WebGLBuffer.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param useBytes set to true if the offset is in bytes
  6521. */
  6522. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6523. /**
  6524. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6525. */
  6526. dispose(): void;
  6527. /**
  6528. * Enumerates each value of this vertex buffer as numbers.
  6529. * @param count the number of values to enumerate
  6530. * @param callback the callback function called for each value
  6531. */
  6532. forEach(count: number, callback: (value: number, index: number) => void): void;
  6533. /**
  6534. * Positions
  6535. */
  6536. static readonly PositionKind: string;
  6537. /**
  6538. * Normals
  6539. */
  6540. static readonly NormalKind: string;
  6541. /**
  6542. * Tangents
  6543. */
  6544. static readonly TangentKind: string;
  6545. /**
  6546. * Texture coordinates
  6547. */
  6548. static readonly UVKind: string;
  6549. /**
  6550. * Texture coordinates 2
  6551. */
  6552. static readonly UV2Kind: string;
  6553. /**
  6554. * Texture coordinates 3
  6555. */
  6556. static readonly UV3Kind: string;
  6557. /**
  6558. * Texture coordinates 4
  6559. */
  6560. static readonly UV4Kind: string;
  6561. /**
  6562. * Texture coordinates 5
  6563. */
  6564. static readonly UV5Kind: string;
  6565. /**
  6566. * Texture coordinates 6
  6567. */
  6568. static readonly UV6Kind: string;
  6569. /**
  6570. * Colors
  6571. */
  6572. static readonly ColorKind: string;
  6573. /**
  6574. * Matrix indices (for bones)
  6575. */
  6576. static readonly MatricesIndicesKind: string;
  6577. /**
  6578. * Matrix weights (for bones)
  6579. */
  6580. static readonly MatricesWeightsKind: string;
  6581. /**
  6582. * Additional matrix indices (for bones)
  6583. */
  6584. static readonly MatricesIndicesExtraKind: string;
  6585. /**
  6586. * Additional matrix weights (for bones)
  6587. */
  6588. static readonly MatricesWeightsExtraKind: string;
  6589. /**
  6590. * Deduces the stride given a kind.
  6591. * @param kind The kind string to deduce
  6592. * @returns The deduced stride
  6593. */
  6594. static DeduceStride(kind: string): number;
  6595. /**
  6596. * Gets the byte length of the given type.
  6597. * @param type the type
  6598. * @returns the number of bytes
  6599. */
  6600. static GetTypeByteLength(type: number): number;
  6601. /**
  6602. * Enumerates each value of the given parameters as numbers.
  6603. * @param data the data to enumerate
  6604. * @param byteOffset the byte offset of the data
  6605. * @param byteStride the byte stride of the data
  6606. * @param componentCount the number of components per element
  6607. * @param componentType the type of the component
  6608. * @param count the number of values to enumerate
  6609. * @param normalized whether the data is normalized
  6610. * @param callback the callback function called for each value
  6611. */
  6612. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6613. private static _GetFloatValue;
  6614. }
  6615. }
  6616. declare module "babylonjs/Collisions/intersectionInfo" {
  6617. import { Nullable } from "babylonjs/types";
  6618. /**
  6619. * @hidden
  6620. */
  6621. export class IntersectionInfo {
  6622. bu: Nullable<number>;
  6623. bv: Nullable<number>;
  6624. distance: number;
  6625. faceId: number;
  6626. subMeshId: number;
  6627. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6628. }
  6629. }
  6630. declare module "babylonjs/Maths/math.plane" {
  6631. import { DeepImmutable } from "babylonjs/types";
  6632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6633. /**
  6634. * Represens a plane by the equation ax + by + cz + d = 0
  6635. */
  6636. export class Plane {
  6637. private static _TmpMatrix;
  6638. /**
  6639. * Normal of the plane (a,b,c)
  6640. */
  6641. normal: Vector3;
  6642. /**
  6643. * d component of the plane
  6644. */
  6645. d: number;
  6646. /**
  6647. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6648. * @param a a component of the plane
  6649. * @param b b component of the plane
  6650. * @param c c component of the plane
  6651. * @param d d component of the plane
  6652. */
  6653. constructor(a: number, b: number, c: number, d: number);
  6654. /**
  6655. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6656. */
  6657. asArray(): number[];
  6658. /**
  6659. * @returns a new plane copied from the current Plane.
  6660. */
  6661. clone(): Plane;
  6662. /**
  6663. * @returns the string "Plane".
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * @returns the Plane hash code.
  6668. */
  6669. getHashCode(): number;
  6670. /**
  6671. * Normalize the current Plane in place.
  6672. * @returns the updated Plane.
  6673. */
  6674. normalize(): Plane;
  6675. /**
  6676. * Applies a transformation the plane and returns the result
  6677. * @param transformation the transformation matrix to be applied to the plane
  6678. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6679. */
  6680. transform(transformation: DeepImmutable<Matrix>): Plane;
  6681. /**
  6682. * Calcualtte the dot product between the point and the plane normal
  6683. * @param point point to calculate the dot product with
  6684. * @returns the dot product (float) of the point coordinates and the plane normal.
  6685. */
  6686. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6687. /**
  6688. * Updates the current Plane from the plane defined by the three given points.
  6689. * @param point1 one of the points used to contruct the plane
  6690. * @param point2 one of the points used to contruct the plane
  6691. * @param point3 one of the points used to contruct the plane
  6692. * @returns the updated Plane.
  6693. */
  6694. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Checks if the plane is facing a given direction
  6697. * @param direction the direction to check if the plane is facing
  6698. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6699. * @returns True is the vector "direction" is the same side than the plane normal.
  6700. */
  6701. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6702. /**
  6703. * Calculates the distance to a point
  6704. * @param point point to calculate distance to
  6705. * @returns the signed distance (float) from the given point to the Plane.
  6706. */
  6707. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Creates a plane from an array
  6710. * @param array the array to create a plane from
  6711. * @returns a new Plane from the given array.
  6712. */
  6713. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6714. /**
  6715. * Creates a plane from three points
  6716. * @param point1 point used to create the plane
  6717. * @param point2 point used to create the plane
  6718. * @param point3 point used to create the plane
  6719. * @returns a new Plane defined by the three given points.
  6720. */
  6721. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6722. /**
  6723. * Creates a plane from an origin point and a normal
  6724. * @param origin origin of the plane to be constructed
  6725. * @param normal normal of the plane to be constructed
  6726. * @returns a new Plane the normal vector to this plane at the given origin point.
  6727. * Note : the vector "normal" is updated because normalized.
  6728. */
  6729. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6730. /**
  6731. * Calculates the distance from a plane and a point
  6732. * @param origin origin of the plane to be constructed
  6733. * @param normal normal of the plane to be constructed
  6734. * @param point point to calculate distance to
  6735. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6736. */
  6737. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6738. }
  6739. }
  6740. declare module "babylonjs/Culling/boundingSphere" {
  6741. import { DeepImmutable } from "babylonjs/types";
  6742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6743. import { Plane } from "babylonjs/Maths/math.plane";
  6744. /**
  6745. * Class used to store bounding sphere information
  6746. */
  6747. export class BoundingSphere {
  6748. /**
  6749. * Gets the center of the bounding sphere in local space
  6750. */
  6751. readonly center: Vector3;
  6752. /**
  6753. * Radius of the bounding sphere in local space
  6754. */
  6755. radius: number;
  6756. /**
  6757. * Gets the center of the bounding sphere in world space
  6758. */
  6759. readonly centerWorld: Vector3;
  6760. /**
  6761. * Radius of the bounding sphere in world space
  6762. */
  6763. radiusWorld: number;
  6764. /**
  6765. * Gets the minimum vector in local space
  6766. */
  6767. readonly minimum: Vector3;
  6768. /**
  6769. * Gets the maximum vector in local space
  6770. */
  6771. readonly maximum: Vector3;
  6772. private _worldMatrix;
  6773. private static readonly TmpVector3;
  6774. /**
  6775. * Creates a new bounding sphere
  6776. * @param min defines the minimum vector (in local space)
  6777. * @param max defines the maximum vector (in local space)
  6778. * @param worldMatrix defines the new world matrix
  6779. */
  6780. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6781. /**
  6782. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6783. * @param min defines the new minimum vector (in local space)
  6784. * @param max defines the new maximum vector (in local space)
  6785. * @param worldMatrix defines the new world matrix
  6786. */
  6787. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6788. /**
  6789. * Scale the current bounding sphere by applying a scale factor
  6790. * @param factor defines the scale factor to apply
  6791. * @returns the current bounding box
  6792. */
  6793. scale(factor: number): BoundingSphere;
  6794. /**
  6795. * Gets the world matrix of the bounding box
  6796. * @returns a matrix
  6797. */
  6798. getWorldMatrix(): DeepImmutable<Matrix>;
  6799. /** @hidden */
  6800. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6801. /**
  6802. * Tests if the bounding sphere is intersecting the frustum planes
  6803. * @param frustumPlanes defines the frustum planes to test
  6804. * @returns true if there is an intersection
  6805. */
  6806. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6807. /**
  6808. * Tests if the bounding sphere center is in between the frustum planes.
  6809. * Used for optimistic fast inclusion.
  6810. * @param frustumPlanes defines the frustum planes to test
  6811. * @returns true if the sphere center is in between the frustum planes
  6812. */
  6813. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6814. /**
  6815. * Tests if a point is inside the bounding sphere
  6816. * @param point defines the point to test
  6817. * @returns true if the point is inside the bounding sphere
  6818. */
  6819. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6820. /**
  6821. * Checks if two sphere intersct
  6822. * @param sphere0 sphere 0
  6823. * @param sphere1 sphere 1
  6824. * @returns true if the speres intersect
  6825. */
  6826. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6827. }
  6828. }
  6829. declare module "babylonjs/Culling/boundingBox" {
  6830. import { DeepImmutable } from "babylonjs/types";
  6831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6832. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6833. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6834. import { Plane } from "babylonjs/Maths/math.plane";
  6835. /**
  6836. * Class used to store bounding box information
  6837. */
  6838. export class BoundingBox implements ICullable {
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in local space
  6841. */
  6842. readonly vectors: Vector3[];
  6843. /**
  6844. * Gets the center of the bounding box in local space
  6845. */
  6846. readonly center: Vector3;
  6847. /**
  6848. * Gets the center of the bounding box in world space
  6849. */
  6850. readonly centerWorld: Vector3;
  6851. /**
  6852. * Gets the extend size in local space
  6853. */
  6854. readonly extendSize: Vector3;
  6855. /**
  6856. * Gets the extend size in world space
  6857. */
  6858. readonly extendSizeWorld: Vector3;
  6859. /**
  6860. * Gets the OBB (object bounding box) directions
  6861. */
  6862. readonly directions: Vector3[];
  6863. /**
  6864. * Gets the 8 vectors representing the bounding box in world space
  6865. */
  6866. readonly vectorsWorld: Vector3[];
  6867. /**
  6868. * Gets the minimum vector in world space
  6869. */
  6870. readonly minimumWorld: Vector3;
  6871. /**
  6872. * Gets the maximum vector in world space
  6873. */
  6874. readonly maximumWorld: Vector3;
  6875. /**
  6876. * Gets the minimum vector in local space
  6877. */
  6878. readonly minimum: Vector3;
  6879. /**
  6880. * Gets the maximum vector in local space
  6881. */
  6882. readonly maximum: Vector3;
  6883. private _worldMatrix;
  6884. private static readonly TmpVector3;
  6885. /**
  6886. * @hidden
  6887. */
  6888. _tag: number;
  6889. /**
  6890. * Creates a new bounding box
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding box by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingBox;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(world: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding box is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding box is entirely inside the frustum planes
  6924. * @param frustumPlanes defines the frustum planes to test
  6925. * @returns true if there is an inclusion
  6926. */
  6927. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6928. /**
  6929. * Tests if a point is inside the bounding box
  6930. * @param point defines the point to test
  6931. * @returns true if the point is inside the bounding box
  6932. */
  6933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6934. /**
  6935. * Tests if the bounding box intersects with a bounding sphere
  6936. * @param sphere defines the sphere to test
  6937. * @returns true if there is an intersection
  6938. */
  6939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6940. /**
  6941. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6942. * @param min defines the min vector to use
  6943. * @param max defines the max vector to use
  6944. * @returns true if there is an intersection
  6945. */
  6946. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Tests if two bounding boxes are intersections
  6949. * @param box0 defines the first box to test
  6950. * @param box1 defines the second box to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6954. /**
  6955. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6956. * @param minPoint defines the minimum vector of the bounding box
  6957. * @param maxPoint defines the maximum vector of the bounding box
  6958. * @param sphereCenter defines the sphere center
  6959. * @param sphereRadius defines the sphere radius
  6960. * @returns true if there is an intersection
  6961. */
  6962. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6963. /**
  6964. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6965. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @return true if there is an inclusion
  6968. */
  6969. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6973. * @param frustumPlanes defines the frustum planes to test
  6974. * @return true if there is an intersection
  6975. */
  6976. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6977. }
  6978. }
  6979. declare module "babylonjs/Collisions/collider" {
  6980. import { Nullable, IndicesArray } from "babylonjs/types";
  6981. import { Vector3 } from "babylonjs/Maths/math.vector";
  6982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6983. import { Plane } from "babylonjs/Maths/math.plane";
  6984. /** @hidden */
  6985. export class Collider {
  6986. /** Define if a collision was found */
  6987. collisionFound: boolean;
  6988. /**
  6989. * Define last intersection point in local space
  6990. */
  6991. intersectionPoint: Vector3;
  6992. /**
  6993. * Define last collided mesh
  6994. */
  6995. collidedMesh: Nullable<AbstractMesh>;
  6996. private _collisionPoint;
  6997. private _planeIntersectionPoint;
  6998. private _tempVector;
  6999. private _tempVector2;
  7000. private _tempVector3;
  7001. private _tempVector4;
  7002. private _edge;
  7003. private _baseToVertex;
  7004. private _destinationPoint;
  7005. private _slidePlaneNormal;
  7006. private _displacementVector;
  7007. /** @hidden */
  7008. _radius: Vector3;
  7009. /** @hidden */
  7010. _retry: number;
  7011. private _velocity;
  7012. private _basePoint;
  7013. private _epsilon;
  7014. /** @hidden */
  7015. _velocityWorldLength: number;
  7016. /** @hidden */
  7017. _basePointWorld: Vector3;
  7018. private _velocityWorld;
  7019. private _normalizedVelocity;
  7020. /** @hidden */
  7021. _initialVelocity: Vector3;
  7022. /** @hidden */
  7023. _initialPosition: Vector3;
  7024. private _nearestDistance;
  7025. private _collisionMask;
  7026. get collisionMask(): number;
  7027. set collisionMask(mask: number);
  7028. /**
  7029. * Gets the plane normal used to compute the sliding response (in local space)
  7030. */
  7031. get slidePlaneNormal(): Vector3;
  7032. /** @hidden */
  7033. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */
  7035. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7036. /** @hidden */
  7037. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7038. /** @hidden */
  7039. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _getResponse(pos: Vector3, vel: Vector3): void;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingInfo" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7050. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. import { Collider } from "babylonjs/Collisions/collider";
  7053. /**
  7054. * Interface for cullable objects
  7055. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7056. */
  7057. export interface ICullable {
  7058. /**
  7059. * Checks if the object or part of the object is in the frustum
  7060. * @param frustumPlanes Camera near/planes
  7061. * @returns true if the object is in frustum otherwise false
  7062. */
  7063. isInFrustum(frustumPlanes: Plane[]): boolean;
  7064. /**
  7065. * Checks if a cullable object (mesh...) is in the camera frustum
  7066. * Unlike isInFrustum this cheks the full bounding box
  7067. * @param frustumPlanes Camera near/planes
  7068. * @returns true if the object is in frustum otherwise false
  7069. */
  7070. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7071. }
  7072. /**
  7073. * Info for a bounding data of a mesh
  7074. */
  7075. export class BoundingInfo implements ICullable {
  7076. /**
  7077. * Bounding box for the mesh
  7078. */
  7079. readonly boundingBox: BoundingBox;
  7080. /**
  7081. * Bounding sphere for the mesh
  7082. */
  7083. readonly boundingSphere: BoundingSphere;
  7084. private _isLocked;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Constructs bounding info
  7088. * @param minimum min vector of the bounding box/sphere
  7089. * @param maximum max vector of the bounding box/sphere
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * min vector of the bounding box/sphere
  7102. */
  7103. get minimum(): Vector3;
  7104. /**
  7105. * max vector of the bounding box/sphere
  7106. */
  7107. get maximum(): Vector3;
  7108. /**
  7109. * If the info is locked and won't be updated to avoid perf overhead
  7110. */
  7111. get isLocked(): boolean;
  7112. set isLocked(value: boolean);
  7113. /**
  7114. * Updates the bounding sphere and box
  7115. * @param world world matrix to be used to update
  7116. */
  7117. update(world: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7120. * @param center New center of the bounding info
  7121. * @param extend New extend of the bounding info
  7122. * @returns the current bounding info
  7123. */
  7124. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7125. /**
  7126. * Scale the current bounding info by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding info
  7129. */
  7130. scale(factor: number): BoundingInfo;
  7131. /**
  7132. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7133. * @param frustumPlanes defines the frustum to test
  7134. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7135. * @returns true if the bounding info is in the frustum planes
  7136. */
  7137. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7138. /**
  7139. * Gets the world distance between the min and max points of the bounding box
  7140. */
  7141. get diagonalLength(): number;
  7142. /**
  7143. * Checks if a cullable object (mesh...) is in the camera frustum
  7144. * Unlike isInFrustum this cheks the full bounding box
  7145. * @param frustumPlanes Camera near/planes
  7146. * @returns true if the object is in frustum otherwise false
  7147. */
  7148. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. /** @hidden */
  7150. _checkCollision(collider: Collider): boolean;
  7151. /**
  7152. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7153. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7154. * @param point the point to check intersection with
  7155. * @returns if the point intersects
  7156. */
  7157. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7158. /**
  7159. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7160. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7161. * @param boundingInfo the bounding info to check intersection with
  7162. * @param precise if the intersection should be done using OBB
  7163. * @returns if the bounding info intersects
  7164. */
  7165. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7166. }
  7167. }
  7168. declare module "babylonjs/Maths/math.functions" {
  7169. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7170. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7171. /**
  7172. * Extracts minimum and maximum values from a list of indexed positions
  7173. * @param positions defines the positions to use
  7174. * @param indices defines the indices to the positions
  7175. * @param indexStart defines the start index
  7176. * @param indexCount defines the end index
  7177. * @param bias defines bias value to add to the result
  7178. * @return minimum and maximum values
  7179. */
  7180. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7181. minimum: Vector3;
  7182. maximum: Vector3;
  7183. };
  7184. /**
  7185. * Extracts minimum and maximum values from a list of positions
  7186. * @param positions defines the positions to use
  7187. * @param start defines the start index in the positions array
  7188. * @param count defines the number of positions to handle
  7189. * @param bias defines bias value to add to the result
  7190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7191. * @return minimum and maximum values
  7192. */
  7193. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7194. minimum: Vector3;
  7195. maximum: Vector3;
  7196. };
  7197. }
  7198. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7200. /** @hidden */
  7201. export class WebGLDataBuffer extends DataBuffer {
  7202. private _buffer;
  7203. constructor(resource: WebGLBuffer);
  7204. get underlyingResource(): any;
  7205. }
  7206. }
  7207. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7208. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7209. import { Nullable } from "babylonjs/types";
  7210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7211. /** @hidden */
  7212. export class WebGLPipelineContext implements IPipelineContext {
  7213. engine: ThinEngine;
  7214. program: Nullable<WebGLProgram>;
  7215. context?: WebGLRenderingContext;
  7216. vertexShader?: WebGLShader;
  7217. fragmentShader?: WebGLShader;
  7218. isParallelCompiled: boolean;
  7219. onCompiled?: () => void;
  7220. transformFeedback?: WebGLTransformFeedback | null;
  7221. vertexCompilationError: Nullable<string>;
  7222. fragmentCompilationError: Nullable<string>;
  7223. programLinkError: Nullable<string>;
  7224. programValidationError: Nullable<string>;
  7225. get isAsync(): boolean;
  7226. get isReady(): boolean;
  7227. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7228. }
  7229. }
  7230. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7231. import { FloatArray, Nullable } from "babylonjs/types";
  7232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7234. module "babylonjs/Engines/thinEngine" {
  7235. interface ThinEngine {
  7236. /**
  7237. * Create an uniform buffer
  7238. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7239. * @param elements defines the content of the uniform buffer
  7240. * @returns the webGL uniform buffer
  7241. */
  7242. createUniformBuffer(elements: FloatArray): DataBuffer;
  7243. /**
  7244. * Create a dynamic uniform buffer
  7245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7246. * @param elements defines the content of the uniform buffer
  7247. * @returns the webGL uniform buffer
  7248. */
  7249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7250. /**
  7251. * Update an existing uniform buffer
  7252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7253. * @param uniformBuffer defines the target uniform buffer
  7254. * @param elements defines the content to update
  7255. * @param offset defines the offset in the uniform buffer where update should start
  7256. * @param count defines the size of the data to update
  7257. */
  7258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7259. /**
  7260. * Bind an uniform buffer to the current webGL context
  7261. * @param buffer defines the buffer to bind
  7262. */
  7263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7264. /**
  7265. * Bind a buffer to the current webGL context at a given location
  7266. * @param buffer defines the buffer to bind
  7267. * @param location defines the index where to bind the buffer
  7268. */
  7269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7270. /**
  7271. * Bind a specific block at a given index in a specific shader program
  7272. * @param pipelineContext defines the pipeline context to use
  7273. * @param blockName defines the block name
  7274. * @param index defines the index where to bind the block
  7275. */
  7276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7277. }
  7278. }
  7279. }
  7280. declare module "babylonjs/Materials/uniformBuffer" {
  7281. import { Nullable, FloatArray } from "babylonjs/types";
  7282. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7283. import { Engine } from "babylonjs/Engines/engine";
  7284. import { Effect } from "babylonjs/Materials/effect";
  7285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7287. import { Color3 } from "babylonjs/Maths/math.color";
  7288. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7289. /**
  7290. * Uniform buffer objects.
  7291. *
  7292. * Handles blocks of uniform on the GPU.
  7293. *
  7294. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7295. *
  7296. * For more information, please refer to :
  7297. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7298. */
  7299. export class UniformBuffer {
  7300. private _engine;
  7301. private _buffer;
  7302. private _data;
  7303. private _bufferData;
  7304. private _dynamic?;
  7305. private _uniformLocations;
  7306. private _uniformSizes;
  7307. private _uniformLocationPointer;
  7308. private _needSync;
  7309. private _noUBO;
  7310. private _currentEffect;
  7311. /** @hidden */
  7312. _alreadyBound: boolean;
  7313. private static _MAX_UNIFORM_SIZE;
  7314. private static _tempBuffer;
  7315. /**
  7316. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7321. /**
  7322. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a single float in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateFloat: (name: string, x: number) => void;
  7333. /**
  7334. * Lambda to Update a vec2 of float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7339. /**
  7340. * Lambda to Update a vec3 of float in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec4 of float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateMatrix: (name: string, mat: Matrix) => void;
  7357. /**
  7358. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateVector3: (name: string, vector: Vector3) => void;
  7363. /**
  7364. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateVector4: (name: string, vector: Vector4) => void;
  7369. /**
  7370. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7375. /**
  7376. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7381. /**
  7382. * Instantiates a new Uniform buffer objects.
  7383. *
  7384. * Handles blocks of uniform on the GPU.
  7385. *
  7386. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7387. *
  7388. * For more information, please refer to :
  7389. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7390. * @param engine Define the engine the buffer is associated with
  7391. * @param data Define the data contained in the buffer
  7392. * @param dynamic Define if the buffer is updatable
  7393. */
  7394. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7395. /**
  7396. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7397. * or just falling back on setUniformXXX calls.
  7398. */
  7399. get useUbo(): boolean;
  7400. /**
  7401. * Indicates if the WebGL underlying uniform buffer is in sync
  7402. * with the javascript cache data.
  7403. */
  7404. get isSync(): boolean;
  7405. /**
  7406. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7407. * Also, a dynamic UniformBuffer will disable cache verification and always
  7408. * update the underlying WebGL uniform buffer to the GPU.
  7409. * @returns if Dynamic, otherwise false
  7410. */
  7411. isDynamic(): boolean;
  7412. /**
  7413. * The data cache on JS side.
  7414. * @returns the underlying data as a float array
  7415. */
  7416. getData(): Float32Array;
  7417. /**
  7418. * The underlying WebGL Uniform buffer.
  7419. * @returns the webgl buffer
  7420. */
  7421. getBuffer(): Nullable<DataBuffer>;
  7422. /**
  7423. * std140 layout specifies how to align data within an UBO structure.
  7424. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7425. * for specs.
  7426. */
  7427. private _fillAlignment;
  7428. /**
  7429. * Adds an uniform in the buffer.
  7430. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7431. * for the layout to be correct !
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param size Data size, or data directly.
  7434. */
  7435. addUniform(name: string, size: number | number[]): void;
  7436. /**
  7437. * Adds a Matrix 4x4 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param mat A 4x4 matrix.
  7440. */
  7441. addMatrix(name: string, mat: Matrix): void;
  7442. /**
  7443. * Adds a vec2 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param x Define the x component value of the vec2
  7446. * @param y Define the y component value of the vec2
  7447. */
  7448. addFloat2(name: string, x: number, y: number): void;
  7449. /**
  7450. * Adds a vec3 to the uniform buffer.
  7451. * @param name Name of the uniform, as used in the uniform block in the shader.
  7452. * @param x Define the x component value of the vec3
  7453. * @param y Define the y component value of the vec3
  7454. * @param z Define the z component value of the vec3
  7455. */
  7456. addFloat3(name: string, x: number, y: number, z: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param color Define the vec3 from a Color
  7461. */
  7462. addColor3(name: string, color: Color3): void;
  7463. /**
  7464. * Adds a vec4 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the rgb components from a Color
  7467. * @param alpha Define the a component of the vec4
  7468. */
  7469. addColor4(name: string, color: Color3, alpha: number): void;
  7470. /**
  7471. * Adds a vec3 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param vector Define the vec3 components from a Vector
  7474. */
  7475. addVector3(name: string, vector: Vector3): void;
  7476. /**
  7477. * Adds a Matrix 3x3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. */
  7480. addMatrix3x3(name: string): void;
  7481. /**
  7482. * Adds a Matrix 2x2 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. */
  7485. addMatrix2x2(name: string): void;
  7486. /**
  7487. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7488. */
  7489. create(): void;
  7490. /** @hidden */
  7491. _rebuild(): void;
  7492. /**
  7493. * Updates the WebGL Uniform Buffer on the GPU.
  7494. * If the `dynamic` flag is set to true, no cache comparison is done.
  7495. * Otherwise, the buffer will be updated only if the cache differs.
  7496. */
  7497. update(): void;
  7498. /**
  7499. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. * @param size Define the size of the data.
  7503. */
  7504. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7505. private _valueCache;
  7506. private _cacheMatrix;
  7507. private _updateMatrix3x3ForUniform;
  7508. private _updateMatrix3x3ForEffect;
  7509. private _updateMatrix2x2ForEffect;
  7510. private _updateMatrix2x2ForUniform;
  7511. private _updateFloatForEffect;
  7512. private _updateFloatForUniform;
  7513. private _updateFloat2ForEffect;
  7514. private _updateFloat2ForUniform;
  7515. private _updateFloat3ForEffect;
  7516. private _updateFloat3ForUniform;
  7517. private _updateFloat4ForEffect;
  7518. private _updateFloat4ForUniform;
  7519. private _updateMatrixForEffect;
  7520. private _updateMatrixForUniform;
  7521. private _updateVector3ForEffect;
  7522. private _updateVector3ForUniform;
  7523. private _updateVector4ForEffect;
  7524. private _updateVector4ForUniform;
  7525. private _updateColor3ForEffect;
  7526. private _updateColor3ForUniform;
  7527. private _updateColor4ForEffect;
  7528. private _updateColor4ForUniform;
  7529. /**
  7530. * Sets a sampler uniform on the effect.
  7531. * @param name Define the name of the sampler.
  7532. * @param texture Define the texture to set in the sampler
  7533. */
  7534. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7535. /**
  7536. * Directly updates the value of the uniform in the cache AND on the GPU.
  7537. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7538. * @param data Define the flattened data
  7539. */
  7540. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7541. /**
  7542. * Binds this uniform buffer to an effect.
  7543. * @param effect Define the effect to bind the buffer to
  7544. * @param name Name of the uniform block in the shader.
  7545. */
  7546. bindToEffect(effect: Effect, name: string): void;
  7547. /**
  7548. * Disposes the uniform buffer.
  7549. */
  7550. dispose(): void;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/iInspectable" {
  7554. /**
  7555. * Enum that determines the text-wrapping mode to use.
  7556. */
  7557. export enum InspectableType {
  7558. /**
  7559. * Checkbox for booleans
  7560. */
  7561. Checkbox = 0,
  7562. /**
  7563. * Sliders for numbers
  7564. */
  7565. Slider = 1,
  7566. /**
  7567. * Vector3
  7568. */
  7569. Vector3 = 2,
  7570. /**
  7571. * Quaternions
  7572. */
  7573. Quaternion = 3,
  7574. /**
  7575. * Color3
  7576. */
  7577. Color3 = 4,
  7578. /**
  7579. * String
  7580. */
  7581. String = 5
  7582. }
  7583. /**
  7584. * Interface used to define custom inspectable properties.
  7585. * This interface is used by the inspector to display custom property grids
  7586. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7587. */
  7588. export interface IInspectable {
  7589. /**
  7590. * Gets the label to display
  7591. */
  7592. label: string;
  7593. /**
  7594. * Gets the name of the property to edit
  7595. */
  7596. propertyName: string;
  7597. /**
  7598. * Gets the type of the editor to use
  7599. */
  7600. type: InspectableType;
  7601. /**
  7602. * Gets the minimum value of the property when using in "slider" mode
  7603. */
  7604. min?: number;
  7605. /**
  7606. * Gets the maximum value of the property when using in "slider" mode
  7607. */
  7608. max?: number;
  7609. /**
  7610. * Gets the setp to use when using in "slider" mode
  7611. */
  7612. step?: number;
  7613. }
  7614. }
  7615. declare module "babylonjs/Misc/timingTools" {
  7616. /**
  7617. * Class used to provide helper for timing
  7618. */
  7619. export class TimingTools {
  7620. /**
  7621. * Polyfill for setImmediate
  7622. * @param action defines the action to execute after the current execution block
  7623. */
  7624. static SetImmediate(action: () => void): void;
  7625. }
  7626. }
  7627. declare module "babylonjs/Misc/instantiationTools" {
  7628. /**
  7629. * Class used to enable instatition of objects by class name
  7630. */
  7631. export class InstantiationTools {
  7632. /**
  7633. * Use this object to register external classes like custom textures or material
  7634. * to allow the laoders to instantiate them
  7635. */
  7636. static RegisteredExternalClasses: {
  7637. [key: string]: Object;
  7638. };
  7639. /**
  7640. * Tries to instantiate a new object from a given class name
  7641. * @param className defines the class name to instantiate
  7642. * @returns the new object or null if the system was not able to do the instantiation
  7643. */
  7644. static Instantiate(className: string): any;
  7645. }
  7646. }
  7647. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7648. /**
  7649. * Define options used to create a depth texture
  7650. */
  7651. export class DepthTextureCreationOptions {
  7652. /** Specifies whether or not a stencil should be allocated in the texture */
  7653. generateStencil?: boolean;
  7654. /** Specifies whether or not bilinear filtering is enable on the texture */
  7655. bilinearFiltering?: boolean;
  7656. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7657. comparisonFunction?: number;
  7658. /** Specifies if the created texture is a cube texture */
  7659. isCube?: boolean;
  7660. }
  7661. }
  7662. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7664. import { Nullable } from "babylonjs/types";
  7665. import { Scene } from "babylonjs/scene";
  7666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7667. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7668. module "babylonjs/Engines/thinEngine" {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7693. * @returns the cube texture as an InternalTexture
  7694. */
  7695. 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;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @returns the cube texture as an InternalTexture
  7707. */
  7708. 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;
  7709. /**
  7710. * Creates a cube texture
  7711. * @param rootUrl defines the url where the files to load is located
  7712. * @param scene defines the current scene
  7713. * @param files defines the list of files to load (1 per face)
  7714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7715. * @param onLoad defines an optional callback raised when the texture is loaded
  7716. * @param onError defines an optional callback raised if there is an issue to load the texture
  7717. * @param format defines the format of the data
  7718. * @param forcedExtension defines the extension to use to pick the right loader
  7719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. 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;
  7725. /** @hidden */
  7726. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7727. /** @hidden */
  7728. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7731. /** @hidden */
  7732. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /**
  7734. * @hidden
  7735. */
  7736. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7737. }
  7738. }
  7739. }
  7740. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7741. import { Nullable } from "babylonjs/types";
  7742. import { Scene } from "babylonjs/scene";
  7743. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7745. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. set boundingBoxSize(value: Vector3);
  7769. /**
  7770. * Returns the bounding box size
  7771. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7772. */
  7773. get boundingBoxSize(): Vector3;
  7774. protected _rotationY: number;
  7775. /**
  7776. * Sets texture matrix rotation angle around Y axis in radians.
  7777. */
  7778. set rotationY(value: number);
  7779. /**
  7780. * Gets texture matrix rotation angle around Y axis radians.
  7781. */
  7782. get rotationY(): number;
  7783. /**
  7784. * Are mip maps generated for this texture or not.
  7785. */
  7786. get noMipmap(): boolean;
  7787. private _noMipmap;
  7788. private _files;
  7789. protected _forcedExtension: Nullable<string>;
  7790. private _extensions;
  7791. private _textureMatrix;
  7792. private _format;
  7793. private _createPolynomials;
  7794. /** @hidden */
  7795. _prefiltered: boolean;
  7796. /**
  7797. * Creates a cube texture from an array of image urls
  7798. * @param files defines an array of image urls
  7799. * @param scene defines the hosting scene
  7800. * @param noMipmap specifies if mip maps are not used
  7801. * @returns a cube texture
  7802. */
  7803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7804. /**
  7805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7806. * @param url defines the url of the prefiltered texture
  7807. * @param scene defines the scene the texture is attached to
  7808. * @param forcedExtension defines the extension of the file if different from the url
  7809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7810. * @return the prefiltered texture
  7811. */
  7812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7813. /**
  7814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7815. * as prefiltered data.
  7816. * @param rootUrl defines the url of the texture or the root name of the six images
  7817. * @param scene defines the scene the texture is attached to
  7818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7819. * @param noMipmap defines if mipmaps should be created or not
  7820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7822. * @param onError defines a callback triggered in case of error during load
  7823. * @param format defines the internal format to use for the texture once loaded
  7824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7829. * @return the cube texture
  7830. */
  7831. 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);
  7832. /**
  7833. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7834. */
  7835. get isPrefiltered(): boolean;
  7836. /**
  7837. * Get the current class name of the texture useful for serialization or dynamic coding.
  7838. * @returns "CubeTexture"
  7839. */
  7840. getClassName(): string;
  7841. /**
  7842. * Update the url (and optional buffer) of this texture if url was null during construction.
  7843. * @param url the url of the texture
  7844. * @param forcedExtension defines the extension to use
  7845. * @param onLoad callback called when the texture is loaded (defaults to null)
  7846. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module "babylonjs/Materials/materialDefines" {
  7880. /**
  7881. * Manages the defines for the Material
  7882. */
  7883. export class MaterialDefines {
  7884. /** @hidden */
  7885. protected _keys: string[];
  7886. private _isDirty;
  7887. /** @hidden */
  7888. _renderId: number;
  7889. /** @hidden */
  7890. _areLightsDirty: boolean;
  7891. /** @hidden */
  7892. _areLightsDisposed: boolean;
  7893. /** @hidden */
  7894. _areAttributesDirty: boolean;
  7895. /** @hidden */
  7896. _areTexturesDirty: boolean;
  7897. /** @hidden */
  7898. _areFresnelDirty: boolean;
  7899. /** @hidden */
  7900. _areMiscDirty: boolean;
  7901. /** @hidden */
  7902. _areImageProcessingDirty: boolean;
  7903. /** @hidden */
  7904. _normals: boolean;
  7905. /** @hidden */
  7906. _uvs: boolean;
  7907. /** @hidden */
  7908. _needNormals: boolean;
  7909. /** @hidden */
  7910. _needUVs: boolean;
  7911. [id: string]: any;
  7912. /**
  7913. * Specifies if the material needs to be re-calculated
  7914. */
  7915. get isDirty(): boolean;
  7916. /**
  7917. * Marks the material to indicate that it has been re-calculated
  7918. */
  7919. markAsProcessed(): void;
  7920. /**
  7921. * Marks the material to indicate that it needs to be re-calculated
  7922. */
  7923. markAsUnprocessed(): void;
  7924. /**
  7925. * Marks the material to indicate all of its defines need to be re-calculated
  7926. */
  7927. markAllAsDirty(): void;
  7928. /**
  7929. * Marks the material to indicate that image processing needs to be re-calculated
  7930. */
  7931. markAsImageProcessingDirty(): void;
  7932. /**
  7933. * Marks the material to indicate the lights need to be re-calculated
  7934. * @param disposed Defines whether the light is dirty due to dispose or not
  7935. */
  7936. markAsLightDirty(disposed?: boolean): void;
  7937. /**
  7938. * Marks the attribute state as changed
  7939. */
  7940. markAsAttributesDirty(): void;
  7941. /**
  7942. * Marks the texture state as changed
  7943. */
  7944. markAsTexturesDirty(): void;
  7945. /**
  7946. * Marks the fresnel state as changed
  7947. */
  7948. markAsFresnelDirty(): void;
  7949. /**
  7950. * Marks the misc state as changed
  7951. */
  7952. markAsMiscDirty(): void;
  7953. /**
  7954. * Rebuilds the material defines
  7955. */
  7956. rebuild(): void;
  7957. /**
  7958. * Specifies if two material defines are equal
  7959. * @param other - A material define instance to compare to
  7960. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7961. */
  7962. isEqual(other: MaterialDefines): boolean;
  7963. /**
  7964. * Clones this instance's defines to another instance
  7965. * @param other - material defines to clone values to
  7966. */
  7967. cloneTo(other: MaterialDefines): void;
  7968. /**
  7969. * Resets the material define values
  7970. */
  7971. reset(): void;
  7972. /**
  7973. * Converts the material define values to a string
  7974. * @returns - String of material define information
  7975. */
  7976. toString(): string;
  7977. }
  7978. }
  7979. declare module "babylonjs/Materials/colorCurves" {
  7980. import { Effect } from "babylonjs/Materials/effect";
  7981. /**
  7982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7984. * 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;
  7985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7986. */
  7987. export class ColorCurves {
  7988. private _dirty;
  7989. private _tempColor;
  7990. private _globalCurve;
  7991. private _highlightsCurve;
  7992. private _midtonesCurve;
  7993. private _shadowsCurve;
  7994. private _positiveCurve;
  7995. private _negativeCurve;
  7996. private _globalHue;
  7997. private _globalDensity;
  7998. private _globalSaturation;
  7999. private _globalExposure;
  8000. /**
  8001. * Gets the global Hue value.
  8002. * 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).
  8003. */
  8004. get globalHue(): number;
  8005. /**
  8006. * Sets the global Hue value.
  8007. * 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).
  8008. */
  8009. set globalHue(value: number);
  8010. /**
  8011. * Gets the global Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get globalDensity(): number;
  8016. /**
  8017. * Sets the global Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set globalDensity(value: number);
  8022. /**
  8023. * Gets the global Saturation value.
  8024. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8025. */
  8026. get globalSaturation(): number;
  8027. /**
  8028. * Sets the global Saturation value.
  8029. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8030. */
  8031. set globalSaturation(value: number);
  8032. /**
  8033. * Gets the global Exposure value.
  8034. * 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.
  8035. */
  8036. get globalExposure(): number;
  8037. /**
  8038. * Sets the global Exposure value.
  8039. * 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.
  8040. */
  8041. set globalExposure(value: number);
  8042. private _highlightsHue;
  8043. private _highlightsDensity;
  8044. private _highlightsSaturation;
  8045. private _highlightsExposure;
  8046. /**
  8047. * Gets the highlights Hue value.
  8048. * 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).
  8049. */
  8050. get highlightsHue(): number;
  8051. /**
  8052. * Sets the highlights Hue value.
  8053. * 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).
  8054. */
  8055. set highlightsHue(value: number);
  8056. /**
  8057. * Gets the highlights Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get highlightsDensity(): number;
  8062. /**
  8063. * Sets the highlights Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set highlightsDensity(value: number);
  8068. /**
  8069. * Gets the highlights Saturation value.
  8070. * 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.
  8071. */
  8072. get highlightsSaturation(): number;
  8073. /**
  8074. * Sets the highlights Saturation value.
  8075. * 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.
  8076. */
  8077. set highlightsSaturation(value: number);
  8078. /**
  8079. * Gets the highlights Exposure value.
  8080. * 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.
  8081. */
  8082. get highlightsExposure(): number;
  8083. /**
  8084. * Sets the highlights Exposure value.
  8085. * 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.
  8086. */
  8087. set highlightsExposure(value: number);
  8088. private _midtonesHue;
  8089. private _midtonesDensity;
  8090. private _midtonesSaturation;
  8091. private _midtonesExposure;
  8092. /**
  8093. * Gets the midtones Hue value.
  8094. * 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).
  8095. */
  8096. get midtonesHue(): number;
  8097. /**
  8098. * Sets the midtones Hue value.
  8099. * 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).
  8100. */
  8101. set midtonesHue(value: number);
  8102. /**
  8103. * Gets the midtones Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get midtonesDensity(): number;
  8108. /**
  8109. * Sets the midtones Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set midtonesDensity(value: number);
  8114. /**
  8115. * Gets the midtones Saturation value.
  8116. * 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.
  8117. */
  8118. get midtonesSaturation(): number;
  8119. /**
  8120. * Sets the midtones Saturation value.
  8121. * 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.
  8122. */
  8123. set midtonesSaturation(value: number);
  8124. /**
  8125. * Gets the midtones Exposure value.
  8126. * 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.
  8127. */
  8128. get midtonesExposure(): number;
  8129. /**
  8130. * Sets the midtones Exposure value.
  8131. * 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.
  8132. */
  8133. set midtonesExposure(value: number);
  8134. private _shadowsHue;
  8135. private _shadowsDensity;
  8136. private _shadowsSaturation;
  8137. private _shadowsExposure;
  8138. /**
  8139. * Gets the shadows Hue value.
  8140. * 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).
  8141. */
  8142. get shadowsHue(): number;
  8143. /**
  8144. * Sets the shadows Hue value.
  8145. * 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).
  8146. */
  8147. set shadowsHue(value: number);
  8148. /**
  8149. * Gets the shadows Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. get shadowsDensity(): number;
  8154. /**
  8155. * Sets the shadows Density value.
  8156. * 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.
  8157. * Values less than zero provide a filter of opposite hue.
  8158. */
  8159. set shadowsDensity(value: number);
  8160. /**
  8161. * Gets the shadows Saturation value.
  8162. * 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.
  8163. */
  8164. get shadowsSaturation(): number;
  8165. /**
  8166. * Sets the shadows Saturation value.
  8167. * 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.
  8168. */
  8169. set shadowsSaturation(value: number);
  8170. /**
  8171. * Gets the shadows Exposure value.
  8172. * 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.
  8173. */
  8174. get shadowsExposure(): number;
  8175. /**
  8176. * Sets the shadows Exposure value.
  8177. * 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.
  8178. */
  8179. set shadowsExposure(value: number);
  8180. /**
  8181. * Returns the class name
  8182. * @returns The class name
  8183. */
  8184. getClassName(): string;
  8185. /**
  8186. * Binds the color curves to the shader.
  8187. * @param colorCurves The color curve to bind
  8188. * @param effect The effect to bind to
  8189. * @param positiveUniform The positive uniform shader parameter
  8190. * @param neutralUniform The neutral uniform shader parameter
  8191. * @param negativeUniform The negative uniform shader parameter
  8192. */
  8193. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8194. /**
  8195. * Prepare the list of uniforms associated with the ColorCurves effects.
  8196. * @param uniformsList The list of uniforms used in the effect
  8197. */
  8198. static PrepareUniforms(uniformsList: string[]): void;
  8199. /**
  8200. * Returns color grading data based on a hue, density, saturation and exposure value.
  8201. * @param filterHue The hue of the color filter.
  8202. * @param filterDensity The density of the color filter.
  8203. * @param saturation The saturation.
  8204. * @param exposure The exposure.
  8205. * @param result The result data container.
  8206. */
  8207. private getColorGradingDataToRef;
  8208. /**
  8209. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8210. * @param value The input slider value in range [-100,100].
  8211. * @returns Adjusted value.
  8212. */
  8213. private static applyColorGradingSliderNonlinear;
  8214. /**
  8215. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8216. * @param hue The hue (H) input.
  8217. * @param saturation The saturation (S) input.
  8218. * @param brightness The brightness (B) input.
  8219. * @result An RGBA color represented as Vector4.
  8220. */
  8221. private static fromHSBToRef;
  8222. /**
  8223. * Returns a value clamped between min and max
  8224. * @param value The value to clamp
  8225. * @param min The minimum of value
  8226. * @param max The maximum of value
  8227. * @returns The clamped value.
  8228. */
  8229. private static clamp;
  8230. /**
  8231. * Clones the current color curve instance.
  8232. * @return The cloned curves
  8233. */
  8234. clone(): ColorCurves;
  8235. /**
  8236. * Serializes the current color curve instance to a json representation.
  8237. * @return a JSON representation
  8238. */
  8239. serialize(): any;
  8240. /**
  8241. * Parses the color curve from a json representation.
  8242. * @param source the JSON source to parse
  8243. * @return The parsed curves
  8244. */
  8245. static Parse(source: any): ColorCurves;
  8246. }
  8247. }
  8248. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8249. import { Observable } from "babylonjs/Misc/observable";
  8250. import { Nullable } from "babylonjs/types";
  8251. import { Color4 } from "babylonjs/Maths/math.color";
  8252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8253. import { Effect } from "babylonjs/Materials/effect";
  8254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8255. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8256. /**
  8257. * Interface to follow in your material defines to integrate easily the
  8258. * Image proccessing functions.
  8259. * @hidden
  8260. */
  8261. export interface IImageProcessingConfigurationDefines {
  8262. IMAGEPROCESSING: boolean;
  8263. VIGNETTE: boolean;
  8264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8265. VIGNETTEBLENDMODEOPAQUE: boolean;
  8266. TONEMAPPING: boolean;
  8267. TONEMAPPING_ACES: boolean;
  8268. CONTRAST: boolean;
  8269. EXPOSURE: boolean;
  8270. COLORCURVES: boolean;
  8271. COLORGRADING: boolean;
  8272. COLORGRADING3D: boolean;
  8273. SAMPLER3DGREENDEPTH: boolean;
  8274. SAMPLER3DBGRMAP: boolean;
  8275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8276. }
  8277. /**
  8278. * @hidden
  8279. */
  8280. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8281. IMAGEPROCESSING: boolean;
  8282. VIGNETTE: boolean;
  8283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8284. VIGNETTEBLENDMODEOPAQUE: boolean;
  8285. TONEMAPPING: boolean;
  8286. TONEMAPPING_ACES: boolean;
  8287. CONTRAST: boolean;
  8288. COLORCURVES: boolean;
  8289. COLORGRADING: boolean;
  8290. COLORGRADING3D: boolean;
  8291. SAMPLER3DGREENDEPTH: boolean;
  8292. SAMPLER3DBGRMAP: boolean;
  8293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8294. EXPOSURE: boolean;
  8295. constructor();
  8296. }
  8297. /**
  8298. * This groups together the common properties used for image processing either in direct forward pass
  8299. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8300. * or not.
  8301. */
  8302. export class ImageProcessingConfiguration {
  8303. /**
  8304. * Default tone mapping applied in BabylonJS.
  8305. */
  8306. static readonly TONEMAPPING_STANDARD: number;
  8307. /**
  8308. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8309. * to other engines rendering to increase portability.
  8310. */
  8311. static readonly TONEMAPPING_ACES: number;
  8312. /**
  8313. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8314. */
  8315. colorCurves: Nullable<ColorCurves>;
  8316. private _colorCurvesEnabled;
  8317. /**
  8318. * Gets wether the color curves effect is enabled.
  8319. */
  8320. get colorCurvesEnabled(): boolean;
  8321. /**
  8322. * Sets wether the color curves effect is enabled.
  8323. */
  8324. set colorCurvesEnabled(value: boolean);
  8325. private _colorGradingTexture;
  8326. /**
  8327. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8328. */
  8329. get colorGradingTexture(): Nullable<BaseTexture>;
  8330. /**
  8331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8332. */
  8333. set colorGradingTexture(value: Nullable<BaseTexture>);
  8334. private _colorGradingEnabled;
  8335. /**
  8336. * Gets wether the color grading effect is enabled.
  8337. */
  8338. get colorGradingEnabled(): boolean;
  8339. /**
  8340. * Sets wether the color grading effect is enabled.
  8341. */
  8342. set colorGradingEnabled(value: boolean);
  8343. private _colorGradingWithGreenDepth;
  8344. /**
  8345. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8346. */
  8347. get colorGradingWithGreenDepth(): boolean;
  8348. /**
  8349. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8350. */
  8351. set colorGradingWithGreenDepth(value: boolean);
  8352. private _colorGradingBGR;
  8353. /**
  8354. * Gets wether the color grading texture contains BGR values.
  8355. */
  8356. get colorGradingBGR(): boolean;
  8357. /**
  8358. * Sets wether the color grading texture contains BGR values.
  8359. */
  8360. set colorGradingBGR(value: boolean);
  8361. /** @hidden */
  8362. _exposure: number;
  8363. /**
  8364. * Gets the Exposure used in the effect.
  8365. */
  8366. get exposure(): number;
  8367. /**
  8368. * Sets the Exposure used in the effect.
  8369. */
  8370. set exposure(value: number);
  8371. private _toneMappingEnabled;
  8372. /**
  8373. * Gets wether the tone mapping effect is enabled.
  8374. */
  8375. get toneMappingEnabled(): boolean;
  8376. /**
  8377. * Sets wether the tone mapping effect is enabled.
  8378. */
  8379. set toneMappingEnabled(value: boolean);
  8380. private _toneMappingType;
  8381. /**
  8382. * Gets the type of tone mapping effect.
  8383. */
  8384. get toneMappingType(): number;
  8385. /**
  8386. * Sets the type of tone mapping effect used in BabylonJS.
  8387. */
  8388. set toneMappingType(value: number);
  8389. protected _contrast: number;
  8390. /**
  8391. * Gets the contrast used in the effect.
  8392. */
  8393. get contrast(): number;
  8394. /**
  8395. * Sets the contrast used in the effect.
  8396. */
  8397. set contrast(value: number);
  8398. /**
  8399. * Vignette stretch size.
  8400. */
  8401. vignetteStretch: number;
  8402. /**
  8403. * Vignette centre X Offset.
  8404. */
  8405. vignetteCentreX: number;
  8406. /**
  8407. * Vignette centre Y Offset.
  8408. */
  8409. vignetteCentreY: number;
  8410. /**
  8411. * Vignette weight or intensity of the vignette effect.
  8412. */
  8413. vignetteWeight: number;
  8414. /**
  8415. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8416. * if vignetteEnabled is set to true.
  8417. */
  8418. vignetteColor: Color4;
  8419. /**
  8420. * Camera field of view used by the Vignette effect.
  8421. */
  8422. vignetteCameraFov: number;
  8423. private _vignetteBlendMode;
  8424. /**
  8425. * Gets the vignette blend mode allowing different kind of effect.
  8426. */
  8427. get vignetteBlendMode(): number;
  8428. /**
  8429. * Sets the vignette blend mode allowing different kind of effect.
  8430. */
  8431. set vignetteBlendMode(value: number);
  8432. private _vignetteEnabled;
  8433. /**
  8434. * Gets wether the vignette effect is enabled.
  8435. */
  8436. get vignetteEnabled(): boolean;
  8437. /**
  8438. * Sets wether the vignette effect is enabled.
  8439. */
  8440. set vignetteEnabled(value: boolean);
  8441. private _applyByPostProcess;
  8442. /**
  8443. * Gets wether the image processing is applied through a post process or not.
  8444. */
  8445. get applyByPostProcess(): boolean;
  8446. /**
  8447. * Sets wether the image processing is applied through a post process or not.
  8448. */
  8449. set applyByPostProcess(value: boolean);
  8450. private _isEnabled;
  8451. /**
  8452. * Gets wether the image processing is enabled or not.
  8453. */
  8454. get isEnabled(): boolean;
  8455. /**
  8456. * Sets wether the image processing is enabled or not.
  8457. */
  8458. set isEnabled(value: boolean);
  8459. /**
  8460. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8461. */
  8462. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8463. /**
  8464. * Method called each time the image processing information changes requires to recompile the effect.
  8465. */
  8466. protected _updateParameters(): void;
  8467. /**
  8468. * Gets the current class name.
  8469. * @return "ImageProcessingConfiguration"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Prepare the list of uniforms associated with the Image Processing effects.
  8474. * @param uniforms The list of uniforms used in the effect
  8475. * @param defines the list of defines currently in use
  8476. */
  8477. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8478. /**
  8479. * Prepare the list of samplers associated with the Image Processing effects.
  8480. * @param samplersList The list of uniforms used in the effect
  8481. * @param defines the list of defines currently in use
  8482. */
  8483. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8484. /**
  8485. * Prepare the list of defines associated to the shader.
  8486. * @param defines the list of defines to complete
  8487. * @param forPostProcess Define if we are currently in post process mode or not
  8488. */
  8489. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8490. /**
  8491. * Returns true if all the image processing information are ready.
  8492. * @returns True if ready, otherwise, false
  8493. */
  8494. isReady(): boolean;
  8495. /**
  8496. * Binds the image processing to the shader.
  8497. * @param effect The effect to bind to
  8498. * @param overrideAspectRatio Override the aspect ratio of the effect
  8499. */
  8500. bind(effect: Effect, overrideAspectRatio?: number): void;
  8501. /**
  8502. * Clones the current image processing instance.
  8503. * @return The cloned image processing
  8504. */
  8505. clone(): ImageProcessingConfiguration;
  8506. /**
  8507. * Serializes the current image processing instance to a json representation.
  8508. * @return a JSON representation
  8509. */
  8510. serialize(): any;
  8511. /**
  8512. * Parses the image processing from a json representation.
  8513. * @param source the JSON source to parse
  8514. * @return The parsed image processing
  8515. */
  8516. static Parse(source: any): ImageProcessingConfiguration;
  8517. private static _VIGNETTEMODE_MULTIPLY;
  8518. private static _VIGNETTEMODE_OPAQUE;
  8519. /**
  8520. * Used to apply the vignette as a mix with the pixel color.
  8521. */
  8522. static get VIGNETTEMODE_MULTIPLY(): number;
  8523. /**
  8524. * Used to apply the vignette as a replacement of the pixel color.
  8525. */
  8526. static get VIGNETTEMODE_OPAQUE(): number;
  8527. }
  8528. }
  8529. declare module "babylonjs/Shaders/postprocess.vertex" {
  8530. /** @hidden */
  8531. export var postprocessVertexShader: {
  8532. name: string;
  8533. shader: string;
  8534. };
  8535. }
  8536. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8539. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8540. module "babylonjs/Engines/thinEngine" {
  8541. interface ThinEngine {
  8542. /**
  8543. * Creates a new render target texture
  8544. * @param size defines the size of the texture
  8545. * @param options defines the options used to create the texture
  8546. * @returns a new render target texture stored in an InternalTexture
  8547. */
  8548. createRenderTargetTexture(size: number | {
  8549. width: number;
  8550. height: number;
  8551. layers?: number;
  8552. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8553. /**
  8554. * Creates a depth stencil texture.
  8555. * This is only available in WebGL 2 or with the depth texture extension available.
  8556. * @param size The size of face edge in the texture.
  8557. * @param options The options defining the texture.
  8558. * @returns The texture
  8559. */
  8560. createDepthStencilTexture(size: number | {
  8561. width: number;
  8562. height: number;
  8563. layers?: number;
  8564. }, options: DepthTextureCreationOptions): InternalTexture;
  8565. /** @hidden */
  8566. _createDepthStencilTexture(size: number | {
  8567. width: number;
  8568. height: number;
  8569. layers?: number;
  8570. }, options: DepthTextureCreationOptions): InternalTexture;
  8571. }
  8572. }
  8573. }
  8574. declare module "babylonjs/Maths/math.axis" {
  8575. import { Vector3 } from "babylonjs/Maths/math.vector";
  8576. /** Defines supported spaces */
  8577. export enum Space {
  8578. /** Local (object) space */
  8579. LOCAL = 0,
  8580. /** World space */
  8581. WORLD = 1,
  8582. /** Bone space */
  8583. BONE = 2
  8584. }
  8585. /** Defines the 3 main axes */
  8586. export class Axis {
  8587. /** X axis */
  8588. static X: Vector3;
  8589. /** Y axis */
  8590. static Y: Vector3;
  8591. /** Z axis */
  8592. static Z: Vector3;
  8593. }
  8594. }
  8595. declare module "babylonjs/Cameras/targetCamera" {
  8596. import { Nullable } from "babylonjs/types";
  8597. import { Camera } from "babylonjs/Cameras/camera";
  8598. import { Scene } from "babylonjs/scene";
  8599. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8600. /**
  8601. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8602. * This is the base of the follow, arc rotate cameras and Free camera
  8603. * @see http://doc.babylonjs.com/features/cameras
  8604. */
  8605. export class TargetCamera extends Camera {
  8606. private static _RigCamTransformMatrix;
  8607. private static _TargetTransformMatrix;
  8608. private static _TargetFocalPoint;
  8609. /**
  8610. * Define the current direction the camera is moving to
  8611. */
  8612. cameraDirection: Vector3;
  8613. /**
  8614. * Define the current rotation the camera is rotating to
  8615. */
  8616. cameraRotation: Vector2;
  8617. /**
  8618. * When set, the up vector of the camera will be updated by the rotation of the camera
  8619. */
  8620. updateUpVectorFromRotation: boolean;
  8621. private _tmpQuaternion;
  8622. /**
  8623. * Define the current rotation of the camera
  8624. */
  8625. rotation: Vector3;
  8626. /**
  8627. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8628. */
  8629. rotationQuaternion: Quaternion;
  8630. /**
  8631. * Define the current speed of the camera
  8632. */
  8633. speed: number;
  8634. /**
  8635. * Add constraint to the camera to prevent it to move freely in all directions and
  8636. * around all axis.
  8637. */
  8638. noRotationConstraint: boolean;
  8639. /**
  8640. * Define the current target of the camera as an object or a position.
  8641. */
  8642. lockedTarget: any;
  8643. /** @hidden */
  8644. _currentTarget: Vector3;
  8645. /** @hidden */
  8646. _initialFocalDistance: number;
  8647. /** @hidden */
  8648. _viewMatrix: Matrix;
  8649. /** @hidden */
  8650. _camMatrix: Matrix;
  8651. /** @hidden */
  8652. _cameraTransformMatrix: Matrix;
  8653. /** @hidden */
  8654. _cameraRotationMatrix: Matrix;
  8655. /** @hidden */
  8656. _referencePoint: Vector3;
  8657. /** @hidden */
  8658. _transformedReferencePoint: Vector3;
  8659. protected _globalCurrentTarget: Vector3;
  8660. protected _globalCurrentUpVector: Vector3;
  8661. /** @hidden */
  8662. _reset: () => void;
  8663. private _defaultUp;
  8664. /**
  8665. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8666. * This is the base of the follow, arc rotate cameras and Free camera
  8667. * @see http://doc.babylonjs.com/features/cameras
  8668. * @param name Defines the name of the camera in the scene
  8669. * @param position Defines the start position of the camera in the scene
  8670. * @param scene Defines the scene the camera belongs to
  8671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8672. */
  8673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8674. /**
  8675. * Gets the position in front of the camera at a given distance.
  8676. * @param distance The distance from the camera we want the position to be
  8677. * @returns the position
  8678. */
  8679. getFrontPosition(distance: number): Vector3;
  8680. /** @hidden */
  8681. _getLockedTargetPosition(): Nullable<Vector3>;
  8682. private _storedPosition;
  8683. private _storedRotation;
  8684. private _storedRotationQuaternion;
  8685. /**
  8686. * Store current camera state of the camera (fov, position, rotation, etc..)
  8687. * @returns the camera
  8688. */
  8689. storeState(): Camera;
  8690. /**
  8691. * Restored camera state. You must call storeState() first
  8692. * @returns whether it was successful or not
  8693. * @hidden
  8694. */
  8695. _restoreStateValues(): boolean;
  8696. /** @hidden */
  8697. _initCache(): void;
  8698. /** @hidden */
  8699. _updateCache(ignoreParentClass?: boolean): void;
  8700. /** @hidden */
  8701. _isSynchronizedViewMatrix(): boolean;
  8702. /** @hidden */
  8703. _computeLocalCameraSpeed(): number;
  8704. /**
  8705. * Defines the target the camera should look at.
  8706. * @param target Defines the new target as a Vector or a mesh
  8707. */
  8708. setTarget(target: Vector3): void;
  8709. /**
  8710. * Return the current target position of the camera. This value is expressed in local space.
  8711. * @returns the target position
  8712. */
  8713. getTarget(): Vector3;
  8714. /** @hidden */
  8715. _decideIfNeedsToMove(): boolean;
  8716. /** @hidden */
  8717. _updatePosition(): void;
  8718. /** @hidden */
  8719. _checkInputs(): void;
  8720. protected _updateCameraRotationMatrix(): void;
  8721. /**
  8722. * 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)
  8723. * @returns the current camera
  8724. */
  8725. private _rotateUpVectorWithCameraRotationMatrix;
  8726. private _cachedRotationZ;
  8727. private _cachedQuaternionRotationZ;
  8728. /** @hidden */
  8729. _getViewMatrix(): Matrix;
  8730. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8731. /**
  8732. * @hidden
  8733. */
  8734. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8735. /**
  8736. * @hidden
  8737. */
  8738. _updateRigCameras(): void;
  8739. private _getRigCamPositionAndTarget;
  8740. /**
  8741. * Gets the current object class name.
  8742. * @return the class name
  8743. */
  8744. getClassName(): string;
  8745. }
  8746. }
  8747. declare module "babylonjs/Events/keyboardEvents" {
  8748. /**
  8749. * Gather the list of keyboard event types as constants.
  8750. */
  8751. export class KeyboardEventTypes {
  8752. /**
  8753. * The keydown event is fired when a key becomes active (pressed).
  8754. */
  8755. static readonly KEYDOWN: number;
  8756. /**
  8757. * The keyup event is fired when a key has been released.
  8758. */
  8759. static readonly KEYUP: number;
  8760. }
  8761. /**
  8762. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8763. */
  8764. export class KeyboardInfo {
  8765. /**
  8766. * Defines the type of event (KeyboardEventTypes)
  8767. */
  8768. type: number;
  8769. /**
  8770. * Defines the related dom event
  8771. */
  8772. event: KeyboardEvent;
  8773. /**
  8774. * Instantiates a new keyboard info.
  8775. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8776. * @param type Defines the type of event (KeyboardEventTypes)
  8777. * @param event Defines the related dom event
  8778. */
  8779. constructor(
  8780. /**
  8781. * Defines the type of event (KeyboardEventTypes)
  8782. */
  8783. type: number,
  8784. /**
  8785. * Defines the related dom event
  8786. */
  8787. event: KeyboardEvent);
  8788. }
  8789. /**
  8790. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8791. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8792. */
  8793. export class KeyboardInfoPre extends KeyboardInfo {
  8794. /**
  8795. * Defines the type of event (KeyboardEventTypes)
  8796. */
  8797. type: number;
  8798. /**
  8799. * Defines the related dom event
  8800. */
  8801. event: KeyboardEvent;
  8802. /**
  8803. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8804. */
  8805. skipOnPointerObservable: boolean;
  8806. /**
  8807. * Instantiates a new keyboard pre info.
  8808. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8809. * @param type Defines the type of event (KeyboardEventTypes)
  8810. * @param event Defines the related dom event
  8811. */
  8812. constructor(
  8813. /**
  8814. * Defines the type of event (KeyboardEventTypes)
  8815. */
  8816. type: number,
  8817. /**
  8818. * Defines the related dom event
  8819. */
  8820. event: KeyboardEvent);
  8821. }
  8822. }
  8823. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8824. import { Nullable } from "babylonjs/types";
  8825. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8826. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8827. /**
  8828. * Manage the keyboard inputs to control the movement of a free camera.
  8829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8830. */
  8831. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8832. /**
  8833. * Defines the camera the input is attached to.
  8834. */
  8835. camera: FreeCamera;
  8836. /**
  8837. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8838. */
  8839. keysUp: number[];
  8840. /**
  8841. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8842. */
  8843. keysDown: number[];
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8846. */
  8847. keysLeft: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8850. */
  8851. keysRight: number[];
  8852. private _keys;
  8853. private _onCanvasBlurObserver;
  8854. private _onKeyboardObserver;
  8855. private _engine;
  8856. private _scene;
  8857. /**
  8858. * Attach the input controls to a specific dom element to get the input from.
  8859. * @param element Defines the element the controls should be listened from
  8860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8861. */
  8862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8863. /**
  8864. * Detach the current controls from the specified dom element.
  8865. * @param element Defines the element to stop listening the inputs from
  8866. */
  8867. detachControl(element: Nullable<HTMLElement>): void;
  8868. /**
  8869. * Update the current camera state depending on the inputs that have been used this frame.
  8870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8871. */
  8872. checkInputs(): void;
  8873. /**
  8874. * Gets the class name of the current intput.
  8875. * @returns the class name
  8876. */
  8877. getClassName(): string;
  8878. /** @hidden */
  8879. _onLostFocus(): void;
  8880. /**
  8881. * Get the friendly name associated with the input class.
  8882. * @returns the input friendly name
  8883. */
  8884. getSimpleName(): string;
  8885. }
  8886. }
  8887. declare module "babylonjs/Lights/shadowLight" {
  8888. import { Camera } from "babylonjs/Cameras/camera";
  8889. import { Scene } from "babylonjs/scene";
  8890. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8892. import { Light } from "babylonjs/Lights/light";
  8893. /**
  8894. * Interface describing all the common properties and methods a shadow light needs to implement.
  8895. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8896. * as well as binding the different shadow properties to the effects.
  8897. */
  8898. export interface IShadowLight extends Light {
  8899. /**
  8900. * The light id in the scene (used in scene.findLighById for instance)
  8901. */
  8902. id: string;
  8903. /**
  8904. * The position the shdow will be casted from.
  8905. */
  8906. position: Vector3;
  8907. /**
  8908. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8909. */
  8910. direction: Vector3;
  8911. /**
  8912. * The transformed position. Position of the light in world space taking parenting in account.
  8913. */
  8914. transformedPosition: Vector3;
  8915. /**
  8916. * The transformed direction. Direction of the light in world space taking parenting in account.
  8917. */
  8918. transformedDirection: Vector3;
  8919. /**
  8920. * The friendly name of the light in the scene.
  8921. */
  8922. name: string;
  8923. /**
  8924. * Defines the shadow projection clipping minimum z value.
  8925. */
  8926. shadowMinZ: number;
  8927. /**
  8928. * Defines the shadow projection clipping maximum z value.
  8929. */
  8930. shadowMaxZ: number;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Gets the scene the light belongs to.
  8938. * @returns The scene
  8939. */
  8940. getScene(): Scene;
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8948. * @param matrix The materix to updated with the projection information
  8949. * @param viewMatrix The transform matrix of the light
  8950. * @param renderList The list of mesh to render in the map
  8951. * @returns The current light
  8952. */
  8953. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8954. /**
  8955. * Gets the current depth scale used in ESM.
  8956. * @returns The scale
  8957. */
  8958. getDepthScale(): number;
  8959. /**
  8960. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8961. * @returns true if a cube texture needs to be use
  8962. */
  8963. needCube(): boolean;
  8964. /**
  8965. * Detects if the projection matrix requires to be recomputed this frame.
  8966. * @returns true if it requires to be recomputed otherwise, false.
  8967. */
  8968. needProjectionMatrixCompute(): boolean;
  8969. /**
  8970. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8971. */
  8972. forceProjectionMatrixCompute(): void;
  8973. /**
  8974. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8975. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8976. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8977. */
  8978. getShadowDirection(faceIndex?: number): Vector3;
  8979. /**
  8980. * Gets the minZ used for shadow according to both the scene and the light.
  8981. * @param activeCamera The camera we are returning the min for
  8982. * @returns the depth min z
  8983. */
  8984. getDepthMinZ(activeCamera: Camera): number;
  8985. /**
  8986. * Gets the maxZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the max for
  8988. * @returns the depth max z
  8989. */
  8990. getDepthMaxZ(activeCamera: Camera): number;
  8991. }
  8992. /**
  8993. * Base implementation IShadowLight
  8994. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8995. */
  8996. export abstract class ShadowLight extends Light implements IShadowLight {
  8997. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8998. protected _position: Vector3;
  8999. protected _setPosition(value: Vector3): void;
  9000. /**
  9001. * Sets the position the shadow will be casted from. Also use as the light position for both
  9002. * point and spot lights.
  9003. */
  9004. get position(): Vector3;
  9005. /**
  9006. * Sets the position the shadow will be casted from. Also use as the light position for both
  9007. * point and spot lights.
  9008. */
  9009. set position(value: Vector3);
  9010. protected _direction: Vector3;
  9011. protected _setDirection(value: Vector3): void;
  9012. /**
  9013. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9014. * Also use as the light direction on spot and directional lights.
  9015. */
  9016. get direction(): Vector3;
  9017. /**
  9018. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. set direction(value: Vector3);
  9022. protected _shadowMinZ: number;
  9023. /**
  9024. * Gets the shadow projection clipping minimum z value.
  9025. */
  9026. get shadowMinZ(): number;
  9027. /**
  9028. * Sets the shadow projection clipping minimum z value.
  9029. */
  9030. set shadowMinZ(value: number);
  9031. protected _shadowMaxZ: number;
  9032. /**
  9033. * Sets the shadow projection clipping maximum z value.
  9034. */
  9035. get shadowMaxZ(): number;
  9036. /**
  9037. * Gets the shadow projection clipping maximum z value.
  9038. */
  9039. set shadowMaxZ(value: number);
  9040. /**
  9041. * Callback defining a custom Projection Matrix Builder.
  9042. * This can be used to override the default projection matrix computation.
  9043. */
  9044. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. private _needProjectionMatrixCompute;
  9054. /**
  9055. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9056. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9057. */
  9058. computeTransformedInformation(): boolean;
  9059. /**
  9060. * Return the depth scale used for the shadow map.
  9061. * @returns the depth scale.
  9062. */
  9063. getDepthScale(): number;
  9064. /**
  9065. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9068. */
  9069. getShadowDirection(faceIndex?: number): Vector3;
  9070. /**
  9071. * Returns the ShadowLight absolute position in the World.
  9072. * @returns the position vector in world space
  9073. */
  9074. getAbsolutePosition(): Vector3;
  9075. /**
  9076. * Sets the ShadowLight direction toward the passed target.
  9077. * @param target The point to target in local space
  9078. * @returns the updated ShadowLight direction
  9079. */
  9080. setDirectionToTarget(target: Vector3): Vector3;
  9081. /**
  9082. * Returns the light rotation in euler definition.
  9083. * @returns the x y z rotation in local space.
  9084. */
  9085. getRotation(): Vector3;
  9086. /**
  9087. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9088. * @returns true if a cube texture needs to be use
  9089. */
  9090. needCube(): boolean;
  9091. /**
  9092. * Detects if the projection matrix requires to be recomputed this frame.
  9093. * @returns true if it requires to be recomputed otherwise, false.
  9094. */
  9095. needProjectionMatrixCompute(): boolean;
  9096. /**
  9097. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9098. */
  9099. forceProjectionMatrixCompute(): void;
  9100. /** @hidden */
  9101. _initCache(): void;
  9102. /** @hidden */
  9103. _isSynchronized(): boolean;
  9104. /**
  9105. * Computes the world matrix of the node
  9106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9107. * @returns the world matrix
  9108. */
  9109. computeWorldMatrix(force?: boolean): Matrix;
  9110. /**
  9111. * Gets the minZ used for shadow according to both the scene and the light.
  9112. * @param activeCamera The camera we are returning the min for
  9113. * @returns the depth min z
  9114. */
  9115. getDepthMinZ(activeCamera: Camera): number;
  9116. /**
  9117. * Gets the maxZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the max for
  9119. * @returns the depth max z
  9120. */
  9121. getDepthMaxZ(activeCamera: Camera): number;
  9122. /**
  9123. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9124. * @param matrix The materix to updated with the projection information
  9125. * @param viewMatrix The transform matrix of the light
  9126. * @param renderList The list of mesh to render in the map
  9127. * @returns The current light
  9128. */
  9129. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9130. }
  9131. }
  9132. declare module "babylonjs/Materials/effectFallbacks" {
  9133. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9134. import { Effect } from "babylonjs/Materials/effect";
  9135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9136. /**
  9137. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9138. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9139. */
  9140. export class EffectFallbacks implements IEffectFallbacks {
  9141. private _defines;
  9142. private _currentRank;
  9143. private _maxRank;
  9144. private _mesh;
  9145. /**
  9146. * Removes the fallback from the bound mesh.
  9147. */
  9148. unBindMesh(): void;
  9149. /**
  9150. * Adds a fallback on the specified property.
  9151. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9152. * @param define The name of the define in the shader
  9153. */
  9154. addFallback(rank: number, define: string): void;
  9155. /**
  9156. * Sets the mesh to use CPU skinning when needing to fallback.
  9157. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9158. * @param mesh The mesh to use the fallbacks.
  9159. */
  9160. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9161. /**
  9162. * Checks to see if more fallbacks are still availible.
  9163. */
  9164. get hasMoreFallbacks(): boolean;
  9165. /**
  9166. * Removes the defines that should be removed when falling back.
  9167. * @param currentDefines defines the current define statements for the shader.
  9168. * @param effect defines the current effect we try to compile
  9169. * @returns The resulting defines with defines of the current rank removed.
  9170. */
  9171. reduce(currentDefines: string, effect: Effect): string;
  9172. }
  9173. }
  9174. declare module "babylonjs/Materials/materialHelper" {
  9175. import { Nullable } from "babylonjs/types";
  9176. import { Scene } from "babylonjs/scene";
  9177. import { Engine } from "babylonjs/Engines/engine";
  9178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9179. import { Light } from "babylonjs/Lights/light";
  9180. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9181. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9183. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9184. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9185. /**
  9186. * "Static Class" containing the most commonly used helper while dealing with material for
  9187. * rendering purpose.
  9188. *
  9189. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9190. *
  9191. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9192. */
  9193. export class MaterialHelper {
  9194. /**
  9195. * Bind the current view position to an effect.
  9196. * @param effect The effect to be bound
  9197. * @param scene The scene the eyes position is used from
  9198. */
  9199. static BindEyePosition(effect: Effect, scene: Scene): void;
  9200. /**
  9201. * Helps preparing the defines values about the UVs in used in the effect.
  9202. * UVs are shared as much as we can accross channels in the shaders.
  9203. * @param texture The texture we are preparing the UVs for
  9204. * @param defines The defines to update
  9205. * @param key The channel key "diffuse", "specular"... used in the shader
  9206. */
  9207. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9208. /**
  9209. * Binds a texture matrix value to its corrsponding uniform
  9210. * @param texture The texture to bind the matrix for
  9211. * @param uniformBuffer The uniform buffer receivin the data
  9212. * @param key The channel key "diffuse", "specular"... used in the shader
  9213. */
  9214. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9215. /**
  9216. * Gets the current status of the fog (should it be enabled?)
  9217. * @param mesh defines the mesh to evaluate for fog support
  9218. * @param scene defines the hosting scene
  9219. * @returns true if fog must be enabled
  9220. */
  9221. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9222. /**
  9223. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9224. * @param mesh defines the current mesh
  9225. * @param scene defines the current scene
  9226. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9227. * @param pointsCloud defines if point cloud rendering has to be turned on
  9228. * @param fogEnabled defines if fog has to be turned on
  9229. * @param alphaTest defines if alpha testing has to be turned on
  9230. * @param defines defines the current list of defines
  9231. */
  9232. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9233. /**
  9234. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9235. * @param scene defines the current scene
  9236. * @param engine defines the current engine
  9237. * @param defines specifies the list of active defines
  9238. * @param useInstances defines if instances have to be turned on
  9239. * @param useClipPlane defines if clip plane have to be turned on
  9240. */
  9241. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9242. /**
  9243. * Prepares the defines for bones
  9244. * @param mesh The mesh containing the geometry data we will draw
  9245. * @param defines The defines to update
  9246. */
  9247. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9248. /**
  9249. * Prepares the defines for morph targets
  9250. * @param mesh The mesh containing the geometry data we will draw
  9251. * @param defines The defines to update
  9252. */
  9253. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9254. /**
  9255. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9256. * @param mesh The mesh containing the geometry data we will draw
  9257. * @param defines The defines to update
  9258. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9259. * @param useBones Precise whether bones should be used or not (override mesh info)
  9260. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9261. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9262. * @returns false if defines are considered not dirty and have not been checked
  9263. */
  9264. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9265. /**
  9266. * Prepares the defines related to multiview
  9267. * @param scene The scene we are intending to draw
  9268. * @param defines The defines to update
  9269. */
  9270. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9271. /**
  9272. * Prepares the defines related to the light information passed in parameter
  9273. * @param scene The scene we are intending to draw
  9274. * @param mesh The mesh the effect is compiling for
  9275. * @param light The light the effect is compiling for
  9276. * @param lightIndex The index of the light
  9277. * @param defines The defines to update
  9278. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9279. * @param state Defines the current state regarding what is needed (normals, etc...)
  9280. */
  9281. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9282. needNormals: boolean;
  9283. needRebuild: boolean;
  9284. shadowEnabled: boolean;
  9285. specularEnabled: boolean;
  9286. lightmapMode: boolean;
  9287. }): void;
  9288. /**
  9289. * Prepares the defines related to the light information passed in parameter
  9290. * @param scene The scene we are intending to draw
  9291. * @param mesh The mesh the effect is compiling for
  9292. * @param defines The defines to update
  9293. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9294. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9295. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9296. * @returns true if normals will be required for the rest of the effect
  9297. */
  9298. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9299. /**
  9300. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9301. * @param lightIndex defines the light index
  9302. * @param uniformsList The uniform list
  9303. * @param samplersList The sampler list
  9304. * @param projectedLightTexture defines if projected texture must be used
  9305. * @param uniformBuffersList defines an optional list of uniform buffers
  9306. */
  9307. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9308. /**
  9309. * Prepares the uniforms and samplers list to be used in the effect
  9310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9311. * @param samplersList The sampler list
  9312. * @param defines The defines helping in the list generation
  9313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9314. */
  9315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9316. /**
  9317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9318. * @param defines The defines to update while falling back
  9319. * @param fallbacks The authorized effect fallbacks
  9320. * @param maxSimultaneousLights The maximum number of lights allowed
  9321. * @param rank the current rank of the Effect
  9322. * @returns The newly affected rank
  9323. */
  9324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9325. private static _TmpMorphInfluencers;
  9326. /**
  9327. * Prepares the list of attributes required for morph targets according to the effect defines.
  9328. * @param attribs The current list of supported attribs
  9329. * @param mesh The mesh to prepare the morph targets attributes for
  9330. * @param influencers The number of influencers
  9331. */
  9332. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9333. /**
  9334. * Prepares the list of attributes required for morph targets according to the effect defines.
  9335. * @param attribs The current list of supported attribs
  9336. * @param mesh The mesh to prepare the morph targets attributes for
  9337. * @param defines The current Defines of the effect
  9338. */
  9339. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9340. /**
  9341. * Prepares the list of attributes required for bones according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param mesh The mesh to prepare the bones attributes for
  9344. * @param defines The current Defines of the effect
  9345. * @param fallbacks The current efffect fallback strategy
  9346. */
  9347. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9348. /**
  9349. * Check and prepare the list of attributes required for instances according to the effect defines.
  9350. * @param attribs The current list of supported attribs
  9351. * @param defines The current MaterialDefines of the effect
  9352. */
  9353. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9354. /**
  9355. * Add the list of attributes required for instances to the attribs array.
  9356. * @param attribs The current list of supported attribs
  9357. */
  9358. static PushAttributesForInstances(attribs: string[]): void;
  9359. /**
  9360. * Binds the light information to the effect.
  9361. * @param light The light containing the generator
  9362. * @param effect The effect we are binding the data to
  9363. * @param lightIndex The light index in the effect used to render
  9364. */
  9365. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9366. /**
  9367. * Binds the lights information from the scene to the effect for the given mesh.
  9368. * @param light Light to bind
  9369. * @param lightIndex Light index
  9370. * @param scene The scene where the light belongs to
  9371. * @param effect The effect we are binding the data to
  9372. * @param useSpecular Defines if specular is supported
  9373. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9374. */
  9375. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9376. /**
  9377. * Binds the lights information from the scene to the effect for the given mesh.
  9378. * @param scene The scene the lights belongs to
  9379. * @param mesh The mesh we are binding the information to render
  9380. * @param effect The effect we are binding the data to
  9381. * @param defines The generated defines for the effect
  9382. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9383. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9384. */
  9385. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9386. private static _tempFogColor;
  9387. /**
  9388. * Binds the fog information from the scene to the effect for the given mesh.
  9389. * @param scene The scene the lights belongs to
  9390. * @param mesh The mesh we are binding the information to render
  9391. * @param effect The effect we are binding the data to
  9392. * @param linearSpace Defines if the fog effect is applied in linear space
  9393. */
  9394. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9395. /**
  9396. * Binds the bones information from the mesh to the effect.
  9397. * @param mesh The mesh we are binding the information to render
  9398. * @param effect The effect we are binding the data to
  9399. */
  9400. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9401. /**
  9402. * Binds the morph targets information from the mesh to the effect.
  9403. * @param abstractMesh The mesh we are binding the information to render
  9404. * @param effect The effect we are binding the data to
  9405. */
  9406. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9407. /**
  9408. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9409. * @param defines The generated defines used in the effect
  9410. * @param effect The effect we are binding the data to
  9411. * @param scene The scene we are willing to render with logarithmic scale for
  9412. */
  9413. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9414. /**
  9415. * Binds the clip plane information from the scene to the effect.
  9416. * @param scene The scene the clip plane information are extracted from
  9417. * @param effect The effect we are binding the data to
  9418. */
  9419. static BindClipPlane(effect: Effect, scene: Scene): void;
  9420. }
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9423. /** @hidden */
  9424. export var packingFunctions: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9430. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9431. /** @hidden */
  9432. export var shadowMapPixelShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9438. /** @hidden */
  9439. export var bonesDeclaration: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9445. /** @hidden */
  9446. export var morphTargetsVertexGlobalDeclaration: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9452. /** @hidden */
  9453. export var morphTargetsVertexDeclaration: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9459. /** @hidden */
  9460. export var instancesDeclaration: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9466. /** @hidden */
  9467. export var helperFunctions: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9473. /** @hidden */
  9474. export var morphTargetsVertex: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9480. /** @hidden */
  9481. export var instancesVertex: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9487. /** @hidden */
  9488. export var bonesVertex: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9502. /** @hidden */
  9503. export var shadowMapVertexShader: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9509. /** @hidden */
  9510. export var depthBoxBlurPixelShader: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9516. import { SmartArray } from "babylonjs/Misc/smartArray";
  9517. import { Nullable } from "babylonjs/types";
  9518. import { Scene } from "babylonjs/scene";
  9519. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9522. import { Mesh } from "babylonjs/Meshes/mesh";
  9523. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9524. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9525. import { Effect } from "babylonjs/Materials/effect";
  9526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9527. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  9528. import "babylonjs/Shaders/shadowMap.fragment";
  9529. import "babylonjs/Shaders/shadowMap.vertex";
  9530. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9531. import { Observable } from "babylonjs/Misc/observable";
  9532. /**
  9533. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9534. */
  9535. export interface ICustomShaderOptions {
  9536. /**
  9537. * Gets or sets the custom shader name to use
  9538. */
  9539. shaderName: string;
  9540. /**
  9541. * The list of attribute names used in the shader
  9542. */
  9543. attributes?: string[];
  9544. /**
  9545. * The list of unifrom names used in the shader
  9546. */
  9547. uniforms?: string[];
  9548. /**
  9549. * The list of sampler names used in the shader
  9550. */
  9551. samplers?: string[];
  9552. /**
  9553. * The list of defines used in the shader
  9554. */
  9555. defines?: string[];
  9556. }
  9557. /**
  9558. * Interface to implement to create a shadow generator compatible with BJS.
  9559. */
  9560. export interface IShadowGenerator {
  9561. /**
  9562. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9563. * @returns The render target texture if present otherwise, null
  9564. */
  9565. getShadowMap(): Nullable<RenderTargetTexture>;
  9566. /**
  9567. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9568. * @param subMesh The submesh we want to render in the shadow map
  9569. * @param useInstances Defines wether will draw in the map using instances
  9570. * @returns true if ready otherwise, false
  9571. */
  9572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9573. /**
  9574. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9575. * @param defines Defines of the material we want to update
  9576. * @param lightIndex Index of the light in the enabled light list of the material
  9577. */
  9578. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9579. /**
  9580. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9581. * defined in the generator but impacting the effect).
  9582. * It implies the unifroms available on the materials are the standard BJS ones.
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. /**
  9599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9600. * @param onCompiled Callback triggered at the and of the effects compilation
  9601. * @param options Sets of optional options forcing the compilation with different modes
  9602. */
  9603. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9604. useInstances: boolean;
  9605. }>): void;
  9606. /**
  9607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9608. * @param options Sets of optional options forcing the compilation with different modes
  9609. * @returns A promise that resolves when the compilation completes
  9610. */
  9611. forceCompilationAsync(options?: Partial<{
  9612. useInstances: boolean;
  9613. }>): Promise<void>;
  9614. /**
  9615. * Serializes the shadow generator setup to a json object.
  9616. * @returns The serialized JSON object
  9617. */
  9618. serialize(): any;
  9619. /**
  9620. * Disposes the Shadow map and related Textures and effects.
  9621. */
  9622. dispose(): void;
  9623. }
  9624. /**
  9625. * Default implementation IShadowGenerator.
  9626. * This is the main object responsible of generating shadows in the framework.
  9627. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9628. */
  9629. export class ShadowGenerator implements IShadowGenerator {
  9630. /**
  9631. * Name of the shadow generator class
  9632. */
  9633. static CLASSNAME: string;
  9634. /**
  9635. * Shadow generator mode None: no filtering applied.
  9636. */
  9637. static readonly FILTER_NONE: number;
  9638. /**
  9639. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9640. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9641. */
  9642. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9643. /**
  9644. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9645. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9646. */
  9647. static readonly FILTER_POISSONSAMPLING: number;
  9648. /**
  9649. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9650. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9651. */
  9652. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9653. /**
  9654. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9655. * edge artifacts on steep falloff.
  9656. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9657. */
  9658. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9659. /**
  9660. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9661. * edge artifacts on steep falloff.
  9662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9663. */
  9664. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9665. /**
  9666. * Shadow generator mode PCF: Percentage Closer Filtering
  9667. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9668. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9669. */
  9670. static readonly FILTER_PCF: number;
  9671. /**
  9672. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9673. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9674. * Contact Hardening
  9675. */
  9676. static readonly FILTER_PCSS: number;
  9677. /**
  9678. * Reserved for PCF and PCSS
  9679. * Highest Quality.
  9680. *
  9681. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9682. *
  9683. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9684. */
  9685. static readonly QUALITY_HIGH: number;
  9686. /**
  9687. * Reserved for PCF and PCSS
  9688. * Good tradeoff for quality/perf cross devices
  9689. *
  9690. * Execute PCF on a 3*3 kernel.
  9691. *
  9692. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9693. */
  9694. static readonly QUALITY_MEDIUM: number;
  9695. /**
  9696. * Reserved for PCF and PCSS
  9697. * The lowest quality but the fastest.
  9698. *
  9699. * Execute PCF on a 1*1 kernel.
  9700. *
  9701. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9702. */
  9703. static readonly QUALITY_LOW: number;
  9704. /** Gets or sets the custom shader name to use */
  9705. customShaderOptions: ICustomShaderOptions;
  9706. /**
  9707. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9708. */
  9709. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9710. /**
  9711. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9712. */
  9713. onAfterShadowMapRenderObservable: Observable<Effect>;
  9714. /**
  9715. * Observable triggered before a mesh is rendered in the shadow map.
  9716. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9717. */
  9718. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9719. /**
  9720. * Observable triggered after a mesh is rendered in the shadow map.
  9721. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9722. */
  9723. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9724. protected _bias: number;
  9725. /**
  9726. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9727. */
  9728. get bias(): number;
  9729. /**
  9730. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9731. */
  9732. set bias(bias: number);
  9733. protected _normalBias: number;
  9734. /**
  9735. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9736. */
  9737. get normalBias(): number;
  9738. /**
  9739. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9740. */
  9741. set normalBias(normalBias: number);
  9742. protected _blurBoxOffset: number;
  9743. /**
  9744. * Gets the blur box offset: offset applied during the blur pass.
  9745. * Only useful if useKernelBlur = false
  9746. */
  9747. get blurBoxOffset(): number;
  9748. /**
  9749. * Sets the blur box offset: offset applied during the blur pass.
  9750. * Only useful if useKernelBlur = false
  9751. */
  9752. set blurBoxOffset(value: number);
  9753. protected _blurScale: number;
  9754. /**
  9755. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9756. * 2 means half of the size.
  9757. */
  9758. get blurScale(): number;
  9759. /**
  9760. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9761. * 2 means half of the size.
  9762. */
  9763. set blurScale(value: number);
  9764. protected _blurKernel: number;
  9765. /**
  9766. * Gets the blur kernel: kernel size of the blur pass.
  9767. * Only useful if useKernelBlur = true
  9768. */
  9769. get blurKernel(): number;
  9770. /**
  9771. * Sets the blur kernel: kernel size of the blur pass.
  9772. * Only useful if useKernelBlur = true
  9773. */
  9774. set blurKernel(value: number);
  9775. protected _useKernelBlur: boolean;
  9776. /**
  9777. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9778. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9779. */
  9780. get useKernelBlur(): boolean;
  9781. /**
  9782. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9783. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9784. */
  9785. set useKernelBlur(value: boolean);
  9786. protected _depthScale: number;
  9787. /**
  9788. * Gets the depth scale used in ESM mode.
  9789. */
  9790. get depthScale(): number;
  9791. /**
  9792. * Sets the depth scale used in ESM mode.
  9793. * This can override the scale stored on the light.
  9794. */
  9795. set depthScale(value: number);
  9796. protected _validateFilter(filter: number): number;
  9797. protected _filter: number;
  9798. /**
  9799. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9800. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9801. */
  9802. get filter(): number;
  9803. /**
  9804. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9805. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9806. */
  9807. set filter(value: number);
  9808. /**
  9809. * Gets if the current filter is set to Poisson Sampling.
  9810. */
  9811. get usePoissonSampling(): boolean;
  9812. /**
  9813. * Sets the current filter to Poisson Sampling.
  9814. */
  9815. set usePoissonSampling(value: boolean);
  9816. /**
  9817. * Gets if the current filter is set to ESM.
  9818. */
  9819. get useExponentialShadowMap(): boolean;
  9820. /**
  9821. * Sets the current filter is to ESM.
  9822. */
  9823. set useExponentialShadowMap(value: boolean);
  9824. /**
  9825. * Gets if the current filter is set to filtered ESM.
  9826. */
  9827. get useBlurExponentialShadowMap(): boolean;
  9828. /**
  9829. * Gets if the current filter is set to filtered ESM.
  9830. */
  9831. set useBlurExponentialShadowMap(value: boolean);
  9832. /**
  9833. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. get useCloseExponentialShadowMap(): boolean;
  9837. /**
  9838. * Sets the current filter to "close ESM" (using the inverse of the
  9839. * exponential to prevent steep falloff artifacts).
  9840. */
  9841. set useCloseExponentialShadowMap(value: boolean);
  9842. /**
  9843. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9844. * exponential to prevent steep falloff artifacts).
  9845. */
  9846. get useBlurCloseExponentialShadowMap(): boolean;
  9847. /**
  9848. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9849. * exponential to prevent steep falloff artifacts).
  9850. */
  9851. set useBlurCloseExponentialShadowMap(value: boolean);
  9852. /**
  9853. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9854. */
  9855. get usePercentageCloserFiltering(): boolean;
  9856. /**
  9857. * Sets the current filter to "PCF" (percentage closer filtering).
  9858. */
  9859. set usePercentageCloserFiltering(value: boolean);
  9860. protected _filteringQuality: number;
  9861. /**
  9862. * Gets the PCF or PCSS Quality.
  9863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9864. */
  9865. get filteringQuality(): number;
  9866. /**
  9867. * Sets the PCF or PCSS Quality.
  9868. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9869. */
  9870. set filteringQuality(filteringQuality: number);
  9871. /**
  9872. * Gets if the current filter is set to "PCSS" (contact hardening).
  9873. */
  9874. get useContactHardeningShadow(): boolean;
  9875. /**
  9876. * Sets the current filter to "PCSS" (contact hardening).
  9877. */
  9878. set useContactHardeningShadow(value: boolean);
  9879. protected _contactHardeningLightSizeUVRatio: number;
  9880. /**
  9881. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9882. * Using a ratio helps keeping shape stability independently of the map size.
  9883. *
  9884. * It does not account for the light projection as it was having too much
  9885. * instability during the light setup or during light position changes.
  9886. *
  9887. * Only valid if useContactHardeningShadow is true.
  9888. */
  9889. get contactHardeningLightSizeUVRatio(): number;
  9890. /**
  9891. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9892. * Using a ratio helps keeping shape stability independently of the map size.
  9893. *
  9894. * It does not account for the light projection as it was having too much
  9895. * instability during the light setup or during light position changes.
  9896. *
  9897. * Only valid if useContactHardeningShadow is true.
  9898. */
  9899. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9900. protected _darkness: number;
  9901. /** Gets or sets the actual darkness of a shadow */
  9902. get darkness(): number;
  9903. set darkness(value: number);
  9904. /**
  9905. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9906. * 0 means strongest and 1 would means no shadow.
  9907. * @returns the darkness.
  9908. */
  9909. getDarkness(): number;
  9910. /**
  9911. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9912. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9913. * @returns the shadow generator allowing fluent coding.
  9914. */
  9915. setDarkness(darkness: number): ShadowGenerator;
  9916. protected _transparencyShadow: boolean;
  9917. /** Gets or sets the ability to have transparent shadow */
  9918. get transparencyShadow(): boolean;
  9919. set transparencyShadow(value: boolean);
  9920. /**
  9921. * Sets the ability to have transparent shadow (boolean).
  9922. * @param transparent True if transparent else False
  9923. * @returns the shadow generator allowing fluent coding
  9924. */
  9925. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9926. protected _shadowMap: Nullable<RenderTargetTexture>;
  9927. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9930. * @returns The render target texture if present otherwise, null
  9931. */
  9932. getShadowMap(): Nullable<RenderTargetTexture>;
  9933. /**
  9934. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9935. * @returns The render target texture if the shadow map is present otherwise, null
  9936. */
  9937. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9938. /**
  9939. * Gets the class name of that object
  9940. * @returns "ShadowGenerator"
  9941. */
  9942. getClassName(): string;
  9943. /**
  9944. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9945. * @param mesh Mesh to add
  9946. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9947. * @returns the Shadow Generator itself
  9948. */
  9949. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9950. /**
  9951. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9952. * @param mesh Mesh to remove
  9953. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9954. * @returns the Shadow Generator itself
  9955. */
  9956. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9957. /**
  9958. * Controls the extent to which the shadows fade out at the edge of the frustum
  9959. */
  9960. frustumEdgeFalloff: number;
  9961. protected _light: IShadowLight;
  9962. /**
  9963. * Returns the associated light object.
  9964. * @returns the light generating the shadow
  9965. */
  9966. getLight(): IShadowLight;
  9967. /**
  9968. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9969. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9970. * It might on the other hand introduce peter panning.
  9971. */
  9972. forceBackFacesOnly: boolean;
  9973. protected _scene: Scene;
  9974. protected _lightDirection: Vector3;
  9975. protected _effect: Effect;
  9976. protected _viewMatrix: Matrix;
  9977. protected _projectionMatrix: Matrix;
  9978. protected _transformMatrix: Matrix;
  9979. protected _cachedPosition: Vector3;
  9980. protected _cachedDirection: Vector3;
  9981. protected _cachedDefines: string;
  9982. protected _currentRenderID: number;
  9983. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9984. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9985. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9986. protected _blurPostProcesses: PostProcess[];
  9987. protected _mapSize: number;
  9988. protected _currentFaceIndex: number;
  9989. protected _currentFaceIndexCache: number;
  9990. protected _textureType: number;
  9991. protected _defaultTextureMatrix: Matrix;
  9992. protected _storedUniqueId: Nullable<number>;
  9993. /** @hidden */
  9994. static _SceneComponentInitialization: (scene: Scene) => void;
  9995. /**
  9996. * Creates a ShadowGenerator object.
  9997. * A ShadowGenerator is the required tool to use the shadows.
  9998. * Each light casting shadows needs to use its own ShadowGenerator.
  9999. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10000. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10001. * @param light The light object generating the shadows.
  10002. * @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.
  10003. */
  10004. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10005. protected _initializeGenerator(): void;
  10006. protected _createTargetRenderTexture(): void;
  10007. protected _initializeShadowMap(): void;
  10008. protected _initializeBlurRTTAndPostProcesses(): void;
  10009. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  10010. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  10011. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  10012. protected _applyFilterValues(): void;
  10013. /**
  10014. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10015. * @param onCompiled Callback triggered at the and of the effects compilation
  10016. * @param options Sets of optional options forcing the compilation with different modes
  10017. */
  10018. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  10019. useInstances: boolean;
  10020. }>): void;
  10021. /**
  10022. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10023. * @param options Sets of optional options forcing the compilation with different modes
  10024. * @returns A promise that resolves when the compilation completes
  10025. */
  10026. forceCompilationAsync(options?: Partial<{
  10027. useInstances: boolean;
  10028. }>): Promise<void>;
  10029. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  10030. /**
  10031. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10032. * @param subMesh The submesh we want to render in the shadow map
  10033. * @param useInstances Defines wether will draw in the map using instances
  10034. * @returns true if ready otherwise, false
  10035. */
  10036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10037. /**
  10038. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10039. * @param defines Defines of the material we want to update
  10040. * @param lightIndex Index of the light in the enabled light list of the material
  10041. */
  10042. prepareDefines(defines: any, lightIndex: number): void;
  10043. /**
  10044. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10045. * defined in the generator but impacting the effect).
  10046. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10047. * @param effect The effect we are binfing the information for
  10048. */
  10049. bindShadowLight(lightIndex: string, effect: Effect): void;
  10050. /**
  10051. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10052. * (eq to shadow prjection matrix * light transform matrix)
  10053. * @returns The transform matrix used to create the shadow map
  10054. */
  10055. getTransformMatrix(): Matrix;
  10056. /**
  10057. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10058. * Cube and 2D textures for instance.
  10059. */
  10060. recreateShadowMap(): void;
  10061. protected _disposeBlurPostProcesses(): void;
  10062. protected _disposeRTTandPostProcesses(): void;
  10063. /**
  10064. * Disposes the ShadowGenerator.
  10065. * Returns nothing.
  10066. */
  10067. dispose(): void;
  10068. /**
  10069. * Serializes the shadow generator setup to a json object.
  10070. * @returns The serialized JSON object
  10071. */
  10072. serialize(): any;
  10073. /**
  10074. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10075. * @param parsedShadowGenerator The JSON object to parse
  10076. * @param scene The scene to create the shadow map for
  10077. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  10078. * @returns The parsed shadow generator
  10079. */
  10080. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  10081. }
  10082. }
  10083. declare module "babylonjs/Lights/light" {
  10084. import { Nullable } from "babylonjs/types";
  10085. import { Scene } from "babylonjs/scene";
  10086. import { Vector3 } from "babylonjs/Maths/math.vector";
  10087. import { Color3 } from "babylonjs/Maths/math.color";
  10088. import { Node } from "babylonjs/node";
  10089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10090. import { Effect } from "babylonjs/Materials/effect";
  10091. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10092. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10093. /**
  10094. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10095. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10096. * 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.
  10097. */
  10098. export abstract class Light extends Node {
  10099. /**
  10100. * Falloff Default: light is falling off following the material specification:
  10101. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10102. */
  10103. static readonly FALLOFF_DEFAULT: number;
  10104. /**
  10105. * Falloff Physical: light is falling off following the inverse squared distance law.
  10106. */
  10107. static readonly FALLOFF_PHYSICAL: number;
  10108. /**
  10109. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10110. * to enhance interoperability with other engines.
  10111. */
  10112. static readonly FALLOFF_GLTF: number;
  10113. /**
  10114. * Falloff Standard: light is falling off like in the standard material
  10115. * to enhance interoperability with other materials.
  10116. */
  10117. static readonly FALLOFF_STANDARD: number;
  10118. /**
  10119. * If every light affecting the material is in this lightmapMode,
  10120. * material.lightmapTexture adds or multiplies
  10121. * (depends on material.useLightmapAsShadowmap)
  10122. * after every other light calculations.
  10123. */
  10124. static readonly LIGHTMAP_DEFAULT: number;
  10125. /**
  10126. * material.lightmapTexture as only diffuse lighting from this light
  10127. * adds only specular lighting from this light
  10128. * adds dynamic shadows
  10129. */
  10130. static readonly LIGHTMAP_SPECULAR: number;
  10131. /**
  10132. * material.lightmapTexture as only lighting
  10133. * no light calculation from this light
  10134. * only adds dynamic shadows from this light
  10135. */
  10136. static readonly LIGHTMAP_SHADOWSONLY: number;
  10137. /**
  10138. * Each light type uses the default quantity according to its type:
  10139. * point/spot lights use luminous intensity
  10140. * directional lights use illuminance
  10141. */
  10142. static readonly INTENSITYMODE_AUTOMATIC: number;
  10143. /**
  10144. * lumen (lm)
  10145. */
  10146. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10147. /**
  10148. * candela (lm/sr)
  10149. */
  10150. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10151. /**
  10152. * lux (lm/m^2)
  10153. */
  10154. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10155. /**
  10156. * nit (cd/m^2)
  10157. */
  10158. static readonly INTENSITYMODE_LUMINANCE: number;
  10159. /**
  10160. * Light type const id of the point light.
  10161. */
  10162. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10163. /**
  10164. * Light type const id of the directional light.
  10165. */
  10166. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10167. /**
  10168. * Light type const id of the spot light.
  10169. */
  10170. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10171. /**
  10172. * Light type const id of the hemispheric light.
  10173. */
  10174. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10175. /**
  10176. * Diffuse gives the basic color to an object.
  10177. */
  10178. diffuse: Color3;
  10179. /**
  10180. * Specular produces a highlight color on an object.
  10181. * Note: This is note affecting PBR materials.
  10182. */
  10183. specular: Color3;
  10184. /**
  10185. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10186. * falling off base on range or angle.
  10187. * This can be set to any values in Light.FALLOFF_x.
  10188. *
  10189. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10190. * other types of materials.
  10191. */
  10192. falloffType: number;
  10193. /**
  10194. * Strength of the light.
  10195. * Note: By default it is define in the framework own unit.
  10196. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10197. */
  10198. intensity: number;
  10199. private _range;
  10200. protected _inverseSquaredRange: number;
  10201. /**
  10202. * Defines how far from the source the light is impacting in scene units.
  10203. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10204. */
  10205. get range(): number;
  10206. /**
  10207. * Defines how far from the source the light is impacting in scene units.
  10208. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10209. */
  10210. set range(value: number);
  10211. /**
  10212. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10213. * of light.
  10214. */
  10215. private _photometricScale;
  10216. private _intensityMode;
  10217. /**
  10218. * Gets the photometric scale used to interpret the intensity.
  10219. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10220. */
  10221. get intensityMode(): number;
  10222. /**
  10223. * Sets the photometric scale used to interpret the intensity.
  10224. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10225. */
  10226. set intensityMode(value: number);
  10227. private _radius;
  10228. /**
  10229. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10230. */
  10231. get radius(): number;
  10232. /**
  10233. * sets the light radius used by PBR Materials to simulate soft area lights.
  10234. */
  10235. set radius(value: number);
  10236. private _renderPriority;
  10237. /**
  10238. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10239. * exceeding the number allowed of the materials.
  10240. */
  10241. renderPriority: number;
  10242. private _shadowEnabled;
  10243. /**
  10244. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10245. * the current shadow generator.
  10246. */
  10247. get shadowEnabled(): boolean;
  10248. /**
  10249. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10250. * the current shadow generator.
  10251. */
  10252. set shadowEnabled(value: boolean);
  10253. private _includedOnlyMeshes;
  10254. /**
  10255. * Gets the only meshes impacted by this light.
  10256. */
  10257. get includedOnlyMeshes(): AbstractMesh[];
  10258. /**
  10259. * Sets the only meshes impacted by this light.
  10260. */
  10261. set includedOnlyMeshes(value: AbstractMesh[]);
  10262. private _excludedMeshes;
  10263. /**
  10264. * Gets the meshes not impacted by this light.
  10265. */
  10266. get excludedMeshes(): AbstractMesh[];
  10267. /**
  10268. * Sets the meshes not impacted by this light.
  10269. */
  10270. set excludedMeshes(value: AbstractMesh[]);
  10271. private _excludeWithLayerMask;
  10272. /**
  10273. * Gets the layer id use to find what meshes are not impacted by the light.
  10274. * Inactive if 0
  10275. */
  10276. get excludeWithLayerMask(): number;
  10277. /**
  10278. * Sets the layer id use to find what meshes are not impacted by the light.
  10279. * Inactive if 0
  10280. */
  10281. set excludeWithLayerMask(value: number);
  10282. private _includeOnlyWithLayerMask;
  10283. /**
  10284. * Gets the layer id use to find what meshes are impacted by the light.
  10285. * Inactive if 0
  10286. */
  10287. get includeOnlyWithLayerMask(): number;
  10288. /**
  10289. * Sets the layer id use to find what meshes are impacted by the light.
  10290. * Inactive if 0
  10291. */
  10292. set includeOnlyWithLayerMask(value: number);
  10293. private _lightmapMode;
  10294. /**
  10295. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10296. */
  10297. get lightmapMode(): number;
  10298. /**
  10299. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10300. */
  10301. set lightmapMode(value: number);
  10302. /**
  10303. * Shadow generator associted to the light.
  10304. * @hidden Internal use only.
  10305. */
  10306. _shadowGenerator: Nullable<IShadowGenerator>;
  10307. /**
  10308. * @hidden Internal use only.
  10309. */
  10310. _excludedMeshesIds: string[];
  10311. /**
  10312. * @hidden Internal use only.
  10313. */
  10314. _includedOnlyMeshesIds: string[];
  10315. /**
  10316. * The current light unifom buffer.
  10317. * @hidden Internal use only.
  10318. */
  10319. _uniformBuffer: UniformBuffer;
  10320. /** @hidden */
  10321. _renderId: number;
  10322. /**
  10323. * Creates a Light object in the scene.
  10324. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10325. * @param name The firendly name of the light
  10326. * @param scene The scene the light belongs too
  10327. */
  10328. constructor(name: string, scene: Scene);
  10329. protected abstract _buildUniformLayout(): void;
  10330. /**
  10331. * Sets the passed Effect "effect" with the Light information.
  10332. * @param effect The effect to update
  10333. * @param lightIndex The index of the light in the effect to update
  10334. * @returns The light
  10335. */
  10336. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10337. /**
  10338. * Sets the passed Effect "effect" with the Light textures.
  10339. * @param effect The effect to update
  10340. * @param lightIndex The index of the light in the effect to update
  10341. * @returns The light
  10342. */
  10343. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10344. /**
  10345. * Binds the lights information from the scene to the effect for the given mesh.
  10346. * @param lightIndex Light index
  10347. * @param scene The scene where the light belongs to
  10348. * @param effect The effect we are binding the data to
  10349. * @param useSpecular Defines if specular is supported
  10350. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10351. */
  10352. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10353. /**
  10354. * Sets the passed Effect "effect" with the Light information.
  10355. * @param effect The effect to update
  10356. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10357. * @returns The light
  10358. */
  10359. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10360. /**
  10361. * Returns the string "Light".
  10362. * @returns the class name
  10363. */
  10364. getClassName(): string;
  10365. /** @hidden */
  10366. readonly _isLight: boolean;
  10367. /**
  10368. * Converts the light information to a readable string for debug purpose.
  10369. * @param fullDetails Supports for multiple levels of logging within scene loading
  10370. * @returns the human readable light info
  10371. */
  10372. toString(fullDetails?: boolean): string;
  10373. /** @hidden */
  10374. protected _syncParentEnabledState(): void;
  10375. /**
  10376. * Set the enabled state of this node.
  10377. * @param value - the new enabled state
  10378. */
  10379. setEnabled(value: boolean): void;
  10380. /**
  10381. * Returns the Light associated shadow generator if any.
  10382. * @return the associated shadow generator.
  10383. */
  10384. getShadowGenerator(): Nullable<IShadowGenerator>;
  10385. /**
  10386. * Returns a Vector3, the absolute light position in the World.
  10387. * @returns the world space position of the light
  10388. */
  10389. getAbsolutePosition(): Vector3;
  10390. /**
  10391. * Specifies if the light will affect the passed mesh.
  10392. * @param mesh The mesh to test against the light
  10393. * @return true the mesh is affected otherwise, false.
  10394. */
  10395. canAffectMesh(mesh: AbstractMesh): boolean;
  10396. /**
  10397. * Sort function to order lights for rendering.
  10398. * @param a First Light object to compare to second.
  10399. * @param b Second Light object to compare first.
  10400. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10401. */
  10402. static CompareLightsPriority(a: Light, b: Light): number;
  10403. /**
  10404. * Releases resources associated with this node.
  10405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10407. */
  10408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10409. /**
  10410. * Returns the light type ID (integer).
  10411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10412. */
  10413. getTypeID(): number;
  10414. /**
  10415. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10416. * @returns the scaled intensity in intensity mode unit
  10417. */
  10418. getScaledIntensity(): number;
  10419. /**
  10420. * Returns a new Light object, named "name", from the current one.
  10421. * @param name The name of the cloned light
  10422. * @returns the new created light
  10423. */
  10424. clone(name: string): Nullable<Light>;
  10425. /**
  10426. * Serializes the current light into a Serialization object.
  10427. * @returns the serialized object.
  10428. */
  10429. serialize(): any;
  10430. /**
  10431. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10432. * This new light is named "name" and added to the passed scene.
  10433. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10434. * @param name The friendly name of the light
  10435. * @param scene The scene the new light will belong to
  10436. * @returns the constructor function
  10437. */
  10438. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10439. /**
  10440. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10441. * @param parsedLight The JSON representation of the light
  10442. * @param scene The scene to create the parsed light in
  10443. * @returns the created light after parsing
  10444. */
  10445. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10446. private _hookArrayForExcluded;
  10447. private _hookArrayForIncludedOnly;
  10448. private _resyncMeshes;
  10449. /**
  10450. * Forces the meshes to update their light related information in their rendering used effects
  10451. * @hidden Internal Use Only
  10452. */
  10453. _markMeshesAsLightDirty(): void;
  10454. /**
  10455. * Recomputes the cached photometric scale if needed.
  10456. */
  10457. private _computePhotometricScale;
  10458. /**
  10459. * Returns the Photometric Scale according to the light type and intensity mode.
  10460. */
  10461. private _getPhotometricScale;
  10462. /**
  10463. * Reorder the light in the scene according to their defined priority.
  10464. * @hidden Internal Use Only
  10465. */
  10466. _reorderLightsInScene(): void;
  10467. /**
  10468. * Prepares the list of defines specific to the light type.
  10469. * @param defines the list of defines
  10470. * @param lightIndex defines the index of the light for the effect
  10471. */
  10472. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10473. }
  10474. }
  10475. declare module "babylonjs/Actions/action" {
  10476. import { Observable } from "babylonjs/Misc/observable";
  10477. import { Condition } from "babylonjs/Actions/condition";
  10478. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10479. import { ActionManager } from "babylonjs/Actions/actionManager";
  10480. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10481. /**
  10482. * Interface used to define Action
  10483. */
  10484. export interface IAction {
  10485. /**
  10486. * Trigger for the action
  10487. */
  10488. trigger: number;
  10489. /** Options of the trigger */
  10490. triggerOptions: any;
  10491. /**
  10492. * Gets the trigger parameters
  10493. * @returns the trigger parameters
  10494. */
  10495. getTriggerParameter(): any;
  10496. /**
  10497. * Internal only - executes current action event
  10498. * @hidden
  10499. */
  10500. _executeCurrent(evt?: ActionEvent): void;
  10501. /**
  10502. * Serialize placeholder for child classes
  10503. * @param parent of child
  10504. * @returns the serialized object
  10505. */
  10506. serialize(parent: any): any;
  10507. /**
  10508. * Internal only
  10509. * @hidden
  10510. */
  10511. _prepare(): void;
  10512. /**
  10513. * Internal only - manager for action
  10514. * @hidden
  10515. */
  10516. _actionManager: AbstractActionManager;
  10517. /**
  10518. * Adds action to chain of actions, may be a DoNothingAction
  10519. * @param action defines the next action to execute
  10520. * @returns The action passed in
  10521. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10522. */
  10523. then(action: IAction): IAction;
  10524. }
  10525. /**
  10526. * The action to be carried out following a trigger
  10527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10528. */
  10529. export class Action implements IAction {
  10530. /** the trigger, with or without parameters, for the action */
  10531. triggerOptions: any;
  10532. /**
  10533. * Trigger for the action
  10534. */
  10535. trigger: number;
  10536. /**
  10537. * Internal only - manager for action
  10538. * @hidden
  10539. */
  10540. _actionManager: ActionManager;
  10541. private _nextActiveAction;
  10542. private _child;
  10543. private _condition?;
  10544. private _triggerParameter;
  10545. /**
  10546. * An event triggered prior to action being executed.
  10547. */
  10548. onBeforeExecuteObservable: Observable<Action>;
  10549. /**
  10550. * Creates a new Action
  10551. * @param triggerOptions the trigger, with or without parameters, for the action
  10552. * @param condition an optional determinant of action
  10553. */
  10554. constructor(
  10555. /** the trigger, with or without parameters, for the action */
  10556. triggerOptions: any, condition?: Condition);
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. _prepare(): void;
  10562. /**
  10563. * Gets the trigger parameters
  10564. * @returns the trigger parameters
  10565. */
  10566. getTriggerParameter(): any;
  10567. /**
  10568. * Internal only - executes current action event
  10569. * @hidden
  10570. */
  10571. _executeCurrent(evt?: ActionEvent): void;
  10572. /**
  10573. * Execute placeholder for child classes
  10574. * @param evt optional action event
  10575. */
  10576. execute(evt?: ActionEvent): void;
  10577. /**
  10578. * Skips to next active action
  10579. */
  10580. skipToNextActiveAction(): void;
  10581. /**
  10582. * Adds action to chain of actions, may be a DoNothingAction
  10583. * @param action defines the next action to execute
  10584. * @returns The action passed in
  10585. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10586. */
  10587. then(action: Action): Action;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. _getProperty(propertyPath: string): string;
  10593. /**
  10594. * Internal only
  10595. * @hidden
  10596. */
  10597. _getEffectiveTarget(target: any, propertyPath: string): any;
  10598. /**
  10599. * Serialize placeholder for child classes
  10600. * @param parent of child
  10601. * @returns the serialized object
  10602. */
  10603. serialize(parent: any): any;
  10604. /**
  10605. * Internal only called by serialize
  10606. * @hidden
  10607. */
  10608. protected _serialize(serializedAction: any, parent?: any): any;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. static _SerializeValueAsString: (value: any) => string;
  10614. /**
  10615. * Internal only
  10616. * @hidden
  10617. */
  10618. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10619. name: string;
  10620. targetType: string;
  10621. value: string;
  10622. };
  10623. }
  10624. }
  10625. declare module "babylonjs/Actions/condition" {
  10626. import { ActionManager } from "babylonjs/Actions/actionManager";
  10627. /**
  10628. * A Condition applied to an Action
  10629. */
  10630. export class Condition {
  10631. /**
  10632. * Internal only - manager for action
  10633. * @hidden
  10634. */
  10635. _actionManager: ActionManager;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. _evaluationId: number;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. _currentResult: boolean;
  10646. /**
  10647. * Creates a new Condition
  10648. * @param actionManager the manager of the action the condition is applied to
  10649. */
  10650. constructor(actionManager: ActionManager);
  10651. /**
  10652. * Check if the current condition is valid
  10653. * @returns a boolean
  10654. */
  10655. isValid(): boolean;
  10656. /**
  10657. * Internal only
  10658. * @hidden
  10659. */
  10660. _getProperty(propertyPath: string): string;
  10661. /**
  10662. * Internal only
  10663. * @hidden
  10664. */
  10665. _getEffectiveTarget(target: any, propertyPath: string): any;
  10666. /**
  10667. * Serialize placeholder for child classes
  10668. * @returns the serialized object
  10669. */
  10670. serialize(): any;
  10671. /**
  10672. * Internal only
  10673. * @hidden
  10674. */
  10675. protected _serialize(serializedCondition: any): any;
  10676. }
  10677. /**
  10678. * Defines specific conditional operators as extensions of Condition
  10679. */
  10680. export class ValueCondition extends Condition {
  10681. /** path to specify the property of the target the conditional operator uses */
  10682. propertyPath: string;
  10683. /** the value compared by the conditional operator against the current value of the property */
  10684. value: any;
  10685. /** the conditional operator, default ValueCondition.IsEqual */
  10686. operator: number;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. private static _IsEqual;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. private static _IsDifferent;
  10697. /**
  10698. * Internal only
  10699. * @hidden
  10700. */
  10701. private static _IsGreater;
  10702. /**
  10703. * Internal only
  10704. * @hidden
  10705. */
  10706. private static _IsLesser;
  10707. /**
  10708. * returns the number for IsEqual
  10709. */
  10710. static get IsEqual(): number;
  10711. /**
  10712. * Returns the number for IsDifferent
  10713. */
  10714. static get IsDifferent(): number;
  10715. /**
  10716. * Returns the number for IsGreater
  10717. */
  10718. static get IsGreater(): number;
  10719. /**
  10720. * Returns the number for IsLesser
  10721. */
  10722. static get IsLesser(): number;
  10723. /**
  10724. * Internal only The action manager for the condition
  10725. * @hidden
  10726. */
  10727. _actionManager: ActionManager;
  10728. /**
  10729. * Internal only
  10730. * @hidden
  10731. */
  10732. private _target;
  10733. /**
  10734. * Internal only
  10735. * @hidden
  10736. */
  10737. private _effectiveTarget;
  10738. /**
  10739. * Internal only
  10740. * @hidden
  10741. */
  10742. private _property;
  10743. /**
  10744. * Creates a new ValueCondition
  10745. * @param actionManager manager for the action the condition applies to
  10746. * @param target for the action
  10747. * @param propertyPath path to specify the property of the target the conditional operator uses
  10748. * @param value the value compared by the conditional operator against the current value of the property
  10749. * @param operator the conditional operator, default ValueCondition.IsEqual
  10750. */
  10751. constructor(actionManager: ActionManager, target: any,
  10752. /** path to specify the property of the target the conditional operator uses */
  10753. propertyPath: string,
  10754. /** the value compared by the conditional operator against the current value of the property */
  10755. value: any,
  10756. /** the conditional operator, default ValueCondition.IsEqual */
  10757. operator?: number);
  10758. /**
  10759. * Compares the given value with the property value for the specified conditional operator
  10760. * @returns the result of the comparison
  10761. */
  10762. isValid(): boolean;
  10763. /**
  10764. * Serialize the ValueCondition into a JSON compatible object
  10765. * @returns serialization object
  10766. */
  10767. serialize(): any;
  10768. /**
  10769. * Gets the name of the conditional operator for the ValueCondition
  10770. * @param operator the conditional operator
  10771. * @returns the name
  10772. */
  10773. static GetOperatorName(operator: number): string;
  10774. }
  10775. /**
  10776. * Defines a predicate condition as an extension of Condition
  10777. */
  10778. export class PredicateCondition extends Condition {
  10779. /** defines the predicate function used to validate the condition */
  10780. predicate: () => boolean;
  10781. /**
  10782. * Internal only - manager for action
  10783. * @hidden
  10784. */
  10785. _actionManager: ActionManager;
  10786. /**
  10787. * Creates a new PredicateCondition
  10788. * @param actionManager manager for the action the condition applies to
  10789. * @param predicate defines the predicate function used to validate the condition
  10790. */
  10791. constructor(actionManager: ActionManager,
  10792. /** defines the predicate function used to validate the condition */
  10793. predicate: () => boolean);
  10794. /**
  10795. * @returns the validity of the predicate condition
  10796. */
  10797. isValid(): boolean;
  10798. }
  10799. /**
  10800. * Defines a state condition as an extension of Condition
  10801. */
  10802. export class StateCondition extends Condition {
  10803. /** Value to compare with target state */
  10804. value: string;
  10805. /**
  10806. * Internal only - manager for action
  10807. * @hidden
  10808. */
  10809. _actionManager: ActionManager;
  10810. /**
  10811. * Internal only
  10812. * @hidden
  10813. */
  10814. private _target;
  10815. /**
  10816. * Creates a new StateCondition
  10817. * @param actionManager manager for the action the condition applies to
  10818. * @param target of the condition
  10819. * @param value to compare with target state
  10820. */
  10821. constructor(actionManager: ActionManager, target: any,
  10822. /** Value to compare with target state */
  10823. value: string);
  10824. /**
  10825. * Gets a boolean indicating if the current condition is met
  10826. * @returns the validity of the state
  10827. */
  10828. isValid(): boolean;
  10829. /**
  10830. * Serialize the StateCondition into a JSON compatible object
  10831. * @returns serialization object
  10832. */
  10833. serialize(): any;
  10834. }
  10835. }
  10836. declare module "babylonjs/Actions/directActions" {
  10837. import { Action } from "babylonjs/Actions/action";
  10838. import { Condition } from "babylonjs/Actions/condition";
  10839. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10840. /**
  10841. * This defines an action responsible to toggle a boolean once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class SwitchBooleanAction extends Action {
  10845. /**
  10846. * The path to the boolean property in the target object
  10847. */
  10848. propertyPath: string;
  10849. private _target;
  10850. private _effectiveTarget;
  10851. private _property;
  10852. /**
  10853. * Instantiate the action
  10854. * @param triggerOptions defines the trigger options
  10855. * @param target defines the object containing the boolean
  10856. * @param propertyPath defines the path to the boolean property in the target object
  10857. * @param condition defines the trigger related conditions
  10858. */
  10859. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10860. /** @hidden */
  10861. _prepare(): void;
  10862. /**
  10863. * Execute the action toggle the boolean value.
  10864. */
  10865. execute(): void;
  10866. /**
  10867. * Serializes the actions and its related information.
  10868. * @param parent defines the object to serialize in
  10869. * @returns the serialized object
  10870. */
  10871. serialize(parent: any): any;
  10872. }
  10873. /**
  10874. * This defines an action responsible to set a the state field of the target
  10875. * to a desired value once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class SetStateAction extends Action {
  10879. /**
  10880. * The value to store in the state field.
  10881. */
  10882. value: string;
  10883. private _target;
  10884. /**
  10885. * Instantiate the action
  10886. * @param triggerOptions defines the trigger options
  10887. * @param target defines the object containing the state property
  10888. * @param value defines the value to store in the state field
  10889. * @param condition defines the trigger related conditions
  10890. */
  10891. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10892. /**
  10893. * Execute the action and store the value on the target state property.
  10894. */
  10895. execute(): void;
  10896. /**
  10897. * Serializes the actions and its related information.
  10898. * @param parent defines the object to serialize in
  10899. * @returns the serialized object
  10900. */
  10901. serialize(parent: any): any;
  10902. }
  10903. /**
  10904. * This defines an action responsible to set a property of the target
  10905. * to a desired value once triggered.
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10907. */
  10908. export class SetValueAction extends Action {
  10909. /**
  10910. * The path of the property to set in the target.
  10911. */
  10912. propertyPath: string;
  10913. /**
  10914. * The value to set in the property
  10915. */
  10916. value: any;
  10917. private _target;
  10918. private _effectiveTarget;
  10919. private _property;
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param target defines the object containing the property
  10924. * @param propertyPath defines the path of the property to set in the target
  10925. * @param value defines the value to set in the property
  10926. * @param condition defines the trigger related conditions
  10927. */
  10928. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10929. /** @hidden */
  10930. _prepare(): void;
  10931. /**
  10932. * Execute the action and set the targetted property to the desired value.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible to increment the target value
  10944. * to a desired value once triggered.
  10945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10946. */
  10947. export class IncrementValueAction extends Action {
  10948. /**
  10949. * The path of the property to increment in the target.
  10950. */
  10951. propertyPath: string;
  10952. /**
  10953. * The value we should increment the property by.
  10954. */
  10955. value: any;
  10956. private _target;
  10957. private _effectiveTarget;
  10958. private _property;
  10959. /**
  10960. * Instantiate the action
  10961. * @param triggerOptions defines the trigger options
  10962. * @param target defines the object containing the property
  10963. * @param propertyPath defines the path of the property to increment in the target
  10964. * @param value defines the value value we should increment the property by
  10965. * @param condition defines the trigger related conditions
  10966. */
  10967. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10968. /** @hidden */
  10969. _prepare(): void;
  10970. /**
  10971. * Execute the action and increment the target of the value amount.
  10972. */
  10973. execute(): void;
  10974. /**
  10975. * Serializes the actions and its related information.
  10976. * @param parent defines the object to serialize in
  10977. * @returns the serialized object
  10978. */
  10979. serialize(parent: any): any;
  10980. }
  10981. /**
  10982. * This defines an action responsible to start an animation once triggered.
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10984. */
  10985. export class PlayAnimationAction extends Action {
  10986. /**
  10987. * Where the animation should start (animation frame)
  10988. */
  10989. from: number;
  10990. /**
  10991. * Where the animation should stop (animation frame)
  10992. */
  10993. to: number;
  10994. /**
  10995. * Define if the animation should loop or stop after the first play.
  10996. */
  10997. loop?: boolean;
  10998. private _target;
  10999. /**
  11000. * Instantiate the action
  11001. * @param triggerOptions defines the trigger options
  11002. * @param target defines the target animation or animation name
  11003. * @param from defines from where the animation should start (animation frame)
  11004. * @param end defines where the animation should stop (animation frame)
  11005. * @param loop defines if the animation should loop or stop after the first play
  11006. * @param condition defines the trigger related conditions
  11007. */
  11008. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11009. /** @hidden */
  11010. _prepare(): void;
  11011. /**
  11012. * Execute the action and play the animation.
  11013. */
  11014. execute(): void;
  11015. /**
  11016. * Serializes the actions and its related information.
  11017. * @param parent defines the object to serialize in
  11018. * @returns the serialized object
  11019. */
  11020. serialize(parent: any): any;
  11021. }
  11022. /**
  11023. * This defines an action responsible to stop an animation once triggered.
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11025. */
  11026. export class StopAnimationAction extends Action {
  11027. private _target;
  11028. /**
  11029. * Instantiate the action
  11030. * @param triggerOptions defines the trigger options
  11031. * @param target defines the target animation or animation name
  11032. * @param condition defines the trigger related conditions
  11033. */
  11034. constructor(triggerOptions: any, target: any, condition?: Condition);
  11035. /** @hidden */
  11036. _prepare(): void;
  11037. /**
  11038. * Execute the action and stop the animation.
  11039. */
  11040. execute(): void;
  11041. /**
  11042. * Serializes the actions and its related information.
  11043. * @param parent defines the object to serialize in
  11044. * @returns the serialized object
  11045. */
  11046. serialize(parent: any): any;
  11047. }
  11048. /**
  11049. * This defines an action responsible that does nothing once triggered.
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11051. */
  11052. export class DoNothingAction extends Action {
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param condition defines the trigger related conditions
  11057. */
  11058. constructor(triggerOptions?: any, condition?: Condition);
  11059. /**
  11060. * Execute the action and do nothing.
  11061. */
  11062. execute(): void;
  11063. /**
  11064. * Serializes the actions and its related information.
  11065. * @param parent defines the object to serialize in
  11066. * @returns the serialized object
  11067. */
  11068. serialize(parent: any): any;
  11069. }
  11070. /**
  11071. * This defines an action responsible to trigger several actions once triggered.
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11073. */
  11074. export class CombineAction extends Action {
  11075. /**
  11076. * The list of aggregated animations to run.
  11077. */
  11078. children: Action[];
  11079. /**
  11080. * Instantiate the action
  11081. * @param triggerOptions defines the trigger options
  11082. * @param children defines the list of aggregated animations to run
  11083. * @param condition defines the trigger related conditions
  11084. */
  11085. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11086. /** @hidden */
  11087. _prepare(): void;
  11088. /**
  11089. * Execute the action and executes all the aggregated actions.
  11090. */
  11091. execute(evt: ActionEvent): void;
  11092. /**
  11093. * Serializes the actions and its related information.
  11094. * @param parent defines the object to serialize in
  11095. * @returns the serialized object
  11096. */
  11097. serialize(parent: any): any;
  11098. }
  11099. /**
  11100. * This defines an action responsible to run code (external event) once triggered.
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11102. */
  11103. export class ExecuteCodeAction extends Action {
  11104. /**
  11105. * The callback function to run.
  11106. */
  11107. func: (evt: ActionEvent) => void;
  11108. /**
  11109. * Instantiate the action
  11110. * @param triggerOptions defines the trigger options
  11111. * @param func defines the callback function to run
  11112. * @param condition defines the trigger related conditions
  11113. */
  11114. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11115. /**
  11116. * Execute the action and run the attached code.
  11117. */
  11118. execute(evt: ActionEvent): void;
  11119. }
  11120. /**
  11121. * This defines an action responsible to set the parent property of the target once triggered.
  11122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11123. */
  11124. export class SetParentAction extends Action {
  11125. private _parent;
  11126. private _target;
  11127. /**
  11128. * Instantiate the action
  11129. * @param triggerOptions defines the trigger options
  11130. * @param target defines the target containing the parent property
  11131. * @param parent defines from where the animation should start (animation frame)
  11132. * @param condition defines the trigger related conditions
  11133. */
  11134. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11135. /** @hidden */
  11136. _prepare(): void;
  11137. /**
  11138. * Execute the action and set the parent property.
  11139. */
  11140. execute(): void;
  11141. /**
  11142. * Serializes the actions and its related information.
  11143. * @param parent defines the object to serialize in
  11144. * @returns the serialized object
  11145. */
  11146. serialize(parent: any): any;
  11147. }
  11148. }
  11149. declare module "babylonjs/Actions/actionManager" {
  11150. import { Nullable } from "babylonjs/types";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { Scene } from "babylonjs/scene";
  11153. import { IAction } from "babylonjs/Actions/action";
  11154. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11155. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11156. /**
  11157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11160. */
  11161. export class ActionManager extends AbstractActionManager {
  11162. /**
  11163. * Nothing
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly NothingTrigger: number;
  11167. /**
  11168. * On pick
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnPickTrigger: number;
  11172. /**
  11173. * On left pick
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnLeftPickTrigger: number;
  11177. /**
  11178. * On right pick
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnRightPickTrigger: number;
  11182. /**
  11183. * On center pick
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnCenterPickTrigger: number;
  11187. /**
  11188. * On pick down
  11189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11190. */
  11191. static readonly OnPickDownTrigger: number;
  11192. /**
  11193. * On double pick
  11194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11195. */
  11196. static readonly OnDoublePickTrigger: number;
  11197. /**
  11198. * On pick up
  11199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11200. */
  11201. static readonly OnPickUpTrigger: number;
  11202. /**
  11203. * On pick out.
  11204. * This trigger will only be raised if you also declared a OnPickDown
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnPickOutTrigger: number;
  11208. /**
  11209. * On long press
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnLongPressTrigger: number;
  11213. /**
  11214. * On pointer over
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnPointerOverTrigger: number;
  11218. /**
  11219. * On pointer out
  11220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11221. */
  11222. static readonly OnPointerOutTrigger: number;
  11223. /**
  11224. * On every frame
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11226. */
  11227. static readonly OnEveryFrameTrigger: number;
  11228. /**
  11229. * On intersection enter
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11231. */
  11232. static readonly OnIntersectionEnterTrigger: number;
  11233. /**
  11234. * On intersection exit
  11235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11236. */
  11237. static readonly OnIntersectionExitTrigger: number;
  11238. /**
  11239. * On key down
  11240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11241. */
  11242. static readonly OnKeyDownTrigger: number;
  11243. /**
  11244. * On key up
  11245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11246. */
  11247. static readonly OnKeyUpTrigger: number;
  11248. private _scene;
  11249. /**
  11250. * Creates a new action manager
  11251. * @param scene defines the hosting scene
  11252. */
  11253. constructor(scene: Scene);
  11254. /**
  11255. * Releases all associated resources
  11256. */
  11257. dispose(): void;
  11258. /**
  11259. * Gets hosting scene
  11260. * @returns the hosting scene
  11261. */
  11262. getScene(): Scene;
  11263. /**
  11264. * Does this action manager handles actions of any of the given triggers
  11265. * @param triggers defines the triggers to be tested
  11266. * @return a boolean indicating whether one (or more) of the triggers is handled
  11267. */
  11268. hasSpecificTriggers(triggers: number[]): boolean;
  11269. /**
  11270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11271. * speed.
  11272. * @param triggerA defines the trigger to be tested
  11273. * @param triggerB defines the trigger to be tested
  11274. * @return a boolean indicating whether one (or more) of the triggers is handled
  11275. */
  11276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11277. /**
  11278. * Does this action manager handles actions of a given trigger
  11279. * @param trigger defines the trigger to be tested
  11280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11281. * @return whether the trigger is handled
  11282. */
  11283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11284. /**
  11285. * Does this action manager has pointer triggers
  11286. */
  11287. get hasPointerTriggers(): boolean;
  11288. /**
  11289. * Does this action manager has pick triggers
  11290. */
  11291. get hasPickTriggers(): boolean;
  11292. /**
  11293. * Registers an action to this action manager
  11294. * @param action defines the action to be registered
  11295. * @return the action amended (prepared) after registration
  11296. */
  11297. registerAction(action: IAction): Nullable<IAction>;
  11298. /**
  11299. * Unregisters an action to this action manager
  11300. * @param action defines the action to be unregistered
  11301. * @return a boolean indicating whether the action has been unregistered
  11302. */
  11303. unregisterAction(action: IAction): Boolean;
  11304. /**
  11305. * Process a specific trigger
  11306. * @param trigger defines the trigger to process
  11307. * @param evt defines the event details to be processed
  11308. */
  11309. processTrigger(trigger: number, evt?: IActionEvent): void;
  11310. /** @hidden */
  11311. _getEffectiveTarget(target: any, propertyPath: string): any;
  11312. /** @hidden */
  11313. _getProperty(propertyPath: string): string;
  11314. /**
  11315. * Serialize this manager to a JSON object
  11316. * @param name defines the property name to store this manager
  11317. * @returns a JSON representation of this manager
  11318. */
  11319. serialize(name: string): any;
  11320. /**
  11321. * Creates a new ActionManager from a JSON data
  11322. * @param parsedActions defines the JSON data to read from
  11323. * @param object defines the hosting mesh
  11324. * @param scene defines the hosting scene
  11325. */
  11326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11327. /**
  11328. * Get a trigger name by index
  11329. * @param trigger defines the trigger index
  11330. * @returns a trigger name
  11331. */
  11332. static GetTriggerName(trigger: number): string;
  11333. }
  11334. }
  11335. declare module "babylonjs/Culling/ray" {
  11336. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11337. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11339. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11340. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11341. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11342. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11343. import { Plane } from "babylonjs/Maths/math.plane";
  11344. /**
  11345. * Class representing a ray with position and direction
  11346. */
  11347. export class Ray {
  11348. /** origin point */
  11349. origin: Vector3;
  11350. /** direction */
  11351. direction: Vector3;
  11352. /** length of the ray */
  11353. length: number;
  11354. private static readonly TmpVector3;
  11355. private _tmpRay;
  11356. /**
  11357. * Creates a new ray
  11358. * @param origin origin point
  11359. * @param direction direction
  11360. * @param length length of the ray
  11361. */
  11362. constructor(
  11363. /** origin point */
  11364. origin: Vector3,
  11365. /** direction */
  11366. direction: Vector3,
  11367. /** length of the ray */
  11368. length?: number);
  11369. /**
  11370. * Checks if the ray intersects a box
  11371. * @param minimum bound of the box
  11372. * @param maximum bound of the box
  11373. * @param intersectionTreshold extra extend to be added to the box in all direction
  11374. * @returns if the box was hit
  11375. */
  11376. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11377. /**
  11378. * Checks if the ray intersects a box
  11379. * @param box the bounding box to check
  11380. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11381. * @returns if the box was hit
  11382. */
  11383. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11384. /**
  11385. * If the ray hits a sphere
  11386. * @param sphere the bounding sphere to check
  11387. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11388. * @returns true if it hits the sphere
  11389. */
  11390. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11391. /**
  11392. * If the ray hits a triange
  11393. * @param vertex0 triangle vertex
  11394. * @param vertex1 triangle vertex
  11395. * @param vertex2 triangle vertex
  11396. * @returns intersection information if hit
  11397. */
  11398. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11399. /**
  11400. * Checks if ray intersects a plane
  11401. * @param plane the plane to check
  11402. * @returns the distance away it was hit
  11403. */
  11404. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11405. /**
  11406. * Calculate the intercept of a ray on a given axis
  11407. * @param axis to check 'x' | 'y' | 'z'
  11408. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11409. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11410. */
  11411. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11412. /**
  11413. * Checks if ray intersects a mesh
  11414. * @param mesh the mesh to check
  11415. * @param fastCheck if only the bounding box should checked
  11416. * @returns picking info of the intersecton
  11417. */
  11418. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11419. /**
  11420. * Checks if ray intersects a mesh
  11421. * @param meshes the meshes to check
  11422. * @param fastCheck if only the bounding box should checked
  11423. * @param results array to store result in
  11424. * @returns Array of picking infos
  11425. */
  11426. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11427. private _comparePickingInfo;
  11428. private static smallnum;
  11429. private static rayl;
  11430. /**
  11431. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11432. * @param sega the first point of the segment to test the intersection against
  11433. * @param segb the second point of the segment to test the intersection against
  11434. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11435. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11436. */
  11437. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11438. /**
  11439. * Update the ray from viewport position
  11440. * @param x position
  11441. * @param y y position
  11442. * @param viewportWidth viewport width
  11443. * @param viewportHeight viewport height
  11444. * @param world world matrix
  11445. * @param view view matrix
  11446. * @param projection projection matrix
  11447. * @returns this ray updated
  11448. */
  11449. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11450. /**
  11451. * Creates a ray with origin and direction of 0,0,0
  11452. * @returns the new ray
  11453. */
  11454. static Zero(): Ray;
  11455. /**
  11456. * Creates a new ray from screen space and viewport
  11457. * @param x position
  11458. * @param y y position
  11459. * @param viewportWidth viewport width
  11460. * @param viewportHeight viewport height
  11461. * @param world world matrix
  11462. * @param view view matrix
  11463. * @param projection projection matrix
  11464. * @returns new ray
  11465. */
  11466. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11467. /**
  11468. * 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
  11469. * transformed to the given world matrix.
  11470. * @param origin The origin point
  11471. * @param end The end point
  11472. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11473. * @returns the new ray
  11474. */
  11475. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11476. /**
  11477. * Transforms a ray by a matrix
  11478. * @param ray ray to transform
  11479. * @param matrix matrix to apply
  11480. * @returns the resulting new ray
  11481. */
  11482. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11483. /**
  11484. * Transforms a ray by a matrix
  11485. * @param ray ray to transform
  11486. * @param matrix matrix to apply
  11487. * @param result ray to store result in
  11488. */
  11489. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11490. /**
  11491. * Unproject a ray from screen space to object space
  11492. * @param sourceX defines the screen space x coordinate to use
  11493. * @param sourceY defines the screen space y coordinate to use
  11494. * @param viewportWidth defines the current width of the viewport
  11495. * @param viewportHeight defines the current height of the viewport
  11496. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11497. * @param view defines the view matrix to use
  11498. * @param projection defines the projection matrix to use
  11499. */
  11500. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11501. }
  11502. /**
  11503. * Type used to define predicate used to select faces when a mesh intersection is detected
  11504. */
  11505. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11506. module "babylonjs/scene" {
  11507. interface Scene {
  11508. /** @hidden */
  11509. _tempPickingRay: Nullable<Ray>;
  11510. /** @hidden */
  11511. _cachedRayForTransform: Ray;
  11512. /** @hidden */
  11513. _pickWithRayInverseMatrix: Matrix;
  11514. /** @hidden */
  11515. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11516. /** @hidden */
  11517. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11518. }
  11519. }
  11520. }
  11521. declare module "babylonjs/sceneComponent" {
  11522. import { Scene } from "babylonjs/scene";
  11523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11525. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11526. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11527. import { Nullable } from "babylonjs/types";
  11528. import { Camera } from "babylonjs/Cameras/camera";
  11529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11530. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11531. import { AbstractScene } from "babylonjs/abstractScene";
  11532. import { Mesh } from "babylonjs/Meshes/mesh";
  11533. /**
  11534. * Groups all the scene component constants in one place to ease maintenance.
  11535. * @hidden
  11536. */
  11537. export class SceneComponentConstants {
  11538. static readonly NAME_EFFECTLAYER: string;
  11539. static readonly NAME_LAYER: string;
  11540. static readonly NAME_LENSFLARESYSTEM: string;
  11541. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11542. static readonly NAME_PARTICLESYSTEM: string;
  11543. static readonly NAME_GAMEPAD: string;
  11544. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11545. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11546. static readonly NAME_DEPTHRENDERER: string;
  11547. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11548. static readonly NAME_SPRITE: string;
  11549. static readonly NAME_OUTLINERENDERER: string;
  11550. static readonly NAME_PROCEDURALTEXTURE: string;
  11551. static readonly NAME_SHADOWGENERATOR: string;
  11552. static readonly NAME_OCTREE: string;
  11553. static readonly NAME_PHYSICSENGINE: string;
  11554. static readonly NAME_AUDIO: string;
  11555. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11556. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11558. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11559. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11560. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11561. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11562. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11563. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11564. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11565. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11566. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11567. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11568. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11569. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11570. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11572. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11573. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11574. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11575. static readonly STEP_AFTERRENDER_AUDIO: number;
  11576. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11577. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11578. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11579. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11580. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11581. static readonly STEP_POINTERMOVE_SPRITE: number;
  11582. static readonly STEP_POINTERDOWN_SPRITE: number;
  11583. static readonly STEP_POINTERUP_SPRITE: number;
  11584. }
  11585. /**
  11586. * This represents a scene component.
  11587. *
  11588. * This is used to decouple the dependency the scene is having on the different workloads like
  11589. * layers, post processes...
  11590. */
  11591. export interface ISceneComponent {
  11592. /**
  11593. * The name of the component. Each component must have a unique name.
  11594. */
  11595. name: string;
  11596. /**
  11597. * The scene the component belongs to.
  11598. */
  11599. scene: Scene;
  11600. /**
  11601. * Register the component to one instance of a scene.
  11602. */
  11603. register(): void;
  11604. /**
  11605. * Rebuilds the elements related to this component in case of
  11606. * context lost for instance.
  11607. */
  11608. rebuild(): void;
  11609. /**
  11610. * Disposes the component and the associated ressources.
  11611. */
  11612. dispose(): void;
  11613. }
  11614. /**
  11615. * This represents a SERIALIZABLE scene component.
  11616. *
  11617. * This extends Scene Component to add Serialization methods on top.
  11618. */
  11619. export interface ISceneSerializableComponent extends ISceneComponent {
  11620. /**
  11621. * Adds all the elements from the container to the scene
  11622. * @param container the container holding the elements
  11623. */
  11624. addFromContainer(container: AbstractScene): void;
  11625. /**
  11626. * Removes all the elements in the container from the scene
  11627. * @param container contains the elements to remove
  11628. * @param dispose if the removed element should be disposed (default: false)
  11629. */
  11630. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11631. /**
  11632. * Serializes the component data to the specified json object
  11633. * @param serializationObject The object to serialize to
  11634. */
  11635. serialize(serializationObject: any): void;
  11636. }
  11637. /**
  11638. * Strong typing of a Mesh related stage step action
  11639. */
  11640. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11641. /**
  11642. * Strong typing of a Evaluate Sub Mesh related stage step action
  11643. */
  11644. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11645. /**
  11646. * Strong typing of a Active Mesh related stage step action
  11647. */
  11648. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11649. /**
  11650. * Strong typing of a Camera related stage step action
  11651. */
  11652. export type CameraStageAction = (camera: Camera) => void;
  11653. /**
  11654. * Strong typing of a Camera Frame buffer related stage step action
  11655. */
  11656. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11657. /**
  11658. * Strong typing of a Render Target related stage step action
  11659. */
  11660. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11661. /**
  11662. * Strong typing of a RenderingGroup related stage step action
  11663. */
  11664. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11665. /**
  11666. * Strong typing of a Mesh Render related stage step action
  11667. */
  11668. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11669. /**
  11670. * Strong typing of a simple stage step action
  11671. */
  11672. export type SimpleStageAction = () => void;
  11673. /**
  11674. * Strong typing of a render target action.
  11675. */
  11676. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11677. /**
  11678. * Strong typing of a pointer move action.
  11679. */
  11680. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11681. /**
  11682. * Strong typing of a pointer up/down action.
  11683. */
  11684. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11685. /**
  11686. * Representation of a stage in the scene (Basically a list of ordered steps)
  11687. * @hidden
  11688. */
  11689. export class Stage<T extends Function> extends Array<{
  11690. index: number;
  11691. component: ISceneComponent;
  11692. action: T;
  11693. }> {
  11694. /**
  11695. * Hide ctor from the rest of the world.
  11696. * @param items The items to add.
  11697. */
  11698. private constructor();
  11699. /**
  11700. * Creates a new Stage.
  11701. * @returns A new instance of a Stage
  11702. */
  11703. static Create<T extends Function>(): Stage<T>;
  11704. /**
  11705. * Registers a step in an ordered way in the targeted stage.
  11706. * @param index Defines the position to register the step in
  11707. * @param component Defines the component attached to the step
  11708. * @param action Defines the action to launch during the step
  11709. */
  11710. registerStep(index: number, component: ISceneComponent, action: T): void;
  11711. /**
  11712. * Clears all the steps from the stage.
  11713. */
  11714. clear(): void;
  11715. }
  11716. }
  11717. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11718. import { Nullable } from "babylonjs/types";
  11719. import { Observable } from "babylonjs/Misc/observable";
  11720. import { Scene } from "babylonjs/scene";
  11721. import { Sprite } from "babylonjs/Sprites/sprite";
  11722. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11723. import { Ray } from "babylonjs/Culling/ray";
  11724. import { Camera } from "babylonjs/Cameras/camera";
  11725. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11726. import { ISceneComponent } from "babylonjs/sceneComponent";
  11727. module "babylonjs/scene" {
  11728. interface Scene {
  11729. /** @hidden */
  11730. _pointerOverSprite: Nullable<Sprite>;
  11731. /** @hidden */
  11732. _pickedDownSprite: Nullable<Sprite>;
  11733. /** @hidden */
  11734. _tempSpritePickingRay: Nullable<Ray>;
  11735. /**
  11736. * All of the sprite managers added to this scene
  11737. * @see http://doc.babylonjs.com/babylon101/sprites
  11738. */
  11739. spriteManagers: Array<ISpriteManager>;
  11740. /**
  11741. * An event triggered when sprites rendering is about to start
  11742. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11743. */
  11744. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11745. /**
  11746. * An event triggered when sprites rendering is done
  11747. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11748. */
  11749. onAfterSpritesRenderingObservable: Observable<Scene>;
  11750. /** @hidden */
  11751. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11752. /** Launch a ray to try to pick a sprite in the scene
  11753. * @param x position on screen
  11754. * @param y position on screen
  11755. * @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
  11756. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11757. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11758. * @returns a PickingInfo
  11759. */
  11760. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** Use the given ray to pick a sprite in the scene
  11762. * @param ray The ray (in world space) to use to pick meshes
  11763. * @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
  11764. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11765. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11766. * @returns a PickingInfo
  11767. */
  11768. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11769. /** @hidden */
  11770. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11771. /** Launch a ray to try to pick sprites in the scene
  11772. * @param x position on screen
  11773. * @param y position on screen
  11774. * @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
  11775. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11776. * @returns a PickingInfo array
  11777. */
  11778. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11779. /** Use the given ray to pick sprites in the scene
  11780. * @param ray The ray (in world space) to use to pick meshes
  11781. * @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
  11782. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11783. * @returns a PickingInfo array
  11784. */
  11785. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11786. /**
  11787. * Force the sprite under the pointer
  11788. * @param sprite defines the sprite to use
  11789. */
  11790. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11791. /**
  11792. * Gets the sprite under the pointer
  11793. * @returns a Sprite or null if no sprite is under the pointer
  11794. */
  11795. getPointerOverSprite(): Nullable<Sprite>;
  11796. }
  11797. }
  11798. /**
  11799. * Defines the sprite scene component responsible to manage sprites
  11800. * in a given scene.
  11801. */
  11802. export class SpriteSceneComponent implements ISceneComponent {
  11803. /**
  11804. * The component name helpfull to identify the component in the list of scene components.
  11805. */
  11806. readonly name: string;
  11807. /**
  11808. * The scene the component belongs to.
  11809. */
  11810. scene: Scene;
  11811. /** @hidden */
  11812. private _spritePredicate;
  11813. /**
  11814. * Creates a new instance of the component for the given scene
  11815. * @param scene Defines the scene to register the component in
  11816. */
  11817. constructor(scene: Scene);
  11818. /**
  11819. * Registers the component in a given scene
  11820. */
  11821. register(): void;
  11822. /**
  11823. * Rebuilds the elements related to this component in case of
  11824. * context lost for instance.
  11825. */
  11826. rebuild(): void;
  11827. /**
  11828. * Disposes the component and the associated ressources.
  11829. */
  11830. dispose(): void;
  11831. private _pickSpriteButKeepRay;
  11832. private _pointerMove;
  11833. private _pointerDown;
  11834. private _pointerUp;
  11835. }
  11836. }
  11837. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11838. /** @hidden */
  11839. export var fogFragmentDeclaration: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11845. /** @hidden */
  11846. export var fogFragment: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module "babylonjs/Shaders/sprites.fragment" {
  11852. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11853. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11854. /** @hidden */
  11855. export var spritesPixelShader: {
  11856. name: string;
  11857. shader: string;
  11858. };
  11859. }
  11860. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11861. /** @hidden */
  11862. export var fogVertexDeclaration: {
  11863. name: string;
  11864. shader: string;
  11865. };
  11866. }
  11867. declare module "babylonjs/Shaders/sprites.vertex" {
  11868. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11869. /** @hidden */
  11870. export var spritesVertexShader: {
  11871. name: string;
  11872. shader: string;
  11873. };
  11874. }
  11875. declare module "babylonjs/Sprites/spriteManager" {
  11876. import { IDisposable, Scene } from "babylonjs/scene";
  11877. import { Nullable } from "babylonjs/types";
  11878. import { Observable } from "babylonjs/Misc/observable";
  11879. import { Sprite } from "babylonjs/Sprites/sprite";
  11880. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11881. import { Camera } from "babylonjs/Cameras/camera";
  11882. import { Texture } from "babylonjs/Materials/Textures/texture";
  11883. import "babylonjs/Shaders/sprites.fragment";
  11884. import "babylonjs/Shaders/sprites.vertex";
  11885. import { Ray } from "babylonjs/Culling/ray";
  11886. /**
  11887. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11888. */
  11889. export interface ISpriteManager extends IDisposable {
  11890. /**
  11891. * Restricts the camera to viewing objects with the same layerMask.
  11892. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11893. */
  11894. layerMask: number;
  11895. /**
  11896. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11897. */
  11898. isPickable: boolean;
  11899. /**
  11900. * Specifies the rendering group id for this mesh (0 by default)
  11901. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11902. */
  11903. renderingGroupId: number;
  11904. /**
  11905. * Defines the list of sprites managed by the manager.
  11906. */
  11907. sprites: Array<Sprite>;
  11908. /**
  11909. * Tests the intersection of a sprite with a specific ray.
  11910. * @param ray The ray we are sending to test the collision
  11911. * @param camera The camera space we are sending rays in
  11912. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11913. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11914. * @returns picking info or null.
  11915. */
  11916. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11917. /**
  11918. * Intersects the sprites with a ray
  11919. * @param ray defines the ray to intersect with
  11920. * @param camera defines the current active camera
  11921. * @param predicate defines a predicate used to select candidate sprites
  11922. * @returns null if no hit or a PickingInfo array
  11923. */
  11924. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11925. /**
  11926. * Renders the list of sprites on screen.
  11927. */
  11928. render(): void;
  11929. }
  11930. /**
  11931. * Class used to manage multiple sprites on the same spritesheet
  11932. * @see http://doc.babylonjs.com/babylon101/sprites
  11933. */
  11934. export class SpriteManager implements ISpriteManager {
  11935. /** defines the manager's name */
  11936. name: string;
  11937. /** Gets the list of sprites */
  11938. sprites: Sprite[];
  11939. /** Gets or sets the rendering group id (0 by default) */
  11940. renderingGroupId: number;
  11941. /** Gets or sets camera layer mask */
  11942. layerMask: number;
  11943. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11944. fogEnabled: boolean;
  11945. /** Gets or sets a boolean indicating if the sprites are pickable */
  11946. isPickable: boolean;
  11947. /** Defines the default width of a cell in the spritesheet */
  11948. cellWidth: number;
  11949. /** Defines the default height of a cell in the spritesheet */
  11950. cellHeight: number;
  11951. /** Associative array from JSON sprite data file */
  11952. private _cellData;
  11953. /** Array of sprite names from JSON sprite data file */
  11954. private _spriteMap;
  11955. /** True when packed cell data from JSON file is ready*/
  11956. private _packedAndReady;
  11957. /**
  11958. * An event triggered when the manager is disposed.
  11959. */
  11960. onDisposeObservable: Observable<SpriteManager>;
  11961. private _onDisposeObserver;
  11962. /**
  11963. * Callback called when the manager is disposed
  11964. */
  11965. set onDispose(callback: () => void);
  11966. private _capacity;
  11967. private _fromPacked;
  11968. private _spriteTexture;
  11969. private _epsilon;
  11970. private _scene;
  11971. private _vertexData;
  11972. private _buffer;
  11973. private _vertexBuffers;
  11974. private _indexBuffer;
  11975. private _effectBase;
  11976. private _effectFog;
  11977. /**
  11978. * Gets or sets the spritesheet texture
  11979. */
  11980. get texture(): Texture;
  11981. set texture(value: Texture);
  11982. /**
  11983. * Creates a new sprite manager
  11984. * @param name defines the manager's name
  11985. * @param imgUrl defines the sprite sheet url
  11986. * @param capacity defines the maximum allowed number of sprites
  11987. * @param cellSize defines the size of a sprite cell
  11988. * @param scene defines the hosting scene
  11989. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11990. * @param samplingMode defines the smapling mode to use with spritesheet
  11991. * @param fromPacked set to false; do not alter
  11992. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11993. */
  11994. constructor(
  11995. /** defines the manager's name */
  11996. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11997. private _makePacked;
  11998. private _appendSpriteVertex;
  11999. /**
  12000. * Intersects the sprites with a ray
  12001. * @param ray defines the ray to intersect with
  12002. * @param camera defines the current active camera
  12003. * @param predicate defines a predicate used to select candidate sprites
  12004. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12005. * @returns null if no hit or a PickingInfo
  12006. */
  12007. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12008. /**
  12009. * Intersects the sprites with a ray
  12010. * @param ray defines the ray to intersect with
  12011. * @param camera defines the current active camera
  12012. * @param predicate defines a predicate used to select candidate sprites
  12013. * @returns null if no hit or a PickingInfo array
  12014. */
  12015. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12016. /**
  12017. * Render all child sprites
  12018. */
  12019. render(): void;
  12020. /**
  12021. * Release associated resources
  12022. */
  12023. dispose(): void;
  12024. }
  12025. }
  12026. declare module "babylonjs/Sprites/sprite" {
  12027. import { Vector3 } from "babylonjs/Maths/math.vector";
  12028. import { Nullable } from "babylonjs/types";
  12029. import { ActionManager } from "babylonjs/Actions/actionManager";
  12030. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12031. import { Color4 } from "babylonjs/Maths/math.color";
  12032. /**
  12033. * Class used to represent a sprite
  12034. * @see http://doc.babylonjs.com/babylon101/sprites
  12035. */
  12036. export class Sprite {
  12037. /** defines the name */
  12038. name: string;
  12039. /** Gets or sets the current world position */
  12040. position: Vector3;
  12041. /** Gets or sets the main color */
  12042. color: Color4;
  12043. /** Gets or sets the width */
  12044. width: number;
  12045. /** Gets or sets the height */
  12046. height: number;
  12047. /** Gets or sets rotation angle */
  12048. angle: number;
  12049. /** Gets or sets the cell index in the sprite sheet */
  12050. cellIndex: number;
  12051. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12052. cellRef: string;
  12053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12054. invertU: number;
  12055. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12056. invertV: number;
  12057. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12058. disposeWhenFinishedAnimating: boolean;
  12059. /** Gets the list of attached animations */
  12060. animations: Animation[];
  12061. /** Gets or sets a boolean indicating if the sprite can be picked */
  12062. isPickable: boolean;
  12063. /**
  12064. * Gets or sets the associated action manager
  12065. */
  12066. actionManager: Nullable<ActionManager>;
  12067. private _animationStarted;
  12068. private _loopAnimation;
  12069. private _fromIndex;
  12070. private _toIndex;
  12071. private _delay;
  12072. private _direction;
  12073. private _manager;
  12074. private _time;
  12075. private _onAnimationEnd;
  12076. /**
  12077. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12078. */
  12079. isVisible: boolean;
  12080. /**
  12081. * Gets or sets the sprite size
  12082. */
  12083. get size(): number;
  12084. set size(value: number);
  12085. /**
  12086. * Creates a new Sprite
  12087. * @param name defines the name
  12088. * @param manager defines the manager
  12089. */
  12090. constructor(
  12091. /** defines the name */
  12092. name: string, manager: ISpriteManager);
  12093. /**
  12094. * Starts an animation
  12095. * @param from defines the initial key
  12096. * @param to defines the end key
  12097. * @param loop defines if the animation must loop
  12098. * @param delay defines the start delay (in ms)
  12099. * @param onAnimationEnd defines a callback to call when animation ends
  12100. */
  12101. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12102. /** Stops current animation (if any) */
  12103. stopAnimation(): void;
  12104. /** @hidden */
  12105. _animate(deltaTime: number): void;
  12106. /** Release associated resources */
  12107. dispose(): void;
  12108. }
  12109. }
  12110. declare module "babylonjs/Collisions/pickingInfo" {
  12111. import { Nullable } from "babylonjs/types";
  12112. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12114. import { Sprite } from "babylonjs/Sprites/sprite";
  12115. import { Ray } from "babylonjs/Culling/ray";
  12116. /**
  12117. * Information about the result of picking within a scene
  12118. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12119. */
  12120. export class PickingInfo {
  12121. /** @hidden */
  12122. _pickingUnavailable: boolean;
  12123. /**
  12124. * If the pick collided with an object
  12125. */
  12126. hit: boolean;
  12127. /**
  12128. * Distance away where the pick collided
  12129. */
  12130. distance: number;
  12131. /**
  12132. * The location of pick collision
  12133. */
  12134. pickedPoint: Nullable<Vector3>;
  12135. /**
  12136. * The mesh corresponding the the pick collision
  12137. */
  12138. pickedMesh: Nullable<AbstractMesh>;
  12139. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12140. bu: number;
  12141. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12142. bv: number;
  12143. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12144. faceId: number;
  12145. /** Id of the the submesh that was picked */
  12146. subMeshId: number;
  12147. /** If a sprite was picked, this will be the sprite the pick collided with */
  12148. pickedSprite: Nullable<Sprite>;
  12149. /**
  12150. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12151. */
  12152. originMesh: Nullable<AbstractMesh>;
  12153. /**
  12154. * The ray that was used to perform the picking.
  12155. */
  12156. ray: Nullable<Ray>;
  12157. /**
  12158. * Gets the normal correspodning to the face the pick collided with
  12159. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12160. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12161. * @returns The normal correspodning to the face the pick collided with
  12162. */
  12163. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12164. /**
  12165. * Gets the texture coordinates of where the pick occured
  12166. * @returns the vector containing the coordnates of the texture
  12167. */
  12168. getTextureCoordinates(): Nullable<Vector2>;
  12169. }
  12170. }
  12171. declare module "babylonjs/Events/pointerEvents" {
  12172. import { Nullable } from "babylonjs/types";
  12173. import { Vector2 } from "babylonjs/Maths/math.vector";
  12174. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12175. import { Ray } from "babylonjs/Culling/ray";
  12176. /**
  12177. * Gather the list of pointer event types as constants.
  12178. */
  12179. export class PointerEventTypes {
  12180. /**
  12181. * 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.
  12182. */
  12183. static readonly POINTERDOWN: number;
  12184. /**
  12185. * The pointerup event is fired when a pointer is no longer active.
  12186. */
  12187. static readonly POINTERUP: number;
  12188. /**
  12189. * The pointermove event is fired when a pointer changes coordinates.
  12190. */
  12191. static readonly POINTERMOVE: number;
  12192. /**
  12193. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12194. */
  12195. static readonly POINTERWHEEL: number;
  12196. /**
  12197. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12198. */
  12199. static readonly POINTERPICK: number;
  12200. /**
  12201. * The pointertap event is fired when a the object has been touched and released without drag.
  12202. */
  12203. static readonly POINTERTAP: number;
  12204. /**
  12205. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12206. */
  12207. static readonly POINTERDOUBLETAP: number;
  12208. }
  12209. /**
  12210. * Base class of pointer info types.
  12211. */
  12212. export class PointerInfoBase {
  12213. /**
  12214. * Defines the type of event (PointerEventTypes)
  12215. */
  12216. type: number;
  12217. /**
  12218. * Defines the related dom event
  12219. */
  12220. event: PointerEvent | MouseWheelEvent;
  12221. /**
  12222. * Instantiates the base class of pointers info.
  12223. * @param type Defines the type of event (PointerEventTypes)
  12224. * @param event Defines the related dom event
  12225. */
  12226. constructor(
  12227. /**
  12228. * Defines the type of event (PointerEventTypes)
  12229. */
  12230. type: number,
  12231. /**
  12232. * Defines the related dom event
  12233. */
  12234. event: PointerEvent | MouseWheelEvent);
  12235. }
  12236. /**
  12237. * This class is used to store pointer related info for the onPrePointerObservable event.
  12238. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12239. */
  12240. export class PointerInfoPre extends PointerInfoBase {
  12241. /**
  12242. * Ray from a pointer if availible (eg. 6dof controller)
  12243. */
  12244. ray: Nullable<Ray>;
  12245. /**
  12246. * Defines the local position of the pointer on the canvas.
  12247. */
  12248. localPosition: Vector2;
  12249. /**
  12250. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12251. */
  12252. skipOnPointerObservable: boolean;
  12253. /**
  12254. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12255. * @param type Defines the type of event (PointerEventTypes)
  12256. * @param event Defines the related dom event
  12257. * @param localX Defines the local x coordinates of the pointer when the event occured
  12258. * @param localY Defines the local y coordinates of the pointer when the event occured
  12259. */
  12260. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12261. }
  12262. /**
  12263. * This type contains all the data related to a pointer event in Babylon.js.
  12264. * 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.
  12265. */
  12266. export class PointerInfo extends PointerInfoBase {
  12267. /**
  12268. * Defines the picking info associated to the info (if any)\
  12269. */
  12270. pickInfo: Nullable<PickingInfo>;
  12271. /**
  12272. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12273. * @param type Defines the type of event (PointerEventTypes)
  12274. * @param event Defines the related dom event
  12275. * @param pickInfo Defines the picking info associated to the info (if any)\
  12276. */
  12277. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12278. /**
  12279. * Defines the picking info associated to the info (if any)\
  12280. */
  12281. pickInfo: Nullable<PickingInfo>);
  12282. }
  12283. /**
  12284. * Data relating to a touch event on the screen.
  12285. */
  12286. export interface PointerTouch {
  12287. /**
  12288. * X coordinate of touch.
  12289. */
  12290. x: number;
  12291. /**
  12292. * Y coordinate of touch.
  12293. */
  12294. y: number;
  12295. /**
  12296. * Id of touch. Unique for each finger.
  12297. */
  12298. pointerId: number;
  12299. /**
  12300. * Event type passed from DOM.
  12301. */
  12302. type: any;
  12303. }
  12304. }
  12305. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12306. import { Observable } from "babylonjs/Misc/observable";
  12307. import { Nullable } from "babylonjs/types";
  12308. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12309. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12310. /**
  12311. * Manage the mouse inputs to control the movement of a free camera.
  12312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12313. */
  12314. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12315. /**
  12316. * Define if touch is enabled in the mouse input
  12317. */
  12318. touchEnabled: boolean;
  12319. /**
  12320. * Defines the camera the input is attached to.
  12321. */
  12322. camera: FreeCamera;
  12323. /**
  12324. * Defines the buttons associated with the input to handle camera move.
  12325. */
  12326. buttons: number[];
  12327. /**
  12328. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12329. */
  12330. angularSensibility: number;
  12331. private _pointerInput;
  12332. private _onMouseMove;
  12333. private _observer;
  12334. private previousPosition;
  12335. /**
  12336. * Observable for when a pointer move event occurs containing the move offset
  12337. */
  12338. onPointerMovedObservable: Observable<{
  12339. offsetX: number;
  12340. offsetY: number;
  12341. }>;
  12342. /**
  12343. * @hidden
  12344. * If the camera should be rotated automatically based on pointer movement
  12345. */
  12346. _allowCameraRotation: boolean;
  12347. /**
  12348. * Manage the mouse inputs to control the movement of a free camera.
  12349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12350. * @param touchEnabled Defines if touch is enabled or not
  12351. */
  12352. constructor(
  12353. /**
  12354. * Define if touch is enabled in the mouse input
  12355. */
  12356. touchEnabled?: boolean);
  12357. /**
  12358. * Attach the input controls to a specific dom element to get the input from.
  12359. * @param element Defines the element the controls should be listened from
  12360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12361. */
  12362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12363. /**
  12364. * Called on JS contextmenu event.
  12365. * Override this method to provide functionality.
  12366. */
  12367. protected onContextMenu(evt: PointerEvent): void;
  12368. /**
  12369. * Detach the current controls from the specified dom element.
  12370. * @param element Defines the element to stop listening the inputs from
  12371. */
  12372. detachControl(element: Nullable<HTMLElement>): void;
  12373. /**
  12374. * Gets the class name of the current intput.
  12375. * @returns the class name
  12376. */
  12377. getClassName(): string;
  12378. /**
  12379. * Get the friendly name associated with the input class.
  12380. * @returns the input friendly name
  12381. */
  12382. getSimpleName(): string;
  12383. }
  12384. }
  12385. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12386. import { Nullable } from "babylonjs/types";
  12387. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12389. /**
  12390. * Manage the touch inputs to control the movement of a free camera.
  12391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12392. */
  12393. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12394. /**
  12395. * Defines the camera the input is attached to.
  12396. */
  12397. camera: FreeCamera;
  12398. /**
  12399. * Defines the touch sensibility for rotation.
  12400. * The higher the faster.
  12401. */
  12402. touchAngularSensibility: number;
  12403. /**
  12404. * Defines the touch sensibility for move.
  12405. * The higher the faster.
  12406. */
  12407. touchMoveSensibility: number;
  12408. private _offsetX;
  12409. private _offsetY;
  12410. private _pointerPressed;
  12411. private _pointerInput;
  12412. private _observer;
  12413. private _onLostFocus;
  12414. /**
  12415. * Attach the input controls to a specific dom element to get the input from.
  12416. * @param element Defines the element the controls should be listened from
  12417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12418. */
  12419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12420. /**
  12421. * Detach the current controls from the specified dom element.
  12422. * @param element Defines the element to stop listening the inputs from
  12423. */
  12424. detachControl(element: Nullable<HTMLElement>): void;
  12425. /**
  12426. * Update the current camera state depending on the inputs that have been used this frame.
  12427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12428. */
  12429. checkInputs(): void;
  12430. /**
  12431. * Gets the class name of the current intput.
  12432. * @returns the class name
  12433. */
  12434. getClassName(): string;
  12435. /**
  12436. * Get the friendly name associated with the input class.
  12437. * @returns the input friendly name
  12438. */
  12439. getSimpleName(): string;
  12440. }
  12441. }
  12442. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12443. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12444. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12445. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12446. import { Nullable } from "babylonjs/types";
  12447. /**
  12448. * Default Inputs manager for the FreeCamera.
  12449. * It groups all the default supported inputs for ease of use.
  12450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12451. */
  12452. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12453. /**
  12454. * @hidden
  12455. */
  12456. _mouseInput: Nullable<FreeCameraMouseInput>;
  12457. /**
  12458. * Instantiates a new FreeCameraInputsManager.
  12459. * @param camera Defines the camera the inputs belong to
  12460. */
  12461. constructor(camera: FreeCamera);
  12462. /**
  12463. * Add keyboard input support to the input manager.
  12464. * @returns the current input manager
  12465. */
  12466. addKeyboard(): FreeCameraInputsManager;
  12467. /**
  12468. * Add mouse input support to the input manager.
  12469. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12470. * @returns the current input manager
  12471. */
  12472. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12473. /**
  12474. * Removes the mouse input support from the manager
  12475. * @returns the current input manager
  12476. */
  12477. removeMouse(): FreeCameraInputsManager;
  12478. /**
  12479. * Add touch input support to the input manager.
  12480. * @returns the current input manager
  12481. */
  12482. addTouch(): FreeCameraInputsManager;
  12483. /**
  12484. * Remove all attached input methods from a camera
  12485. */
  12486. clear(): void;
  12487. }
  12488. }
  12489. declare module "babylonjs/Cameras/freeCamera" {
  12490. import { Vector3 } from "babylonjs/Maths/math.vector";
  12491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12492. import { Scene } from "babylonjs/scene";
  12493. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12494. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12495. /**
  12496. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12497. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12499. */
  12500. export class FreeCamera extends TargetCamera {
  12501. /**
  12502. * Define the collision ellipsoid of the camera.
  12503. * This is helpful to simulate a camera body like the player body around the camera
  12504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12505. */
  12506. ellipsoid: Vector3;
  12507. /**
  12508. * Define an offset for the position of the ellipsoid around the camera.
  12509. * This can be helpful to determine the center of the body near the gravity center of the body
  12510. * instead of its head.
  12511. */
  12512. ellipsoidOffset: Vector3;
  12513. /**
  12514. * Enable or disable collisions of the camera with the rest of the scene objects.
  12515. */
  12516. checkCollisions: boolean;
  12517. /**
  12518. * Enable or disable gravity on the camera.
  12519. */
  12520. applyGravity: boolean;
  12521. /**
  12522. * Define the input manager associated to the camera.
  12523. */
  12524. inputs: FreeCameraInputsManager;
  12525. /**
  12526. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12527. * Higher values reduce sensitivity.
  12528. */
  12529. get angularSensibility(): number;
  12530. /**
  12531. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12532. * Higher values reduce sensitivity.
  12533. */
  12534. set angularSensibility(value: number);
  12535. /**
  12536. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12537. */
  12538. get keysUp(): number[];
  12539. set keysUp(value: number[]);
  12540. /**
  12541. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12542. */
  12543. get keysDown(): number[];
  12544. set keysDown(value: number[]);
  12545. /**
  12546. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12547. */
  12548. get keysLeft(): number[];
  12549. set keysLeft(value: number[]);
  12550. /**
  12551. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12552. */
  12553. get keysRight(): number[];
  12554. set keysRight(value: number[]);
  12555. /**
  12556. * Event raised when the camera collide with a mesh in the scene.
  12557. */
  12558. onCollide: (collidedMesh: AbstractMesh) => void;
  12559. private _collider;
  12560. private _needMoveForGravity;
  12561. private _oldPosition;
  12562. private _diffPosition;
  12563. private _newPosition;
  12564. /** @hidden */
  12565. _localDirection: Vector3;
  12566. /** @hidden */
  12567. _transformedDirection: Vector3;
  12568. /**
  12569. * Instantiates a Free Camera.
  12570. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12571. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12573. * @param name Define the name of the camera in the scene
  12574. * @param position Define the start position of the camera in the scene
  12575. * @param scene Define the scene the camera belongs to
  12576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12577. */
  12578. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12579. /**
  12580. * Attached controls to the current camera.
  12581. * @param element Defines the element the controls should be listened from
  12582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12583. */
  12584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12585. /**
  12586. * Detach the current controls from the camera.
  12587. * The camera will stop reacting to inputs.
  12588. * @param element Defines the element to stop listening the inputs from
  12589. */
  12590. detachControl(element: HTMLElement): void;
  12591. private _collisionMask;
  12592. /**
  12593. * Define a collision mask to limit the list of object the camera can collide with
  12594. */
  12595. get collisionMask(): number;
  12596. set collisionMask(mask: number);
  12597. /** @hidden */
  12598. _collideWithWorld(displacement: Vector3): void;
  12599. private _onCollisionPositionChange;
  12600. /** @hidden */
  12601. _checkInputs(): void;
  12602. /** @hidden */
  12603. _decideIfNeedsToMove(): boolean;
  12604. /** @hidden */
  12605. _updatePosition(): void;
  12606. /**
  12607. * Destroy the camera and release the current resources hold by it.
  12608. */
  12609. dispose(): void;
  12610. /**
  12611. * Gets the current object class name.
  12612. * @return the class name
  12613. */
  12614. getClassName(): string;
  12615. }
  12616. }
  12617. declare module "babylonjs/Gamepads/gamepad" {
  12618. import { Observable } from "babylonjs/Misc/observable";
  12619. /**
  12620. * Represents a gamepad control stick position
  12621. */
  12622. export class StickValues {
  12623. /**
  12624. * The x component of the control stick
  12625. */
  12626. x: number;
  12627. /**
  12628. * The y component of the control stick
  12629. */
  12630. y: number;
  12631. /**
  12632. * Initializes the gamepad x and y control stick values
  12633. * @param x The x component of the gamepad control stick value
  12634. * @param y The y component of the gamepad control stick value
  12635. */
  12636. constructor(
  12637. /**
  12638. * The x component of the control stick
  12639. */
  12640. x: number,
  12641. /**
  12642. * The y component of the control stick
  12643. */
  12644. y: number);
  12645. }
  12646. /**
  12647. * An interface which manages callbacks for gamepad button changes
  12648. */
  12649. export interface GamepadButtonChanges {
  12650. /**
  12651. * Called when a gamepad has been changed
  12652. */
  12653. changed: boolean;
  12654. /**
  12655. * Called when a gamepad press event has been triggered
  12656. */
  12657. pressChanged: boolean;
  12658. /**
  12659. * Called when a touch event has been triggered
  12660. */
  12661. touchChanged: boolean;
  12662. /**
  12663. * Called when a value has changed
  12664. */
  12665. valueChanged: boolean;
  12666. }
  12667. /**
  12668. * Represents a gamepad
  12669. */
  12670. export class Gamepad {
  12671. /**
  12672. * The id of the gamepad
  12673. */
  12674. id: string;
  12675. /**
  12676. * The index of the gamepad
  12677. */
  12678. index: number;
  12679. /**
  12680. * The browser gamepad
  12681. */
  12682. browserGamepad: any;
  12683. /**
  12684. * Specifies what type of gamepad this represents
  12685. */
  12686. type: number;
  12687. private _leftStick;
  12688. private _rightStick;
  12689. /** @hidden */
  12690. _isConnected: boolean;
  12691. private _leftStickAxisX;
  12692. private _leftStickAxisY;
  12693. private _rightStickAxisX;
  12694. private _rightStickAxisY;
  12695. /**
  12696. * Triggered when the left control stick has been changed
  12697. */
  12698. private _onleftstickchanged;
  12699. /**
  12700. * Triggered when the right control stick has been changed
  12701. */
  12702. private _onrightstickchanged;
  12703. /**
  12704. * Represents a gamepad controller
  12705. */
  12706. static GAMEPAD: number;
  12707. /**
  12708. * Represents a generic controller
  12709. */
  12710. static GENERIC: number;
  12711. /**
  12712. * Represents an XBox controller
  12713. */
  12714. static XBOX: number;
  12715. /**
  12716. * Represents a pose-enabled controller
  12717. */
  12718. static POSE_ENABLED: number;
  12719. /**
  12720. * Represents an Dual Shock controller
  12721. */
  12722. static DUALSHOCK: number;
  12723. /**
  12724. * Specifies whether the left control stick should be Y-inverted
  12725. */
  12726. protected _invertLeftStickY: boolean;
  12727. /**
  12728. * Specifies if the gamepad has been connected
  12729. */
  12730. get isConnected(): boolean;
  12731. /**
  12732. * Initializes the gamepad
  12733. * @param id The id of the gamepad
  12734. * @param index The index of the gamepad
  12735. * @param browserGamepad The browser gamepad
  12736. * @param leftStickX The x component of the left joystick
  12737. * @param leftStickY The y component of the left joystick
  12738. * @param rightStickX The x component of the right joystick
  12739. * @param rightStickY The y component of the right joystick
  12740. */
  12741. constructor(
  12742. /**
  12743. * The id of the gamepad
  12744. */
  12745. id: string,
  12746. /**
  12747. * The index of the gamepad
  12748. */
  12749. index: number,
  12750. /**
  12751. * The browser gamepad
  12752. */
  12753. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12754. /**
  12755. * Callback triggered when the left joystick has changed
  12756. * @param callback
  12757. */
  12758. onleftstickchanged(callback: (values: StickValues) => void): void;
  12759. /**
  12760. * Callback triggered when the right joystick has changed
  12761. * @param callback
  12762. */
  12763. onrightstickchanged(callback: (values: StickValues) => void): void;
  12764. /**
  12765. * Gets the left joystick
  12766. */
  12767. get leftStick(): StickValues;
  12768. /**
  12769. * Sets the left joystick values
  12770. */
  12771. set leftStick(newValues: StickValues);
  12772. /**
  12773. * Gets the right joystick
  12774. */
  12775. get rightStick(): StickValues;
  12776. /**
  12777. * Sets the right joystick value
  12778. */
  12779. set rightStick(newValues: StickValues);
  12780. /**
  12781. * Updates the gamepad joystick positions
  12782. */
  12783. update(): void;
  12784. /**
  12785. * Disposes the gamepad
  12786. */
  12787. dispose(): void;
  12788. }
  12789. /**
  12790. * Represents a generic gamepad
  12791. */
  12792. export class GenericPad extends Gamepad {
  12793. private _buttons;
  12794. private _onbuttondown;
  12795. private _onbuttonup;
  12796. /**
  12797. * Observable triggered when a button has been pressed
  12798. */
  12799. onButtonDownObservable: Observable<number>;
  12800. /**
  12801. * Observable triggered when a button has been released
  12802. */
  12803. onButtonUpObservable: Observable<number>;
  12804. /**
  12805. * Callback triggered when a button has been pressed
  12806. * @param callback Called when a button has been pressed
  12807. */
  12808. onbuttondown(callback: (buttonPressed: number) => void): void;
  12809. /**
  12810. * Callback triggered when a button has been released
  12811. * @param callback Called when a button has been released
  12812. */
  12813. onbuttonup(callback: (buttonReleased: number) => void): void;
  12814. /**
  12815. * Initializes the generic gamepad
  12816. * @param id The id of the generic gamepad
  12817. * @param index The index of the generic gamepad
  12818. * @param browserGamepad The browser gamepad
  12819. */
  12820. constructor(id: string, index: number, browserGamepad: any);
  12821. private _setButtonValue;
  12822. /**
  12823. * Updates the generic gamepad
  12824. */
  12825. update(): void;
  12826. /**
  12827. * Disposes the generic gamepad
  12828. */
  12829. dispose(): void;
  12830. }
  12831. }
  12832. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12833. import { Nullable } from "babylonjs/types";
  12834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12835. import { Scene } from "babylonjs/scene";
  12836. module "babylonjs/Engines/engine" {
  12837. interface Engine {
  12838. /**
  12839. * Creates a raw texture
  12840. * @param data defines the data to store in the texture
  12841. * @param width defines the width of the texture
  12842. * @param height defines the height of the texture
  12843. * @param format defines the format of the data
  12844. * @param generateMipMaps defines if the engine should generate the mip levels
  12845. * @param invertY defines if data must be stored with Y axis inverted
  12846. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12847. * @param compression defines the compression used (null by default)
  12848. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12849. * @returns the raw texture inside an InternalTexture
  12850. */
  12851. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12852. /**
  12853. * Update a raw texture
  12854. * @param texture defines the texture to update
  12855. * @param data defines the data to store in the texture
  12856. * @param format defines the format of the data
  12857. * @param invertY defines if data must be stored with Y axis inverted
  12858. */
  12859. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12860. /**
  12861. * Update a raw texture
  12862. * @param texture defines the texture to update
  12863. * @param data defines the data to store in the texture
  12864. * @param format defines the format of the data
  12865. * @param invertY defines if data must be stored with Y axis inverted
  12866. * @param compression defines the compression used (null by default)
  12867. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12868. */
  12869. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12870. /**
  12871. * Creates a new raw cube texture
  12872. * @param data defines the array of data to use to create each face
  12873. * @param size defines the size of the textures
  12874. * @param format defines the format of the data
  12875. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12876. * @param generateMipMaps defines if the engine should generate the mip levels
  12877. * @param invertY defines if data must be stored with Y axis inverted
  12878. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12879. * @param compression defines the compression used (null by default)
  12880. * @returns the cube texture as an InternalTexture
  12881. */
  12882. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12883. /**
  12884. * Update a raw cube texture
  12885. * @param texture defines the texture to udpdate
  12886. * @param data defines the data to store
  12887. * @param format defines the data format
  12888. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12889. * @param invertY defines if data must be stored with Y axis inverted
  12890. */
  12891. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12892. /**
  12893. * Update a raw cube texture
  12894. * @param texture defines the texture to udpdate
  12895. * @param data defines the data to store
  12896. * @param format defines the data format
  12897. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12898. * @param invertY defines if data must be stored with Y axis inverted
  12899. * @param compression defines the compression used (null by default)
  12900. */
  12901. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12902. /**
  12903. * Update a raw cube texture
  12904. * @param texture defines the texture to udpdate
  12905. * @param data defines the data to store
  12906. * @param format defines the data format
  12907. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12908. * @param invertY defines if data must be stored with Y axis inverted
  12909. * @param compression defines the compression used (null by default)
  12910. * @param level defines which level of the texture to update
  12911. */
  12912. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12913. /**
  12914. * Creates a new raw cube texture from a specified url
  12915. * @param url defines the url where the data is located
  12916. * @param scene defines the current scene
  12917. * @param size defines the size of the textures
  12918. * @param format defines the format of the data
  12919. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12920. * @param noMipmap defines if the engine should avoid generating the mip levels
  12921. * @param callback defines a callback used to extract texture data from loaded data
  12922. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12923. * @param onLoad defines a callback called when texture is loaded
  12924. * @param onError defines a callback called if there is an error
  12925. * @returns the cube texture as an InternalTexture
  12926. */
  12927. 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;
  12928. /**
  12929. * Creates a new raw cube texture from a specified url
  12930. * @param url defines the url where the data is located
  12931. * @param scene defines the current scene
  12932. * @param size defines the size of the textures
  12933. * @param format defines the format of the data
  12934. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12935. * @param noMipmap defines if the engine should avoid generating the mip levels
  12936. * @param callback defines a callback used to extract texture data from loaded data
  12937. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12938. * @param onLoad defines a callback called when texture is loaded
  12939. * @param onError defines a callback called if there is an error
  12940. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12941. * @param invertY defines if data must be stored with Y axis inverted
  12942. * @returns the cube texture as an InternalTexture
  12943. */
  12944. 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;
  12945. /**
  12946. * Creates a new raw 3D texture
  12947. * @param data defines the data used to create the texture
  12948. * @param width defines the width of the texture
  12949. * @param height defines the height of the texture
  12950. * @param depth defines the depth of the texture
  12951. * @param format defines the format of the texture
  12952. * @param generateMipMaps defines if the engine must generate mip levels
  12953. * @param invertY defines if data must be stored with Y axis inverted
  12954. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12955. * @param compression defines the compressed used (can be null)
  12956. * @param textureType defines the compressed used (can be null)
  12957. * @returns a new raw 3D texture (stored in an InternalTexture)
  12958. */
  12959. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12960. /**
  12961. * Update a raw 3D texture
  12962. * @param texture defines the texture to update
  12963. * @param data defines the data to store
  12964. * @param format defines the data format
  12965. * @param invertY defines if data must be stored with Y axis inverted
  12966. */
  12967. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12968. /**
  12969. * Update a raw 3D texture
  12970. * @param texture defines the texture to update
  12971. * @param data defines the data to store
  12972. * @param format defines the data format
  12973. * @param invertY defines if data must be stored with Y axis inverted
  12974. * @param compression defines the used compression (can be null)
  12975. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12976. */
  12977. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12978. /**
  12979. * Creates a new raw 2D array texture
  12980. * @param data defines the data used to create the texture
  12981. * @param width defines the width of the texture
  12982. * @param height defines the height of the texture
  12983. * @param depth defines the number of layers of the texture
  12984. * @param format defines the format of the texture
  12985. * @param generateMipMaps defines if the engine must generate mip levels
  12986. * @param invertY defines if data must be stored with Y axis inverted
  12987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12988. * @param compression defines the compressed used (can be null)
  12989. * @param textureType defines the compressed used (can be null)
  12990. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12991. */
  12992. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12993. /**
  12994. * Update a raw 2D array texture
  12995. * @param texture defines the texture to update
  12996. * @param data defines the data to store
  12997. * @param format defines the data format
  12998. * @param invertY defines if data must be stored with Y axis inverted
  12999. */
  13000. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13001. /**
  13002. * Update a raw 2D array texture
  13003. * @param texture defines the texture to update
  13004. * @param data defines the data to store
  13005. * @param format defines the data format
  13006. * @param invertY defines if data must be stored with Y axis inverted
  13007. * @param compression defines the used compression (can be null)
  13008. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13009. */
  13010. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13011. }
  13012. }
  13013. }
  13014. declare module "babylonjs/Materials/Textures/rawTexture" {
  13015. import { Scene } from "babylonjs/scene";
  13016. import { Texture } from "babylonjs/Materials/Textures/texture";
  13017. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13018. /**
  13019. * Raw texture can help creating a texture directly from an array of data.
  13020. * This can be super useful if you either get the data from an uncompressed source or
  13021. * if you wish to create your texture pixel by pixel.
  13022. */
  13023. export class RawTexture extends Texture {
  13024. /**
  13025. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13026. */
  13027. format: number;
  13028. private _engine;
  13029. /**
  13030. * Instantiates a new RawTexture.
  13031. * Raw texture can help creating a texture directly from an array of data.
  13032. * This can be super useful if you either get the data from an uncompressed source or
  13033. * if you wish to create your texture pixel by pixel.
  13034. * @param data define the array of data to use to create the texture
  13035. * @param width define the width of the texture
  13036. * @param height define the height of the texture
  13037. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13038. * @param scene define the scene the texture belongs to
  13039. * @param generateMipMaps define whether mip maps should be generated or not
  13040. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13041. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13042. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13043. */
  13044. constructor(data: ArrayBufferView, width: number, height: number,
  13045. /**
  13046. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13047. */
  13048. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13049. /**
  13050. * Updates the texture underlying data.
  13051. * @param data Define the new data of the texture
  13052. */
  13053. update(data: ArrayBufferView): void;
  13054. /**
  13055. * Creates a luminance texture from some data.
  13056. * @param data Define the texture data
  13057. * @param width Define the width of the texture
  13058. * @param height Define the height of the texture
  13059. * @param scene Define the scene the texture belongs to
  13060. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13061. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13062. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13063. * @returns the luminance texture
  13064. */
  13065. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13066. /**
  13067. * Creates a luminance alpha texture from some data.
  13068. * @param data Define the texture data
  13069. * @param width Define the width of the texture
  13070. * @param height Define the height of the texture
  13071. * @param scene Define the scene the texture belongs to
  13072. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13073. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13074. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13075. * @returns the luminance alpha texture
  13076. */
  13077. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13078. /**
  13079. * Creates an alpha texture from some data.
  13080. * @param data Define the texture data
  13081. * @param width Define the width of the texture
  13082. * @param height Define the height of the texture
  13083. * @param scene Define the scene the texture belongs to
  13084. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13085. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13086. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13087. * @returns the alpha texture
  13088. */
  13089. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13090. /**
  13091. * Creates a RGB texture from some data.
  13092. * @param data Define the texture data
  13093. * @param width Define the width of the texture
  13094. * @param height Define the height of the texture
  13095. * @param scene Define the scene the texture belongs to
  13096. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13097. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13098. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13099. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13100. * @returns the RGB alpha texture
  13101. */
  13102. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13103. /**
  13104. * Creates a RGBA texture from some data.
  13105. * @param data Define the texture data
  13106. * @param width Define the width of the texture
  13107. * @param height Define the height of the texture
  13108. * @param scene Define the scene the texture belongs to
  13109. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13110. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13111. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13112. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13113. * @returns the RGBA texture
  13114. */
  13115. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13116. /**
  13117. * Creates a R texture from some data.
  13118. * @param data Define the texture data
  13119. * @param width Define the width of the texture
  13120. * @param height Define the height of the texture
  13121. * @param scene Define the scene the texture belongs to
  13122. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13123. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13124. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13125. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13126. * @returns the R texture
  13127. */
  13128. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13129. }
  13130. }
  13131. declare module "babylonjs/Maths/math.size" {
  13132. /**
  13133. * Interface for the size containing width and height
  13134. */
  13135. export interface ISize {
  13136. /**
  13137. * Width
  13138. */
  13139. width: number;
  13140. /**
  13141. * Heighht
  13142. */
  13143. height: number;
  13144. }
  13145. /**
  13146. * Size containing widht and height
  13147. */
  13148. export class Size implements ISize {
  13149. /**
  13150. * Width
  13151. */
  13152. width: number;
  13153. /**
  13154. * Height
  13155. */
  13156. height: number;
  13157. /**
  13158. * Creates a Size object from the given width and height (floats).
  13159. * @param width width of the new size
  13160. * @param height height of the new size
  13161. */
  13162. constructor(width: number, height: number);
  13163. /**
  13164. * Returns a string with the Size width and height
  13165. * @returns a string with the Size width and height
  13166. */
  13167. toString(): string;
  13168. /**
  13169. * "Size"
  13170. * @returns the string "Size"
  13171. */
  13172. getClassName(): string;
  13173. /**
  13174. * Returns the Size hash code.
  13175. * @returns a hash code for a unique width and height
  13176. */
  13177. getHashCode(): number;
  13178. /**
  13179. * Updates the current size from the given one.
  13180. * @param src the given size
  13181. */
  13182. copyFrom(src: Size): void;
  13183. /**
  13184. * Updates in place the current Size from the given floats.
  13185. * @param width width of the new size
  13186. * @param height height of the new size
  13187. * @returns the updated Size.
  13188. */
  13189. copyFromFloats(width: number, height: number): Size;
  13190. /**
  13191. * Updates in place the current Size from the given floats.
  13192. * @param width width to set
  13193. * @param height height to set
  13194. * @returns the updated Size.
  13195. */
  13196. set(width: number, height: number): Size;
  13197. /**
  13198. * Multiplies the width and height by numbers
  13199. * @param w factor to multiple the width by
  13200. * @param h factor to multiple the height by
  13201. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13202. */
  13203. multiplyByFloats(w: number, h: number): Size;
  13204. /**
  13205. * Clones the size
  13206. * @returns a new Size copied from the given one.
  13207. */
  13208. clone(): Size;
  13209. /**
  13210. * True if the current Size and the given one width and height are strictly equal.
  13211. * @param other the other size to compare against
  13212. * @returns True if the current Size and the given one width and height are strictly equal.
  13213. */
  13214. equals(other: Size): boolean;
  13215. /**
  13216. * The surface of the Size : width * height (float).
  13217. */
  13218. get surface(): number;
  13219. /**
  13220. * Create a new size of zero
  13221. * @returns a new Size set to (0.0, 0.0)
  13222. */
  13223. static Zero(): Size;
  13224. /**
  13225. * Sums the width and height of two sizes
  13226. * @param otherSize size to add to this size
  13227. * @returns a new Size set as the addition result of the current Size and the given one.
  13228. */
  13229. add(otherSize: Size): Size;
  13230. /**
  13231. * Subtracts the width and height of two
  13232. * @param otherSize size to subtract to this size
  13233. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13234. */
  13235. subtract(otherSize: Size): Size;
  13236. /**
  13237. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13238. * @param start starting size to lerp between
  13239. * @param end end size to lerp between
  13240. * @param amount amount to lerp between the start and end values
  13241. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13242. */
  13243. static Lerp(start: Size, end: Size, amount: number): Size;
  13244. }
  13245. }
  13246. declare module "babylonjs/Animations/runtimeAnimation" {
  13247. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13248. import { Animatable } from "babylonjs/Animations/animatable";
  13249. import { Scene } from "babylonjs/scene";
  13250. /**
  13251. * Defines a runtime animation
  13252. */
  13253. export class RuntimeAnimation {
  13254. private _events;
  13255. /**
  13256. * The current frame of the runtime animation
  13257. */
  13258. private _currentFrame;
  13259. /**
  13260. * The animation used by the runtime animation
  13261. */
  13262. private _animation;
  13263. /**
  13264. * The target of the runtime animation
  13265. */
  13266. private _target;
  13267. /**
  13268. * The initiating animatable
  13269. */
  13270. private _host;
  13271. /**
  13272. * The original value of the runtime animation
  13273. */
  13274. private _originalValue;
  13275. /**
  13276. * The original blend value of the runtime animation
  13277. */
  13278. private _originalBlendValue;
  13279. /**
  13280. * The offsets cache of the runtime animation
  13281. */
  13282. private _offsetsCache;
  13283. /**
  13284. * The high limits cache of the runtime animation
  13285. */
  13286. private _highLimitsCache;
  13287. /**
  13288. * Specifies if the runtime animation has been stopped
  13289. */
  13290. private _stopped;
  13291. /**
  13292. * The blending factor of the runtime animation
  13293. */
  13294. private _blendingFactor;
  13295. /**
  13296. * The BabylonJS scene
  13297. */
  13298. private _scene;
  13299. /**
  13300. * The current value of the runtime animation
  13301. */
  13302. private _currentValue;
  13303. /** @hidden */
  13304. _animationState: _IAnimationState;
  13305. /**
  13306. * The active target of the runtime animation
  13307. */
  13308. private _activeTargets;
  13309. private _currentActiveTarget;
  13310. private _directTarget;
  13311. /**
  13312. * The target path of the runtime animation
  13313. */
  13314. private _targetPath;
  13315. /**
  13316. * The weight of the runtime animation
  13317. */
  13318. private _weight;
  13319. /**
  13320. * The ratio offset of the runtime animation
  13321. */
  13322. private _ratioOffset;
  13323. /**
  13324. * The previous delay of the runtime animation
  13325. */
  13326. private _previousDelay;
  13327. /**
  13328. * The previous ratio of the runtime animation
  13329. */
  13330. private _previousRatio;
  13331. private _enableBlending;
  13332. private _keys;
  13333. private _minFrame;
  13334. private _maxFrame;
  13335. private _minValue;
  13336. private _maxValue;
  13337. private _targetIsArray;
  13338. /**
  13339. * Gets the current frame of the runtime animation
  13340. */
  13341. get currentFrame(): number;
  13342. /**
  13343. * Gets the weight of the runtime animation
  13344. */
  13345. get weight(): number;
  13346. /**
  13347. * Gets the current value of the runtime animation
  13348. */
  13349. get currentValue(): any;
  13350. /**
  13351. * Gets the target path of the runtime animation
  13352. */
  13353. get targetPath(): string;
  13354. /**
  13355. * Gets the actual target of the runtime animation
  13356. */
  13357. get target(): any;
  13358. /** @hidden */
  13359. _onLoop: () => void;
  13360. /**
  13361. * Create a new RuntimeAnimation object
  13362. * @param target defines the target of the animation
  13363. * @param animation defines the source animation object
  13364. * @param scene defines the hosting scene
  13365. * @param host defines the initiating Animatable
  13366. */
  13367. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13368. private _preparePath;
  13369. /**
  13370. * Gets the animation from the runtime animation
  13371. */
  13372. get animation(): Animation;
  13373. /**
  13374. * Resets the runtime animation to the beginning
  13375. * @param restoreOriginal defines whether to restore the target property to the original value
  13376. */
  13377. reset(restoreOriginal?: boolean): void;
  13378. /**
  13379. * Specifies if the runtime animation is stopped
  13380. * @returns Boolean specifying if the runtime animation is stopped
  13381. */
  13382. isStopped(): boolean;
  13383. /**
  13384. * Disposes of the runtime animation
  13385. */
  13386. dispose(): void;
  13387. /**
  13388. * Apply the interpolated value to the target
  13389. * @param currentValue defines the value computed by the animation
  13390. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13391. */
  13392. setValue(currentValue: any, weight: number): void;
  13393. private _getOriginalValues;
  13394. private _setValue;
  13395. /**
  13396. * Gets the loop pmode of the runtime animation
  13397. * @returns Loop Mode
  13398. */
  13399. private _getCorrectLoopMode;
  13400. /**
  13401. * Move the current animation to a given frame
  13402. * @param frame defines the frame to move to
  13403. */
  13404. goToFrame(frame: number): void;
  13405. /**
  13406. * @hidden Internal use only
  13407. */
  13408. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13409. /**
  13410. * Execute the current animation
  13411. * @param delay defines the delay to add to the current frame
  13412. * @param from defines the lower bound of the animation range
  13413. * @param to defines the upper bound of the animation range
  13414. * @param loop defines if the current animation must loop
  13415. * @param speedRatio defines the current speed ratio
  13416. * @param weight defines the weight of the animation (default is -1 so no weight)
  13417. * @param onLoop optional callback called when animation loops
  13418. * @returns a boolean indicating if the animation is running
  13419. */
  13420. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13421. }
  13422. }
  13423. declare module "babylonjs/Animations/animatable" {
  13424. import { Animation } from "babylonjs/Animations/animation";
  13425. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13426. import { Nullable } from "babylonjs/types";
  13427. import { Observable } from "babylonjs/Misc/observable";
  13428. import { Scene } from "babylonjs/scene";
  13429. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13430. import { Node } from "babylonjs/node";
  13431. /**
  13432. * Class used to store an actual running animation
  13433. */
  13434. export class Animatable {
  13435. /** defines the target object */
  13436. target: any;
  13437. /** defines the starting frame number (default is 0) */
  13438. fromFrame: number;
  13439. /** defines the ending frame number (default is 100) */
  13440. toFrame: number;
  13441. /** defines if the animation must loop (default is false) */
  13442. loopAnimation: boolean;
  13443. /** defines a callback to call when animation ends if it is not looping */
  13444. onAnimationEnd?: (() => void) | null | undefined;
  13445. /** defines a callback to call when animation loops */
  13446. onAnimationLoop?: (() => void) | null | undefined;
  13447. private _localDelayOffset;
  13448. private _pausedDelay;
  13449. private _runtimeAnimations;
  13450. private _paused;
  13451. private _scene;
  13452. private _speedRatio;
  13453. private _weight;
  13454. private _syncRoot;
  13455. /**
  13456. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13457. * This will only apply for non looping animation (default is true)
  13458. */
  13459. disposeOnEnd: boolean;
  13460. /**
  13461. * Gets a boolean indicating if the animation has started
  13462. */
  13463. animationStarted: boolean;
  13464. /**
  13465. * Observer raised when the animation ends
  13466. */
  13467. onAnimationEndObservable: Observable<Animatable>;
  13468. /**
  13469. * Observer raised when the animation loops
  13470. */
  13471. onAnimationLoopObservable: Observable<Animatable>;
  13472. /**
  13473. * Gets the root Animatable used to synchronize and normalize animations
  13474. */
  13475. get syncRoot(): Nullable<Animatable>;
  13476. /**
  13477. * Gets the current frame of the first RuntimeAnimation
  13478. * Used to synchronize Animatables
  13479. */
  13480. get masterFrame(): number;
  13481. /**
  13482. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13483. */
  13484. get weight(): number;
  13485. set weight(value: number);
  13486. /**
  13487. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13488. */
  13489. get speedRatio(): number;
  13490. set speedRatio(value: number);
  13491. /**
  13492. * Creates a new Animatable
  13493. * @param scene defines the hosting scene
  13494. * @param target defines the target object
  13495. * @param fromFrame defines the starting frame number (default is 0)
  13496. * @param toFrame defines the ending frame number (default is 100)
  13497. * @param loopAnimation defines if the animation must loop (default is false)
  13498. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13499. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13500. * @param animations defines a group of animation to add to the new Animatable
  13501. * @param onAnimationLoop defines a callback to call when animation loops
  13502. */
  13503. constructor(scene: Scene,
  13504. /** defines the target object */
  13505. target: any,
  13506. /** defines the starting frame number (default is 0) */
  13507. fromFrame?: number,
  13508. /** defines the ending frame number (default is 100) */
  13509. toFrame?: number,
  13510. /** defines if the animation must loop (default is false) */
  13511. loopAnimation?: boolean, speedRatio?: number,
  13512. /** defines a callback to call when animation ends if it is not looping */
  13513. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13514. /** defines a callback to call when animation loops */
  13515. onAnimationLoop?: (() => void) | null | undefined);
  13516. /**
  13517. * Synchronize and normalize current Animatable with a source Animatable
  13518. * This is useful when using animation weights and when animations are not of the same length
  13519. * @param root defines the root Animatable to synchronize with
  13520. * @returns the current Animatable
  13521. */
  13522. syncWith(root: Animatable): Animatable;
  13523. /**
  13524. * Gets the list of runtime animations
  13525. * @returns an array of RuntimeAnimation
  13526. */
  13527. getAnimations(): RuntimeAnimation[];
  13528. /**
  13529. * Adds more animations to the current animatable
  13530. * @param target defines the target of the animations
  13531. * @param animations defines the new animations to add
  13532. */
  13533. appendAnimations(target: any, animations: Animation[]): void;
  13534. /**
  13535. * Gets the source animation for a specific property
  13536. * @param property defines the propertyu to look for
  13537. * @returns null or the source animation for the given property
  13538. */
  13539. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13540. /**
  13541. * Gets the runtime animation for a specific property
  13542. * @param property defines the propertyu to look for
  13543. * @returns null or the runtime animation for the given property
  13544. */
  13545. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13546. /**
  13547. * Resets the animatable to its original state
  13548. */
  13549. reset(): void;
  13550. /**
  13551. * Allows the animatable to blend with current running animations
  13552. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13553. * @param blendingSpeed defines the blending speed to use
  13554. */
  13555. enableBlending(blendingSpeed: number): void;
  13556. /**
  13557. * Disable animation blending
  13558. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13559. */
  13560. disableBlending(): void;
  13561. /**
  13562. * Jump directly to a given frame
  13563. * @param frame defines the frame to jump to
  13564. */
  13565. goToFrame(frame: number): void;
  13566. /**
  13567. * Pause the animation
  13568. */
  13569. pause(): void;
  13570. /**
  13571. * Restart the animation
  13572. */
  13573. restart(): void;
  13574. private _raiseOnAnimationEnd;
  13575. /**
  13576. * Stop and delete the current animation
  13577. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13578. * @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)
  13579. */
  13580. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13581. /**
  13582. * Wait asynchronously for the animation to end
  13583. * @returns a promise which will be fullfilled when the animation ends
  13584. */
  13585. waitAsync(): Promise<Animatable>;
  13586. /** @hidden */
  13587. _animate(delay: number): boolean;
  13588. }
  13589. module "babylonjs/scene" {
  13590. interface Scene {
  13591. /** @hidden */
  13592. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13593. /** @hidden */
  13594. _processLateAnimationBindingsForMatrices(holder: {
  13595. totalWeight: number;
  13596. animations: RuntimeAnimation[];
  13597. originalValue: Matrix;
  13598. }): any;
  13599. /** @hidden */
  13600. _processLateAnimationBindingsForQuaternions(holder: {
  13601. totalWeight: number;
  13602. animations: RuntimeAnimation[];
  13603. originalValue: Quaternion;
  13604. }, refQuaternion: Quaternion): Quaternion;
  13605. /** @hidden */
  13606. _processLateAnimationBindings(): void;
  13607. /**
  13608. * Will start the animation sequence of a given target
  13609. * @param target defines the target
  13610. * @param from defines from which frame should animation start
  13611. * @param to defines until which frame should animation run.
  13612. * @param weight defines the weight to apply to the animation (1.0 by default)
  13613. * @param loop defines if the animation loops
  13614. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13615. * @param onAnimationEnd defines the function to be executed when the animation ends
  13616. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13617. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13618. * @param onAnimationLoop defines the callback to call when an animation loops
  13619. * @returns the animatable object created for this animation
  13620. */
  13621. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13622. /**
  13623. * Will start the animation sequence of a given target
  13624. * @param target defines the target
  13625. * @param from defines from which frame should animation start
  13626. * @param to defines until which frame should animation run.
  13627. * @param loop defines if the animation loops
  13628. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13629. * @param onAnimationEnd defines the function to be executed when the animation ends
  13630. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13631. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13632. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13633. * @param onAnimationLoop defines the callback to call when an animation loops
  13634. * @returns the animatable object created for this animation
  13635. */
  13636. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13637. /**
  13638. * Will start the animation sequence of a given target and its hierarchy
  13639. * @param target defines the target
  13640. * @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.
  13641. * @param from defines from which frame should animation start
  13642. * @param to defines until which frame should animation run.
  13643. * @param loop defines if the animation loops
  13644. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13645. * @param onAnimationEnd defines the function to be executed when the animation ends
  13646. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13647. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13648. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13649. * @param onAnimationLoop defines the callback to call when an animation loops
  13650. * @returns the list of created animatables
  13651. */
  13652. 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[];
  13653. /**
  13654. * Begin a new animation on a given node
  13655. * @param target defines the target where the animation will take place
  13656. * @param animations defines the list of animations to start
  13657. * @param from defines the initial value
  13658. * @param to defines the final value
  13659. * @param loop defines if you want animation to loop (off by default)
  13660. * @param speedRatio defines the speed ratio to apply to all animations
  13661. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13662. * @param onAnimationLoop defines the callback to call when an animation loops
  13663. * @returns the list of created animatables
  13664. */
  13665. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13666. /**
  13667. * Begin a new animation on a given node and its hierarchy
  13668. * @param target defines the root node where the animation will take place
  13669. * @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.
  13670. * @param animations defines the list of animations to start
  13671. * @param from defines the initial value
  13672. * @param to defines the final value
  13673. * @param loop defines if you want animation to loop (off by default)
  13674. * @param speedRatio defines the speed ratio to apply to all animations
  13675. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13676. * @param onAnimationLoop defines the callback to call when an animation loops
  13677. * @returns the list of animatables created for all nodes
  13678. */
  13679. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13680. /**
  13681. * Gets the animatable associated with a specific target
  13682. * @param target defines the target of the animatable
  13683. * @returns the required animatable if found
  13684. */
  13685. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13686. /**
  13687. * Gets all animatables associated with a given target
  13688. * @param target defines the target to look animatables for
  13689. * @returns an array of Animatables
  13690. */
  13691. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13692. /**
  13693. * Stops and removes all animations that have been applied to the scene
  13694. */
  13695. stopAllAnimations(): void;
  13696. /**
  13697. * Gets the current delta time used by animation engine
  13698. */
  13699. deltaTime: number;
  13700. }
  13701. }
  13702. module "babylonjs/Bones/bone" {
  13703. interface Bone {
  13704. /**
  13705. * Copy an animation range from another bone
  13706. * @param source defines the source bone
  13707. * @param rangeName defines the range name to copy
  13708. * @param frameOffset defines the frame offset
  13709. * @param rescaleAsRequired defines if rescaling must be applied if required
  13710. * @param skelDimensionsRatio defines the scaling ratio
  13711. * @returns true if operation was successful
  13712. */
  13713. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13714. }
  13715. }
  13716. }
  13717. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13718. /**
  13719. * Class used to override all child animations of a given target
  13720. */
  13721. export class AnimationPropertiesOverride {
  13722. /**
  13723. * Gets or sets a value indicating if animation blending must be used
  13724. */
  13725. enableBlending: boolean;
  13726. /**
  13727. * Gets or sets the blending speed to use when enableBlending is true
  13728. */
  13729. blendingSpeed: number;
  13730. /**
  13731. * Gets or sets the default loop mode to use
  13732. */
  13733. loopMode: number;
  13734. }
  13735. }
  13736. declare module "babylonjs/Bones/skeleton" {
  13737. import { Bone } from "babylonjs/Bones/bone";
  13738. import { Observable } from "babylonjs/Misc/observable";
  13739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Scene } from "babylonjs/scene";
  13741. import { Nullable } from "babylonjs/types";
  13742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13743. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13744. import { Animatable } from "babylonjs/Animations/animatable";
  13745. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13746. import { Animation } from "babylonjs/Animations/animation";
  13747. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13748. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13749. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13750. /**
  13751. * Class used to handle skinning animations
  13752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13753. */
  13754. export class Skeleton implements IAnimatable {
  13755. /** defines the skeleton name */
  13756. name: string;
  13757. /** defines the skeleton Id */
  13758. id: string;
  13759. /**
  13760. * Defines the list of child bones
  13761. */
  13762. bones: Bone[];
  13763. /**
  13764. * Defines an estimate of the dimension of the skeleton at rest
  13765. */
  13766. dimensionsAtRest: Vector3;
  13767. /**
  13768. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13769. */
  13770. needInitialSkinMatrix: boolean;
  13771. /**
  13772. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13773. */
  13774. overrideMesh: Nullable<AbstractMesh>;
  13775. /**
  13776. * Gets the list of animations attached to this skeleton
  13777. */
  13778. animations: Array<Animation>;
  13779. private _scene;
  13780. private _isDirty;
  13781. private _transformMatrices;
  13782. private _transformMatrixTexture;
  13783. private _meshesWithPoseMatrix;
  13784. private _animatables;
  13785. private _identity;
  13786. private _synchronizedWithMesh;
  13787. private _ranges;
  13788. private _lastAbsoluteTransformsUpdateId;
  13789. private _canUseTextureForBones;
  13790. private _uniqueId;
  13791. /** @hidden */
  13792. _numBonesWithLinkedTransformNode: number;
  13793. /** @hidden */
  13794. _hasWaitingData: Nullable<boolean>;
  13795. /**
  13796. * Specifies if the skeleton should be serialized
  13797. */
  13798. doNotSerialize: boolean;
  13799. private _useTextureToStoreBoneMatrices;
  13800. /**
  13801. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13802. * Please note that this option is not available if the hardware does not support it
  13803. */
  13804. get useTextureToStoreBoneMatrices(): boolean;
  13805. set useTextureToStoreBoneMatrices(value: boolean);
  13806. private _animationPropertiesOverride;
  13807. /**
  13808. * Gets or sets the animation properties override
  13809. */
  13810. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13811. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13812. /**
  13813. * List of inspectable custom properties (used by the Inspector)
  13814. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13815. */
  13816. inspectableCustomProperties: IInspectable[];
  13817. /**
  13818. * An observable triggered before computing the skeleton's matrices
  13819. */
  13820. onBeforeComputeObservable: Observable<Skeleton>;
  13821. /**
  13822. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13823. */
  13824. get isUsingTextureForMatrices(): boolean;
  13825. /**
  13826. * Gets the unique ID of this skeleton
  13827. */
  13828. get uniqueId(): number;
  13829. /**
  13830. * Creates a new skeleton
  13831. * @param name defines the skeleton name
  13832. * @param id defines the skeleton Id
  13833. * @param scene defines the hosting scene
  13834. */
  13835. constructor(
  13836. /** defines the skeleton name */
  13837. name: string,
  13838. /** defines the skeleton Id */
  13839. id: string, scene: Scene);
  13840. /**
  13841. * Gets the current object class name.
  13842. * @return the class name
  13843. */
  13844. getClassName(): string;
  13845. /**
  13846. * Returns an array containing the root bones
  13847. * @returns an array containing the root bones
  13848. */
  13849. getChildren(): Array<Bone>;
  13850. /**
  13851. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13852. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13853. * @returns a Float32Array containing matrices data
  13854. */
  13855. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13856. /**
  13857. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13858. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13859. * @returns a raw texture containing the data
  13860. */
  13861. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13862. /**
  13863. * Gets the current hosting scene
  13864. * @returns a scene object
  13865. */
  13866. getScene(): Scene;
  13867. /**
  13868. * Gets a string representing the current skeleton data
  13869. * @param fullDetails defines a boolean indicating if we want a verbose version
  13870. * @returns a string representing the current skeleton data
  13871. */
  13872. toString(fullDetails?: boolean): string;
  13873. /**
  13874. * Get bone's index searching by name
  13875. * @param name defines bone's name to search for
  13876. * @return the indice of the bone. Returns -1 if not found
  13877. */
  13878. getBoneIndexByName(name: string): number;
  13879. /**
  13880. * Creater a new animation range
  13881. * @param name defines the name of the range
  13882. * @param from defines the start key
  13883. * @param to defines the end key
  13884. */
  13885. createAnimationRange(name: string, from: number, to: number): void;
  13886. /**
  13887. * Delete a specific animation range
  13888. * @param name defines the name of the range
  13889. * @param deleteFrames defines if frames must be removed as well
  13890. */
  13891. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13892. /**
  13893. * Gets a specific animation range
  13894. * @param name defines the name of the range to look for
  13895. * @returns the requested animation range or null if not found
  13896. */
  13897. getAnimationRange(name: string): Nullable<AnimationRange>;
  13898. /**
  13899. * Gets the list of all animation ranges defined on this skeleton
  13900. * @returns an array
  13901. */
  13902. getAnimationRanges(): Nullable<AnimationRange>[];
  13903. /**
  13904. * Copy animation range from a source skeleton.
  13905. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13906. * @param source defines the source skeleton
  13907. * @param name defines the name of the range to copy
  13908. * @param rescaleAsRequired defines if rescaling must be applied if required
  13909. * @returns true if operation was successful
  13910. */
  13911. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13912. /**
  13913. * Forces the skeleton to go to rest pose
  13914. */
  13915. returnToRest(): void;
  13916. private _getHighestAnimationFrame;
  13917. /**
  13918. * Begin a specific animation range
  13919. * @param name defines the name of the range to start
  13920. * @param loop defines if looping must be turned on (false by default)
  13921. * @param speedRatio defines the speed ratio to apply (1 by default)
  13922. * @param onAnimationEnd defines a callback which will be called when animation will end
  13923. * @returns a new animatable
  13924. */
  13925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13926. /** @hidden */
  13927. _markAsDirty(): void;
  13928. /** @hidden */
  13929. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13930. /** @hidden */
  13931. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13932. private _computeTransformMatrices;
  13933. /**
  13934. * Build all resources required to render a skeleton
  13935. */
  13936. prepare(): void;
  13937. /**
  13938. * Gets the list of animatables currently running for this skeleton
  13939. * @returns an array of animatables
  13940. */
  13941. getAnimatables(): IAnimatable[];
  13942. /**
  13943. * Clone the current skeleton
  13944. * @param name defines the name of the new skeleton
  13945. * @param id defines the id of the new skeleton
  13946. * @returns the new skeleton
  13947. */
  13948. clone(name: string, id?: string): Skeleton;
  13949. /**
  13950. * Enable animation blending for this skeleton
  13951. * @param blendingSpeed defines the blending speed to apply
  13952. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13953. */
  13954. enableBlending(blendingSpeed?: number): void;
  13955. /**
  13956. * Releases all resources associated with the current skeleton
  13957. */
  13958. dispose(): void;
  13959. /**
  13960. * Serialize the skeleton in a JSON object
  13961. * @returns a JSON object
  13962. */
  13963. serialize(): any;
  13964. /**
  13965. * Creates a new skeleton from serialized data
  13966. * @param parsedSkeleton defines the serialized data
  13967. * @param scene defines the hosting scene
  13968. * @returns a new skeleton
  13969. */
  13970. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13971. /**
  13972. * Compute all node absolute transforms
  13973. * @param forceUpdate defines if computation must be done even if cache is up to date
  13974. */
  13975. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13976. /**
  13977. * Gets the root pose matrix
  13978. * @returns a matrix
  13979. */
  13980. getPoseMatrix(): Nullable<Matrix>;
  13981. /**
  13982. * Sorts bones per internal index
  13983. */
  13984. sortBones(): void;
  13985. private _sortBones;
  13986. }
  13987. }
  13988. declare module "babylonjs/Bones/bone" {
  13989. import { Skeleton } from "babylonjs/Bones/skeleton";
  13990. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13991. import { Nullable } from "babylonjs/types";
  13992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13994. import { Node } from "babylonjs/node";
  13995. import { Space } from "babylonjs/Maths/math.axis";
  13996. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13997. /**
  13998. * Class used to store bone information
  13999. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14000. */
  14001. export class Bone extends Node {
  14002. /**
  14003. * defines the bone name
  14004. */
  14005. name: string;
  14006. private static _tmpVecs;
  14007. private static _tmpQuat;
  14008. private static _tmpMats;
  14009. /**
  14010. * Gets the list of child bones
  14011. */
  14012. children: Bone[];
  14013. /** Gets the animations associated with this bone */
  14014. animations: import("babylonjs/Animations/animation").Animation[];
  14015. /**
  14016. * Gets or sets bone length
  14017. */
  14018. length: number;
  14019. /**
  14020. * @hidden Internal only
  14021. * Set this value to map this bone to a different index in the transform matrices
  14022. * Set this value to -1 to exclude the bone from the transform matrices
  14023. */
  14024. _index: Nullable<number>;
  14025. private _skeleton;
  14026. private _localMatrix;
  14027. private _restPose;
  14028. private _baseMatrix;
  14029. private _absoluteTransform;
  14030. private _invertedAbsoluteTransform;
  14031. private _parent;
  14032. private _scalingDeterminant;
  14033. private _worldTransform;
  14034. private _localScaling;
  14035. private _localRotation;
  14036. private _localPosition;
  14037. private _needToDecompose;
  14038. private _needToCompose;
  14039. /** @hidden */
  14040. _linkedTransformNode: Nullable<TransformNode>;
  14041. /** @hidden */
  14042. _waitingTransformNodeId: Nullable<string>;
  14043. /** @hidden */
  14044. get _matrix(): Matrix;
  14045. /** @hidden */
  14046. set _matrix(value: Matrix);
  14047. /**
  14048. * Create a new bone
  14049. * @param name defines the bone name
  14050. * @param skeleton defines the parent skeleton
  14051. * @param parentBone defines the parent (can be null if the bone is the root)
  14052. * @param localMatrix defines the local matrix
  14053. * @param restPose defines the rest pose matrix
  14054. * @param baseMatrix defines the base matrix
  14055. * @param index defines index of the bone in the hiearchy
  14056. */
  14057. constructor(
  14058. /**
  14059. * defines the bone name
  14060. */
  14061. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14062. /**
  14063. * Gets the current object class name.
  14064. * @return the class name
  14065. */
  14066. getClassName(): string;
  14067. /**
  14068. * Gets the parent skeleton
  14069. * @returns a skeleton
  14070. */
  14071. getSkeleton(): Skeleton;
  14072. /**
  14073. * Gets parent bone
  14074. * @returns a bone or null if the bone is the root of the bone hierarchy
  14075. */
  14076. getParent(): Nullable<Bone>;
  14077. /**
  14078. * Returns an array containing the root bones
  14079. * @returns an array containing the root bones
  14080. */
  14081. getChildren(): Array<Bone>;
  14082. /**
  14083. * Gets the node index in matrix array generated for rendering
  14084. * @returns the node index
  14085. */
  14086. getIndex(): number;
  14087. /**
  14088. * Sets the parent bone
  14089. * @param parent defines the parent (can be null if the bone is the root)
  14090. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14091. */
  14092. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14093. /**
  14094. * Gets the local matrix
  14095. * @returns a matrix
  14096. */
  14097. getLocalMatrix(): Matrix;
  14098. /**
  14099. * Gets the base matrix (initial matrix which remains unchanged)
  14100. * @returns a matrix
  14101. */
  14102. getBaseMatrix(): Matrix;
  14103. /**
  14104. * Gets the rest pose matrix
  14105. * @returns a matrix
  14106. */
  14107. getRestPose(): Matrix;
  14108. /**
  14109. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14110. */
  14111. getWorldMatrix(): Matrix;
  14112. /**
  14113. * Sets the local matrix to rest pose matrix
  14114. */
  14115. returnToRest(): void;
  14116. /**
  14117. * Gets the inverse of the absolute transform matrix.
  14118. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14119. * @returns a matrix
  14120. */
  14121. getInvertedAbsoluteTransform(): Matrix;
  14122. /**
  14123. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14124. * @returns a matrix
  14125. */
  14126. getAbsoluteTransform(): Matrix;
  14127. /**
  14128. * Links with the given transform node.
  14129. * The local matrix of this bone is copied from the transform node every frame.
  14130. * @param transformNode defines the transform node to link to
  14131. */
  14132. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14133. /**
  14134. * Gets the node used to drive the bone's transformation
  14135. * @returns a transform node or null
  14136. */
  14137. getTransformNode(): Nullable<TransformNode>;
  14138. /** Gets or sets current position (in local space) */
  14139. get position(): Vector3;
  14140. set position(newPosition: Vector3);
  14141. /** Gets or sets current rotation (in local space) */
  14142. get rotation(): Vector3;
  14143. set rotation(newRotation: Vector3);
  14144. /** Gets or sets current rotation quaternion (in local space) */
  14145. get rotationQuaternion(): Quaternion;
  14146. set rotationQuaternion(newRotation: Quaternion);
  14147. /** Gets or sets current scaling (in local space) */
  14148. get scaling(): Vector3;
  14149. set scaling(newScaling: Vector3);
  14150. /**
  14151. * Gets the animation properties override
  14152. */
  14153. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14154. private _decompose;
  14155. private _compose;
  14156. /**
  14157. * Update the base and local matrices
  14158. * @param matrix defines the new base or local matrix
  14159. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14160. * @param updateLocalMatrix defines if the local matrix should be updated
  14161. */
  14162. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14163. /** @hidden */
  14164. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14165. /**
  14166. * Flag the bone as dirty (Forcing it to update everything)
  14167. */
  14168. markAsDirty(): void;
  14169. /** @hidden */
  14170. _markAsDirtyAndCompose(): void;
  14171. private _markAsDirtyAndDecompose;
  14172. /**
  14173. * Translate the bone in local or world space
  14174. * @param vec The amount to translate the bone
  14175. * @param space The space that the translation is in
  14176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14177. */
  14178. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14179. /**
  14180. * Set the postion of the bone in local or world space
  14181. * @param position The position to set the bone
  14182. * @param space The space that the position is in
  14183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14184. */
  14185. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14186. /**
  14187. * Set the absolute position of the bone (world space)
  14188. * @param position The position to set the bone
  14189. * @param mesh The mesh that this bone is attached to
  14190. */
  14191. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14192. /**
  14193. * Scale the bone on the x, y and z axes (in local space)
  14194. * @param x The amount to scale the bone on the x axis
  14195. * @param y The amount to scale the bone on the y axis
  14196. * @param z The amount to scale the bone on the z axis
  14197. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14198. */
  14199. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14200. /**
  14201. * Set the bone scaling in local space
  14202. * @param scale defines the scaling vector
  14203. */
  14204. setScale(scale: Vector3): void;
  14205. /**
  14206. * Gets the current scaling in local space
  14207. * @returns the current scaling vector
  14208. */
  14209. getScale(): Vector3;
  14210. /**
  14211. * Gets the current scaling in local space and stores it in a target vector
  14212. * @param result defines the target vector
  14213. */
  14214. getScaleToRef(result: Vector3): void;
  14215. /**
  14216. * Set the yaw, pitch, and roll of the bone in local or world space
  14217. * @param yaw The rotation of the bone on the y axis
  14218. * @param pitch The rotation of the bone on the x axis
  14219. * @param roll The rotation of the bone on the z axis
  14220. * @param space The space that the axes of rotation are in
  14221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14222. */
  14223. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14224. /**
  14225. * Add a rotation to the bone on an axis in local or world space
  14226. * @param axis The axis to rotate the bone on
  14227. * @param amount The amount to rotate the bone
  14228. * @param space The space that the axis is in
  14229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14230. */
  14231. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14232. /**
  14233. * Set the rotation of the bone to a particular axis angle in local or world space
  14234. * @param axis The axis to rotate the bone on
  14235. * @param angle The angle that the bone should be rotated to
  14236. * @param space The space that the axis is in
  14237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14238. */
  14239. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14240. /**
  14241. * Set the euler rotation of the bone in local of world space
  14242. * @param rotation The euler rotation that the bone should be set to
  14243. * @param space The space that the rotation is in
  14244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14245. */
  14246. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14247. /**
  14248. * Set the quaternion rotation of the bone in local of world space
  14249. * @param quat The quaternion rotation that the bone should be set to
  14250. * @param space The space that the rotation is in
  14251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14252. */
  14253. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14254. /**
  14255. * Set the rotation matrix of the bone in local of world space
  14256. * @param rotMat The rotation matrix that the bone should be set to
  14257. * @param space The space that the rotation is in
  14258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14259. */
  14260. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14261. private _rotateWithMatrix;
  14262. private _getNegativeRotationToRef;
  14263. /**
  14264. * Get the position of the bone in local or world space
  14265. * @param space The space that the returned position is in
  14266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14267. * @returns The position of the bone
  14268. */
  14269. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14270. /**
  14271. * Copy the position of the bone to a vector3 in local or world space
  14272. * @param space The space that the returned position is in
  14273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14274. * @param result The vector3 to copy the position to
  14275. */
  14276. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14277. /**
  14278. * Get the absolute position of the bone (world space)
  14279. * @param mesh The mesh that this bone is attached to
  14280. * @returns The absolute position of the bone
  14281. */
  14282. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14283. /**
  14284. * Copy the absolute position of the bone (world space) to the result param
  14285. * @param mesh The mesh that this bone is attached to
  14286. * @param result The vector3 to copy the absolute position to
  14287. */
  14288. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14289. /**
  14290. * Compute the absolute transforms of this bone and its children
  14291. */
  14292. computeAbsoluteTransforms(): void;
  14293. /**
  14294. * Get the world direction from an axis that is in the local space of the bone
  14295. * @param localAxis The local direction that is used to compute the world direction
  14296. * @param mesh The mesh that this bone is attached to
  14297. * @returns The world direction
  14298. */
  14299. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14300. /**
  14301. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14302. * @param localAxis The local direction that is used to compute the world direction
  14303. * @param mesh The mesh that this bone is attached to
  14304. * @param result The vector3 that the world direction will be copied to
  14305. */
  14306. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14307. /**
  14308. * Get the euler rotation of the bone in local or world space
  14309. * @param space The space that the rotation should be in
  14310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14311. * @returns The euler rotation
  14312. */
  14313. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14314. /**
  14315. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14316. * @param space The space that the rotation should be in
  14317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14318. * @param result The vector3 that the rotation should be copied to
  14319. */
  14320. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14321. /**
  14322. * Get the quaternion rotation of the bone in either local or world space
  14323. * @param space The space that the rotation should be in
  14324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14325. * @returns The quaternion rotation
  14326. */
  14327. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14328. /**
  14329. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14330. * @param space The space that the rotation should be in
  14331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14332. * @param result The quaternion that the rotation should be copied to
  14333. */
  14334. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14335. /**
  14336. * Get the rotation matrix of the bone in local or world space
  14337. * @param space The space that the rotation should be in
  14338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14339. * @returns The rotation matrix
  14340. */
  14341. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14342. /**
  14343. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14344. * @param space The space that the rotation should be in
  14345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14346. * @param result The quaternion that the rotation should be copied to
  14347. */
  14348. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14349. /**
  14350. * Get the world position of a point that is in the local space of the bone
  14351. * @param position The local position
  14352. * @param mesh The mesh that this bone is attached to
  14353. * @returns The world position
  14354. */
  14355. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14356. /**
  14357. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14358. * @param position The local position
  14359. * @param mesh The mesh that this bone is attached to
  14360. * @param result The vector3 that the world position should be copied to
  14361. */
  14362. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14363. /**
  14364. * Get the local position of a point that is in world space
  14365. * @param position The world position
  14366. * @param mesh The mesh that this bone is attached to
  14367. * @returns The local position
  14368. */
  14369. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14370. /**
  14371. * Get the local position of a point that is in world space and copy it to the result param
  14372. * @param position The world position
  14373. * @param mesh The mesh that this bone is attached to
  14374. * @param result The vector3 that the local position should be copied to
  14375. */
  14376. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14377. }
  14378. }
  14379. declare module "babylonjs/Meshes/transformNode" {
  14380. import { DeepImmutable } from "babylonjs/types";
  14381. import { Observable } from "babylonjs/Misc/observable";
  14382. import { Nullable } from "babylonjs/types";
  14383. import { Camera } from "babylonjs/Cameras/camera";
  14384. import { Scene } from "babylonjs/scene";
  14385. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14386. import { Node } from "babylonjs/node";
  14387. import { Bone } from "babylonjs/Bones/bone";
  14388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14389. import { Space } from "babylonjs/Maths/math.axis";
  14390. /**
  14391. * 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.
  14392. * @see https://doc.babylonjs.com/how_to/transformnode
  14393. */
  14394. export class TransformNode extends Node {
  14395. /**
  14396. * Object will not rotate to face the camera
  14397. */
  14398. static BILLBOARDMODE_NONE: number;
  14399. /**
  14400. * Object will rotate to face the camera but only on the x axis
  14401. */
  14402. static BILLBOARDMODE_X: number;
  14403. /**
  14404. * Object will rotate to face the camera but only on the y axis
  14405. */
  14406. static BILLBOARDMODE_Y: number;
  14407. /**
  14408. * Object will rotate to face the camera but only on the z axis
  14409. */
  14410. static BILLBOARDMODE_Z: number;
  14411. /**
  14412. * Object will rotate to face the camera
  14413. */
  14414. static BILLBOARDMODE_ALL: number;
  14415. /**
  14416. * Object will rotate to face the camera's position instead of orientation
  14417. */
  14418. static BILLBOARDMODE_USE_POSITION: number;
  14419. private _forward;
  14420. private _forwardInverted;
  14421. private _up;
  14422. private _right;
  14423. private _rightInverted;
  14424. private _position;
  14425. private _rotation;
  14426. private _rotationQuaternion;
  14427. protected _scaling: Vector3;
  14428. protected _isDirty: boolean;
  14429. private _transformToBoneReferal;
  14430. private _isAbsoluteSynced;
  14431. private _billboardMode;
  14432. /**
  14433. * Gets or sets the billboard mode. Default is 0.
  14434. *
  14435. * | Value | Type | Description |
  14436. * | --- | --- | --- |
  14437. * | 0 | BILLBOARDMODE_NONE | |
  14438. * | 1 | BILLBOARDMODE_X | |
  14439. * | 2 | BILLBOARDMODE_Y | |
  14440. * | 4 | BILLBOARDMODE_Z | |
  14441. * | 7 | BILLBOARDMODE_ALL | |
  14442. *
  14443. */
  14444. get billboardMode(): number;
  14445. set billboardMode(value: number);
  14446. private _preserveParentRotationForBillboard;
  14447. /**
  14448. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14449. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14450. */
  14451. get preserveParentRotationForBillboard(): boolean;
  14452. set preserveParentRotationForBillboard(value: boolean);
  14453. /**
  14454. * 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
  14455. */
  14456. scalingDeterminant: number;
  14457. private _infiniteDistance;
  14458. /**
  14459. * Gets or sets the distance of the object to max, often used by skybox
  14460. */
  14461. get infiniteDistance(): boolean;
  14462. set infiniteDistance(value: boolean);
  14463. /**
  14464. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14465. * By default the system will update normals to compensate
  14466. */
  14467. ignoreNonUniformScaling: boolean;
  14468. /**
  14469. * 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
  14470. */
  14471. reIntegrateRotationIntoRotationQuaternion: boolean;
  14472. /** @hidden */
  14473. _poseMatrix: Nullable<Matrix>;
  14474. /** @hidden */
  14475. _localMatrix: Matrix;
  14476. private _usePivotMatrix;
  14477. private _absolutePosition;
  14478. private _absoluteScaling;
  14479. private _absoluteRotationQuaternion;
  14480. private _pivotMatrix;
  14481. private _pivotMatrixInverse;
  14482. protected _postMultiplyPivotMatrix: boolean;
  14483. protected _isWorldMatrixFrozen: boolean;
  14484. /** @hidden */
  14485. _indexInSceneTransformNodesArray: number;
  14486. /**
  14487. * An event triggered after the world matrix is updated
  14488. */
  14489. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14490. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14491. /**
  14492. * Gets a string identifying the name of the class
  14493. * @returns "TransformNode" string
  14494. */
  14495. getClassName(): string;
  14496. /**
  14497. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14498. */
  14499. get position(): Vector3;
  14500. set position(newPosition: Vector3);
  14501. /**
  14502. * 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)).
  14503. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14504. */
  14505. get rotation(): Vector3;
  14506. set rotation(newRotation: Vector3);
  14507. /**
  14508. * 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)).
  14509. */
  14510. get scaling(): Vector3;
  14511. set scaling(newScaling: Vector3);
  14512. /**
  14513. * 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).
  14514. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14515. */
  14516. get rotationQuaternion(): Nullable<Quaternion>;
  14517. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14518. /**
  14519. * The forward direction of that transform in world space.
  14520. */
  14521. get forward(): Vector3;
  14522. /**
  14523. * The up direction of that transform in world space.
  14524. */
  14525. get up(): Vector3;
  14526. /**
  14527. * The right direction of that transform in world space.
  14528. */
  14529. get right(): Vector3;
  14530. /**
  14531. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14532. * @param matrix the matrix to copy the pose from
  14533. * @returns this TransformNode.
  14534. */
  14535. updatePoseMatrix(matrix: Matrix): TransformNode;
  14536. /**
  14537. * Returns the mesh Pose matrix.
  14538. * @returns the pose matrix
  14539. */
  14540. getPoseMatrix(): Matrix;
  14541. /** @hidden */
  14542. _isSynchronized(): boolean;
  14543. /** @hidden */
  14544. _initCache(): void;
  14545. /**
  14546. * Flag the transform node as dirty (Forcing it to update everything)
  14547. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14548. * @returns this transform node
  14549. */
  14550. markAsDirty(property: string): TransformNode;
  14551. /**
  14552. * Returns the current mesh absolute position.
  14553. * Returns a Vector3.
  14554. */
  14555. get absolutePosition(): Vector3;
  14556. /**
  14557. * Returns the current mesh absolute scaling.
  14558. * Returns a Vector3.
  14559. */
  14560. get absoluteScaling(): Vector3;
  14561. /**
  14562. * Returns the current mesh absolute rotation.
  14563. * Returns a Quaternion.
  14564. */
  14565. get absoluteRotationQuaternion(): Quaternion;
  14566. /**
  14567. * Sets a new matrix to apply before all other transformation
  14568. * @param matrix defines the transform matrix
  14569. * @returns the current TransformNode
  14570. */
  14571. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14572. /**
  14573. * Sets a new pivot matrix to the current node
  14574. * @param matrix defines the new pivot matrix to use
  14575. * @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
  14576. * @returns the current TransformNode
  14577. */
  14578. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14579. /**
  14580. * Returns the mesh pivot matrix.
  14581. * Default : Identity.
  14582. * @returns the matrix
  14583. */
  14584. getPivotMatrix(): Matrix;
  14585. /**
  14586. * Instantiate (when possible) or clone that node with its hierarchy
  14587. * @param newParent defines the new parent to use for the instance (or clone)
  14588. * @param options defines options to configure how copy is done
  14589. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14590. * @returns an instance (or a clone) of the current node with its hiearchy
  14591. */
  14592. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14593. doNotInstantiate: boolean;
  14594. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14595. /**
  14596. * Prevents the World matrix to be computed any longer
  14597. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14598. * @returns the TransformNode.
  14599. */
  14600. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14601. /**
  14602. * Allows back the World matrix computation.
  14603. * @returns the TransformNode.
  14604. */
  14605. unfreezeWorldMatrix(): this;
  14606. /**
  14607. * True if the World matrix has been frozen.
  14608. */
  14609. get isWorldMatrixFrozen(): boolean;
  14610. /**
  14611. * Retuns the mesh absolute position in the World.
  14612. * @returns a Vector3.
  14613. */
  14614. getAbsolutePosition(): Vector3;
  14615. /**
  14616. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14617. * @param absolutePosition the absolute position to set
  14618. * @returns the TransformNode.
  14619. */
  14620. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14621. /**
  14622. * Sets the mesh position in its local space.
  14623. * @param vector3 the position to set in localspace
  14624. * @returns the TransformNode.
  14625. */
  14626. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14627. /**
  14628. * Returns the mesh position in the local space from the current World matrix values.
  14629. * @returns a new Vector3.
  14630. */
  14631. getPositionExpressedInLocalSpace(): Vector3;
  14632. /**
  14633. * Translates the mesh along the passed Vector3 in its local space.
  14634. * @param vector3 the distance to translate in localspace
  14635. * @returns the TransformNode.
  14636. */
  14637. locallyTranslate(vector3: Vector3): TransformNode;
  14638. private static _lookAtVectorCache;
  14639. /**
  14640. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14641. * @param targetPoint the position (must be in same space as current mesh) to look at
  14642. * @param yawCor optional yaw (y-axis) correction in radians
  14643. * @param pitchCor optional pitch (x-axis) correction in radians
  14644. * @param rollCor optional roll (z-axis) correction in radians
  14645. * @param space the choosen space of the target
  14646. * @returns the TransformNode.
  14647. */
  14648. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14649. /**
  14650. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14651. * This Vector3 is expressed in the World space.
  14652. * @param localAxis axis to rotate
  14653. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14654. */
  14655. getDirection(localAxis: Vector3): Vector3;
  14656. /**
  14657. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14658. * localAxis is expressed in the mesh local space.
  14659. * result is computed in the Wordl space from the mesh World matrix.
  14660. * @param localAxis axis to rotate
  14661. * @param result the resulting transformnode
  14662. * @returns this TransformNode.
  14663. */
  14664. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14665. /**
  14666. * Sets this transform node rotation to the given local axis.
  14667. * @param localAxis the axis in local space
  14668. * @param yawCor optional yaw (y-axis) correction in radians
  14669. * @param pitchCor optional pitch (x-axis) correction in radians
  14670. * @param rollCor optional roll (z-axis) correction in radians
  14671. * @returns this TransformNode
  14672. */
  14673. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14674. /**
  14675. * Sets a new pivot point to the current node
  14676. * @param point defines the new pivot point to use
  14677. * @param space defines if the point is in world or local space (local by default)
  14678. * @returns the current TransformNode
  14679. */
  14680. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14681. /**
  14682. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14683. * @returns the pivot point
  14684. */
  14685. getPivotPoint(): Vector3;
  14686. /**
  14687. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14688. * @param result the vector3 to store the result
  14689. * @returns this TransformNode.
  14690. */
  14691. getPivotPointToRef(result: Vector3): TransformNode;
  14692. /**
  14693. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14694. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14695. */
  14696. getAbsolutePivotPoint(): Vector3;
  14697. /**
  14698. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14699. * @param result vector3 to store the result
  14700. * @returns this TransformNode.
  14701. */
  14702. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14703. /**
  14704. * Defines the passed node as the parent of the current node.
  14705. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14706. * @see https://doc.babylonjs.com/how_to/parenting
  14707. * @param node the node ot set as the parent
  14708. * @returns this TransformNode.
  14709. */
  14710. setParent(node: Nullable<Node>): TransformNode;
  14711. private _nonUniformScaling;
  14712. /**
  14713. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14714. */
  14715. get nonUniformScaling(): boolean;
  14716. /** @hidden */
  14717. _updateNonUniformScalingState(value: boolean): boolean;
  14718. /**
  14719. * Attach the current TransformNode to another TransformNode associated with a bone
  14720. * @param bone Bone affecting the TransformNode
  14721. * @param affectedTransformNode TransformNode associated with the bone
  14722. * @returns this object
  14723. */
  14724. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14725. /**
  14726. * Detach the transform node if its associated with a bone
  14727. * @returns this object
  14728. */
  14729. detachFromBone(): TransformNode;
  14730. private static _rotationAxisCache;
  14731. /**
  14732. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14733. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14734. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14735. * The passed axis is also normalized.
  14736. * @param axis the axis to rotate around
  14737. * @param amount the amount to rotate in radians
  14738. * @param space Space to rotate in (Default: local)
  14739. * @returns the TransformNode.
  14740. */
  14741. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14742. /**
  14743. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14744. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14745. * The passed axis is also normalized. .
  14746. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14747. * @param point the point to rotate around
  14748. * @param axis the axis to rotate around
  14749. * @param amount the amount to rotate in radians
  14750. * @returns the TransformNode
  14751. */
  14752. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14753. /**
  14754. * Translates the mesh along the axis vector for the passed distance in the given space.
  14755. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14756. * @param axis the axis to translate in
  14757. * @param distance the distance to translate
  14758. * @param space Space to rotate in (Default: local)
  14759. * @returns the TransformNode.
  14760. */
  14761. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14762. /**
  14763. * Adds a rotation step to the mesh current rotation.
  14764. * x, y, z are Euler angles expressed in radians.
  14765. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14766. * This means this rotation is made in the mesh local space only.
  14767. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14768. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14769. * ```javascript
  14770. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14771. * ```
  14772. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14773. * 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.
  14774. * @param x Rotation to add
  14775. * @param y Rotation to add
  14776. * @param z Rotation to add
  14777. * @returns the TransformNode.
  14778. */
  14779. addRotation(x: number, y: number, z: number): TransformNode;
  14780. /**
  14781. * @hidden
  14782. */
  14783. protected _getEffectiveParent(): Nullable<Node>;
  14784. /**
  14785. * Computes the world matrix of the node
  14786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14787. * @returns the world matrix
  14788. */
  14789. computeWorldMatrix(force?: boolean): Matrix;
  14790. /**
  14791. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14792. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14793. */
  14794. resetLocalMatrix(independentOfChildren?: boolean): void;
  14795. protected _afterComputeWorldMatrix(): void;
  14796. /**
  14797. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14798. * @param func callback function to add
  14799. *
  14800. * @returns the TransformNode.
  14801. */
  14802. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14803. /**
  14804. * Removes a registered callback function.
  14805. * @param func callback function to remove
  14806. * @returns the TransformNode.
  14807. */
  14808. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14809. /**
  14810. * Gets the position of the current mesh in camera space
  14811. * @param camera defines the camera to use
  14812. * @returns a position
  14813. */
  14814. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14815. /**
  14816. * Returns the distance from the mesh to the active camera
  14817. * @param camera defines the camera to use
  14818. * @returns the distance
  14819. */
  14820. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14821. /**
  14822. * Clone the current transform node
  14823. * @param name Name of the new clone
  14824. * @param newParent New parent for the clone
  14825. * @param doNotCloneChildren Do not clone children hierarchy
  14826. * @returns the new transform node
  14827. */
  14828. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14829. /**
  14830. * Serializes the objects information.
  14831. * @param currentSerializationObject defines the object to serialize in
  14832. * @returns the serialized object
  14833. */
  14834. serialize(currentSerializationObject?: any): any;
  14835. /**
  14836. * Returns a new TransformNode object parsed from the source provided.
  14837. * @param parsedTransformNode is the source.
  14838. * @param scene the scne the object belongs to
  14839. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14840. * @returns a new TransformNode object parsed from the source provided.
  14841. */
  14842. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14843. /**
  14844. * Get all child-transformNodes of this node
  14845. * @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
  14846. * @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
  14847. * @returns an array of TransformNode
  14848. */
  14849. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14850. /**
  14851. * Releases resources associated with this transform node.
  14852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14854. */
  14855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14856. /**
  14857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14860. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14861. * @returns the current mesh
  14862. */
  14863. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14864. private _syncAbsoluteScalingAndRotation;
  14865. }
  14866. }
  14867. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14868. import { Observable } from "babylonjs/Misc/observable";
  14869. import { Nullable } from "babylonjs/types";
  14870. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14871. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14873. import { Ray } from "babylonjs/Culling/ray";
  14874. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14875. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14876. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14877. /**
  14878. * Defines the types of pose enabled controllers that are supported
  14879. */
  14880. export enum PoseEnabledControllerType {
  14881. /**
  14882. * HTC Vive
  14883. */
  14884. VIVE = 0,
  14885. /**
  14886. * Oculus Rift
  14887. */
  14888. OCULUS = 1,
  14889. /**
  14890. * Windows mixed reality
  14891. */
  14892. WINDOWS = 2,
  14893. /**
  14894. * Samsung gear VR
  14895. */
  14896. GEAR_VR = 3,
  14897. /**
  14898. * Google Daydream
  14899. */
  14900. DAYDREAM = 4,
  14901. /**
  14902. * Generic
  14903. */
  14904. GENERIC = 5
  14905. }
  14906. /**
  14907. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14908. */
  14909. export interface MutableGamepadButton {
  14910. /**
  14911. * Value of the button/trigger
  14912. */
  14913. value: number;
  14914. /**
  14915. * If the button/trigger is currently touched
  14916. */
  14917. touched: boolean;
  14918. /**
  14919. * If the button/trigger is currently pressed
  14920. */
  14921. pressed: boolean;
  14922. }
  14923. /**
  14924. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14925. * @hidden
  14926. */
  14927. export interface ExtendedGamepadButton extends GamepadButton {
  14928. /**
  14929. * If the button/trigger is currently pressed
  14930. */
  14931. readonly pressed: boolean;
  14932. /**
  14933. * If the button/trigger is currently touched
  14934. */
  14935. readonly touched: boolean;
  14936. /**
  14937. * Value of the button/trigger
  14938. */
  14939. readonly value: number;
  14940. }
  14941. /** @hidden */
  14942. export interface _GamePadFactory {
  14943. /**
  14944. * Returns wether or not the current gamepad can be created for this type of controller.
  14945. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14946. * @returns true if it can be created, otherwise false
  14947. */
  14948. canCreate(gamepadInfo: any): boolean;
  14949. /**
  14950. * Creates a new instance of the Gamepad.
  14951. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14952. * @returns the new gamepad instance
  14953. */
  14954. create(gamepadInfo: any): Gamepad;
  14955. }
  14956. /**
  14957. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14958. */
  14959. export class PoseEnabledControllerHelper {
  14960. /** @hidden */
  14961. static _ControllerFactories: _GamePadFactory[];
  14962. /** @hidden */
  14963. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14964. /**
  14965. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14966. * @param vrGamepad the gamepad to initialized
  14967. * @returns a vr controller of the type the gamepad identified as
  14968. */
  14969. static InitiateController(vrGamepad: any): Gamepad;
  14970. }
  14971. /**
  14972. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14973. */
  14974. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14975. /**
  14976. * If the controller is used in a webXR session
  14977. */
  14978. isXR: boolean;
  14979. private _deviceRoomPosition;
  14980. private _deviceRoomRotationQuaternion;
  14981. /**
  14982. * The device position in babylon space
  14983. */
  14984. devicePosition: Vector3;
  14985. /**
  14986. * The device rotation in babylon space
  14987. */
  14988. deviceRotationQuaternion: Quaternion;
  14989. /**
  14990. * The scale factor of the device in babylon space
  14991. */
  14992. deviceScaleFactor: number;
  14993. /**
  14994. * (Likely devicePosition should be used instead) The device position in its room space
  14995. */
  14996. position: Vector3;
  14997. /**
  14998. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14999. */
  15000. rotationQuaternion: Quaternion;
  15001. /**
  15002. * The type of controller (Eg. Windows mixed reality)
  15003. */
  15004. controllerType: PoseEnabledControllerType;
  15005. protected _calculatedPosition: Vector3;
  15006. private _calculatedRotation;
  15007. /**
  15008. * The raw pose from the device
  15009. */
  15010. rawPose: DevicePose;
  15011. private _trackPosition;
  15012. private _maxRotationDistFromHeadset;
  15013. private _draggedRoomRotation;
  15014. /**
  15015. * @hidden
  15016. */
  15017. _disableTrackPosition(fixedPosition: Vector3): void;
  15018. /**
  15019. * Internal, the mesh attached to the controller
  15020. * @hidden
  15021. */
  15022. _mesh: Nullable<AbstractMesh>;
  15023. private _poseControlledCamera;
  15024. private _leftHandSystemQuaternion;
  15025. /**
  15026. * Internal, matrix used to convert room space to babylon space
  15027. * @hidden
  15028. */
  15029. _deviceToWorld: Matrix;
  15030. /**
  15031. * Node to be used when casting a ray from the controller
  15032. * @hidden
  15033. */
  15034. _pointingPoseNode: Nullable<TransformNode>;
  15035. /**
  15036. * Name of the child mesh that can be used to cast a ray from the controller
  15037. */
  15038. static readonly POINTING_POSE: string;
  15039. /**
  15040. * Creates a new PoseEnabledController from a gamepad
  15041. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15042. */
  15043. constructor(browserGamepad: any);
  15044. private _workingMatrix;
  15045. /**
  15046. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15047. */
  15048. update(): void;
  15049. /**
  15050. * Updates only the pose device and mesh without doing any button event checking
  15051. */
  15052. protected _updatePoseAndMesh(): void;
  15053. /**
  15054. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15055. * @param poseData raw pose fromthe device
  15056. */
  15057. updateFromDevice(poseData: DevicePose): void;
  15058. /**
  15059. * @hidden
  15060. */
  15061. _meshAttachedObservable: Observable<AbstractMesh>;
  15062. /**
  15063. * Attaches a mesh to the controller
  15064. * @param mesh the mesh to be attached
  15065. */
  15066. attachToMesh(mesh: AbstractMesh): void;
  15067. /**
  15068. * Attaches the controllers mesh to a camera
  15069. * @param camera the camera the mesh should be attached to
  15070. */
  15071. attachToPoseControlledCamera(camera: TargetCamera): void;
  15072. /**
  15073. * Disposes of the controller
  15074. */
  15075. dispose(): void;
  15076. /**
  15077. * The mesh that is attached to the controller
  15078. */
  15079. get mesh(): Nullable<AbstractMesh>;
  15080. /**
  15081. * Gets the ray of the controller in the direction the controller is pointing
  15082. * @param length the length the resulting ray should be
  15083. * @returns a ray in the direction the controller is pointing
  15084. */
  15085. getForwardRay(length?: number): Ray;
  15086. }
  15087. }
  15088. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15089. import { Observable } from "babylonjs/Misc/observable";
  15090. import { Scene } from "babylonjs/scene";
  15091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15092. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15093. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15094. import { Nullable } from "babylonjs/types";
  15095. /**
  15096. * Defines the WebVRController object that represents controllers tracked in 3D space
  15097. */
  15098. export abstract class WebVRController extends PoseEnabledController {
  15099. /**
  15100. * Internal, the default controller model for the controller
  15101. */
  15102. protected _defaultModel: Nullable<AbstractMesh>;
  15103. /**
  15104. * Fired when the trigger state has changed
  15105. */
  15106. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15107. /**
  15108. * Fired when the main button state has changed
  15109. */
  15110. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15111. /**
  15112. * Fired when the secondary button state has changed
  15113. */
  15114. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15115. /**
  15116. * Fired when the pad state has changed
  15117. */
  15118. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15119. /**
  15120. * Fired when controllers stick values have changed
  15121. */
  15122. onPadValuesChangedObservable: Observable<StickValues>;
  15123. /**
  15124. * Array of button availible on the controller
  15125. */
  15126. protected _buttons: Array<MutableGamepadButton>;
  15127. private _onButtonStateChange;
  15128. /**
  15129. * Fired when a controller button's state has changed
  15130. * @param callback the callback containing the button that was modified
  15131. */
  15132. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15133. /**
  15134. * X and Y axis corresponding to the controllers joystick
  15135. */
  15136. pad: StickValues;
  15137. /**
  15138. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15139. */
  15140. hand: string;
  15141. /**
  15142. * The default controller model for the controller
  15143. */
  15144. get defaultModel(): Nullable<AbstractMesh>;
  15145. /**
  15146. * Creates a new WebVRController from a gamepad
  15147. * @param vrGamepad the gamepad that the WebVRController should be created from
  15148. */
  15149. constructor(vrGamepad: any);
  15150. /**
  15151. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15152. */
  15153. update(): void;
  15154. /**
  15155. * Function to be called when a button is modified
  15156. */
  15157. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15158. /**
  15159. * Loads a mesh and attaches it to the controller
  15160. * @param scene the scene the mesh should be added to
  15161. * @param meshLoaded callback for when the mesh has been loaded
  15162. */
  15163. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15164. private _setButtonValue;
  15165. private _changes;
  15166. private _checkChanges;
  15167. /**
  15168. * Disposes of th webVRCOntroller
  15169. */
  15170. dispose(): void;
  15171. }
  15172. }
  15173. declare module "babylonjs/Lights/hemisphericLight" {
  15174. import { Nullable } from "babylonjs/types";
  15175. import { Scene } from "babylonjs/scene";
  15176. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15177. import { Color3 } from "babylonjs/Maths/math.color";
  15178. import { Effect } from "babylonjs/Materials/effect";
  15179. import { Light } from "babylonjs/Lights/light";
  15180. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15181. /**
  15182. * The HemisphericLight simulates the ambient environment light,
  15183. * so the passed direction is the light reflection direction, not the incoming direction.
  15184. */
  15185. export class HemisphericLight extends Light {
  15186. /**
  15187. * The groundColor is the light in the opposite direction to the one specified during creation.
  15188. * 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.
  15189. */
  15190. groundColor: Color3;
  15191. /**
  15192. * The light reflection direction, not the incoming direction.
  15193. */
  15194. direction: Vector3;
  15195. /**
  15196. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15197. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15198. * The HemisphericLight can't cast shadows.
  15199. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15200. * @param name The friendly name of the light
  15201. * @param direction The direction of the light reflection
  15202. * @param scene The scene the light belongs to
  15203. */
  15204. constructor(name: string, direction: Vector3, scene: Scene);
  15205. protected _buildUniformLayout(): void;
  15206. /**
  15207. * Returns the string "HemisphericLight".
  15208. * @return The class name
  15209. */
  15210. getClassName(): string;
  15211. /**
  15212. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15213. * Returns the updated direction.
  15214. * @param target The target the direction should point to
  15215. * @return The computed direction
  15216. */
  15217. setDirectionToTarget(target: Vector3): Vector3;
  15218. /**
  15219. * Returns the shadow generator associated to the light.
  15220. * @returns Always null for hemispheric lights because it does not support shadows.
  15221. */
  15222. getShadowGenerator(): Nullable<IShadowGenerator>;
  15223. /**
  15224. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15225. * @param effect The effect to update
  15226. * @param lightIndex The index of the light in the effect to update
  15227. * @returns The hemispheric light
  15228. */
  15229. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15230. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15231. /**
  15232. * Computes the world matrix of the node
  15233. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15234. * @param useWasUpdatedFlag defines a reserved property
  15235. * @returns the world matrix
  15236. */
  15237. computeWorldMatrix(): Matrix;
  15238. /**
  15239. * Returns the integer 3.
  15240. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15241. */
  15242. getTypeID(): number;
  15243. /**
  15244. * Prepares the list of defines specific to the light type.
  15245. * @param defines the list of defines
  15246. * @param lightIndex defines the index of the light for the effect
  15247. */
  15248. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15249. }
  15250. }
  15251. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15252. /** @hidden */
  15253. export var vrMultiviewToSingleviewPixelShader: {
  15254. name: string;
  15255. shader: string;
  15256. };
  15257. }
  15258. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15260. import { Scene } from "babylonjs/scene";
  15261. /**
  15262. * Renders to multiple views with a single draw call
  15263. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15264. */
  15265. export class MultiviewRenderTarget extends RenderTargetTexture {
  15266. /**
  15267. * Creates a multiview render target
  15268. * @param scene scene used with the render target
  15269. * @param size the size of the render target (used for each view)
  15270. */
  15271. constructor(scene: Scene, size?: number | {
  15272. width: number;
  15273. height: number;
  15274. } | {
  15275. ratio: number;
  15276. });
  15277. /**
  15278. * @hidden
  15279. * @param faceIndex the face index, if its a cube texture
  15280. */
  15281. _bindFrameBuffer(faceIndex?: number): void;
  15282. /**
  15283. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15284. * @returns the view count
  15285. */
  15286. getViewCount(): number;
  15287. }
  15288. }
  15289. declare module "babylonjs/Maths/math.frustum" {
  15290. import { Matrix } from "babylonjs/Maths/math.vector";
  15291. import { DeepImmutable } from "babylonjs/types";
  15292. import { Plane } from "babylonjs/Maths/math.plane";
  15293. /**
  15294. * Represents a camera frustum
  15295. */
  15296. export class Frustum {
  15297. /**
  15298. * Gets the planes representing the frustum
  15299. * @param transform matrix to be applied to the returned planes
  15300. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15301. */
  15302. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15303. /**
  15304. * Gets the near frustum plane transformed by the transform matrix
  15305. * @param transform transformation matrix to be applied to the resulting frustum plane
  15306. * @param frustumPlane the resuling frustum plane
  15307. */
  15308. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15309. /**
  15310. * Gets the far frustum plane transformed by the transform matrix
  15311. * @param transform transformation matrix to be applied to the resulting frustum plane
  15312. * @param frustumPlane the resuling frustum plane
  15313. */
  15314. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15315. /**
  15316. * Gets the left frustum plane transformed by the transform matrix
  15317. * @param transform transformation matrix to be applied to the resulting frustum plane
  15318. * @param frustumPlane the resuling frustum plane
  15319. */
  15320. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15321. /**
  15322. * Gets the right frustum plane transformed by the transform matrix
  15323. * @param transform transformation matrix to be applied to the resulting frustum plane
  15324. * @param frustumPlane the resuling frustum plane
  15325. */
  15326. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15327. /**
  15328. * Gets the top frustum plane transformed by the transform matrix
  15329. * @param transform transformation matrix to be applied to the resulting frustum plane
  15330. * @param frustumPlane the resuling frustum plane
  15331. */
  15332. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15333. /**
  15334. * Gets the bottom frustum plane transformed by the transform matrix
  15335. * @param transform transformation matrix to be applied to the resulting frustum plane
  15336. * @param frustumPlane the resuling frustum plane
  15337. */
  15338. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15339. /**
  15340. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15341. * @param transform transformation matrix to be applied to the resulting frustum planes
  15342. * @param frustumPlanes the resuling frustum planes
  15343. */
  15344. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15345. }
  15346. }
  15347. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15348. import { Camera } from "babylonjs/Cameras/camera";
  15349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15350. import { Nullable } from "babylonjs/types";
  15351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15352. import { Matrix } from "babylonjs/Maths/math.vector";
  15353. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15354. module "babylonjs/Engines/engine" {
  15355. interface Engine {
  15356. /**
  15357. * Creates a new multiview render target
  15358. * @param width defines the width of the texture
  15359. * @param height defines the height of the texture
  15360. * @returns the created multiview texture
  15361. */
  15362. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15363. /**
  15364. * Binds a multiview framebuffer to be drawn to
  15365. * @param multiviewTexture texture to bind
  15366. */
  15367. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15368. }
  15369. }
  15370. module "babylonjs/Cameras/camera" {
  15371. interface Camera {
  15372. /**
  15373. * @hidden
  15374. * 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)
  15375. */
  15376. _useMultiviewToSingleView: boolean;
  15377. /**
  15378. * @hidden
  15379. * 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)
  15380. */
  15381. _multiviewTexture: Nullable<RenderTargetTexture>;
  15382. /**
  15383. * @hidden
  15384. * ensures the multiview texture of the camera exists and has the specified width/height
  15385. * @param width height to set on the multiview texture
  15386. * @param height width to set on the multiview texture
  15387. */
  15388. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15389. }
  15390. }
  15391. module "babylonjs/scene" {
  15392. interface Scene {
  15393. /** @hidden */
  15394. _transformMatrixR: Matrix;
  15395. /** @hidden */
  15396. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15397. /** @hidden */
  15398. _createMultiviewUbo(): void;
  15399. /** @hidden */
  15400. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15401. /** @hidden */
  15402. _renderMultiviewToSingleView(camera: Camera): void;
  15403. }
  15404. }
  15405. }
  15406. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15407. import { Camera } from "babylonjs/Cameras/camera";
  15408. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15409. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15410. import "babylonjs/Engines/Extensions/engine.multiview";
  15411. /**
  15412. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15413. * This will not be used for webXR as it supports displaying texture arrays directly
  15414. */
  15415. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15416. /**
  15417. * Initializes a VRMultiviewToSingleview
  15418. * @param name name of the post process
  15419. * @param camera camera to be applied to
  15420. * @param scaleFactor scaling factor to the size of the output texture
  15421. */
  15422. constructor(name: string, camera: Camera, scaleFactor: number);
  15423. }
  15424. }
  15425. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15426. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15427. import { Nullable } from "babylonjs/types";
  15428. import { Size } from "babylonjs/Maths/math.size";
  15429. import { Observable } from "babylonjs/Misc/observable";
  15430. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15431. /**
  15432. * Interface used to define additional presentation attributes
  15433. */
  15434. export interface IVRPresentationAttributes {
  15435. /**
  15436. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15437. */
  15438. highRefreshRate: boolean;
  15439. /**
  15440. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15441. */
  15442. foveationLevel: number;
  15443. }
  15444. module "babylonjs/Engines/engine" {
  15445. interface Engine {
  15446. /** @hidden */
  15447. _vrDisplay: any;
  15448. /** @hidden */
  15449. _vrSupported: boolean;
  15450. /** @hidden */
  15451. _oldSize: Size;
  15452. /** @hidden */
  15453. _oldHardwareScaleFactor: number;
  15454. /** @hidden */
  15455. _vrExclusivePointerMode: boolean;
  15456. /** @hidden */
  15457. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15458. /** @hidden */
  15459. _onVRDisplayPointerRestricted: () => void;
  15460. /** @hidden */
  15461. _onVRDisplayPointerUnrestricted: () => void;
  15462. /** @hidden */
  15463. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15464. /** @hidden */
  15465. _onVrDisplayDisconnect: Nullable<() => void>;
  15466. /** @hidden */
  15467. _onVrDisplayPresentChange: Nullable<() => void>;
  15468. /**
  15469. * Observable signaled when VR display mode changes
  15470. */
  15471. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15472. /**
  15473. * Observable signaled when VR request present is complete
  15474. */
  15475. onVRRequestPresentComplete: Observable<boolean>;
  15476. /**
  15477. * Observable signaled when VR request present starts
  15478. */
  15479. onVRRequestPresentStart: Observable<Engine>;
  15480. /**
  15481. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15482. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15483. */
  15484. isInVRExclusivePointerMode: boolean;
  15485. /**
  15486. * Gets a boolean indicating if a webVR device was detected
  15487. * @returns true if a webVR device was detected
  15488. */
  15489. isVRDevicePresent(): boolean;
  15490. /**
  15491. * Gets the current webVR device
  15492. * @returns the current webVR device (or null)
  15493. */
  15494. getVRDevice(): any;
  15495. /**
  15496. * Initializes a webVR display and starts listening to display change events
  15497. * The onVRDisplayChangedObservable will be notified upon these changes
  15498. * @returns A promise containing a VRDisplay and if vr is supported
  15499. */
  15500. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15501. /** @hidden */
  15502. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15503. /**
  15504. * Gets or sets the presentation attributes used to configure VR rendering
  15505. */
  15506. vrPresentationAttributes?: IVRPresentationAttributes;
  15507. /**
  15508. * Call this function to switch to webVR mode
  15509. * Will do nothing if webVR is not supported or if there is no webVR device
  15510. * @param options the webvr options provided to the camera. mainly used for multiview
  15511. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15512. */
  15513. enableVR(options: WebVROptions): void;
  15514. /** @hidden */
  15515. _onVRFullScreenTriggered(): void;
  15516. }
  15517. }
  15518. }
  15519. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15520. import { Nullable } from "babylonjs/types";
  15521. import { Observable } from "babylonjs/Misc/observable";
  15522. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15523. import { Scene } from "babylonjs/scene";
  15524. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15525. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15526. import { Node } from "babylonjs/node";
  15527. import { Ray } from "babylonjs/Culling/ray";
  15528. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15529. import "babylonjs/Engines/Extensions/engine.webVR";
  15530. /**
  15531. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15532. * IMPORTANT!! The data is right-hand data.
  15533. * @export
  15534. * @interface DevicePose
  15535. */
  15536. export interface DevicePose {
  15537. /**
  15538. * The position of the device, values in array are [x,y,z].
  15539. */
  15540. readonly position: Nullable<Float32Array>;
  15541. /**
  15542. * The linearVelocity of the device, values in array are [x,y,z].
  15543. */
  15544. readonly linearVelocity: Nullable<Float32Array>;
  15545. /**
  15546. * The linearAcceleration of the device, values in array are [x,y,z].
  15547. */
  15548. readonly linearAcceleration: Nullable<Float32Array>;
  15549. /**
  15550. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15551. */
  15552. readonly orientation: Nullable<Float32Array>;
  15553. /**
  15554. * The angularVelocity of the device, values in array are [x,y,z].
  15555. */
  15556. readonly angularVelocity: Nullable<Float32Array>;
  15557. /**
  15558. * The angularAcceleration of the device, values in array are [x,y,z].
  15559. */
  15560. readonly angularAcceleration: Nullable<Float32Array>;
  15561. }
  15562. /**
  15563. * Interface representing a pose controlled object in Babylon.
  15564. * A pose controlled object has both regular pose values as well as pose values
  15565. * from an external device such as a VR head mounted display
  15566. */
  15567. export interface PoseControlled {
  15568. /**
  15569. * The position of the object in babylon space.
  15570. */
  15571. position: Vector3;
  15572. /**
  15573. * The rotation quaternion of the object in babylon space.
  15574. */
  15575. rotationQuaternion: Quaternion;
  15576. /**
  15577. * The position of the device in babylon space.
  15578. */
  15579. devicePosition?: Vector3;
  15580. /**
  15581. * The rotation quaternion of the device in babylon space.
  15582. */
  15583. deviceRotationQuaternion: Quaternion;
  15584. /**
  15585. * The raw pose coming from the device.
  15586. */
  15587. rawPose: Nullable<DevicePose>;
  15588. /**
  15589. * The scale of the device to be used when translating from device space to babylon space.
  15590. */
  15591. deviceScaleFactor: number;
  15592. /**
  15593. * Updates the poseControlled values based on the input device pose.
  15594. * @param poseData the pose data to update the object with
  15595. */
  15596. updateFromDevice(poseData: DevicePose): void;
  15597. }
  15598. /**
  15599. * Set of options to customize the webVRCamera
  15600. */
  15601. export interface WebVROptions {
  15602. /**
  15603. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15604. */
  15605. trackPosition?: boolean;
  15606. /**
  15607. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15608. */
  15609. positionScale?: number;
  15610. /**
  15611. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15612. */
  15613. displayName?: string;
  15614. /**
  15615. * Should the native controller meshes be initialized. (default: true)
  15616. */
  15617. controllerMeshes?: boolean;
  15618. /**
  15619. * Creating a default HemiLight only on controllers. (default: true)
  15620. */
  15621. defaultLightingOnControllers?: boolean;
  15622. /**
  15623. * If you don't want to use the default VR button of the helper. (default: false)
  15624. */
  15625. useCustomVRButton?: boolean;
  15626. /**
  15627. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15628. */
  15629. customVRButton?: HTMLButtonElement;
  15630. /**
  15631. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15632. */
  15633. rayLength?: number;
  15634. /**
  15635. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15636. */
  15637. defaultHeight?: number;
  15638. /**
  15639. * If multiview should be used if availible (default: false)
  15640. */
  15641. useMultiview?: boolean;
  15642. }
  15643. /**
  15644. * This represents a WebVR camera.
  15645. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15646. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15647. */
  15648. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15649. private webVROptions;
  15650. /**
  15651. * @hidden
  15652. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15653. */
  15654. _vrDevice: any;
  15655. /**
  15656. * The rawPose of the vrDevice.
  15657. */
  15658. rawPose: Nullable<DevicePose>;
  15659. private _onVREnabled;
  15660. private _specsVersion;
  15661. private _attached;
  15662. private _frameData;
  15663. protected _descendants: Array<Node>;
  15664. private _deviceRoomPosition;
  15665. /** @hidden */
  15666. _deviceRoomRotationQuaternion: Quaternion;
  15667. private _standingMatrix;
  15668. /**
  15669. * Represents device position in babylon space.
  15670. */
  15671. devicePosition: Vector3;
  15672. /**
  15673. * Represents device rotation in babylon space.
  15674. */
  15675. deviceRotationQuaternion: Quaternion;
  15676. /**
  15677. * The scale of the device to be used when translating from device space to babylon space.
  15678. */
  15679. deviceScaleFactor: number;
  15680. private _deviceToWorld;
  15681. private _worldToDevice;
  15682. /**
  15683. * References to the webVR controllers for the vrDevice.
  15684. */
  15685. controllers: Array<WebVRController>;
  15686. /**
  15687. * Emits an event when a controller is attached.
  15688. */
  15689. onControllersAttachedObservable: Observable<WebVRController[]>;
  15690. /**
  15691. * Emits an event when a controller's mesh has been loaded;
  15692. */
  15693. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15694. /**
  15695. * Emits an event when the HMD's pose has been updated.
  15696. */
  15697. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15698. private _poseSet;
  15699. /**
  15700. * If the rig cameras be used as parent instead of this camera.
  15701. */
  15702. rigParenting: boolean;
  15703. private _lightOnControllers;
  15704. private _defaultHeight?;
  15705. /**
  15706. * Instantiates a WebVRFreeCamera.
  15707. * @param name The name of the WebVRFreeCamera
  15708. * @param position The starting anchor position for the camera
  15709. * @param scene The scene the camera belongs to
  15710. * @param webVROptions a set of customizable options for the webVRCamera
  15711. */
  15712. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15713. /**
  15714. * Gets the device distance from the ground in meters.
  15715. * @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.
  15716. */
  15717. deviceDistanceToRoomGround(): number;
  15718. /**
  15719. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15720. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15721. */
  15722. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15723. /**
  15724. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15725. * @returns A promise with a boolean set to if the standing matrix is supported.
  15726. */
  15727. useStandingMatrixAsync(): Promise<boolean>;
  15728. /**
  15729. * Disposes the camera
  15730. */
  15731. dispose(): void;
  15732. /**
  15733. * Gets a vrController by name.
  15734. * @param name The name of the controller to retreive
  15735. * @returns the controller matching the name specified or null if not found
  15736. */
  15737. getControllerByName(name: string): Nullable<WebVRController>;
  15738. private _leftController;
  15739. /**
  15740. * The controller corresponding to the users left hand.
  15741. */
  15742. get leftController(): Nullable<WebVRController>;
  15743. private _rightController;
  15744. /**
  15745. * The controller corresponding to the users right hand.
  15746. */
  15747. get rightController(): Nullable<WebVRController>;
  15748. /**
  15749. * Casts a ray forward from the vrCamera's gaze.
  15750. * @param length Length of the ray (default: 100)
  15751. * @returns the ray corresponding to the gaze
  15752. */
  15753. getForwardRay(length?: number): Ray;
  15754. /**
  15755. * @hidden
  15756. * Updates the camera based on device's frame data
  15757. */
  15758. _checkInputs(): void;
  15759. /**
  15760. * Updates the poseControlled values based on the input device pose.
  15761. * @param poseData Pose coming from the device
  15762. */
  15763. updateFromDevice(poseData: DevicePose): void;
  15764. private _htmlElementAttached;
  15765. private _detachIfAttached;
  15766. /**
  15767. * WebVR's attach control will start broadcasting frames to the device.
  15768. * Note that in certain browsers (chrome for example) this function must be called
  15769. * within a user-interaction callback. Example:
  15770. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15771. *
  15772. * @param element html element to attach the vrDevice to
  15773. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15774. */
  15775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15776. /**
  15777. * Detaches the camera from the html element and disables VR
  15778. *
  15779. * @param element html element to detach from
  15780. */
  15781. detachControl(element: HTMLElement): void;
  15782. /**
  15783. * @returns the name of this class
  15784. */
  15785. getClassName(): string;
  15786. /**
  15787. * Calls resetPose on the vrDisplay
  15788. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15789. */
  15790. resetToCurrentRotation(): void;
  15791. /**
  15792. * @hidden
  15793. * Updates the rig cameras (left and right eye)
  15794. */
  15795. _updateRigCameras(): void;
  15796. private _workingVector;
  15797. private _oneVector;
  15798. private _workingMatrix;
  15799. private updateCacheCalled;
  15800. private _correctPositionIfNotTrackPosition;
  15801. /**
  15802. * @hidden
  15803. * Updates the cached values of the camera
  15804. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15805. */
  15806. _updateCache(ignoreParentClass?: boolean): void;
  15807. /**
  15808. * @hidden
  15809. * Get current device position in babylon world
  15810. */
  15811. _computeDevicePosition(): void;
  15812. /**
  15813. * Updates the current device position and rotation in the babylon world
  15814. */
  15815. update(): void;
  15816. /**
  15817. * @hidden
  15818. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15819. * @returns an identity matrix
  15820. */
  15821. _getViewMatrix(): Matrix;
  15822. private _tmpMatrix;
  15823. /**
  15824. * This function is called by the two RIG cameras.
  15825. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15826. * @hidden
  15827. */
  15828. _getWebVRViewMatrix(): Matrix;
  15829. /** @hidden */
  15830. _getWebVRProjectionMatrix(): Matrix;
  15831. private _onGamepadConnectedObserver;
  15832. private _onGamepadDisconnectedObserver;
  15833. private _updateCacheWhenTrackingDisabledObserver;
  15834. /**
  15835. * Initializes the controllers and their meshes
  15836. */
  15837. initControllers(): void;
  15838. }
  15839. }
  15840. declare module "babylonjs/PostProcesses/postProcess" {
  15841. import { Nullable } from "babylonjs/types";
  15842. import { SmartArray } from "babylonjs/Misc/smartArray";
  15843. import { Observable } from "babylonjs/Misc/observable";
  15844. import { Vector2 } from "babylonjs/Maths/math.vector";
  15845. import { Camera } from "babylonjs/Cameras/camera";
  15846. import { Effect } from "babylonjs/Materials/effect";
  15847. import "babylonjs/Shaders/postprocess.vertex";
  15848. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15849. import { Engine } from "babylonjs/Engines/engine";
  15850. import { Color4 } from "babylonjs/Maths/math.color";
  15851. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15852. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15853. /**
  15854. * Size options for a post process
  15855. */
  15856. export type PostProcessOptions = {
  15857. width: number;
  15858. height: number;
  15859. };
  15860. /**
  15861. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15862. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15863. */
  15864. export class PostProcess {
  15865. /** Name of the PostProcess. */
  15866. name: string;
  15867. /**
  15868. * Gets or sets the unique id of the post process
  15869. */
  15870. uniqueId: number;
  15871. /**
  15872. * Width of the texture to apply the post process on
  15873. */
  15874. width: number;
  15875. /**
  15876. * Height of the texture to apply the post process on
  15877. */
  15878. height: number;
  15879. /**
  15880. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15881. * @hidden
  15882. */
  15883. _outputTexture: Nullable<InternalTexture>;
  15884. /**
  15885. * Sampling mode used by the shader
  15886. * See https://doc.babylonjs.com/classes/3.1/texture
  15887. */
  15888. renderTargetSamplingMode: number;
  15889. /**
  15890. * Clear color to use when screen clearing
  15891. */
  15892. clearColor: Color4;
  15893. /**
  15894. * If the buffer needs to be cleared before applying the post process. (default: true)
  15895. * Should be set to false if shader will overwrite all previous pixels.
  15896. */
  15897. autoClear: boolean;
  15898. /**
  15899. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15900. */
  15901. alphaMode: number;
  15902. /**
  15903. * Sets the setAlphaBlendConstants of the babylon engine
  15904. */
  15905. alphaConstants: Color4;
  15906. /**
  15907. * Animations to be used for the post processing
  15908. */
  15909. animations: import("babylonjs/Animations/animation").Animation[];
  15910. /**
  15911. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15912. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15913. */
  15914. enablePixelPerfectMode: boolean;
  15915. /**
  15916. * Force the postprocess to be applied without taking in account viewport
  15917. */
  15918. forceFullscreenViewport: boolean;
  15919. /**
  15920. * List of inspectable custom properties (used by the Inspector)
  15921. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15922. */
  15923. inspectableCustomProperties: IInspectable[];
  15924. /**
  15925. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15926. *
  15927. * | Value | Type | Description |
  15928. * | ----- | ----------------------------------- | ----------- |
  15929. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15930. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15931. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15932. *
  15933. */
  15934. scaleMode: number;
  15935. /**
  15936. * Force textures to be a power of two (default: false)
  15937. */
  15938. alwaysForcePOT: boolean;
  15939. private _samples;
  15940. /**
  15941. * Number of sample textures (default: 1)
  15942. */
  15943. get samples(): number;
  15944. set samples(n: number);
  15945. /**
  15946. * Modify the scale of the post process to be the same as the viewport (default: false)
  15947. */
  15948. adaptScaleToCurrentViewport: boolean;
  15949. private _camera;
  15950. private _scene;
  15951. private _engine;
  15952. private _options;
  15953. private _reusable;
  15954. private _textureType;
  15955. private _textureFormat;
  15956. /**
  15957. * Smart array of input and output textures for the post process.
  15958. * @hidden
  15959. */
  15960. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15961. /**
  15962. * The index in _textures that corresponds to the output texture.
  15963. * @hidden
  15964. */
  15965. _currentRenderTextureInd: number;
  15966. private _effect;
  15967. private _samplers;
  15968. private _fragmentUrl;
  15969. private _vertexUrl;
  15970. private _parameters;
  15971. private _scaleRatio;
  15972. protected _indexParameters: any;
  15973. private _shareOutputWithPostProcess;
  15974. private _texelSize;
  15975. private _forcedOutputTexture;
  15976. /**
  15977. * Returns the fragment url or shader name used in the post process.
  15978. * @returns the fragment url or name in the shader store.
  15979. */
  15980. getEffectName(): string;
  15981. /**
  15982. * An event triggered when the postprocess is activated.
  15983. */
  15984. onActivateObservable: Observable<Camera>;
  15985. private _onActivateObserver;
  15986. /**
  15987. * A function that is added to the onActivateObservable
  15988. */
  15989. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15990. /**
  15991. * An event triggered when the postprocess changes its size.
  15992. */
  15993. onSizeChangedObservable: Observable<PostProcess>;
  15994. private _onSizeChangedObserver;
  15995. /**
  15996. * A function that is added to the onSizeChangedObservable
  15997. */
  15998. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15999. /**
  16000. * An event triggered when the postprocess applies its effect.
  16001. */
  16002. onApplyObservable: Observable<Effect>;
  16003. private _onApplyObserver;
  16004. /**
  16005. * A function that is added to the onApplyObservable
  16006. */
  16007. set onApply(callback: (effect: Effect) => void);
  16008. /**
  16009. * An event triggered before rendering the postprocess
  16010. */
  16011. onBeforeRenderObservable: Observable<Effect>;
  16012. private _onBeforeRenderObserver;
  16013. /**
  16014. * A function that is added to the onBeforeRenderObservable
  16015. */
  16016. set onBeforeRender(callback: (effect: Effect) => void);
  16017. /**
  16018. * An event triggered after rendering the postprocess
  16019. */
  16020. onAfterRenderObservable: Observable<Effect>;
  16021. private _onAfterRenderObserver;
  16022. /**
  16023. * A function that is added to the onAfterRenderObservable
  16024. */
  16025. set onAfterRender(callback: (efect: Effect) => void);
  16026. /**
  16027. * 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
  16028. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16029. */
  16030. get inputTexture(): InternalTexture;
  16031. set inputTexture(value: InternalTexture);
  16032. /**
  16033. * Gets the camera which post process is applied to.
  16034. * @returns The camera the post process is applied to.
  16035. */
  16036. getCamera(): Camera;
  16037. /**
  16038. * Gets the texel size of the postprocess.
  16039. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16040. */
  16041. get texelSize(): Vector2;
  16042. /**
  16043. * Creates a new instance PostProcess
  16044. * @param name The name of the PostProcess.
  16045. * @param fragmentUrl The url of the fragment shader to be used.
  16046. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16047. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16048. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16049. * @param camera The camera to apply the render pass to.
  16050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16051. * @param engine The engine which the post process will be applied. (default: current engine)
  16052. * @param reusable If the post process can be reused on the same frame. (default: false)
  16053. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16054. * @param textureType Type of textures used when performing the post process. (default: 0)
  16055. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16056. * @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
  16057. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16058. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  16059. */
  16060. constructor(
  16061. /** Name of the PostProcess. */
  16062. 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);
  16063. /**
  16064. * Gets a string idenfifying the name of the class
  16065. * @returns "PostProcess" string
  16066. */
  16067. getClassName(): string;
  16068. /**
  16069. * Gets the engine which this post process belongs to.
  16070. * @returns The engine the post process was enabled with.
  16071. */
  16072. getEngine(): Engine;
  16073. /**
  16074. * The effect that is created when initializing the post process.
  16075. * @returns The created effect corresponding the the postprocess.
  16076. */
  16077. getEffect(): Effect;
  16078. /**
  16079. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16080. * @param postProcess The post process to share the output with.
  16081. * @returns This post process.
  16082. */
  16083. shareOutputWith(postProcess: PostProcess): PostProcess;
  16084. /**
  16085. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16086. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16087. */
  16088. useOwnOutput(): void;
  16089. /**
  16090. * Updates the effect with the current post process compile time values and recompiles the shader.
  16091. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16092. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16093. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16094. * @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
  16095. * @param onCompiled Called when the shader has been compiled.
  16096. * @param onError Called if there is an error when compiling a shader.
  16097. */
  16098. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16099. /**
  16100. * The post process is reusable if it can be used multiple times within one frame.
  16101. * @returns If the post process is reusable
  16102. */
  16103. isReusable(): boolean;
  16104. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16105. markTextureDirty(): void;
  16106. /**
  16107. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16108. * 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.
  16109. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16110. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16111. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16112. * @returns The target texture that was bound to be written to.
  16113. */
  16114. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16115. /**
  16116. * If the post process is supported.
  16117. */
  16118. get isSupported(): boolean;
  16119. /**
  16120. * The aspect ratio of the output texture.
  16121. */
  16122. get aspectRatio(): number;
  16123. /**
  16124. * Get a value indicating if the post-process is ready to be used
  16125. * @returns true if the post-process is ready (shader is compiled)
  16126. */
  16127. isReady(): boolean;
  16128. /**
  16129. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16130. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16131. */
  16132. apply(): Nullable<Effect>;
  16133. private _disposeTextures;
  16134. /**
  16135. * Disposes the post process.
  16136. * @param camera The camera to dispose the post process on.
  16137. */
  16138. dispose(camera?: Camera): void;
  16139. }
  16140. }
  16141. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16142. /** @hidden */
  16143. export var kernelBlurVaryingDeclaration: {
  16144. name: string;
  16145. shader: string;
  16146. };
  16147. }
  16148. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16149. /** @hidden */
  16150. export var kernelBlurFragment: {
  16151. name: string;
  16152. shader: string;
  16153. };
  16154. }
  16155. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16156. /** @hidden */
  16157. export var kernelBlurFragment2: {
  16158. name: string;
  16159. shader: string;
  16160. };
  16161. }
  16162. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16163. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16164. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16165. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16166. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16167. /** @hidden */
  16168. export var kernelBlurPixelShader: {
  16169. name: string;
  16170. shader: string;
  16171. };
  16172. }
  16173. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16174. /** @hidden */
  16175. export var kernelBlurVertex: {
  16176. name: string;
  16177. shader: string;
  16178. };
  16179. }
  16180. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16181. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16182. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16183. /** @hidden */
  16184. export var kernelBlurVertexShader: {
  16185. name: string;
  16186. shader: string;
  16187. };
  16188. }
  16189. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16190. import { Vector2 } from "babylonjs/Maths/math.vector";
  16191. import { Nullable } from "babylonjs/types";
  16192. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16193. import { Camera } from "babylonjs/Cameras/camera";
  16194. import { Effect } from "babylonjs/Materials/effect";
  16195. import { Engine } from "babylonjs/Engines/engine";
  16196. import "babylonjs/Shaders/kernelBlur.fragment";
  16197. import "babylonjs/Shaders/kernelBlur.vertex";
  16198. /**
  16199. * The Blur Post Process which blurs an image based on a kernel and direction.
  16200. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16201. */
  16202. export class BlurPostProcess extends PostProcess {
  16203. /** The direction in which to blur the image. */
  16204. direction: Vector2;
  16205. private blockCompilation;
  16206. protected _kernel: number;
  16207. protected _idealKernel: number;
  16208. protected _packedFloat: boolean;
  16209. private _staticDefines;
  16210. /**
  16211. * Sets the length in pixels of the blur sample region
  16212. */
  16213. set kernel(v: number);
  16214. /**
  16215. * Gets the length in pixels of the blur sample region
  16216. */
  16217. get kernel(): number;
  16218. /**
  16219. * Sets wether or not the blur needs to unpack/repack floats
  16220. */
  16221. set packedFloat(v: boolean);
  16222. /**
  16223. * Gets wether or not the blur is unpacking/repacking floats
  16224. */
  16225. get packedFloat(): boolean;
  16226. /**
  16227. * Creates a new instance BlurPostProcess
  16228. * @param name The name of the effect.
  16229. * @param direction The direction in which to blur the image.
  16230. * @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.
  16231. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16232. * @param camera The camera to apply the render pass to.
  16233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16234. * @param engine The engine which the post process will be applied. (default: current engine)
  16235. * @param reusable If the post process can be reused on the same frame. (default: false)
  16236. * @param textureType Type of textures used when performing the post process. (default: 0)
  16237. * @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)
  16238. */
  16239. constructor(name: string,
  16240. /** The direction in which to blur the image. */
  16241. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16242. /**
  16243. * Updates the effect with the current post process compile time values and recompiles the shader.
  16244. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16245. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16246. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16247. * @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
  16248. * @param onCompiled Called when the shader has been compiled.
  16249. * @param onError Called if there is an error when compiling a shader.
  16250. */
  16251. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16252. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16253. /**
  16254. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16255. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16256. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16257. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16258. * The gaps between physical kernels are compensated for in the weighting of the samples
  16259. * @param idealKernel Ideal blur kernel.
  16260. * @return Nearest best kernel.
  16261. */
  16262. protected _nearestBestKernel(idealKernel: number): number;
  16263. /**
  16264. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16265. * @param x The point on the Gaussian distribution to sample.
  16266. * @return the value of the Gaussian function at x.
  16267. */
  16268. protected _gaussianWeight(x: number): number;
  16269. /**
  16270. * Generates a string that can be used as a floating point number in GLSL.
  16271. * @param x Value to print.
  16272. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16273. * @return GLSL float string.
  16274. */
  16275. protected _glslFloat(x: number, decimalFigures?: number): string;
  16276. }
  16277. }
  16278. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16279. import { Scene } from "babylonjs/scene";
  16280. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16281. import { Plane } from "babylonjs/Maths/math.plane";
  16282. /**
  16283. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16284. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16285. * You can then easily use it as a reflectionTexture on a flat surface.
  16286. * In case the surface is not a plane, please consider relying on reflection probes.
  16287. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16288. */
  16289. export class MirrorTexture extends RenderTargetTexture {
  16290. private scene;
  16291. /**
  16292. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16293. * 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.
  16294. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16295. */
  16296. mirrorPlane: Plane;
  16297. /**
  16298. * Define the blur ratio used to blur the reflection if needed.
  16299. */
  16300. set blurRatio(value: number);
  16301. get blurRatio(): number;
  16302. /**
  16303. * Define the adaptive blur kernel used to blur the reflection if needed.
  16304. * This will autocompute the closest best match for the `blurKernel`
  16305. */
  16306. set adaptiveBlurKernel(value: number);
  16307. /**
  16308. * Define the blur kernel used to blur the reflection if needed.
  16309. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16310. */
  16311. set blurKernel(value: number);
  16312. /**
  16313. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16314. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16315. */
  16316. set blurKernelX(value: number);
  16317. get blurKernelX(): number;
  16318. /**
  16319. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16320. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16321. */
  16322. set blurKernelY(value: number);
  16323. get blurKernelY(): number;
  16324. private _autoComputeBlurKernel;
  16325. protected _onRatioRescale(): void;
  16326. private _updateGammaSpace;
  16327. private _imageProcessingConfigChangeObserver;
  16328. private _transformMatrix;
  16329. private _mirrorMatrix;
  16330. private _savedViewMatrix;
  16331. private _blurX;
  16332. private _blurY;
  16333. private _adaptiveBlurKernel;
  16334. private _blurKernelX;
  16335. private _blurKernelY;
  16336. private _blurRatio;
  16337. /**
  16338. * Instantiates a Mirror Texture.
  16339. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16340. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16341. * You can then easily use it as a reflectionTexture on a flat surface.
  16342. * In case the surface is not a plane, please consider relying on reflection probes.
  16343. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16344. * @param name
  16345. * @param size
  16346. * @param scene
  16347. * @param generateMipMaps
  16348. * @param type
  16349. * @param samplingMode
  16350. * @param generateDepthBuffer
  16351. */
  16352. constructor(name: string, size: number | {
  16353. width: number;
  16354. height: number;
  16355. } | {
  16356. ratio: number;
  16357. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16358. private _preparePostProcesses;
  16359. /**
  16360. * Clone the mirror texture.
  16361. * @returns the cloned texture
  16362. */
  16363. clone(): MirrorTexture;
  16364. /**
  16365. * Serialize the texture to a JSON representation you could use in Parse later on
  16366. * @returns the serialized JSON representation
  16367. */
  16368. serialize(): any;
  16369. /**
  16370. * Dispose the texture and release its associated resources.
  16371. */
  16372. dispose(): void;
  16373. }
  16374. }
  16375. declare module "babylonjs/Materials/Textures/texture" {
  16376. import { Observable } from "babylonjs/Misc/observable";
  16377. import { Nullable } from "babylonjs/types";
  16378. import { Matrix } from "babylonjs/Maths/math.vector";
  16379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16380. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16381. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16382. import { Scene } from "babylonjs/scene";
  16383. /**
  16384. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16385. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16386. */
  16387. export class Texture extends BaseTexture {
  16388. /**
  16389. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16390. */
  16391. static SerializeBuffers: boolean;
  16392. /** @hidden */
  16393. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16394. /** @hidden */
  16395. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16396. /** @hidden */
  16397. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16398. /** nearest is mag = nearest and min = nearest and mip = linear */
  16399. static readonly NEAREST_SAMPLINGMODE: number;
  16400. /** nearest is mag = nearest and min = nearest and mip = linear */
  16401. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16402. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16403. static readonly BILINEAR_SAMPLINGMODE: number;
  16404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16405. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16406. /** Trilinear is mag = linear and min = linear and mip = linear */
  16407. static readonly TRILINEAR_SAMPLINGMODE: number;
  16408. /** Trilinear is mag = linear and min = linear and mip = linear */
  16409. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16410. /** mag = nearest and min = nearest and mip = nearest */
  16411. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16412. /** mag = nearest and min = linear and mip = nearest */
  16413. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16414. /** mag = nearest and min = linear and mip = linear */
  16415. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16416. /** mag = nearest and min = linear and mip = none */
  16417. static readonly NEAREST_LINEAR: number;
  16418. /** mag = nearest and min = nearest and mip = none */
  16419. static readonly NEAREST_NEAREST: number;
  16420. /** mag = linear and min = nearest and mip = nearest */
  16421. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16422. /** mag = linear and min = nearest and mip = linear */
  16423. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16424. /** mag = linear and min = linear and mip = none */
  16425. static readonly LINEAR_LINEAR: number;
  16426. /** mag = linear and min = nearest and mip = none */
  16427. static readonly LINEAR_NEAREST: number;
  16428. /** Explicit coordinates mode */
  16429. static readonly EXPLICIT_MODE: number;
  16430. /** Spherical coordinates mode */
  16431. static readonly SPHERICAL_MODE: number;
  16432. /** Planar coordinates mode */
  16433. static readonly PLANAR_MODE: number;
  16434. /** Cubic coordinates mode */
  16435. static readonly CUBIC_MODE: number;
  16436. /** Projection coordinates mode */
  16437. static readonly PROJECTION_MODE: number;
  16438. /** Inverse Cubic coordinates mode */
  16439. static readonly SKYBOX_MODE: number;
  16440. /** Inverse Cubic coordinates mode */
  16441. static readonly INVCUBIC_MODE: number;
  16442. /** Equirectangular coordinates mode */
  16443. static readonly EQUIRECTANGULAR_MODE: number;
  16444. /** Equirectangular Fixed coordinates mode */
  16445. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16446. /** Equirectangular Fixed Mirrored coordinates mode */
  16447. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16448. /** Texture is not repeating outside of 0..1 UVs */
  16449. static readonly CLAMP_ADDRESSMODE: number;
  16450. /** Texture is repeating outside of 0..1 UVs */
  16451. static readonly WRAP_ADDRESSMODE: number;
  16452. /** Texture is repeating and mirrored */
  16453. static readonly MIRROR_ADDRESSMODE: number;
  16454. /**
  16455. * 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
  16456. */
  16457. static UseSerializedUrlIfAny: boolean;
  16458. /**
  16459. * Define the url of the texture.
  16460. */
  16461. url: Nullable<string>;
  16462. /**
  16463. * Define an offset on the texture to offset the u coordinates of the UVs
  16464. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16465. */
  16466. uOffset: number;
  16467. /**
  16468. * Define an offset on the texture to offset the v coordinates of the UVs
  16469. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16470. */
  16471. vOffset: number;
  16472. /**
  16473. * Define an offset on the texture to scale the u coordinates of the UVs
  16474. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16475. */
  16476. uScale: number;
  16477. /**
  16478. * Define an offset on the texture to scale the v coordinates of the UVs
  16479. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16480. */
  16481. vScale: number;
  16482. /**
  16483. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16484. * @see http://doc.babylonjs.com/how_to/more_materials
  16485. */
  16486. uAng: number;
  16487. /**
  16488. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16489. * @see http://doc.babylonjs.com/how_to/more_materials
  16490. */
  16491. vAng: number;
  16492. /**
  16493. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16494. * @see http://doc.babylonjs.com/how_to/more_materials
  16495. */
  16496. wAng: number;
  16497. /**
  16498. * Defines the center of rotation (U)
  16499. */
  16500. uRotationCenter: number;
  16501. /**
  16502. * Defines the center of rotation (V)
  16503. */
  16504. vRotationCenter: number;
  16505. /**
  16506. * Defines the center of rotation (W)
  16507. */
  16508. wRotationCenter: number;
  16509. /**
  16510. * Are mip maps generated for this texture or not.
  16511. */
  16512. get noMipmap(): boolean;
  16513. /**
  16514. * List of inspectable custom properties (used by the Inspector)
  16515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16516. */
  16517. inspectableCustomProperties: Nullable<IInspectable[]>;
  16518. private _noMipmap;
  16519. /** @hidden */
  16520. _invertY: boolean;
  16521. private _rowGenerationMatrix;
  16522. private _cachedTextureMatrix;
  16523. private _projectionModeMatrix;
  16524. private _t0;
  16525. private _t1;
  16526. private _t2;
  16527. private _cachedUOffset;
  16528. private _cachedVOffset;
  16529. private _cachedUScale;
  16530. private _cachedVScale;
  16531. private _cachedUAng;
  16532. private _cachedVAng;
  16533. private _cachedWAng;
  16534. private _cachedProjectionMatrixId;
  16535. private _cachedCoordinatesMode;
  16536. /** @hidden */
  16537. protected _initialSamplingMode: number;
  16538. /** @hidden */
  16539. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16540. private _deleteBuffer;
  16541. protected _format: Nullable<number>;
  16542. private _delayedOnLoad;
  16543. private _delayedOnError;
  16544. private _mimeType?;
  16545. /**
  16546. * Observable triggered once the texture has been loaded.
  16547. */
  16548. onLoadObservable: Observable<Texture>;
  16549. protected _isBlocking: boolean;
  16550. /**
  16551. * Is the texture preventing material to render while loading.
  16552. * If false, a default texture will be used instead of the loading one during the preparation step.
  16553. */
  16554. set isBlocking(value: boolean);
  16555. get isBlocking(): boolean;
  16556. /**
  16557. * Get the current sampling mode associated with the texture.
  16558. */
  16559. get samplingMode(): number;
  16560. /**
  16561. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16562. */
  16563. get invertY(): boolean;
  16564. /**
  16565. * Instantiates a new texture.
  16566. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16567. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16568. * @param url defines the url of the picture to load as a texture
  16569. * @param scene defines the scene or engine the texture will belong to
  16570. * @param noMipmap defines if the texture will require mip maps or not
  16571. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16572. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16573. * @param onLoad defines a callback triggered when the texture has been loaded
  16574. * @param onError defines a callback triggered when an error occurred during the loading session
  16575. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16576. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16577. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16578. * @param mimeType defines an optional mime type information
  16579. */
  16580. 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);
  16581. /**
  16582. * Update the url (and optional buffer) of this texture if url was null during construction.
  16583. * @param url the url of the texture
  16584. * @param buffer the buffer of the texture (defaults to null)
  16585. * @param onLoad callback called when the texture is loaded (defaults to null)
  16586. */
  16587. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16588. /**
  16589. * Finish the loading sequence of a texture flagged as delayed load.
  16590. * @hidden
  16591. */
  16592. delayLoad(): void;
  16593. private _prepareRowForTextureGeneration;
  16594. /**
  16595. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16596. * @returns the transform matrix of the texture.
  16597. */
  16598. getTextureMatrix(uBase?: number): Matrix;
  16599. /**
  16600. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16601. * @returns The reflection texture transform
  16602. */
  16603. getReflectionTextureMatrix(): Matrix;
  16604. /**
  16605. * Clones the texture.
  16606. * @returns the cloned texture
  16607. */
  16608. clone(): Texture;
  16609. /**
  16610. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16611. * @returns The JSON representation of the texture
  16612. */
  16613. serialize(): any;
  16614. /**
  16615. * Get the current class name of the texture useful for serialization or dynamic coding.
  16616. * @returns "Texture"
  16617. */
  16618. getClassName(): string;
  16619. /**
  16620. * Dispose the texture and release its associated resources.
  16621. */
  16622. dispose(): void;
  16623. /**
  16624. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16625. * @param parsedTexture Define the JSON representation of the texture
  16626. * @param scene Define the scene the parsed texture should be instantiated in
  16627. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16628. * @returns The parsed texture if successful
  16629. */
  16630. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16631. /**
  16632. * Creates a texture from its base 64 representation.
  16633. * @param data Define the base64 payload without the data: prefix
  16634. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16635. * @param scene Define the scene the texture should belong to
  16636. * @param noMipmap Forces the texture to not create mip map information if true
  16637. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16638. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16639. * @param onLoad define a callback triggered when the texture has been loaded
  16640. * @param onError define a callback triggered when an error occurred during the loading session
  16641. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16642. * @returns the created texture
  16643. */
  16644. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16645. /**
  16646. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16647. * @param data Define the base64 payload without the data: prefix
  16648. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16649. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16650. * @param scene Define the scene the texture should belong to
  16651. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16652. * @param noMipmap Forces the texture to not create mip map information if true
  16653. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16654. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16655. * @param onLoad define a callback triggered when the texture has been loaded
  16656. * @param onError define a callback triggered when an error occurred during the loading session
  16657. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16658. * @returns the created texture
  16659. */
  16660. 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;
  16661. }
  16662. }
  16663. declare module "babylonjs/PostProcesses/postProcessManager" {
  16664. import { Nullable } from "babylonjs/types";
  16665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16666. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16667. import { Scene } from "babylonjs/scene";
  16668. /**
  16669. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16670. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16671. */
  16672. export class PostProcessManager {
  16673. private _scene;
  16674. private _indexBuffer;
  16675. private _vertexBuffers;
  16676. /**
  16677. * Creates a new instance PostProcess
  16678. * @param scene The scene that the post process is associated with.
  16679. */
  16680. constructor(scene: Scene);
  16681. private _prepareBuffers;
  16682. private _buildIndexBuffer;
  16683. /**
  16684. * Rebuilds the vertex buffers of the manager.
  16685. * @hidden
  16686. */
  16687. _rebuild(): void;
  16688. /**
  16689. * Prepares a frame to be run through a post process.
  16690. * @param sourceTexture The input texture to the post procesess. (default: null)
  16691. * @param postProcesses An array of post processes to be run. (default: null)
  16692. * @returns True if the post processes were able to be run.
  16693. * @hidden
  16694. */
  16695. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16696. /**
  16697. * Manually render a set of post processes to a texture.
  16698. * @param postProcesses An array of post processes to be run.
  16699. * @param targetTexture The target texture to render to.
  16700. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16701. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16702. * @param lodLevel defines which lod of the texture to render to
  16703. */
  16704. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16705. /**
  16706. * Finalize the result of the output of the postprocesses.
  16707. * @param doNotPresent If true the result will not be displayed to the screen.
  16708. * @param targetTexture The target texture to render to.
  16709. * @param faceIndex The index of the face to bind the target texture to.
  16710. * @param postProcesses The array of post processes to render.
  16711. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16712. * @hidden
  16713. */
  16714. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16715. /**
  16716. * Disposes of the post process manager.
  16717. */
  16718. dispose(): void;
  16719. }
  16720. }
  16721. declare module "babylonjs/Misc/gradients" {
  16722. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16723. /** Interface used by value gradients (color, factor, ...) */
  16724. export interface IValueGradient {
  16725. /**
  16726. * Gets or sets the gradient value (between 0 and 1)
  16727. */
  16728. gradient: number;
  16729. }
  16730. /** Class used to store color4 gradient */
  16731. export class ColorGradient implements IValueGradient {
  16732. /**
  16733. * Gets or sets the gradient value (between 0 and 1)
  16734. */
  16735. gradient: number;
  16736. /**
  16737. * Gets or sets first associated color
  16738. */
  16739. color1: Color4;
  16740. /**
  16741. * Gets or sets second associated color
  16742. */
  16743. color2?: Color4;
  16744. /**
  16745. * Will get a color picked randomly between color1 and color2.
  16746. * If color2 is undefined then color1 will be used
  16747. * @param result defines the target Color4 to store the result in
  16748. */
  16749. getColorToRef(result: Color4): void;
  16750. }
  16751. /** Class used to store color 3 gradient */
  16752. export class Color3Gradient implements IValueGradient {
  16753. /**
  16754. * Gets or sets the gradient value (between 0 and 1)
  16755. */
  16756. gradient: number;
  16757. /**
  16758. * Gets or sets the associated color
  16759. */
  16760. color: Color3;
  16761. }
  16762. /** Class used to store factor gradient */
  16763. export class FactorGradient implements IValueGradient {
  16764. /**
  16765. * Gets or sets the gradient value (between 0 and 1)
  16766. */
  16767. gradient: number;
  16768. /**
  16769. * Gets or sets first associated factor
  16770. */
  16771. factor1: number;
  16772. /**
  16773. * Gets or sets second associated factor
  16774. */
  16775. factor2?: number;
  16776. /**
  16777. * Will get a number picked randomly between factor1 and factor2.
  16778. * If factor2 is undefined then factor1 will be used
  16779. * @returns the picked number
  16780. */
  16781. getFactor(): number;
  16782. }
  16783. /**
  16784. * Helper used to simplify some generic gradient tasks
  16785. */
  16786. export class GradientHelper {
  16787. /**
  16788. * Gets the current gradient from an array of IValueGradient
  16789. * @param ratio defines the current ratio to get
  16790. * @param gradients defines the array of IValueGradient
  16791. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16792. */
  16793. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16794. }
  16795. }
  16796. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16798. import { Nullable } from "babylonjs/types";
  16799. module "babylonjs/Engines/thinEngine" {
  16800. interface ThinEngine {
  16801. /**
  16802. * Creates a dynamic texture
  16803. * @param width defines the width of the texture
  16804. * @param height defines the height of the texture
  16805. * @param generateMipMaps defines if the engine should generate the mip levels
  16806. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16807. * @returns the dynamic texture inside an InternalTexture
  16808. */
  16809. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16810. /**
  16811. * Update the content of a dynamic texture
  16812. * @param texture defines the texture to update
  16813. * @param canvas defines the canvas containing the source
  16814. * @param invertY defines if data must be stored with Y axis inverted
  16815. * @param premulAlpha defines if alpha is stored as premultiplied
  16816. * @param format defines the format of the data
  16817. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16818. */
  16819. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16820. }
  16821. }
  16822. }
  16823. declare module "babylonjs/Misc/canvasGenerator" {
  16824. /**
  16825. * Helper class used to generate a canvas to manipulate images
  16826. */
  16827. export class CanvasGenerator {
  16828. /**
  16829. * Create a new canvas (or offscreen canvas depending on the context)
  16830. * @param width defines the expected width
  16831. * @param height defines the expected height
  16832. * @return a new canvas or offscreen canvas
  16833. */
  16834. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16835. }
  16836. }
  16837. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16838. import { Scene } from "babylonjs/scene";
  16839. import { Texture } from "babylonjs/Materials/Textures/texture";
  16840. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16841. /**
  16842. * A class extending Texture allowing drawing on a texture
  16843. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16844. */
  16845. export class DynamicTexture extends Texture {
  16846. private _generateMipMaps;
  16847. private _canvas;
  16848. private _context;
  16849. private _engine;
  16850. /**
  16851. * Creates a DynamicTexture
  16852. * @param name defines the name of the texture
  16853. * @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
  16854. * @param scene defines the scene where you want the texture
  16855. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16856. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16857. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16858. */
  16859. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16860. /**
  16861. * Get the current class name of the texture useful for serialization or dynamic coding.
  16862. * @returns "DynamicTexture"
  16863. */
  16864. getClassName(): string;
  16865. /**
  16866. * Gets the current state of canRescale
  16867. */
  16868. get canRescale(): boolean;
  16869. private _recreate;
  16870. /**
  16871. * Scales the texture
  16872. * @param ratio the scale factor to apply to both width and height
  16873. */
  16874. scale(ratio: number): void;
  16875. /**
  16876. * Resizes the texture
  16877. * @param width the new width
  16878. * @param height the new height
  16879. */
  16880. scaleTo(width: number, height: number): void;
  16881. /**
  16882. * Gets the context of the canvas used by the texture
  16883. * @returns the canvas context of the dynamic texture
  16884. */
  16885. getContext(): CanvasRenderingContext2D;
  16886. /**
  16887. * Clears the texture
  16888. */
  16889. clear(): void;
  16890. /**
  16891. * Updates the texture
  16892. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16893. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16894. */
  16895. update(invertY?: boolean, premulAlpha?: boolean): void;
  16896. /**
  16897. * Draws text onto the texture
  16898. * @param text defines the text to be drawn
  16899. * @param x defines the placement of the text from the left
  16900. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16901. * @param font defines the font to be used with font-style, font-size, font-name
  16902. * @param color defines the color used for the text
  16903. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16904. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16905. * @param update defines whether texture is immediately update (default is true)
  16906. */
  16907. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16908. /**
  16909. * Clones the texture
  16910. * @returns the clone of the texture.
  16911. */
  16912. clone(): DynamicTexture;
  16913. /**
  16914. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16915. * @returns a serialized dynamic texture object
  16916. */
  16917. serialize(): any;
  16918. /** @hidden */
  16919. _rebuild(): void;
  16920. }
  16921. }
  16922. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16923. import { Scene } from "babylonjs/scene";
  16924. import { ISceneComponent } from "babylonjs/sceneComponent";
  16925. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16926. module "babylonjs/abstractScene" {
  16927. interface AbstractScene {
  16928. /**
  16929. * The list of procedural textures added to the scene
  16930. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16931. */
  16932. proceduralTextures: Array<ProceduralTexture>;
  16933. }
  16934. }
  16935. /**
  16936. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16937. * in a given scene.
  16938. */
  16939. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16940. /**
  16941. * The component name helpfull to identify the component in the list of scene components.
  16942. */
  16943. readonly name: string;
  16944. /**
  16945. * The scene the component belongs to.
  16946. */
  16947. scene: Scene;
  16948. /**
  16949. * Creates a new instance of the component for the given scene
  16950. * @param scene Defines the scene to register the component in
  16951. */
  16952. constructor(scene: Scene);
  16953. /**
  16954. * Registers the component in a given scene
  16955. */
  16956. register(): void;
  16957. /**
  16958. * Rebuilds the elements related to this component in case of
  16959. * context lost for instance.
  16960. */
  16961. rebuild(): void;
  16962. /**
  16963. * Disposes the component and the associated ressources.
  16964. */
  16965. dispose(): void;
  16966. private _beforeClear;
  16967. }
  16968. }
  16969. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16970. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16971. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16972. module "babylonjs/Engines/thinEngine" {
  16973. interface ThinEngine {
  16974. /**
  16975. * Creates a new render target cube texture
  16976. * @param size defines the size of the texture
  16977. * @param options defines the options used to create the texture
  16978. * @returns a new render target cube texture stored in an InternalTexture
  16979. */
  16980. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16981. }
  16982. }
  16983. }
  16984. declare module "babylonjs/Shaders/procedural.vertex" {
  16985. /** @hidden */
  16986. export var proceduralVertexShader: {
  16987. name: string;
  16988. shader: string;
  16989. };
  16990. }
  16991. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16992. import { Observable } from "babylonjs/Misc/observable";
  16993. import { Nullable } from "babylonjs/types";
  16994. import { Scene } from "babylonjs/scene";
  16995. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16996. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16997. import { Effect } from "babylonjs/Materials/effect";
  16998. import { Texture } from "babylonjs/Materials/Textures/texture";
  16999. import "babylonjs/Engines/Extensions/engine.renderTarget";
  17000. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  17001. import "babylonjs/Shaders/procedural.vertex";
  17002. /**
  17003. * 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.
  17004. * This is the base class of any Procedural texture and contains most of the shareable code.
  17005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17006. */
  17007. export class ProceduralTexture extends Texture {
  17008. isCube: boolean;
  17009. /**
  17010. * Define if the texture is enabled or not (disabled texture will not render)
  17011. */
  17012. isEnabled: boolean;
  17013. /**
  17014. * Define if the texture must be cleared before rendering (default is true)
  17015. */
  17016. autoClear: boolean;
  17017. /**
  17018. * Callback called when the texture is generated
  17019. */
  17020. onGenerated: () => void;
  17021. /**
  17022. * Event raised when the texture is generated
  17023. */
  17024. onGeneratedObservable: Observable<ProceduralTexture>;
  17025. /** @hidden */
  17026. _generateMipMaps: boolean;
  17027. /** @hidden **/
  17028. _effect: Effect;
  17029. /** @hidden */
  17030. _textures: {
  17031. [key: string]: Texture;
  17032. };
  17033. private _size;
  17034. private _currentRefreshId;
  17035. private _frameId;
  17036. private _refreshRate;
  17037. private _vertexBuffers;
  17038. private _indexBuffer;
  17039. private _uniforms;
  17040. private _samplers;
  17041. private _fragment;
  17042. private _floats;
  17043. private _ints;
  17044. private _floatsArrays;
  17045. private _colors3;
  17046. private _colors4;
  17047. private _vectors2;
  17048. private _vectors3;
  17049. private _matrices;
  17050. private _fallbackTexture;
  17051. private _fallbackTextureUsed;
  17052. private _engine;
  17053. private _cachedDefines;
  17054. private _contentUpdateId;
  17055. private _contentData;
  17056. /**
  17057. * Instantiates a new procedural texture.
  17058. * 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.
  17059. * This is the base class of any Procedural texture and contains most of the shareable code.
  17060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17061. * @param name Define the name of the texture
  17062. * @param size Define the size of the texture to create
  17063. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17064. * @param scene Define the scene the texture belongs to
  17065. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17066. * @param generateMipMaps Define if the texture should creates mip maps or not
  17067. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17068. */
  17069. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17070. /**
  17071. * The effect that is created when initializing the post process.
  17072. * @returns The created effect corresponding the the postprocess.
  17073. */
  17074. getEffect(): Effect;
  17075. /**
  17076. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17077. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17078. */
  17079. getContent(): Nullable<ArrayBufferView>;
  17080. private _createIndexBuffer;
  17081. /** @hidden */
  17082. _rebuild(): void;
  17083. /**
  17084. * Resets the texture in order to recreate its associated resources.
  17085. * This can be called in case of context loss
  17086. */
  17087. reset(): void;
  17088. protected _getDefines(): string;
  17089. /**
  17090. * Is the texture ready to be used ? (rendered at least once)
  17091. * @returns true if ready, otherwise, false.
  17092. */
  17093. isReady(): boolean;
  17094. /**
  17095. * Resets the refresh counter of the texture and start bak from scratch.
  17096. * Could be useful to regenerate the texture if it is setup to render only once.
  17097. */
  17098. resetRefreshCounter(): void;
  17099. /**
  17100. * Set the fragment shader to use in order to render the texture.
  17101. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17102. */
  17103. setFragment(fragment: any): void;
  17104. /**
  17105. * Define the refresh rate of the texture or the rendering frequency.
  17106. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17107. */
  17108. get refreshRate(): number;
  17109. set refreshRate(value: number);
  17110. /** @hidden */
  17111. _shouldRender(): boolean;
  17112. /**
  17113. * Get the size the texture is rendering at.
  17114. * @returns the size (texture is always squared)
  17115. */
  17116. getRenderSize(): number;
  17117. /**
  17118. * Resize the texture to new value.
  17119. * @param size Define the new size the texture should have
  17120. * @param generateMipMaps Define whether the new texture should create mip maps
  17121. */
  17122. resize(size: number, generateMipMaps: boolean): void;
  17123. private _checkUniform;
  17124. /**
  17125. * Set a texture in the shader program used to render.
  17126. * @param name Define the name of the uniform samplers as defined in the shader
  17127. * @param texture Define the texture to bind to this sampler
  17128. * @return the texture itself allowing "fluent" like uniform updates
  17129. */
  17130. setTexture(name: string, texture: Texture): ProceduralTexture;
  17131. /**
  17132. * Set a float in the shader.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the texture itself allowing "fluent" like uniform updates
  17136. */
  17137. setFloat(name: string, value: number): ProceduralTexture;
  17138. /**
  17139. * Set a int in the shader.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the texture itself allowing "fluent" like uniform updates
  17143. */
  17144. setInt(name: string, value: number): ProceduralTexture;
  17145. /**
  17146. * Set an array of floats in the shader.
  17147. * @param name Define the name of the uniform as defined in the shader
  17148. * @param value Define the value to give to the uniform
  17149. * @return the texture itself allowing "fluent" like uniform updates
  17150. */
  17151. setFloats(name: string, value: number[]): ProceduralTexture;
  17152. /**
  17153. * Set a vec3 in the shader from a Color3.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the texture itself allowing "fluent" like uniform updates
  17157. */
  17158. setColor3(name: string, value: Color3): ProceduralTexture;
  17159. /**
  17160. * Set a vec4 in the shader from a Color4.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the texture itself allowing "fluent" like uniform updates
  17164. */
  17165. setColor4(name: string, value: Color4): ProceduralTexture;
  17166. /**
  17167. * Set a vec2 in the shader from a Vector2.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the texture itself allowing "fluent" like uniform updates
  17171. */
  17172. setVector2(name: string, value: Vector2): ProceduralTexture;
  17173. /**
  17174. * Set a vec3 in the shader from a Vector3.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the texture itself allowing "fluent" like uniform updates
  17178. */
  17179. setVector3(name: string, value: Vector3): ProceduralTexture;
  17180. /**
  17181. * Set a mat4 in the shader from a MAtrix.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the texture itself allowing "fluent" like uniform updates
  17185. */
  17186. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17187. /**
  17188. * Render the texture to its associated render target.
  17189. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17190. */
  17191. render(useCameraPostProcess?: boolean): void;
  17192. /**
  17193. * Clone the texture.
  17194. * @returns the cloned texture
  17195. */
  17196. clone(): ProceduralTexture;
  17197. /**
  17198. * Dispose the texture and release its asoociated resources.
  17199. */
  17200. dispose(): void;
  17201. }
  17202. }
  17203. declare module "babylonjs/Particles/baseParticleSystem" {
  17204. import { Nullable } from "babylonjs/types";
  17205. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17207. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17208. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17209. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17210. import { Scene } from "babylonjs/scene";
  17211. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17212. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17213. import { Texture } from "babylonjs/Materials/Textures/texture";
  17214. import { Color4 } from "babylonjs/Maths/math.color";
  17215. import { Animation } from "babylonjs/Animations/animation";
  17216. /**
  17217. * This represents the base class for particle system in Babylon.
  17218. * 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.
  17219. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17220. * @example https://doc.babylonjs.com/babylon101/particles
  17221. */
  17222. export class BaseParticleSystem {
  17223. /**
  17224. * Source color is added to the destination color without alpha affecting the result
  17225. */
  17226. static BLENDMODE_ONEONE: number;
  17227. /**
  17228. * Blend current color and particle color using particle’s alpha
  17229. */
  17230. static BLENDMODE_STANDARD: number;
  17231. /**
  17232. * Add current color and particle color multiplied by particle’s alpha
  17233. */
  17234. static BLENDMODE_ADD: number;
  17235. /**
  17236. * Multiply current color with particle color
  17237. */
  17238. static BLENDMODE_MULTIPLY: number;
  17239. /**
  17240. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17241. */
  17242. static BLENDMODE_MULTIPLYADD: number;
  17243. /**
  17244. * List of animations used by the particle system.
  17245. */
  17246. animations: Animation[];
  17247. /**
  17248. * The id of the Particle system.
  17249. */
  17250. id: string;
  17251. /**
  17252. * The friendly name of the Particle system.
  17253. */
  17254. name: string;
  17255. /**
  17256. * The rendering group used by the Particle system to chose when to render.
  17257. */
  17258. renderingGroupId: number;
  17259. /**
  17260. * The emitter represents the Mesh or position we are attaching the particle system to.
  17261. */
  17262. emitter: Nullable<AbstractMesh | Vector3>;
  17263. /**
  17264. * The maximum number of particles to emit per frame
  17265. */
  17266. emitRate: number;
  17267. /**
  17268. * If you want to launch only a few particles at once, that can be done, as well.
  17269. */
  17270. manualEmitCount: number;
  17271. /**
  17272. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17273. */
  17274. updateSpeed: number;
  17275. /**
  17276. * The amount of time the particle system is running (depends of the overall update speed).
  17277. */
  17278. targetStopDuration: number;
  17279. /**
  17280. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17281. */
  17282. disposeOnStop: boolean;
  17283. /**
  17284. * Minimum power of emitting particles.
  17285. */
  17286. minEmitPower: number;
  17287. /**
  17288. * Maximum power of emitting particles.
  17289. */
  17290. maxEmitPower: number;
  17291. /**
  17292. * Minimum life time of emitting particles.
  17293. */
  17294. minLifeTime: number;
  17295. /**
  17296. * Maximum life time of emitting particles.
  17297. */
  17298. maxLifeTime: number;
  17299. /**
  17300. * Minimum Size of emitting particles.
  17301. */
  17302. minSize: number;
  17303. /**
  17304. * Maximum Size of emitting particles.
  17305. */
  17306. maxSize: number;
  17307. /**
  17308. * Minimum scale of emitting particles on X axis.
  17309. */
  17310. minScaleX: number;
  17311. /**
  17312. * Maximum scale of emitting particles on X axis.
  17313. */
  17314. maxScaleX: number;
  17315. /**
  17316. * Minimum scale of emitting particles on Y axis.
  17317. */
  17318. minScaleY: number;
  17319. /**
  17320. * Maximum scale of emitting particles on Y axis.
  17321. */
  17322. maxScaleY: number;
  17323. /**
  17324. * Gets or sets the minimal initial rotation in radians.
  17325. */
  17326. minInitialRotation: number;
  17327. /**
  17328. * Gets or sets the maximal initial rotation in radians.
  17329. */
  17330. maxInitialRotation: number;
  17331. /**
  17332. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17333. */
  17334. minAngularSpeed: number;
  17335. /**
  17336. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17337. */
  17338. maxAngularSpeed: number;
  17339. /**
  17340. * The texture used to render each particle. (this can be a spritesheet)
  17341. */
  17342. particleTexture: Nullable<Texture>;
  17343. /**
  17344. * The layer mask we are rendering the particles through.
  17345. */
  17346. layerMask: number;
  17347. /**
  17348. * This can help using your own shader to render the particle system.
  17349. * The according effect will be created
  17350. */
  17351. customShader: any;
  17352. /**
  17353. * By default particle system starts as soon as they are created. This prevents the
  17354. * automatic start to happen and let you decide when to start emitting particles.
  17355. */
  17356. preventAutoStart: boolean;
  17357. private _noiseTexture;
  17358. /**
  17359. * Gets or sets a texture used to add random noise to particle positions
  17360. */
  17361. get noiseTexture(): Nullable<ProceduralTexture>;
  17362. set noiseTexture(value: Nullable<ProceduralTexture>);
  17363. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17364. noiseStrength: Vector3;
  17365. /**
  17366. * Callback triggered when the particle animation is ending.
  17367. */
  17368. onAnimationEnd: Nullable<() => void>;
  17369. /**
  17370. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17371. */
  17372. blendMode: number;
  17373. /**
  17374. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17375. * to override the particles.
  17376. */
  17377. forceDepthWrite: boolean;
  17378. /** 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 */
  17379. preWarmCycles: number;
  17380. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17381. preWarmStepOffset: number;
  17382. /**
  17383. * 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)
  17384. */
  17385. spriteCellChangeSpeed: number;
  17386. /**
  17387. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17388. */
  17389. startSpriteCellID: number;
  17390. /**
  17391. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17392. */
  17393. endSpriteCellID: number;
  17394. /**
  17395. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17396. */
  17397. spriteCellWidth: number;
  17398. /**
  17399. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17400. */
  17401. spriteCellHeight: number;
  17402. /**
  17403. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17404. */
  17405. spriteRandomStartCell: boolean;
  17406. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17407. translationPivot: Vector2;
  17408. /** @hidden */
  17409. protected _isAnimationSheetEnabled: boolean;
  17410. /**
  17411. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17412. */
  17413. beginAnimationOnStart: boolean;
  17414. /**
  17415. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17416. */
  17417. beginAnimationFrom: number;
  17418. /**
  17419. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17420. */
  17421. beginAnimationTo: number;
  17422. /**
  17423. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17424. */
  17425. beginAnimationLoop: boolean;
  17426. /**
  17427. * Gets or sets a world offset applied to all particles
  17428. */
  17429. worldOffset: Vector3;
  17430. /**
  17431. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17432. */
  17433. get isAnimationSheetEnabled(): boolean;
  17434. set isAnimationSheetEnabled(value: boolean);
  17435. /**
  17436. * Get hosting scene
  17437. * @returns the scene
  17438. */
  17439. getScene(): Scene;
  17440. /**
  17441. * You can use gravity if you want to give an orientation to your particles.
  17442. */
  17443. gravity: Vector3;
  17444. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17445. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17446. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17447. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17448. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17449. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17450. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17451. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17452. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17453. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17454. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17455. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17456. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17457. /**
  17458. * Defines the delay in milliseconds before starting the system (0 by default)
  17459. */
  17460. startDelay: number;
  17461. /**
  17462. * Gets the current list of drag gradients.
  17463. * You must use addDragGradient and removeDragGradient to udpate this list
  17464. * @returns the list of drag gradients
  17465. */
  17466. getDragGradients(): Nullable<Array<FactorGradient>>;
  17467. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17468. limitVelocityDamping: number;
  17469. /**
  17470. * Gets the current list of limit velocity gradients.
  17471. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17472. * @returns the list of limit velocity gradients
  17473. */
  17474. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17475. /**
  17476. * Gets the current list of color gradients.
  17477. * You must use addColorGradient and removeColorGradient to udpate this list
  17478. * @returns the list of color gradients
  17479. */
  17480. getColorGradients(): Nullable<Array<ColorGradient>>;
  17481. /**
  17482. * Gets the current list of size gradients.
  17483. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17484. * @returns the list of size gradients
  17485. */
  17486. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17487. /**
  17488. * Gets the current list of color remap gradients.
  17489. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17490. * @returns the list of color remap gradients
  17491. */
  17492. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17493. /**
  17494. * Gets the current list of alpha remap gradients.
  17495. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17496. * @returns the list of alpha remap gradients
  17497. */
  17498. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17499. /**
  17500. * Gets the current list of life time gradients.
  17501. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17502. * @returns the list of life time gradients
  17503. */
  17504. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17505. /**
  17506. * Gets the current list of angular speed gradients.
  17507. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17508. * @returns the list of angular speed gradients
  17509. */
  17510. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17511. /**
  17512. * Gets the current list of velocity gradients.
  17513. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17514. * @returns the list of velocity gradients
  17515. */
  17516. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17517. /**
  17518. * Gets the current list of start size gradients.
  17519. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17520. * @returns the list of start size gradients
  17521. */
  17522. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17523. /**
  17524. * Gets the current list of emit rate gradients.
  17525. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17526. * @returns the list of emit rate gradients
  17527. */
  17528. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17529. /**
  17530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17532. */
  17533. get direction1(): Vector3;
  17534. set direction1(value: Vector3);
  17535. /**
  17536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17537. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17538. */
  17539. get direction2(): Vector3;
  17540. set direction2(value: Vector3);
  17541. /**
  17542. * 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.
  17543. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17544. */
  17545. get minEmitBox(): Vector3;
  17546. set minEmitBox(value: Vector3);
  17547. /**
  17548. * 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.
  17549. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17550. */
  17551. get maxEmitBox(): Vector3;
  17552. set maxEmitBox(value: Vector3);
  17553. /**
  17554. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17555. */
  17556. color1: Color4;
  17557. /**
  17558. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17559. */
  17560. color2: Color4;
  17561. /**
  17562. * Color the particle will have at the end of its lifetime
  17563. */
  17564. colorDead: Color4;
  17565. /**
  17566. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17567. */
  17568. textureMask: Color4;
  17569. /**
  17570. * The particle emitter type defines the emitter used by the particle system.
  17571. * It can be for example box, sphere, or cone...
  17572. */
  17573. particleEmitterType: IParticleEmitterType;
  17574. /** @hidden */
  17575. _isSubEmitter: boolean;
  17576. /**
  17577. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17578. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17579. */
  17580. billboardMode: number;
  17581. protected _isBillboardBased: boolean;
  17582. /**
  17583. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17584. */
  17585. get isBillboardBased(): boolean;
  17586. set isBillboardBased(value: boolean);
  17587. /**
  17588. * The scene the particle system belongs to.
  17589. */
  17590. protected _scene: Scene;
  17591. /**
  17592. * Local cache of defines for image processing.
  17593. */
  17594. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17595. /**
  17596. * Default configuration related to image processing available in the standard Material.
  17597. */
  17598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17599. /**
  17600. * Gets the image processing configuration used either in this material.
  17601. */
  17602. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17603. /**
  17604. * Sets the Default image processing configuration used either in the this material.
  17605. *
  17606. * If sets to null, the scene one is in use.
  17607. */
  17608. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17609. /**
  17610. * Attaches a new image processing configuration to the Standard Material.
  17611. * @param configuration
  17612. */
  17613. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17614. /** @hidden */
  17615. protected _reset(): void;
  17616. /** @hidden */
  17617. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17618. /**
  17619. * Instantiates a particle system.
  17620. * 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.
  17621. * @param name The name of the particle system
  17622. */
  17623. constructor(name: string);
  17624. /**
  17625. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17628. * @returns the emitter
  17629. */
  17630. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17631. /**
  17632. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17633. * @param radius The radius of the hemisphere to emit from
  17634. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17635. * @returns the emitter
  17636. */
  17637. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17638. /**
  17639. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17640. * @param radius The radius of the sphere to emit from
  17641. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17642. * @returns the emitter
  17643. */
  17644. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17645. /**
  17646. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17647. * @param radius The radius of the sphere to emit from
  17648. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17649. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17650. * @returns the emitter
  17651. */
  17652. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17653. /**
  17654. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17655. * @param radius The radius of the emission cylinder
  17656. * @param height The height of the emission cylinder
  17657. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17658. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17659. * @returns the emitter
  17660. */
  17661. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17662. /**
  17663. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17664. * @param radius The radius of the cylinder to emit from
  17665. * @param height The height of the emission cylinder
  17666. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17669. * @returns the emitter
  17670. */
  17671. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17672. /**
  17673. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17674. * @param radius The radius of the cone to emit from
  17675. * @param angle The base angle of the cone
  17676. * @returns the emitter
  17677. */
  17678. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17679. /**
  17680. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17681. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17682. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17683. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17684. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17685. * @returns the emitter
  17686. */
  17687. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17688. }
  17689. }
  17690. declare module "babylonjs/Particles/subEmitter" {
  17691. import { Scene } from "babylonjs/scene";
  17692. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17693. /**
  17694. * Type of sub emitter
  17695. */
  17696. export enum SubEmitterType {
  17697. /**
  17698. * Attached to the particle over it's lifetime
  17699. */
  17700. ATTACHED = 0,
  17701. /**
  17702. * Created when the particle dies
  17703. */
  17704. END = 1
  17705. }
  17706. /**
  17707. * Sub emitter class used to emit particles from an existing particle
  17708. */
  17709. export class SubEmitter {
  17710. /**
  17711. * the particle system to be used by the sub emitter
  17712. */
  17713. particleSystem: ParticleSystem;
  17714. /**
  17715. * Type of the submitter (Default: END)
  17716. */
  17717. type: SubEmitterType;
  17718. /**
  17719. * 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)
  17720. * Note: This only is supported when using an emitter of type Mesh
  17721. */
  17722. inheritDirection: boolean;
  17723. /**
  17724. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17725. */
  17726. inheritedVelocityAmount: number;
  17727. /**
  17728. * Creates a sub emitter
  17729. * @param particleSystem the particle system to be used by the sub emitter
  17730. */
  17731. constructor(
  17732. /**
  17733. * the particle system to be used by the sub emitter
  17734. */
  17735. particleSystem: ParticleSystem);
  17736. /**
  17737. * Clones the sub emitter
  17738. * @returns the cloned sub emitter
  17739. */
  17740. clone(): SubEmitter;
  17741. /**
  17742. * Serialize current object to a JSON object
  17743. * @returns the serialized object
  17744. */
  17745. serialize(): any;
  17746. /** @hidden */
  17747. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17748. /**
  17749. * Creates a new SubEmitter from a serialized JSON version
  17750. * @param serializationObject defines the JSON object to read from
  17751. * @param scene defines the hosting scene
  17752. * @param rootUrl defines the rootUrl for data loading
  17753. * @returns a new SubEmitter
  17754. */
  17755. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17756. /** Release associated resources */
  17757. dispose(): void;
  17758. }
  17759. }
  17760. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17761. /** @hidden */
  17762. export var clipPlaneFragmentDeclaration: {
  17763. name: string;
  17764. shader: string;
  17765. };
  17766. }
  17767. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17768. /** @hidden */
  17769. export var imageProcessingDeclaration: {
  17770. name: string;
  17771. shader: string;
  17772. };
  17773. }
  17774. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17775. /** @hidden */
  17776. export var imageProcessingFunctions: {
  17777. name: string;
  17778. shader: string;
  17779. };
  17780. }
  17781. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17782. /** @hidden */
  17783. export var clipPlaneFragment: {
  17784. name: string;
  17785. shader: string;
  17786. };
  17787. }
  17788. declare module "babylonjs/Shaders/particles.fragment" {
  17789. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17790. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17791. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17792. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17793. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17794. /** @hidden */
  17795. export var particlesPixelShader: {
  17796. name: string;
  17797. shader: string;
  17798. };
  17799. }
  17800. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17801. /** @hidden */
  17802. export var clipPlaneVertexDeclaration: {
  17803. name: string;
  17804. shader: string;
  17805. };
  17806. }
  17807. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17808. /** @hidden */
  17809. export var clipPlaneVertex: {
  17810. name: string;
  17811. shader: string;
  17812. };
  17813. }
  17814. declare module "babylonjs/Shaders/particles.vertex" {
  17815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17816. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17817. /** @hidden */
  17818. export var particlesVertexShader: {
  17819. name: string;
  17820. shader: string;
  17821. };
  17822. }
  17823. declare module "babylonjs/Particles/particleSystem" {
  17824. import { Nullable } from "babylonjs/types";
  17825. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17826. import { Observable } from "babylonjs/Misc/observable";
  17827. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17828. import { Effect } from "babylonjs/Materials/effect";
  17829. import { Scene, IDisposable } from "babylonjs/scene";
  17830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17831. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17832. import { Particle } from "babylonjs/Particles/particle";
  17833. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17835. import "babylonjs/Shaders/particles.fragment";
  17836. import "babylonjs/Shaders/particles.vertex";
  17837. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17838. /**
  17839. * This represents a particle system in Babylon.
  17840. * 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.
  17841. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17842. * @example https://doc.babylonjs.com/babylon101/particles
  17843. */
  17844. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17845. /**
  17846. * Billboard mode will only apply to Y axis
  17847. */
  17848. static readonly BILLBOARDMODE_Y: number;
  17849. /**
  17850. * Billboard mode will apply to all axes
  17851. */
  17852. static readonly BILLBOARDMODE_ALL: number;
  17853. /**
  17854. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17855. */
  17856. static readonly BILLBOARDMODE_STRETCHED: number;
  17857. /**
  17858. * This function can be defined to provide custom update for active particles.
  17859. * This function will be called instead of regular update (age, position, color, etc.).
  17860. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17861. */
  17862. updateFunction: (particles: Particle[]) => void;
  17863. private _emitterWorldMatrix;
  17864. /**
  17865. * This function can be defined to specify initial direction for every new particle.
  17866. * It by default use the emitterType defined function
  17867. */
  17868. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17869. /**
  17870. * This function can be defined to specify initial position for every new particle.
  17871. * It by default use the emitterType defined function
  17872. */
  17873. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17874. /**
  17875. * @hidden
  17876. */
  17877. _inheritedVelocityOffset: Vector3;
  17878. /**
  17879. * An event triggered when the system is disposed
  17880. */
  17881. onDisposeObservable: Observable<ParticleSystem>;
  17882. private _onDisposeObserver;
  17883. /**
  17884. * Sets a callback that will be triggered when the system is disposed
  17885. */
  17886. set onDispose(callback: () => void);
  17887. private _particles;
  17888. private _epsilon;
  17889. private _capacity;
  17890. private _stockParticles;
  17891. private _newPartsExcess;
  17892. private _vertexData;
  17893. private _vertexBuffer;
  17894. private _vertexBuffers;
  17895. private _spriteBuffer;
  17896. private _indexBuffer;
  17897. private _effect;
  17898. private _customEffect;
  17899. private _cachedDefines;
  17900. private _scaledColorStep;
  17901. private _colorDiff;
  17902. private _scaledDirection;
  17903. private _scaledGravity;
  17904. private _currentRenderId;
  17905. private _alive;
  17906. private _useInstancing;
  17907. private _started;
  17908. private _stopped;
  17909. private _actualFrame;
  17910. private _scaledUpdateSpeed;
  17911. private _vertexBufferSize;
  17912. /** @hidden */
  17913. _currentEmitRateGradient: Nullable<FactorGradient>;
  17914. /** @hidden */
  17915. _currentEmitRate1: number;
  17916. /** @hidden */
  17917. _currentEmitRate2: number;
  17918. /** @hidden */
  17919. _currentStartSizeGradient: Nullable<FactorGradient>;
  17920. /** @hidden */
  17921. _currentStartSize1: number;
  17922. /** @hidden */
  17923. _currentStartSize2: number;
  17924. private readonly _rawTextureWidth;
  17925. private _rampGradientsTexture;
  17926. private _useRampGradients;
  17927. /** Gets or sets a boolean indicating that ramp gradients must be used
  17928. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17929. */
  17930. get useRampGradients(): boolean;
  17931. set useRampGradients(value: boolean);
  17932. /**
  17933. * 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.
  17934. * 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: [])
  17935. */
  17936. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17937. private _subEmitters;
  17938. /**
  17939. * @hidden
  17940. * If the particle systems emitter should be disposed when the particle system is disposed
  17941. */
  17942. _disposeEmitterOnDispose: boolean;
  17943. /**
  17944. * The current active Sub-systems, this property is used by the root particle system only.
  17945. */
  17946. activeSubSystems: Array<ParticleSystem>;
  17947. private _rootParticleSystem;
  17948. /**
  17949. * Gets the current list of active particles
  17950. */
  17951. get particles(): Particle[];
  17952. /**
  17953. * Returns the string "ParticleSystem"
  17954. * @returns a string containing the class name
  17955. */
  17956. getClassName(): string;
  17957. /**
  17958. * Instantiates a particle system.
  17959. * 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.
  17960. * @param name The name of the particle system
  17961. * @param capacity The max number of particles alive at the same time
  17962. * @param scene The scene the particle system belongs to
  17963. * @param customEffect a custom effect used to change the way particles are rendered by default
  17964. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17965. * @param epsilon Offset used to render the particles
  17966. */
  17967. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17968. private _addFactorGradient;
  17969. private _removeFactorGradient;
  17970. /**
  17971. * Adds a new life time gradient
  17972. * @param gradient defines the gradient to use (between 0 and 1)
  17973. * @param factor defines the life time factor to affect to the specified gradient
  17974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17975. * @returns the current particle system
  17976. */
  17977. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17978. /**
  17979. * Remove a specific life time gradient
  17980. * @param gradient defines the gradient to remove
  17981. * @returns the current particle system
  17982. */
  17983. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17984. /**
  17985. * Adds a new size gradient
  17986. * @param gradient defines the gradient to use (between 0 and 1)
  17987. * @param factor defines the size factor to affect to the specified gradient
  17988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17989. * @returns the current particle system
  17990. */
  17991. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17992. /**
  17993. * Remove a specific size gradient
  17994. * @param gradient defines the gradient to remove
  17995. * @returns the current particle system
  17996. */
  17997. removeSizeGradient(gradient: number): IParticleSystem;
  17998. /**
  17999. * Adds a new color remap gradient
  18000. * @param gradient defines the gradient to use (between 0 and 1)
  18001. * @param min defines the color remap minimal range
  18002. * @param max defines the color remap maximal range
  18003. * @returns the current particle system
  18004. */
  18005. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18006. /**
  18007. * Remove a specific color remap gradient
  18008. * @param gradient defines the gradient to remove
  18009. * @returns the current particle system
  18010. */
  18011. removeColorRemapGradient(gradient: number): IParticleSystem;
  18012. /**
  18013. * Adds a new alpha remap gradient
  18014. * @param gradient defines the gradient to use (between 0 and 1)
  18015. * @param min defines the alpha remap minimal range
  18016. * @param max defines the alpha remap maximal range
  18017. * @returns the current particle system
  18018. */
  18019. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18020. /**
  18021. * Remove a specific alpha remap gradient
  18022. * @param gradient defines the gradient to remove
  18023. * @returns the current particle system
  18024. */
  18025. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18026. /**
  18027. * Adds a new angular speed gradient
  18028. * @param gradient defines the gradient to use (between 0 and 1)
  18029. * @param factor defines the angular speed to affect to the specified gradient
  18030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18031. * @returns the current particle system
  18032. */
  18033. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18034. /**
  18035. * Remove a specific angular speed gradient
  18036. * @param gradient defines the gradient to remove
  18037. * @returns the current particle system
  18038. */
  18039. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18040. /**
  18041. * Adds a new velocity gradient
  18042. * @param gradient defines the gradient to use (between 0 and 1)
  18043. * @param factor defines the velocity to affect to the specified gradient
  18044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18045. * @returns the current particle system
  18046. */
  18047. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18048. /**
  18049. * Remove a specific velocity gradient
  18050. * @param gradient defines the gradient to remove
  18051. * @returns the current particle system
  18052. */
  18053. removeVelocityGradient(gradient: number): IParticleSystem;
  18054. /**
  18055. * Adds a new limit velocity gradient
  18056. * @param gradient defines the gradient to use (between 0 and 1)
  18057. * @param factor defines the limit velocity value to affect to the specified gradient
  18058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18059. * @returns the current particle system
  18060. */
  18061. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18062. /**
  18063. * Remove a specific limit velocity gradient
  18064. * @param gradient defines the gradient to remove
  18065. * @returns the current particle system
  18066. */
  18067. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18068. /**
  18069. * Adds a new drag gradient
  18070. * @param gradient defines the gradient to use (between 0 and 1)
  18071. * @param factor defines the drag value to affect to the specified gradient
  18072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18073. * @returns the current particle system
  18074. */
  18075. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18076. /**
  18077. * Remove a specific drag gradient
  18078. * @param gradient defines the gradient to remove
  18079. * @returns the current particle system
  18080. */
  18081. removeDragGradient(gradient: number): IParticleSystem;
  18082. /**
  18083. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18084. * @param gradient defines the gradient to use (between 0 and 1)
  18085. * @param factor defines the emit rate value to affect to the specified gradient
  18086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18087. * @returns the current particle system
  18088. */
  18089. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18090. /**
  18091. * Remove a specific emit rate gradient
  18092. * @param gradient defines the gradient to remove
  18093. * @returns the current particle system
  18094. */
  18095. removeEmitRateGradient(gradient: number): IParticleSystem;
  18096. /**
  18097. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18098. * @param gradient defines the gradient to use (between 0 and 1)
  18099. * @param factor defines the start size value to affect to the specified gradient
  18100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18101. * @returns the current particle system
  18102. */
  18103. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18104. /**
  18105. * Remove a specific start size gradient
  18106. * @param gradient defines the gradient to remove
  18107. * @returns the current particle system
  18108. */
  18109. removeStartSizeGradient(gradient: number): IParticleSystem;
  18110. private _createRampGradientTexture;
  18111. /**
  18112. * Gets the current list of ramp gradients.
  18113. * You must use addRampGradient and removeRampGradient to udpate this list
  18114. * @returns the list of ramp gradients
  18115. */
  18116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18117. /**
  18118. * Adds a new ramp gradient used to remap particle colors
  18119. * @param gradient defines the gradient to use (between 0 and 1)
  18120. * @param color defines the color to affect to the specified gradient
  18121. * @returns the current particle system
  18122. */
  18123. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18124. /**
  18125. * Remove a specific ramp gradient
  18126. * @param gradient defines the gradient to remove
  18127. * @returns the current particle system
  18128. */
  18129. removeRampGradient(gradient: number): ParticleSystem;
  18130. /**
  18131. * Adds a new color gradient
  18132. * @param gradient defines the gradient to use (between 0 and 1)
  18133. * @param color1 defines the color to affect to the specified gradient
  18134. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18135. * @returns this particle system
  18136. */
  18137. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18138. /**
  18139. * Remove a specific color gradient
  18140. * @param gradient defines the gradient to remove
  18141. * @returns this particle system
  18142. */
  18143. removeColorGradient(gradient: number): IParticleSystem;
  18144. private _fetchR;
  18145. protected _reset(): void;
  18146. private _resetEffect;
  18147. private _createVertexBuffers;
  18148. private _createIndexBuffer;
  18149. /**
  18150. * Gets the maximum number of particles active at the same time.
  18151. * @returns The max number of active particles.
  18152. */
  18153. getCapacity(): number;
  18154. /**
  18155. * Gets whether there are still active particles in the system.
  18156. * @returns True if it is alive, otherwise false.
  18157. */
  18158. isAlive(): boolean;
  18159. /**
  18160. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18161. * @returns True if it has been started, otherwise false.
  18162. */
  18163. isStarted(): boolean;
  18164. private _prepareSubEmitterInternalArray;
  18165. /**
  18166. * Starts the particle system and begins to emit
  18167. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18168. */
  18169. start(delay?: number): void;
  18170. /**
  18171. * Stops the particle system.
  18172. * @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.
  18173. */
  18174. stop(stopSubEmitters?: boolean): void;
  18175. /**
  18176. * Remove all active particles
  18177. */
  18178. reset(): void;
  18179. /**
  18180. * @hidden (for internal use only)
  18181. */
  18182. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18183. /**
  18184. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18185. * Its lifetime will start back at 0.
  18186. */
  18187. recycleParticle: (particle: Particle) => void;
  18188. private _stopSubEmitters;
  18189. private _createParticle;
  18190. private _removeFromRoot;
  18191. private _emitFromParticle;
  18192. private _update;
  18193. /** @hidden */
  18194. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18195. /** @hidden */
  18196. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18197. /** @hidden */
  18198. private _getEffect;
  18199. /**
  18200. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18201. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18202. */
  18203. animate(preWarmOnly?: boolean): void;
  18204. private _appendParticleVertices;
  18205. /**
  18206. * Rebuilds the particle system.
  18207. */
  18208. rebuild(): void;
  18209. /**
  18210. * Is this system ready to be used/rendered
  18211. * @return true if the system is ready
  18212. */
  18213. isReady(): boolean;
  18214. private _render;
  18215. /**
  18216. * Renders the particle system in its current state.
  18217. * @returns the current number of particles
  18218. */
  18219. render(): number;
  18220. /**
  18221. * Disposes the particle system and free the associated resources
  18222. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18223. */
  18224. dispose(disposeTexture?: boolean): void;
  18225. /**
  18226. * Clones the particle system.
  18227. * @param name The name of the cloned object
  18228. * @param newEmitter The new emitter to use
  18229. * @returns the cloned particle system
  18230. */
  18231. clone(name: string, newEmitter: any): ParticleSystem;
  18232. /**
  18233. * Serializes the particle system to a JSON object.
  18234. * @returns the JSON object
  18235. */
  18236. serialize(): any;
  18237. /** @hidden */
  18238. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18239. /** @hidden */
  18240. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18241. /**
  18242. * Parses a JSON object to create a particle system.
  18243. * @param parsedParticleSystem The JSON object to parse
  18244. * @param scene The scene to create the particle system in
  18245. * @param rootUrl The root url to use to load external dependencies like texture
  18246. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18247. * @returns the Parsed particle system
  18248. */
  18249. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18250. }
  18251. }
  18252. declare module "babylonjs/Particles/particle" {
  18253. import { Nullable } from "babylonjs/types";
  18254. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18255. import { Color4 } from "babylonjs/Maths/math.color";
  18256. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18257. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18258. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18259. /**
  18260. * A particle represents one of the element emitted by a particle system.
  18261. * This is mainly define by its coordinates, direction, velocity and age.
  18262. */
  18263. export class Particle {
  18264. /**
  18265. * The particle system the particle belongs to.
  18266. */
  18267. particleSystem: ParticleSystem;
  18268. private static _Count;
  18269. /**
  18270. * Unique ID of the particle
  18271. */
  18272. id: number;
  18273. /**
  18274. * The world position of the particle in the scene.
  18275. */
  18276. position: Vector3;
  18277. /**
  18278. * The world direction of the particle in the scene.
  18279. */
  18280. direction: Vector3;
  18281. /**
  18282. * The color of the particle.
  18283. */
  18284. color: Color4;
  18285. /**
  18286. * The color change of the particle per step.
  18287. */
  18288. colorStep: Color4;
  18289. /**
  18290. * Defines how long will the life of the particle be.
  18291. */
  18292. lifeTime: number;
  18293. /**
  18294. * The current age of the particle.
  18295. */
  18296. age: number;
  18297. /**
  18298. * The current size of the particle.
  18299. */
  18300. size: number;
  18301. /**
  18302. * The current scale of the particle.
  18303. */
  18304. scale: Vector2;
  18305. /**
  18306. * The current angle of the particle.
  18307. */
  18308. angle: number;
  18309. /**
  18310. * Defines how fast is the angle changing.
  18311. */
  18312. angularSpeed: number;
  18313. /**
  18314. * Defines the cell index used by the particle to be rendered from a sprite.
  18315. */
  18316. cellIndex: number;
  18317. /**
  18318. * The information required to support color remapping
  18319. */
  18320. remapData: Vector4;
  18321. /** @hidden */
  18322. _randomCellOffset?: number;
  18323. /** @hidden */
  18324. _initialDirection: Nullable<Vector3>;
  18325. /** @hidden */
  18326. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18327. /** @hidden */
  18328. _initialStartSpriteCellID: number;
  18329. /** @hidden */
  18330. _initialEndSpriteCellID: number;
  18331. /** @hidden */
  18332. _currentColorGradient: Nullable<ColorGradient>;
  18333. /** @hidden */
  18334. _currentColor1: Color4;
  18335. /** @hidden */
  18336. _currentColor2: Color4;
  18337. /** @hidden */
  18338. _currentSizeGradient: Nullable<FactorGradient>;
  18339. /** @hidden */
  18340. _currentSize1: number;
  18341. /** @hidden */
  18342. _currentSize2: number;
  18343. /** @hidden */
  18344. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18345. /** @hidden */
  18346. _currentAngularSpeed1: number;
  18347. /** @hidden */
  18348. _currentAngularSpeed2: number;
  18349. /** @hidden */
  18350. _currentVelocityGradient: Nullable<FactorGradient>;
  18351. /** @hidden */
  18352. _currentVelocity1: number;
  18353. /** @hidden */
  18354. _currentVelocity2: number;
  18355. /** @hidden */
  18356. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18357. /** @hidden */
  18358. _currentLimitVelocity1: number;
  18359. /** @hidden */
  18360. _currentLimitVelocity2: number;
  18361. /** @hidden */
  18362. _currentDragGradient: Nullable<FactorGradient>;
  18363. /** @hidden */
  18364. _currentDrag1: number;
  18365. /** @hidden */
  18366. _currentDrag2: number;
  18367. /** @hidden */
  18368. _randomNoiseCoordinates1: Vector3;
  18369. /** @hidden */
  18370. _randomNoiseCoordinates2: Vector3;
  18371. /**
  18372. * Creates a new instance Particle
  18373. * @param particleSystem the particle system the particle belongs to
  18374. */
  18375. constructor(
  18376. /**
  18377. * The particle system the particle belongs to.
  18378. */
  18379. particleSystem: ParticleSystem);
  18380. private updateCellInfoFromSystem;
  18381. /**
  18382. * Defines how the sprite cell index is updated for the particle
  18383. */
  18384. updateCellIndex(): void;
  18385. /** @hidden */
  18386. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18387. /** @hidden */
  18388. _inheritParticleInfoToSubEmitters(): void;
  18389. /** @hidden */
  18390. _reset(): void;
  18391. /**
  18392. * Copy the properties of particle to another one.
  18393. * @param other the particle to copy the information to.
  18394. */
  18395. copyTo(other: Particle): void;
  18396. }
  18397. }
  18398. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18399. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18400. import { Effect } from "babylonjs/Materials/effect";
  18401. import { Particle } from "babylonjs/Particles/particle";
  18402. /**
  18403. * Particle emitter represents a volume emitting particles.
  18404. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18405. */
  18406. export interface IParticleEmitterType {
  18407. /**
  18408. * Called by the particle System when the direction is computed for the created particle.
  18409. * @param worldMatrix is the world matrix of the particle system
  18410. * @param directionToUpdate is the direction vector to update with the result
  18411. * @param particle is the particle we are computed the direction for
  18412. */
  18413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18414. /**
  18415. * Called by the particle System when the position is computed for the created particle.
  18416. * @param worldMatrix is the world matrix of the particle system
  18417. * @param positionToUpdate is the position vector to update with the result
  18418. * @param particle is the particle we are computed the position for
  18419. */
  18420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18421. /**
  18422. * Clones the current emitter and returns a copy of it
  18423. * @returns the new emitter
  18424. */
  18425. clone(): IParticleEmitterType;
  18426. /**
  18427. * Called by the GPUParticleSystem to setup the update shader
  18428. * @param effect defines the update shader
  18429. */
  18430. applyToShader(effect: Effect): void;
  18431. /**
  18432. * Returns a string to use to update the GPU particles update shader
  18433. * @returns the effect defines string
  18434. */
  18435. getEffectDefines(): string;
  18436. /**
  18437. * Returns a string representing the class name
  18438. * @returns a string containing the class name
  18439. */
  18440. getClassName(): string;
  18441. /**
  18442. * Serializes the particle system to a JSON object.
  18443. * @returns the JSON object
  18444. */
  18445. serialize(): any;
  18446. /**
  18447. * Parse properties from a JSON object
  18448. * @param serializationObject defines the JSON object
  18449. */
  18450. parse(serializationObject: any): void;
  18451. }
  18452. }
  18453. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18454. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18455. import { Effect } from "babylonjs/Materials/effect";
  18456. import { Particle } from "babylonjs/Particles/particle";
  18457. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18458. /**
  18459. * Particle emitter emitting particles from the inside of a box.
  18460. * It emits the particles randomly between 2 given directions.
  18461. */
  18462. export class BoxParticleEmitter implements IParticleEmitterType {
  18463. /**
  18464. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18465. */
  18466. direction1: Vector3;
  18467. /**
  18468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18469. */
  18470. direction2: Vector3;
  18471. /**
  18472. * 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.
  18473. */
  18474. minEmitBox: Vector3;
  18475. /**
  18476. * 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.
  18477. */
  18478. maxEmitBox: Vector3;
  18479. /**
  18480. * Creates a new instance BoxParticleEmitter
  18481. */
  18482. constructor();
  18483. /**
  18484. * Called by the particle System when the direction is computed for the created particle.
  18485. * @param worldMatrix is the world matrix of the particle system
  18486. * @param directionToUpdate is the direction vector to update with the result
  18487. * @param particle is the particle we are computed the direction for
  18488. */
  18489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18490. /**
  18491. * Called by the particle System when the position is computed for the created particle.
  18492. * @param worldMatrix is the world matrix of the particle system
  18493. * @param positionToUpdate is the position vector to update with the result
  18494. * @param particle is the particle we are computed the position for
  18495. */
  18496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18497. /**
  18498. * Clones the current emitter and returns a copy of it
  18499. * @returns the new emitter
  18500. */
  18501. clone(): BoxParticleEmitter;
  18502. /**
  18503. * Called by the GPUParticleSystem to setup the update shader
  18504. * @param effect defines the update shader
  18505. */
  18506. applyToShader(effect: Effect): void;
  18507. /**
  18508. * Returns a string to use to update the GPU particles update shader
  18509. * @returns a string containng the defines string
  18510. */
  18511. getEffectDefines(): string;
  18512. /**
  18513. * Returns the string "BoxParticleEmitter"
  18514. * @returns a string containing the class name
  18515. */
  18516. getClassName(): string;
  18517. /**
  18518. * Serializes the particle system to a JSON object.
  18519. * @returns the JSON object
  18520. */
  18521. serialize(): any;
  18522. /**
  18523. * Parse properties from a JSON object
  18524. * @param serializationObject defines the JSON object
  18525. */
  18526. parse(serializationObject: any): void;
  18527. }
  18528. }
  18529. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18530. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18531. import { Effect } from "babylonjs/Materials/effect";
  18532. import { Particle } from "babylonjs/Particles/particle";
  18533. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18534. /**
  18535. * Particle emitter emitting particles from the inside of a cone.
  18536. * It emits the particles alongside the cone volume from the base to the particle.
  18537. * The emission direction might be randomized.
  18538. */
  18539. export class ConeParticleEmitter implements IParticleEmitterType {
  18540. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18541. directionRandomizer: number;
  18542. private _radius;
  18543. private _angle;
  18544. private _height;
  18545. /**
  18546. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18547. */
  18548. radiusRange: number;
  18549. /**
  18550. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18551. */
  18552. heightRange: number;
  18553. /**
  18554. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18555. */
  18556. emitFromSpawnPointOnly: boolean;
  18557. /**
  18558. * Gets or sets the radius of the emission cone
  18559. */
  18560. get radius(): number;
  18561. set radius(value: number);
  18562. /**
  18563. * Gets or sets the angle of the emission cone
  18564. */
  18565. get angle(): number;
  18566. set angle(value: number);
  18567. private _buildHeight;
  18568. /**
  18569. * Creates a new instance ConeParticleEmitter
  18570. * @param radius the radius of the emission cone (1 by default)
  18571. * @param angle the cone base angle (PI by default)
  18572. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18573. */
  18574. constructor(radius?: number, angle?: number,
  18575. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18576. directionRandomizer?: number);
  18577. /**
  18578. * Called by the particle System when the direction is computed for the created particle.
  18579. * @param worldMatrix is the world matrix of the particle system
  18580. * @param directionToUpdate is the direction vector to update with the result
  18581. * @param particle is the particle we are computed the direction for
  18582. */
  18583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18584. /**
  18585. * Called by the particle System when the position is computed for the created particle.
  18586. * @param worldMatrix is the world matrix of the particle system
  18587. * @param positionToUpdate is the position vector to update with the result
  18588. * @param particle is the particle we are computed the position for
  18589. */
  18590. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18591. /**
  18592. * Clones the current emitter and returns a copy of it
  18593. * @returns the new emitter
  18594. */
  18595. clone(): ConeParticleEmitter;
  18596. /**
  18597. * Called by the GPUParticleSystem to setup the update shader
  18598. * @param effect defines the update shader
  18599. */
  18600. applyToShader(effect: Effect): void;
  18601. /**
  18602. * Returns a string to use to update the GPU particles update shader
  18603. * @returns a string containng the defines string
  18604. */
  18605. getEffectDefines(): string;
  18606. /**
  18607. * Returns the string "ConeParticleEmitter"
  18608. * @returns a string containing the class name
  18609. */
  18610. getClassName(): string;
  18611. /**
  18612. * Serializes the particle system to a JSON object.
  18613. * @returns the JSON object
  18614. */
  18615. serialize(): any;
  18616. /**
  18617. * Parse properties from a JSON object
  18618. * @param serializationObject defines the JSON object
  18619. */
  18620. parse(serializationObject: any): void;
  18621. }
  18622. }
  18623. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18624. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18625. import { Effect } from "babylonjs/Materials/effect";
  18626. import { Particle } from "babylonjs/Particles/particle";
  18627. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18628. /**
  18629. * Particle emitter emitting particles from the inside of a cylinder.
  18630. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18631. */
  18632. export class CylinderParticleEmitter implements IParticleEmitterType {
  18633. /**
  18634. * The radius of the emission cylinder.
  18635. */
  18636. radius: number;
  18637. /**
  18638. * The height of the emission cylinder.
  18639. */
  18640. height: number;
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange: number;
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer: number;
  18649. /**
  18650. * Creates a new instance CylinderParticleEmitter
  18651. * @param radius the radius of the emission cylinder (1 by default)
  18652. * @param height the height of the emission cylinder (1 by default)
  18653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18654. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18655. */
  18656. constructor(
  18657. /**
  18658. * The radius of the emission cylinder.
  18659. */
  18660. radius?: number,
  18661. /**
  18662. * The height of the emission cylinder.
  18663. */
  18664. height?: number,
  18665. /**
  18666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18667. */
  18668. radiusRange?: number,
  18669. /**
  18670. * How much to randomize the particle direction [0-1].
  18671. */
  18672. directionRandomizer?: number);
  18673. /**
  18674. * Called by the particle System when the direction is computed for the created particle.
  18675. * @param worldMatrix is the world matrix of the particle system
  18676. * @param directionToUpdate is the direction vector to update with the result
  18677. * @param particle is the particle we are computed the direction for
  18678. */
  18679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18680. /**
  18681. * Called by the particle System when the position is computed for the created particle.
  18682. * @param worldMatrix is the world matrix of the particle system
  18683. * @param positionToUpdate is the position vector to update with the result
  18684. * @param particle is the particle we are computed the position for
  18685. */
  18686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18687. /**
  18688. * Clones the current emitter and returns a copy of it
  18689. * @returns the new emitter
  18690. */
  18691. clone(): CylinderParticleEmitter;
  18692. /**
  18693. * Called by the GPUParticleSystem to setup the update shader
  18694. * @param effect defines the update shader
  18695. */
  18696. applyToShader(effect: Effect): void;
  18697. /**
  18698. * Returns a string to use to update the GPU particles update shader
  18699. * @returns a string containng the defines string
  18700. */
  18701. getEffectDefines(): string;
  18702. /**
  18703. * Returns the string "CylinderParticleEmitter"
  18704. * @returns a string containing the class name
  18705. */
  18706. getClassName(): string;
  18707. /**
  18708. * Serializes the particle system to a JSON object.
  18709. * @returns the JSON object
  18710. */
  18711. serialize(): any;
  18712. /**
  18713. * Parse properties from a JSON object
  18714. * @param serializationObject defines the JSON object
  18715. */
  18716. parse(serializationObject: any): void;
  18717. }
  18718. /**
  18719. * Particle emitter emitting particles from the inside of a cylinder.
  18720. * It emits the particles randomly between two vectors.
  18721. */
  18722. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18723. /**
  18724. * The min limit of the emission direction.
  18725. */
  18726. direction1: Vector3;
  18727. /**
  18728. * The max limit of the emission direction.
  18729. */
  18730. direction2: Vector3;
  18731. /**
  18732. * Creates a new instance CylinderDirectedParticleEmitter
  18733. * @param radius the radius of the emission cylinder (1 by default)
  18734. * @param height the height of the emission cylinder (1 by default)
  18735. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18736. * @param direction1 the min limit of the emission direction (up vector by default)
  18737. * @param direction2 the max limit of the emission direction (up vector by default)
  18738. */
  18739. constructor(radius?: number, height?: number, radiusRange?: number,
  18740. /**
  18741. * The min limit of the emission direction.
  18742. */
  18743. direction1?: Vector3,
  18744. /**
  18745. * The max limit of the emission direction.
  18746. */
  18747. direction2?: Vector3);
  18748. /**
  18749. * Called by the particle System when the direction is computed for the created particle.
  18750. * @param worldMatrix is the world matrix of the particle system
  18751. * @param directionToUpdate is the direction vector to update with the result
  18752. * @param particle is the particle we are computed the direction for
  18753. */
  18754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18755. /**
  18756. * Clones the current emitter and returns a copy of it
  18757. * @returns the new emitter
  18758. */
  18759. clone(): CylinderDirectedParticleEmitter;
  18760. /**
  18761. * Called by the GPUParticleSystem to setup the update shader
  18762. * @param effect defines the update shader
  18763. */
  18764. applyToShader(effect: Effect): void;
  18765. /**
  18766. * Returns a string to use to update the GPU particles update shader
  18767. * @returns a string containng the defines string
  18768. */
  18769. getEffectDefines(): string;
  18770. /**
  18771. * Returns the string "CylinderDirectedParticleEmitter"
  18772. * @returns a string containing the class name
  18773. */
  18774. getClassName(): string;
  18775. /**
  18776. * Serializes the particle system to a JSON object.
  18777. * @returns the JSON object
  18778. */
  18779. serialize(): any;
  18780. /**
  18781. * Parse properties from a JSON object
  18782. * @param serializationObject defines the JSON object
  18783. */
  18784. parse(serializationObject: any): void;
  18785. }
  18786. }
  18787. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18788. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18789. import { Effect } from "babylonjs/Materials/effect";
  18790. import { Particle } from "babylonjs/Particles/particle";
  18791. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18792. /**
  18793. * Particle emitter emitting particles from the inside of a hemisphere.
  18794. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18795. */
  18796. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18797. /**
  18798. * The radius of the emission hemisphere.
  18799. */
  18800. radius: number;
  18801. /**
  18802. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18803. */
  18804. radiusRange: number;
  18805. /**
  18806. * How much to randomize the particle direction [0-1].
  18807. */
  18808. directionRandomizer: number;
  18809. /**
  18810. * Creates a new instance HemisphericParticleEmitter
  18811. * @param radius the radius of the emission hemisphere (1 by default)
  18812. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18813. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18814. */
  18815. constructor(
  18816. /**
  18817. * The radius of the emission hemisphere.
  18818. */
  18819. radius?: number,
  18820. /**
  18821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18822. */
  18823. radiusRange?: number,
  18824. /**
  18825. * How much to randomize the particle direction [0-1].
  18826. */
  18827. directionRandomizer?: number);
  18828. /**
  18829. * Called by the particle System when the direction is computed for the created particle.
  18830. * @param worldMatrix is the world matrix of the particle system
  18831. * @param directionToUpdate is the direction vector to update with the result
  18832. * @param particle is the particle we are computed the direction for
  18833. */
  18834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18835. /**
  18836. * Called by the particle System when the position is computed for the created particle.
  18837. * @param worldMatrix is the world matrix of the particle system
  18838. * @param positionToUpdate is the position vector to update with the result
  18839. * @param particle is the particle we are computed the position for
  18840. */
  18841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18842. /**
  18843. * Clones the current emitter and returns a copy of it
  18844. * @returns the new emitter
  18845. */
  18846. clone(): HemisphericParticleEmitter;
  18847. /**
  18848. * Called by the GPUParticleSystem to setup the update shader
  18849. * @param effect defines the update shader
  18850. */
  18851. applyToShader(effect: Effect): void;
  18852. /**
  18853. * Returns a string to use to update the GPU particles update shader
  18854. * @returns a string containng the defines string
  18855. */
  18856. getEffectDefines(): string;
  18857. /**
  18858. * Returns the string "HemisphericParticleEmitter"
  18859. * @returns a string containing the class name
  18860. */
  18861. getClassName(): string;
  18862. /**
  18863. * Serializes the particle system to a JSON object.
  18864. * @returns the JSON object
  18865. */
  18866. serialize(): any;
  18867. /**
  18868. * Parse properties from a JSON object
  18869. * @param serializationObject defines the JSON object
  18870. */
  18871. parse(serializationObject: any): void;
  18872. }
  18873. }
  18874. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18875. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18876. import { Effect } from "babylonjs/Materials/effect";
  18877. import { Particle } from "babylonjs/Particles/particle";
  18878. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18879. /**
  18880. * Particle emitter emitting particles from a point.
  18881. * It emits the particles randomly between 2 given directions.
  18882. */
  18883. export class PointParticleEmitter implements IParticleEmitterType {
  18884. /**
  18885. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18886. */
  18887. direction1: Vector3;
  18888. /**
  18889. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18890. */
  18891. direction2: Vector3;
  18892. /**
  18893. * Creates a new instance PointParticleEmitter
  18894. */
  18895. constructor();
  18896. /**
  18897. * Called by the particle System when the direction is computed for the created particle.
  18898. * @param worldMatrix is the world matrix of the particle system
  18899. * @param directionToUpdate is the direction vector to update with the result
  18900. * @param particle is the particle we are computed the direction for
  18901. */
  18902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18903. /**
  18904. * Called by the particle System when the position is computed for the created particle.
  18905. * @param worldMatrix is the world matrix of the particle system
  18906. * @param positionToUpdate is the position vector to update with the result
  18907. * @param particle is the particle we are computed the position for
  18908. */
  18909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18910. /**
  18911. * Clones the current emitter and returns a copy of it
  18912. * @returns the new emitter
  18913. */
  18914. clone(): PointParticleEmitter;
  18915. /**
  18916. * Called by the GPUParticleSystem to setup the update shader
  18917. * @param effect defines the update shader
  18918. */
  18919. applyToShader(effect: Effect): void;
  18920. /**
  18921. * Returns a string to use to update the GPU particles update shader
  18922. * @returns a string containng the defines string
  18923. */
  18924. getEffectDefines(): string;
  18925. /**
  18926. * Returns the string "PointParticleEmitter"
  18927. * @returns a string containing the class name
  18928. */
  18929. getClassName(): string;
  18930. /**
  18931. * Serializes the particle system to a JSON object.
  18932. * @returns the JSON object
  18933. */
  18934. serialize(): any;
  18935. /**
  18936. * Parse properties from a JSON object
  18937. * @param serializationObject defines the JSON object
  18938. */
  18939. parse(serializationObject: any): void;
  18940. }
  18941. }
  18942. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18943. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18944. import { Effect } from "babylonjs/Materials/effect";
  18945. import { Particle } from "babylonjs/Particles/particle";
  18946. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18947. /**
  18948. * Particle emitter emitting particles from the inside of a sphere.
  18949. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18950. */
  18951. export class SphereParticleEmitter implements IParticleEmitterType {
  18952. /**
  18953. * The radius of the emission sphere.
  18954. */
  18955. radius: number;
  18956. /**
  18957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18958. */
  18959. radiusRange: number;
  18960. /**
  18961. * How much to randomize the particle direction [0-1].
  18962. */
  18963. directionRandomizer: number;
  18964. /**
  18965. * Creates a new instance SphereParticleEmitter
  18966. * @param radius the radius of the emission sphere (1 by default)
  18967. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18968. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18969. */
  18970. constructor(
  18971. /**
  18972. * The radius of the emission sphere.
  18973. */
  18974. radius?: number,
  18975. /**
  18976. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18977. */
  18978. radiusRange?: number,
  18979. /**
  18980. * How much to randomize the particle direction [0-1].
  18981. */
  18982. directionRandomizer?: number);
  18983. /**
  18984. * Called by the particle System when the direction is computed for the created particle.
  18985. * @param worldMatrix is the world matrix of the particle system
  18986. * @param directionToUpdate is the direction vector to update with the result
  18987. * @param particle is the particle we are computed the direction for
  18988. */
  18989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18990. /**
  18991. * Called by the particle System when the position is computed for the created particle.
  18992. * @param worldMatrix is the world matrix of the particle system
  18993. * @param positionToUpdate is the position vector to update with the result
  18994. * @param particle is the particle we are computed the position for
  18995. */
  18996. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18997. /**
  18998. * Clones the current emitter and returns a copy of it
  18999. * @returns the new emitter
  19000. */
  19001. clone(): SphereParticleEmitter;
  19002. /**
  19003. * Called by the GPUParticleSystem to setup the update shader
  19004. * @param effect defines the update shader
  19005. */
  19006. applyToShader(effect: Effect): void;
  19007. /**
  19008. * Returns a string to use to update the GPU particles update shader
  19009. * @returns a string containng the defines string
  19010. */
  19011. getEffectDefines(): string;
  19012. /**
  19013. * Returns the string "SphereParticleEmitter"
  19014. * @returns a string containing the class name
  19015. */
  19016. getClassName(): string;
  19017. /**
  19018. * Serializes the particle system to a JSON object.
  19019. * @returns the JSON object
  19020. */
  19021. serialize(): any;
  19022. /**
  19023. * Parse properties from a JSON object
  19024. * @param serializationObject defines the JSON object
  19025. */
  19026. parse(serializationObject: any): void;
  19027. }
  19028. /**
  19029. * Particle emitter emitting particles from the inside of a sphere.
  19030. * It emits the particles randomly between two vectors.
  19031. */
  19032. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19033. /**
  19034. * The min limit of the emission direction.
  19035. */
  19036. direction1: Vector3;
  19037. /**
  19038. * The max limit of the emission direction.
  19039. */
  19040. direction2: Vector3;
  19041. /**
  19042. * Creates a new instance SphereDirectedParticleEmitter
  19043. * @param radius the radius of the emission sphere (1 by default)
  19044. * @param direction1 the min limit of the emission direction (up vector by default)
  19045. * @param direction2 the max limit of the emission direction (up vector by default)
  19046. */
  19047. constructor(radius?: number,
  19048. /**
  19049. * The min limit of the emission direction.
  19050. */
  19051. direction1?: Vector3,
  19052. /**
  19053. * The max limit of the emission direction.
  19054. */
  19055. direction2?: Vector3);
  19056. /**
  19057. * Called by the particle System when the direction is computed for the created particle.
  19058. * @param worldMatrix is the world matrix of the particle system
  19059. * @param directionToUpdate is the direction vector to update with the result
  19060. * @param particle is the particle we are computed the direction for
  19061. */
  19062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19063. /**
  19064. * Clones the current emitter and returns a copy of it
  19065. * @returns the new emitter
  19066. */
  19067. clone(): SphereDirectedParticleEmitter;
  19068. /**
  19069. * Called by the GPUParticleSystem to setup the update shader
  19070. * @param effect defines the update shader
  19071. */
  19072. applyToShader(effect: Effect): void;
  19073. /**
  19074. * Returns a string to use to update the GPU particles update shader
  19075. * @returns a string containng the defines string
  19076. */
  19077. getEffectDefines(): string;
  19078. /**
  19079. * Returns the string "SphereDirectedParticleEmitter"
  19080. * @returns a string containing the class name
  19081. */
  19082. getClassName(): string;
  19083. /**
  19084. * Serializes the particle system to a JSON object.
  19085. * @returns the JSON object
  19086. */
  19087. serialize(): any;
  19088. /**
  19089. * Parse properties from a JSON object
  19090. * @param serializationObject defines the JSON object
  19091. */
  19092. parse(serializationObject: any): void;
  19093. }
  19094. }
  19095. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  19096. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19097. import { Effect } from "babylonjs/Materials/effect";
  19098. import { Particle } from "babylonjs/Particles/particle";
  19099. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19100. import { Nullable } from "babylonjs/types";
  19101. /**
  19102. * Particle emitter emitting particles from a custom list of positions.
  19103. */
  19104. export class CustomParticleEmitter implements IParticleEmitterType {
  19105. /**
  19106. * Gets or sets the position generator that will create the inital position of each particle.
  19107. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19108. */
  19109. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  19110. /**
  19111. * Gets or sets the destination generator that will create the final destination of each particle.
  19112. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19113. */
  19114. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  19115. /**
  19116. * Creates a new instance CustomParticleEmitter
  19117. */
  19118. constructor();
  19119. /**
  19120. * Called by the particle System when the direction is computed for the created particle.
  19121. * @param worldMatrix is the world matrix of the particle system
  19122. * @param directionToUpdate is the direction vector to update with the result
  19123. * @param particle is the particle we are computed the direction for
  19124. */
  19125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19126. /**
  19127. * Called by the particle System when the position is computed for the created particle.
  19128. * @param worldMatrix is the world matrix of the particle system
  19129. * @param positionToUpdate is the position vector to update with the result
  19130. * @param particle is the particle we are computed the position for
  19131. */
  19132. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19133. /**
  19134. * Clones the current emitter and returns a copy of it
  19135. * @returns the new emitter
  19136. */
  19137. clone(): CustomParticleEmitter;
  19138. /**
  19139. * Called by the GPUParticleSystem to setup the update shader
  19140. * @param effect defines the update shader
  19141. */
  19142. applyToShader(effect: Effect): void;
  19143. /**
  19144. * Returns a string to use to update the GPU particles update shader
  19145. * @returns a string containng the defines string
  19146. */
  19147. getEffectDefines(): string;
  19148. /**
  19149. * Returns the string "PointParticleEmitter"
  19150. * @returns a string containing the class name
  19151. */
  19152. getClassName(): string;
  19153. /**
  19154. * Serializes the particle system to a JSON object.
  19155. * @returns the JSON object
  19156. */
  19157. serialize(): any;
  19158. /**
  19159. * Parse properties from a JSON object
  19160. * @param serializationObject defines the JSON object
  19161. */
  19162. parse(serializationObject: any): void;
  19163. }
  19164. }
  19165. declare module "babylonjs/Particles/EmitterTypes/index" {
  19166. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19167. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19168. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19169. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19170. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19171. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19172. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19173. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  19174. }
  19175. declare module "babylonjs/Particles/IParticleSystem" {
  19176. import { Nullable } from "babylonjs/types";
  19177. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19178. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19181. import { Texture } from "babylonjs/Materials/Textures/texture";
  19182. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19183. import { Scene } from "babylonjs/scene";
  19184. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19185. import { Animation } from "babylonjs/Animations/animation";
  19186. /**
  19187. * Interface representing a particle system in Babylon.js.
  19188. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19189. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19190. */
  19191. export interface IParticleSystem {
  19192. /**
  19193. * List of animations used by the particle system.
  19194. */
  19195. animations: Animation[];
  19196. /**
  19197. * The id of the Particle system.
  19198. */
  19199. id: string;
  19200. /**
  19201. * The name of the Particle system.
  19202. */
  19203. name: string;
  19204. /**
  19205. * The emitter represents the Mesh or position we are attaching the particle system to.
  19206. */
  19207. emitter: Nullable<AbstractMesh | Vector3>;
  19208. /**
  19209. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19210. */
  19211. isBillboardBased: boolean;
  19212. /**
  19213. * The rendering group used by the Particle system to chose when to render.
  19214. */
  19215. renderingGroupId: number;
  19216. /**
  19217. * The layer mask we are rendering the particles through.
  19218. */
  19219. layerMask: number;
  19220. /**
  19221. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19222. */
  19223. updateSpeed: number;
  19224. /**
  19225. * The amount of time the particle system is running (depends of the overall update speed).
  19226. */
  19227. targetStopDuration: number;
  19228. /**
  19229. * The texture used to render each particle. (this can be a spritesheet)
  19230. */
  19231. particleTexture: Nullable<Texture>;
  19232. /**
  19233. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19234. */
  19235. blendMode: number;
  19236. /**
  19237. * Minimum life time of emitting particles.
  19238. */
  19239. minLifeTime: number;
  19240. /**
  19241. * Maximum life time of emitting particles.
  19242. */
  19243. maxLifeTime: number;
  19244. /**
  19245. * Minimum Size of emitting particles.
  19246. */
  19247. minSize: number;
  19248. /**
  19249. * Maximum Size of emitting particles.
  19250. */
  19251. maxSize: number;
  19252. /**
  19253. * Minimum scale of emitting particles on X axis.
  19254. */
  19255. minScaleX: number;
  19256. /**
  19257. * Maximum scale of emitting particles on X axis.
  19258. */
  19259. maxScaleX: number;
  19260. /**
  19261. * Minimum scale of emitting particles on Y axis.
  19262. */
  19263. minScaleY: number;
  19264. /**
  19265. * Maximum scale of emitting particles on Y axis.
  19266. */
  19267. maxScaleY: number;
  19268. /**
  19269. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19270. */
  19271. color1: Color4;
  19272. /**
  19273. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19274. */
  19275. color2: Color4;
  19276. /**
  19277. * Color the particle will have at the end of its lifetime.
  19278. */
  19279. colorDead: Color4;
  19280. /**
  19281. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19282. */
  19283. emitRate: number;
  19284. /**
  19285. * You can use gravity if you want to give an orientation to your particles.
  19286. */
  19287. gravity: Vector3;
  19288. /**
  19289. * Minimum power of emitting particles.
  19290. */
  19291. minEmitPower: number;
  19292. /**
  19293. * Maximum power of emitting particles.
  19294. */
  19295. maxEmitPower: number;
  19296. /**
  19297. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19298. */
  19299. minAngularSpeed: number;
  19300. /**
  19301. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19302. */
  19303. maxAngularSpeed: number;
  19304. /**
  19305. * Gets or sets the minimal initial rotation in radians.
  19306. */
  19307. minInitialRotation: number;
  19308. /**
  19309. * Gets or sets the maximal initial rotation in radians.
  19310. */
  19311. maxInitialRotation: number;
  19312. /**
  19313. * The particle emitter type defines the emitter used by the particle system.
  19314. * It can be for example box, sphere, or cone...
  19315. */
  19316. particleEmitterType: Nullable<IParticleEmitterType>;
  19317. /**
  19318. * Defines the delay in milliseconds before starting the system (0 by default)
  19319. */
  19320. startDelay: number;
  19321. /**
  19322. * 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
  19323. */
  19324. preWarmCycles: number;
  19325. /**
  19326. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19327. */
  19328. preWarmStepOffset: number;
  19329. /**
  19330. * 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)
  19331. */
  19332. spriteCellChangeSpeed: number;
  19333. /**
  19334. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19335. */
  19336. startSpriteCellID: number;
  19337. /**
  19338. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19339. */
  19340. endSpriteCellID: number;
  19341. /**
  19342. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19343. */
  19344. spriteCellWidth: number;
  19345. /**
  19346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19347. */
  19348. spriteCellHeight: number;
  19349. /**
  19350. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19351. */
  19352. spriteRandomStartCell: boolean;
  19353. /**
  19354. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19355. */
  19356. isAnimationSheetEnabled: boolean;
  19357. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19358. translationPivot: Vector2;
  19359. /**
  19360. * Gets or sets a texture used to add random noise to particle positions
  19361. */
  19362. noiseTexture: Nullable<BaseTexture>;
  19363. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19364. noiseStrength: Vector3;
  19365. /**
  19366. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19367. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19368. */
  19369. billboardMode: number;
  19370. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19371. limitVelocityDamping: number;
  19372. /**
  19373. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19374. */
  19375. beginAnimationOnStart: boolean;
  19376. /**
  19377. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19378. */
  19379. beginAnimationFrom: number;
  19380. /**
  19381. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19382. */
  19383. beginAnimationTo: number;
  19384. /**
  19385. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19386. */
  19387. beginAnimationLoop: boolean;
  19388. /**
  19389. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19390. */
  19391. disposeOnStop: boolean;
  19392. /**
  19393. * Gets the maximum number of particles active at the same time.
  19394. * @returns The max number of active particles.
  19395. */
  19396. getCapacity(): number;
  19397. /**
  19398. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19399. * @returns True if it has been started, otherwise false.
  19400. */
  19401. isStarted(): boolean;
  19402. /**
  19403. * Animates the particle system for this frame.
  19404. */
  19405. animate(): void;
  19406. /**
  19407. * Renders the particle system in its current state.
  19408. * @returns the current number of particles
  19409. */
  19410. render(): number;
  19411. /**
  19412. * Dispose the particle system and frees its associated resources.
  19413. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19414. */
  19415. dispose(disposeTexture?: boolean): void;
  19416. /**
  19417. * Clones the particle system.
  19418. * @param name The name of the cloned object
  19419. * @param newEmitter The new emitter to use
  19420. * @returns the cloned particle system
  19421. */
  19422. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19423. /**
  19424. * Serializes the particle system to a JSON object.
  19425. * @returns the JSON object
  19426. */
  19427. serialize(): any;
  19428. /**
  19429. * Rebuild the particle system
  19430. */
  19431. rebuild(): void;
  19432. /**
  19433. * Starts the particle system and begins to emit
  19434. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19435. */
  19436. start(delay?: number): void;
  19437. /**
  19438. * Stops the particle system.
  19439. */
  19440. stop(): void;
  19441. /**
  19442. * Remove all active particles
  19443. */
  19444. reset(): void;
  19445. /**
  19446. * Is this system ready to be used/rendered
  19447. * @return true if the system is ready
  19448. */
  19449. isReady(): boolean;
  19450. /**
  19451. * Adds a new color gradient
  19452. * @param gradient defines the gradient to use (between 0 and 1)
  19453. * @param color1 defines the color to affect to the specified gradient
  19454. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19455. * @returns the current particle system
  19456. */
  19457. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19458. /**
  19459. * Remove a specific color gradient
  19460. * @param gradient defines the gradient to remove
  19461. * @returns the current particle system
  19462. */
  19463. removeColorGradient(gradient: number): IParticleSystem;
  19464. /**
  19465. * Adds a new size gradient
  19466. * @param gradient defines the gradient to use (between 0 and 1)
  19467. * @param factor defines the size factor to affect to the specified gradient
  19468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19469. * @returns the current particle system
  19470. */
  19471. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19472. /**
  19473. * Remove a specific size gradient
  19474. * @param gradient defines the gradient to remove
  19475. * @returns the current particle system
  19476. */
  19477. removeSizeGradient(gradient: number): IParticleSystem;
  19478. /**
  19479. * Gets the current list of color gradients.
  19480. * You must use addColorGradient and removeColorGradient to udpate this list
  19481. * @returns the list of color gradients
  19482. */
  19483. getColorGradients(): Nullable<Array<ColorGradient>>;
  19484. /**
  19485. * Gets the current list of size gradients.
  19486. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19487. * @returns the list of size gradients
  19488. */
  19489. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19490. /**
  19491. * Gets the current list of angular speed gradients.
  19492. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19493. * @returns the list of angular speed gradients
  19494. */
  19495. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19496. /**
  19497. * Adds a new angular speed gradient
  19498. * @param gradient defines the gradient to use (between 0 and 1)
  19499. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19504. /**
  19505. * Remove a specific angular speed gradient
  19506. * @param gradient defines the gradient to remove
  19507. * @returns the current particle system
  19508. */
  19509. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19510. /**
  19511. * Gets the current list of velocity gradients.
  19512. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19513. * @returns the list of velocity gradients
  19514. */
  19515. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19516. /**
  19517. * Adds a new velocity gradient
  19518. * @param gradient defines the gradient to use (between 0 and 1)
  19519. * @param factor defines the velocity to affect to the specified gradient
  19520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19521. * @returns the current particle system
  19522. */
  19523. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19524. /**
  19525. * Remove a specific velocity gradient
  19526. * @param gradient defines the gradient to remove
  19527. * @returns the current particle system
  19528. */
  19529. removeVelocityGradient(gradient: number): IParticleSystem;
  19530. /**
  19531. * Gets the current list of limit velocity gradients.
  19532. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19533. * @returns the list of limit velocity gradients
  19534. */
  19535. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19536. /**
  19537. * Adds a new limit velocity gradient
  19538. * @param gradient defines the gradient to use (between 0 and 1)
  19539. * @param factor defines the limit velocity to affect to the specified gradient
  19540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19541. * @returns the current particle system
  19542. */
  19543. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19544. /**
  19545. * Remove a specific limit velocity gradient
  19546. * @param gradient defines the gradient to remove
  19547. * @returns the current particle system
  19548. */
  19549. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19550. /**
  19551. * Adds a new drag gradient
  19552. * @param gradient defines the gradient to use (between 0 and 1)
  19553. * @param factor defines the drag to affect to the specified gradient
  19554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19555. * @returns the current particle system
  19556. */
  19557. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19558. /**
  19559. * Remove a specific drag gradient
  19560. * @param gradient defines the gradient to remove
  19561. * @returns the current particle system
  19562. */
  19563. removeDragGradient(gradient: number): IParticleSystem;
  19564. /**
  19565. * Gets the current list of drag gradients.
  19566. * You must use addDragGradient and removeDragGradient to udpate this list
  19567. * @returns the list of drag gradients
  19568. */
  19569. getDragGradients(): Nullable<Array<FactorGradient>>;
  19570. /**
  19571. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19572. * @param gradient defines the gradient to use (between 0 and 1)
  19573. * @param factor defines the emit rate to affect to the specified gradient
  19574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19575. * @returns the current particle system
  19576. */
  19577. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19578. /**
  19579. * Remove a specific emit rate gradient
  19580. * @param gradient defines the gradient to remove
  19581. * @returns the current particle system
  19582. */
  19583. removeEmitRateGradient(gradient: number): IParticleSystem;
  19584. /**
  19585. * Gets the current list of emit rate gradients.
  19586. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19587. * @returns the list of emit rate gradients
  19588. */
  19589. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19590. /**
  19591. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19592. * @param gradient defines the gradient to use (between 0 and 1)
  19593. * @param factor defines the start size to affect to the specified gradient
  19594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19595. * @returns the current particle system
  19596. */
  19597. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19598. /**
  19599. * Remove a specific start size gradient
  19600. * @param gradient defines the gradient to remove
  19601. * @returns the current particle system
  19602. */
  19603. removeStartSizeGradient(gradient: number): IParticleSystem;
  19604. /**
  19605. * Gets the current list of start size gradients.
  19606. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19607. * @returns the list of start size gradients
  19608. */
  19609. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19610. /**
  19611. * Adds a new life time gradient
  19612. * @param gradient defines the gradient to use (between 0 and 1)
  19613. * @param factor defines the life time factor to affect to the specified gradient
  19614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19615. * @returns the current particle system
  19616. */
  19617. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19618. /**
  19619. * Remove a specific life time gradient
  19620. * @param gradient defines the gradient to remove
  19621. * @returns the current particle system
  19622. */
  19623. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19624. /**
  19625. * Gets the current list of life time gradients.
  19626. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19627. * @returns the list of life time gradients
  19628. */
  19629. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19630. /**
  19631. * Gets the current list of color gradients.
  19632. * You must use addColorGradient and removeColorGradient to udpate this list
  19633. * @returns the list of color gradients
  19634. */
  19635. getColorGradients(): Nullable<Array<ColorGradient>>;
  19636. /**
  19637. * Adds a new ramp gradient used to remap particle colors
  19638. * @param gradient defines the gradient to use (between 0 and 1)
  19639. * @param color defines the color to affect to the specified gradient
  19640. * @returns the current particle system
  19641. */
  19642. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19643. /**
  19644. * Gets the current list of ramp gradients.
  19645. * You must use addRampGradient and removeRampGradient to udpate this list
  19646. * @returns the list of ramp gradients
  19647. */
  19648. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19649. /** Gets or sets a boolean indicating that ramp gradients must be used
  19650. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19651. */
  19652. useRampGradients: boolean;
  19653. /**
  19654. * Adds a new color remap gradient
  19655. * @param gradient defines the gradient to use (between 0 and 1)
  19656. * @param min defines the color remap minimal range
  19657. * @param max defines the color remap maximal range
  19658. * @returns the current particle system
  19659. */
  19660. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19661. /**
  19662. * Gets the current list of color remap gradients.
  19663. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19664. * @returns the list of color remap gradients
  19665. */
  19666. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19667. /**
  19668. * Adds a new alpha remap gradient
  19669. * @param gradient defines the gradient to use (between 0 and 1)
  19670. * @param min defines the alpha remap minimal range
  19671. * @param max defines the alpha remap maximal range
  19672. * @returns the current particle system
  19673. */
  19674. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19675. /**
  19676. * Gets the current list of alpha remap gradients.
  19677. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19678. * @returns the list of alpha remap gradients
  19679. */
  19680. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19681. /**
  19682. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19685. * @returns the emitter
  19686. */
  19687. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19688. /**
  19689. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19690. * @param radius The radius of the hemisphere to emit from
  19691. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19692. * @returns the emitter
  19693. */
  19694. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19695. /**
  19696. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19697. * @param radius The radius of the sphere to emit from
  19698. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19699. * @returns the emitter
  19700. */
  19701. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19702. /**
  19703. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19704. * @param radius The radius of the sphere to emit from
  19705. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19706. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19707. * @returns the emitter
  19708. */
  19709. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19710. /**
  19711. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19712. * @param radius The radius of the emission cylinder
  19713. * @param height The height of the emission cylinder
  19714. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19715. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19716. * @returns the emitter
  19717. */
  19718. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19719. /**
  19720. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19721. * @param radius The radius of the cylinder to emit from
  19722. * @param height The height of the emission cylinder
  19723. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19726. * @returns the emitter
  19727. */
  19728. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19729. /**
  19730. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19731. * @param radius The radius of the cone to emit from
  19732. * @param angle The base angle of the cone
  19733. * @returns the emitter
  19734. */
  19735. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19736. /**
  19737. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19740. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19741. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19742. * @returns the emitter
  19743. */
  19744. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19745. /**
  19746. * Get hosting scene
  19747. * @returns the scene
  19748. */
  19749. getScene(): Scene;
  19750. }
  19751. }
  19752. declare module "babylonjs/Meshes/instancedMesh" {
  19753. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19755. import { Camera } from "babylonjs/Cameras/camera";
  19756. import { Node } from "babylonjs/node";
  19757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19758. import { Mesh } from "babylonjs/Meshes/mesh";
  19759. import { Material } from "babylonjs/Materials/material";
  19760. import { Skeleton } from "babylonjs/Bones/skeleton";
  19761. import { Light } from "babylonjs/Lights/light";
  19762. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19763. /**
  19764. * Creates an instance based on a source mesh.
  19765. */
  19766. export class InstancedMesh extends AbstractMesh {
  19767. private _sourceMesh;
  19768. private _currentLOD;
  19769. /** @hidden */
  19770. _indexInSourceMeshInstanceArray: number;
  19771. constructor(name: string, source: Mesh);
  19772. /**
  19773. * Returns the string "InstancedMesh".
  19774. */
  19775. getClassName(): string;
  19776. /** Gets the list of lights affecting that mesh */
  19777. get lightSources(): Light[];
  19778. _resyncLightSources(): void;
  19779. _resyncLightSource(light: Light): void;
  19780. _removeLightSource(light: Light, dispose: boolean): void;
  19781. /**
  19782. * If the source mesh receives shadows
  19783. */
  19784. get receiveShadows(): boolean;
  19785. /**
  19786. * The material of the source mesh
  19787. */
  19788. get material(): Nullable<Material>;
  19789. /**
  19790. * Visibility of the source mesh
  19791. */
  19792. get visibility(): number;
  19793. /**
  19794. * Skeleton of the source mesh
  19795. */
  19796. get skeleton(): Nullable<Skeleton>;
  19797. /**
  19798. * Rendering ground id of the source mesh
  19799. */
  19800. get renderingGroupId(): number;
  19801. set renderingGroupId(value: number);
  19802. /**
  19803. * Returns the total number of vertices (integer).
  19804. */
  19805. getTotalVertices(): number;
  19806. /**
  19807. * Returns a positive integer : the total number of indices in this mesh geometry.
  19808. * @returns the numner of indices or zero if the mesh has no geometry.
  19809. */
  19810. getTotalIndices(): number;
  19811. /**
  19812. * The source mesh of the instance
  19813. */
  19814. get sourceMesh(): Mesh;
  19815. /**
  19816. * Is this node ready to be used/rendered
  19817. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19818. * @return {boolean} is it ready
  19819. */
  19820. isReady(completeCheck?: boolean): boolean;
  19821. /**
  19822. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19823. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19824. * @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.
  19825. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19826. */
  19827. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19828. /**
  19829. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19830. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19831. * The `data` are either a numeric array either a Float32Array.
  19832. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19833. * 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).
  19834. * Note that a new underlying VertexBuffer object is created each call.
  19835. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19836. *
  19837. * Possible `kind` values :
  19838. * - VertexBuffer.PositionKind
  19839. * - VertexBuffer.UVKind
  19840. * - VertexBuffer.UV2Kind
  19841. * - VertexBuffer.UV3Kind
  19842. * - VertexBuffer.UV4Kind
  19843. * - VertexBuffer.UV5Kind
  19844. * - VertexBuffer.UV6Kind
  19845. * - VertexBuffer.ColorKind
  19846. * - VertexBuffer.MatricesIndicesKind
  19847. * - VertexBuffer.MatricesIndicesExtraKind
  19848. * - VertexBuffer.MatricesWeightsKind
  19849. * - VertexBuffer.MatricesWeightsExtraKind
  19850. *
  19851. * Returns the Mesh.
  19852. */
  19853. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19854. /**
  19855. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19856. * If the mesh has no geometry, it is simply returned as it is.
  19857. * The `data` are either a numeric array either a Float32Array.
  19858. * No new underlying VertexBuffer object is created.
  19859. * 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.
  19860. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19861. *
  19862. * Possible `kind` values :
  19863. * - VertexBuffer.PositionKind
  19864. * - VertexBuffer.UVKind
  19865. * - VertexBuffer.UV2Kind
  19866. * - VertexBuffer.UV3Kind
  19867. * - VertexBuffer.UV4Kind
  19868. * - VertexBuffer.UV5Kind
  19869. * - VertexBuffer.UV6Kind
  19870. * - VertexBuffer.ColorKind
  19871. * - VertexBuffer.MatricesIndicesKind
  19872. * - VertexBuffer.MatricesIndicesExtraKind
  19873. * - VertexBuffer.MatricesWeightsKind
  19874. * - VertexBuffer.MatricesWeightsExtraKind
  19875. *
  19876. * Returns the Mesh.
  19877. */
  19878. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19879. /**
  19880. * Sets the mesh indices.
  19881. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19882. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19883. * This method creates a new index buffer each call.
  19884. * Returns the Mesh.
  19885. */
  19886. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19887. /**
  19888. * Boolean : True if the mesh owns the requested kind of data.
  19889. */
  19890. isVerticesDataPresent(kind: string): boolean;
  19891. /**
  19892. * Returns an array of indices (IndicesArray).
  19893. */
  19894. getIndices(): Nullable<IndicesArray>;
  19895. get _positions(): Nullable<Vector3[]>;
  19896. /**
  19897. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19898. * This means the mesh underlying bounding box and sphere are recomputed.
  19899. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19900. * @returns the current mesh
  19901. */
  19902. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19903. /** @hidden */
  19904. _preActivate(): InstancedMesh;
  19905. /** @hidden */
  19906. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19907. /** @hidden */
  19908. _postActivate(): void;
  19909. getWorldMatrix(): Matrix;
  19910. get isAnInstance(): boolean;
  19911. /**
  19912. * Returns the current associated LOD AbstractMesh.
  19913. */
  19914. getLOD(camera: Camera): AbstractMesh;
  19915. /** @hidden */
  19916. _syncSubMeshes(): InstancedMesh;
  19917. /** @hidden */
  19918. _generatePointsArray(): boolean;
  19919. /**
  19920. * Creates a new InstancedMesh from the current mesh.
  19921. * - name (string) : the cloned mesh name
  19922. * - newParent (optional Node) : the optional Node to parent the clone to.
  19923. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19924. *
  19925. * Returns the clone.
  19926. */
  19927. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19928. /**
  19929. * Disposes the InstancedMesh.
  19930. * Returns nothing.
  19931. */
  19932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19933. }
  19934. module "babylonjs/Meshes/mesh" {
  19935. interface Mesh {
  19936. /**
  19937. * Register a custom buffer that will be instanced
  19938. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19939. * @param kind defines the buffer kind
  19940. * @param stride defines the stride in floats
  19941. */
  19942. registerInstancedBuffer(kind: string, stride: number): void;
  19943. /** @hidden */
  19944. _userInstancedBuffersStorage: {
  19945. data: {
  19946. [key: string]: Float32Array;
  19947. };
  19948. sizes: {
  19949. [key: string]: number;
  19950. };
  19951. vertexBuffers: {
  19952. [key: string]: Nullable<VertexBuffer>;
  19953. };
  19954. strides: {
  19955. [key: string]: number;
  19956. };
  19957. };
  19958. }
  19959. }
  19960. module "babylonjs/Meshes/abstractMesh" {
  19961. interface AbstractMesh {
  19962. /**
  19963. * Object used to store instanced buffers defined by user
  19964. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19965. */
  19966. instancedBuffers: {
  19967. [key: string]: any;
  19968. };
  19969. }
  19970. }
  19971. }
  19972. declare module "babylonjs/Materials/shaderMaterial" {
  19973. import { Scene } from "babylonjs/scene";
  19974. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19976. import { Mesh } from "babylonjs/Meshes/mesh";
  19977. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19979. import { Texture } from "babylonjs/Materials/Textures/texture";
  19980. import { Material } from "babylonjs/Materials/material";
  19981. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19982. /**
  19983. * Defines the options associated with the creation of a shader material.
  19984. */
  19985. export interface IShaderMaterialOptions {
  19986. /**
  19987. * Does the material work in alpha blend mode
  19988. */
  19989. needAlphaBlending: boolean;
  19990. /**
  19991. * Does the material work in alpha test mode
  19992. */
  19993. needAlphaTesting: boolean;
  19994. /**
  19995. * The list of attribute names used in the shader
  19996. */
  19997. attributes: string[];
  19998. /**
  19999. * The list of unifrom names used in the shader
  20000. */
  20001. uniforms: string[];
  20002. /**
  20003. * The list of UBO names used in the shader
  20004. */
  20005. uniformBuffers: string[];
  20006. /**
  20007. * The list of sampler names used in the shader
  20008. */
  20009. samplers: string[];
  20010. /**
  20011. * The list of defines used in the shader
  20012. */
  20013. defines: string[];
  20014. }
  20015. /**
  20016. * 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.
  20017. *
  20018. * This returned material effects how the mesh will look based on the code in the shaders.
  20019. *
  20020. * @see http://doc.babylonjs.com/how_to/shader_material
  20021. */
  20022. export class ShaderMaterial extends Material {
  20023. private _shaderPath;
  20024. private _options;
  20025. private _textures;
  20026. private _textureArrays;
  20027. private _floats;
  20028. private _ints;
  20029. private _floatsArrays;
  20030. private _colors3;
  20031. private _colors3Arrays;
  20032. private _colors4;
  20033. private _colors4Arrays;
  20034. private _vectors2;
  20035. private _vectors3;
  20036. private _vectors4;
  20037. private _matrices;
  20038. private _matrixArrays;
  20039. private _matrices3x3;
  20040. private _matrices2x2;
  20041. private _vectors2Arrays;
  20042. private _vectors3Arrays;
  20043. private _vectors4Arrays;
  20044. private _cachedWorldViewMatrix;
  20045. private _cachedWorldViewProjectionMatrix;
  20046. private _renderId;
  20047. private _multiview;
  20048. /**
  20049. * Instantiate a new shader material.
  20050. * 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.
  20051. * This returned material effects how the mesh will look based on the code in the shaders.
  20052. * @see http://doc.babylonjs.com/how_to/shader_material
  20053. * @param name Define the name of the material in the scene
  20054. * @param scene Define the scene the material belongs to
  20055. * @param shaderPath Defines the route to the shader code in one of three ways:
  20056. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  20057. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  20058. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  20059. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  20060. * @param options Define the options used to create the shader
  20061. */
  20062. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  20063. /**
  20064. * Gets the shader path used to define the shader code
  20065. * It can be modified to trigger a new compilation
  20066. */
  20067. get shaderPath(): any;
  20068. /**
  20069. * Sets the shader path used to define the shader code
  20070. * It can be modified to trigger a new compilation
  20071. */
  20072. set shaderPath(shaderPath: any);
  20073. /**
  20074. * Gets the options used to compile the shader.
  20075. * They can be modified to trigger a new compilation
  20076. */
  20077. get options(): IShaderMaterialOptions;
  20078. /**
  20079. * Gets the current class name of the material e.g. "ShaderMaterial"
  20080. * Mainly use in serialization.
  20081. * @returns the class name
  20082. */
  20083. getClassName(): string;
  20084. /**
  20085. * Specifies if the material will require alpha blending
  20086. * @returns a boolean specifying if alpha blending is needed
  20087. */
  20088. needAlphaBlending(): boolean;
  20089. /**
  20090. * Specifies if this material should be rendered in alpha test mode
  20091. * @returns a boolean specifying if an alpha test is needed.
  20092. */
  20093. needAlphaTesting(): boolean;
  20094. private _checkUniform;
  20095. /**
  20096. * Set a texture in the shader.
  20097. * @param name Define the name of the uniform samplers as defined in the shader
  20098. * @param texture Define the texture to bind to this sampler
  20099. * @return the material itself allowing "fluent" like uniform updates
  20100. */
  20101. setTexture(name: string, texture: Texture): ShaderMaterial;
  20102. /**
  20103. * Set a texture array in the shader.
  20104. * @param name Define the name of the uniform sampler array as defined in the shader
  20105. * @param textures Define the list of textures to bind to this sampler
  20106. * @return the material itself allowing "fluent" like uniform updates
  20107. */
  20108. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20109. /**
  20110. * Set a float in the shader.
  20111. * @param name Define the name of the uniform as defined in the shader
  20112. * @param value Define the value to give to the uniform
  20113. * @return the material itself allowing "fluent" like uniform updates
  20114. */
  20115. setFloat(name: string, value: number): ShaderMaterial;
  20116. /**
  20117. * Set a int in the shader.
  20118. * @param name Define the name of the uniform as defined in the shader
  20119. * @param value Define the value to give to the uniform
  20120. * @return the material itself allowing "fluent" like uniform updates
  20121. */
  20122. setInt(name: string, value: number): ShaderMaterial;
  20123. /**
  20124. * Set an array of floats in the shader.
  20125. * @param name Define the name of the uniform as defined in the shader
  20126. * @param value Define the value to give to the uniform
  20127. * @return the material itself allowing "fluent" like uniform updates
  20128. */
  20129. setFloats(name: string, value: number[]): ShaderMaterial;
  20130. /**
  20131. * Set a vec3 in the shader from a Color3.
  20132. * @param name Define the name of the uniform as defined in the shader
  20133. * @param value Define the value to give to the uniform
  20134. * @return the material itself allowing "fluent" like uniform updates
  20135. */
  20136. setColor3(name: string, value: Color3): ShaderMaterial;
  20137. /**
  20138. * Set a vec3 array in the shader from a Color3 array.
  20139. * @param name Define the name of the uniform as defined in the shader
  20140. * @param value Define the value to give to the uniform
  20141. * @return the material itself allowing "fluent" like uniform updates
  20142. */
  20143. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20144. /**
  20145. * Set a vec4 in the shader from a Color4.
  20146. * @param name Define the name of the uniform as defined in the shader
  20147. * @param value Define the value to give to the uniform
  20148. * @return the material itself allowing "fluent" like uniform updates
  20149. */
  20150. setColor4(name: string, value: Color4): ShaderMaterial;
  20151. /**
  20152. * Set a vec4 array in the shader from a Color4 array.
  20153. * @param name Define the name of the uniform as defined in the shader
  20154. * @param value Define the value to give to the uniform
  20155. * @return the material itself allowing "fluent" like uniform updates
  20156. */
  20157. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20158. /**
  20159. * Set a vec2 in the shader from a Vector2.
  20160. * @param name Define the name of the uniform as defined in the shader
  20161. * @param value Define the value to give to the uniform
  20162. * @return the material itself allowing "fluent" like uniform updates
  20163. */
  20164. setVector2(name: string, value: Vector2): ShaderMaterial;
  20165. /**
  20166. * Set a vec3 in the shader from a Vector3.
  20167. * @param name Define the name of the uniform as defined in the shader
  20168. * @param value Define the value to give to the uniform
  20169. * @return the material itself allowing "fluent" like uniform updates
  20170. */
  20171. setVector3(name: string, value: Vector3): ShaderMaterial;
  20172. /**
  20173. * Set a vec4 in the shader from a Vector4.
  20174. * @param name Define the name of the uniform as defined in the shader
  20175. * @param value Define the value to give to the uniform
  20176. * @return the material itself allowing "fluent" like uniform updates
  20177. */
  20178. setVector4(name: string, value: Vector4): ShaderMaterial;
  20179. /**
  20180. * Set a mat4 in the shader from a Matrix.
  20181. * @param name Define the name of the uniform as defined in the shader
  20182. * @param value Define the value to give to the uniform
  20183. * @return the material itself allowing "fluent" like uniform updates
  20184. */
  20185. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20186. /**
  20187. * Set a float32Array in the shader from a matrix array.
  20188. * @param name Define the name of the uniform as defined in the shader
  20189. * @param value Define the value to give to the uniform
  20190. * @return the material itself allowing "fluent" like uniform updates
  20191. */
  20192. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20193. /**
  20194. * Set a mat3 in the shader from a Float32Array.
  20195. * @param name Define the name of the uniform as defined in the shader
  20196. * @param value Define the value to give to the uniform
  20197. * @return the material itself allowing "fluent" like uniform updates
  20198. */
  20199. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20200. /**
  20201. * Set a mat2 in the shader from a Float32Array.
  20202. * @param name Define the name of the uniform as defined in the shader
  20203. * @param value Define the value to give to the uniform
  20204. * @return the material itself allowing "fluent" like uniform updates
  20205. */
  20206. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20207. /**
  20208. * Set a vec2 array in the shader from a number array.
  20209. * @param name Define the name of the uniform as defined in the shader
  20210. * @param value Define the value to give to the uniform
  20211. * @return the material itself allowing "fluent" like uniform updates
  20212. */
  20213. setArray2(name: string, value: number[]): ShaderMaterial;
  20214. /**
  20215. * Set a vec3 array in the shader from a number array.
  20216. * @param name Define the name of the uniform as defined in the shader
  20217. * @param value Define the value to give to the uniform
  20218. * @return the material itself allowing "fluent" like uniform updates
  20219. */
  20220. setArray3(name: string, value: number[]): ShaderMaterial;
  20221. /**
  20222. * Set a vec4 array in the shader from a number array.
  20223. * @param name Define the name of the uniform as defined in the shader
  20224. * @param value Define the value to give to the uniform
  20225. * @return the material itself allowing "fluent" like uniform updates
  20226. */
  20227. setArray4(name: string, value: number[]): ShaderMaterial;
  20228. private _checkCache;
  20229. /**
  20230. * Specifies that the submesh is ready to be used
  20231. * @param mesh defines the mesh to check
  20232. * @param subMesh defines which submesh to check
  20233. * @param useInstances specifies that instances should be used
  20234. * @returns a boolean indicating that the submesh is ready or not
  20235. */
  20236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20237. /**
  20238. * Checks if the material is ready to render the requested mesh
  20239. * @param mesh Define the mesh to render
  20240. * @param useInstances Define whether or not the material is used with instances
  20241. * @returns true if ready, otherwise false
  20242. */
  20243. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20244. /**
  20245. * Binds the world matrix to the material
  20246. * @param world defines the world transformation matrix
  20247. */
  20248. bindOnlyWorldMatrix(world: Matrix): void;
  20249. /**
  20250. * Binds the material to the mesh
  20251. * @param world defines the world transformation matrix
  20252. * @param mesh defines the mesh to bind the material to
  20253. */
  20254. bind(world: Matrix, mesh?: Mesh): void;
  20255. /**
  20256. * Gets the active textures from the material
  20257. * @returns an array of textures
  20258. */
  20259. getActiveTextures(): BaseTexture[];
  20260. /**
  20261. * Specifies if the material uses a texture
  20262. * @param texture defines the texture to check against the material
  20263. * @returns a boolean specifying if the material uses the texture
  20264. */
  20265. hasTexture(texture: BaseTexture): boolean;
  20266. /**
  20267. * Makes a duplicate of the material, and gives it a new name
  20268. * @param name defines the new name for the duplicated material
  20269. * @returns the cloned material
  20270. */
  20271. clone(name: string): ShaderMaterial;
  20272. /**
  20273. * Disposes the material
  20274. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20275. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20276. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20277. */
  20278. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20279. /**
  20280. * Serializes this material in a JSON representation
  20281. * @returns the serialized material object
  20282. */
  20283. serialize(): any;
  20284. /**
  20285. * Creates a shader material from parsed shader material data
  20286. * @param source defines the JSON represnetation of the material
  20287. * @param scene defines the hosting scene
  20288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20289. * @returns a new material
  20290. */
  20291. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20292. }
  20293. }
  20294. declare module "babylonjs/Shaders/color.fragment" {
  20295. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20296. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20297. /** @hidden */
  20298. export var colorPixelShader: {
  20299. name: string;
  20300. shader: string;
  20301. };
  20302. }
  20303. declare module "babylonjs/Shaders/color.vertex" {
  20304. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20305. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20306. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20307. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20308. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20310. /** @hidden */
  20311. export var colorVertexShader: {
  20312. name: string;
  20313. shader: string;
  20314. };
  20315. }
  20316. declare module "babylonjs/Meshes/linesMesh" {
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Scene } from "babylonjs/scene";
  20319. import { Color3 } from "babylonjs/Maths/math.color";
  20320. import { Node } from "babylonjs/node";
  20321. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20322. import { Mesh } from "babylonjs/Meshes/mesh";
  20323. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20324. import { Effect } from "babylonjs/Materials/effect";
  20325. import { Material } from "babylonjs/Materials/material";
  20326. import "babylonjs/Shaders/color.fragment";
  20327. import "babylonjs/Shaders/color.vertex";
  20328. /**
  20329. * Line mesh
  20330. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20331. */
  20332. export class LinesMesh extends Mesh {
  20333. /**
  20334. * If vertex color should be applied to the mesh
  20335. */
  20336. readonly useVertexColor?: boolean | undefined;
  20337. /**
  20338. * If vertex alpha should be applied to the mesh
  20339. */
  20340. readonly useVertexAlpha?: boolean | undefined;
  20341. /**
  20342. * Color of the line (Default: White)
  20343. */
  20344. color: Color3;
  20345. /**
  20346. * Alpha of the line (Default: 1)
  20347. */
  20348. alpha: number;
  20349. /**
  20350. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20351. * This margin is expressed in world space coordinates, so its value may vary.
  20352. * Default value is 0.1
  20353. */
  20354. intersectionThreshold: number;
  20355. private _colorShader;
  20356. private color4;
  20357. /**
  20358. * Creates a new LinesMesh
  20359. * @param name defines the name
  20360. * @param scene defines the hosting scene
  20361. * @param parent defines the parent mesh if any
  20362. * @param source defines the optional source LinesMesh used to clone data from
  20363. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20364. * When false, achieved by calling a clone(), also passing False.
  20365. * This will make creation of children, recursive.
  20366. * @param useVertexColor defines if this LinesMesh supports vertex color
  20367. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20368. */
  20369. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20370. /**
  20371. * If vertex color should be applied to the mesh
  20372. */
  20373. useVertexColor?: boolean | undefined,
  20374. /**
  20375. * If vertex alpha should be applied to the mesh
  20376. */
  20377. useVertexAlpha?: boolean | undefined);
  20378. private _addClipPlaneDefine;
  20379. private _removeClipPlaneDefine;
  20380. isReady(): boolean;
  20381. /**
  20382. * Returns the string "LineMesh"
  20383. */
  20384. getClassName(): string;
  20385. /**
  20386. * @hidden
  20387. */
  20388. get material(): Material;
  20389. /**
  20390. * @hidden
  20391. */
  20392. set material(value: Material);
  20393. /**
  20394. * @hidden
  20395. */
  20396. get checkCollisions(): boolean;
  20397. /** @hidden */
  20398. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20399. /** @hidden */
  20400. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20401. /**
  20402. * Disposes of the line mesh
  20403. * @param doNotRecurse If children should be disposed
  20404. */
  20405. dispose(doNotRecurse?: boolean): void;
  20406. /**
  20407. * Returns a new LineMesh object cloned from the current one.
  20408. */
  20409. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  20410. /**
  20411. * Creates a new InstancedLinesMesh object from the mesh model.
  20412. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20413. * @param name defines the name of the new instance
  20414. * @returns a new InstancedLinesMesh
  20415. */
  20416. createInstance(name: string): InstancedLinesMesh;
  20417. }
  20418. /**
  20419. * Creates an instance based on a source LinesMesh
  20420. */
  20421. export class InstancedLinesMesh extends InstancedMesh {
  20422. /**
  20423. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20424. * This margin is expressed in world space coordinates, so its value may vary.
  20425. * Initilized with the intersectionThreshold value of the source LinesMesh
  20426. */
  20427. intersectionThreshold: number;
  20428. constructor(name: string, source: LinesMesh);
  20429. /**
  20430. * Returns the string "InstancedLinesMesh".
  20431. */
  20432. getClassName(): string;
  20433. }
  20434. }
  20435. declare module "babylonjs/Shaders/line.fragment" {
  20436. /** @hidden */
  20437. export var linePixelShader: {
  20438. name: string;
  20439. shader: string;
  20440. };
  20441. }
  20442. declare module "babylonjs/Shaders/line.vertex" {
  20443. /** @hidden */
  20444. export var lineVertexShader: {
  20445. name: string;
  20446. shader: string;
  20447. };
  20448. }
  20449. declare module "babylonjs/Rendering/edgesRenderer" {
  20450. import { Nullable } from "babylonjs/types";
  20451. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20453. import { Vector3 } from "babylonjs/Maths/math.vector";
  20454. import { IDisposable } from "babylonjs/scene";
  20455. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20456. import "babylonjs/Shaders/line.fragment";
  20457. import "babylonjs/Shaders/line.vertex";
  20458. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20459. module "babylonjs/Meshes/abstractMesh" {
  20460. interface AbstractMesh {
  20461. /**
  20462. * Gets the edgesRenderer associated with the mesh
  20463. */
  20464. edgesRenderer: Nullable<EdgesRenderer>;
  20465. }
  20466. }
  20467. module "babylonjs/Meshes/linesMesh" {
  20468. interface LinesMesh {
  20469. /**
  20470. * Enables the edge rendering mode on the mesh.
  20471. * This mode makes the mesh edges visible
  20472. * @param epsilon defines the maximal distance between two angles to detect a face
  20473. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20474. * @returns the currentAbstractMesh
  20475. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20476. */
  20477. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20478. }
  20479. }
  20480. module "babylonjs/Meshes/linesMesh" {
  20481. interface InstancedLinesMesh {
  20482. /**
  20483. * Enables the edge rendering mode on the mesh.
  20484. * This mode makes the mesh edges visible
  20485. * @param epsilon defines the maximal distance between two angles to detect a face
  20486. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20487. * @returns the current InstancedLinesMesh
  20488. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20489. */
  20490. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20491. }
  20492. }
  20493. /**
  20494. * Defines the minimum contract an Edges renderer should follow.
  20495. */
  20496. export interface IEdgesRenderer extends IDisposable {
  20497. /**
  20498. * Gets or sets a boolean indicating if the edgesRenderer is active
  20499. */
  20500. isEnabled: boolean;
  20501. /**
  20502. * Renders the edges of the attached mesh,
  20503. */
  20504. render(): void;
  20505. /**
  20506. * Checks wether or not the edges renderer is ready to render.
  20507. * @return true if ready, otherwise false.
  20508. */
  20509. isReady(): boolean;
  20510. }
  20511. /**
  20512. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20513. */
  20514. export class EdgesRenderer implements IEdgesRenderer {
  20515. /**
  20516. * Define the size of the edges with an orthographic camera
  20517. */
  20518. edgesWidthScalerForOrthographic: number;
  20519. /**
  20520. * Define the size of the edges with a perspective camera
  20521. */
  20522. edgesWidthScalerForPerspective: number;
  20523. protected _source: AbstractMesh;
  20524. protected _linesPositions: number[];
  20525. protected _linesNormals: number[];
  20526. protected _linesIndices: number[];
  20527. protected _epsilon: number;
  20528. protected _indicesCount: number;
  20529. protected _lineShader: ShaderMaterial;
  20530. protected _ib: DataBuffer;
  20531. protected _buffers: {
  20532. [key: string]: Nullable<VertexBuffer>;
  20533. };
  20534. protected _checkVerticesInsteadOfIndices: boolean;
  20535. private _meshRebuildObserver;
  20536. private _meshDisposeObserver;
  20537. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20538. isEnabled: boolean;
  20539. /**
  20540. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20541. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20542. * @param source Mesh used to create edges
  20543. * @param epsilon sum of angles in adjacency to check for edge
  20544. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20545. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20546. */
  20547. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20548. protected _prepareRessources(): void;
  20549. /** @hidden */
  20550. _rebuild(): void;
  20551. /**
  20552. * Releases the required resources for the edges renderer
  20553. */
  20554. dispose(): void;
  20555. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20556. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20557. /**
  20558. * Checks if the pair of p0 and p1 is en edge
  20559. * @param faceIndex
  20560. * @param edge
  20561. * @param faceNormals
  20562. * @param p0
  20563. * @param p1
  20564. * @private
  20565. */
  20566. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20567. /**
  20568. * push line into the position, normal and index buffer
  20569. * @protected
  20570. */
  20571. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20572. /**
  20573. * Generates lines edges from adjacencjes
  20574. * @private
  20575. */
  20576. _generateEdgesLines(): void;
  20577. /**
  20578. * Checks wether or not the edges renderer is ready to render.
  20579. * @return true if ready, otherwise false.
  20580. */
  20581. isReady(): boolean;
  20582. /**
  20583. * Renders the edges of the attached mesh,
  20584. */
  20585. render(): void;
  20586. }
  20587. /**
  20588. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20589. */
  20590. export class LineEdgesRenderer extends EdgesRenderer {
  20591. /**
  20592. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20593. * @param source LineMesh used to generate edges
  20594. * @param epsilon not important (specified angle for edge detection)
  20595. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20596. */
  20597. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20598. /**
  20599. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20600. */
  20601. _generateEdgesLines(): void;
  20602. }
  20603. }
  20604. declare module "babylonjs/Rendering/renderingGroup" {
  20605. import { SmartArray } from "babylonjs/Misc/smartArray";
  20606. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20608. import { Nullable } from "babylonjs/types";
  20609. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20610. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20611. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20612. import { Material } from "babylonjs/Materials/material";
  20613. import { Scene } from "babylonjs/scene";
  20614. /**
  20615. * This represents the object necessary to create a rendering group.
  20616. * This is exclusively used and created by the rendering manager.
  20617. * To modify the behavior, you use the available helpers in your scene or meshes.
  20618. * @hidden
  20619. */
  20620. export class RenderingGroup {
  20621. index: number;
  20622. private static _zeroVector;
  20623. private _scene;
  20624. private _opaqueSubMeshes;
  20625. private _transparentSubMeshes;
  20626. private _alphaTestSubMeshes;
  20627. private _depthOnlySubMeshes;
  20628. private _particleSystems;
  20629. private _spriteManagers;
  20630. private _opaqueSortCompareFn;
  20631. private _alphaTestSortCompareFn;
  20632. private _transparentSortCompareFn;
  20633. private _renderOpaque;
  20634. private _renderAlphaTest;
  20635. private _renderTransparent;
  20636. /** @hidden */
  20637. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20638. onBeforeTransparentRendering: () => void;
  20639. /**
  20640. * Set the opaque sort comparison function.
  20641. * If null the sub meshes will be render in the order they were created
  20642. */
  20643. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20644. /**
  20645. * Set the alpha test sort comparison function.
  20646. * If null the sub meshes will be render in the order they were created
  20647. */
  20648. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20649. /**
  20650. * Set the transparent sort comparison function.
  20651. * If null the sub meshes will be render in the order they were created
  20652. */
  20653. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20654. /**
  20655. * Creates a new rendering group.
  20656. * @param index The rendering group index
  20657. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20658. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20659. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20660. */
  20661. 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>);
  20662. /**
  20663. * Render all the sub meshes contained in the group.
  20664. * @param customRenderFunction Used to override the default render behaviour of the group.
  20665. * @returns true if rendered some submeshes.
  20666. */
  20667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20668. /**
  20669. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20670. * @param subMeshes The submeshes to render
  20671. */
  20672. private renderOpaqueSorted;
  20673. /**
  20674. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20675. * @param subMeshes The submeshes to render
  20676. */
  20677. private renderAlphaTestSorted;
  20678. /**
  20679. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20680. * @param subMeshes The submeshes to render
  20681. */
  20682. private renderTransparentSorted;
  20683. /**
  20684. * Renders the submeshes in a specified order.
  20685. * @param subMeshes The submeshes to sort before render
  20686. * @param sortCompareFn The comparison function use to sort
  20687. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20688. * @param transparent Specifies to activate blending if true
  20689. */
  20690. private static renderSorted;
  20691. /**
  20692. * Renders the submeshes in the order they were dispatched (no sort applied).
  20693. * @param subMeshes The submeshes to render
  20694. */
  20695. private static renderUnsorted;
  20696. /**
  20697. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20698. * are rendered back to front if in the same alpha index.
  20699. *
  20700. * @param a The first submesh
  20701. * @param b The second submesh
  20702. * @returns The result of the comparison
  20703. */
  20704. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20705. /**
  20706. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20707. * are rendered back to front.
  20708. *
  20709. * @param a The first submesh
  20710. * @param b The second submesh
  20711. * @returns The result of the comparison
  20712. */
  20713. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20714. /**
  20715. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20716. * are rendered front to back (prevent overdraw).
  20717. *
  20718. * @param a The first submesh
  20719. * @param b The second submesh
  20720. * @returns The result of the comparison
  20721. */
  20722. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20723. /**
  20724. * Resets the different lists of submeshes to prepare a new frame.
  20725. */
  20726. prepare(): void;
  20727. dispose(): void;
  20728. /**
  20729. * Inserts the submesh in its correct queue depending on its material.
  20730. * @param subMesh The submesh to dispatch
  20731. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20732. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20733. */
  20734. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20735. dispatchSprites(spriteManager: ISpriteManager): void;
  20736. dispatchParticles(particleSystem: IParticleSystem): void;
  20737. private _renderParticles;
  20738. private _renderSprites;
  20739. }
  20740. }
  20741. declare module "babylonjs/Rendering/renderingManager" {
  20742. import { Nullable } from "babylonjs/types";
  20743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20744. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20745. import { SmartArray } from "babylonjs/Misc/smartArray";
  20746. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20748. import { Material } from "babylonjs/Materials/material";
  20749. import { Scene } from "babylonjs/scene";
  20750. import { Camera } from "babylonjs/Cameras/camera";
  20751. /**
  20752. * Interface describing the different options available in the rendering manager
  20753. * regarding Auto Clear between groups.
  20754. */
  20755. export interface IRenderingManagerAutoClearSetup {
  20756. /**
  20757. * Defines whether or not autoclear is enable.
  20758. */
  20759. autoClear: boolean;
  20760. /**
  20761. * Defines whether or not to autoclear the depth buffer.
  20762. */
  20763. depth: boolean;
  20764. /**
  20765. * Defines whether or not to autoclear the stencil buffer.
  20766. */
  20767. stencil: boolean;
  20768. }
  20769. /**
  20770. * This class is used by the onRenderingGroupObservable
  20771. */
  20772. export class RenderingGroupInfo {
  20773. /**
  20774. * The Scene that being rendered
  20775. */
  20776. scene: Scene;
  20777. /**
  20778. * The camera currently used for the rendering pass
  20779. */
  20780. camera: Nullable<Camera>;
  20781. /**
  20782. * The ID of the renderingGroup being processed
  20783. */
  20784. renderingGroupId: number;
  20785. }
  20786. /**
  20787. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20788. * It is enable to manage the different groups as well as the different necessary sort functions.
  20789. * This should not be used directly aside of the few static configurations
  20790. */
  20791. export class RenderingManager {
  20792. /**
  20793. * The max id used for rendering groups (not included)
  20794. */
  20795. static MAX_RENDERINGGROUPS: number;
  20796. /**
  20797. * The min id used for rendering groups (included)
  20798. */
  20799. static MIN_RENDERINGGROUPS: number;
  20800. /**
  20801. * Used to globally prevent autoclearing scenes.
  20802. */
  20803. static AUTOCLEAR: boolean;
  20804. /**
  20805. * @hidden
  20806. */
  20807. _useSceneAutoClearSetup: boolean;
  20808. private _scene;
  20809. private _renderingGroups;
  20810. private _depthStencilBufferAlreadyCleaned;
  20811. private _autoClearDepthStencil;
  20812. private _customOpaqueSortCompareFn;
  20813. private _customAlphaTestSortCompareFn;
  20814. private _customTransparentSortCompareFn;
  20815. private _renderingGroupInfo;
  20816. /**
  20817. * Instantiates a new rendering group for a particular scene
  20818. * @param scene Defines the scene the groups belongs to
  20819. */
  20820. constructor(scene: Scene);
  20821. private _clearDepthStencilBuffer;
  20822. /**
  20823. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20824. * @hidden
  20825. */
  20826. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20827. /**
  20828. * Resets the different information of the group to prepare a new frame
  20829. * @hidden
  20830. */
  20831. reset(): void;
  20832. /**
  20833. * Dispose and release the group and its associated resources.
  20834. * @hidden
  20835. */
  20836. dispose(): void;
  20837. /**
  20838. * Clear the info related to rendering groups preventing retention points during dispose.
  20839. */
  20840. freeRenderingGroups(): void;
  20841. private _prepareRenderingGroup;
  20842. /**
  20843. * Add a sprite manager to the rendering manager in order to render it this frame.
  20844. * @param spriteManager Define the sprite manager to render
  20845. */
  20846. dispatchSprites(spriteManager: ISpriteManager): void;
  20847. /**
  20848. * Add a particle system to the rendering manager in order to render it this frame.
  20849. * @param particleSystem Define the particle system to render
  20850. */
  20851. dispatchParticles(particleSystem: IParticleSystem): void;
  20852. /**
  20853. * Add a submesh to the manager in order to render it this frame
  20854. * @param subMesh The submesh to dispatch
  20855. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20856. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20857. */
  20858. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20859. /**
  20860. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20861. * This allowed control for front to back rendering or reversly depending of the special needs.
  20862. *
  20863. * @param renderingGroupId The rendering group id corresponding to its index
  20864. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20865. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20866. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20867. */
  20868. 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;
  20869. /**
  20870. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20871. *
  20872. * @param renderingGroupId The rendering group id corresponding to its index
  20873. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20874. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20875. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20876. */
  20877. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20878. /**
  20879. * Gets the current auto clear configuration for one rendering group of the rendering
  20880. * manager.
  20881. * @param index the rendering group index to get the information for
  20882. * @returns The auto clear setup for the requested rendering group
  20883. */
  20884. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20885. }
  20886. }
  20887. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20888. import { Observable } from "babylonjs/Misc/observable";
  20889. import { SmartArray } from "babylonjs/Misc/smartArray";
  20890. import { Nullable, Immutable } from "babylonjs/types";
  20891. import { Camera } from "babylonjs/Cameras/camera";
  20892. import { Scene } from "babylonjs/scene";
  20893. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20894. import { Color4 } from "babylonjs/Maths/math.color";
  20895. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20899. import { Texture } from "babylonjs/Materials/Textures/texture";
  20900. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20901. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20902. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20903. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20904. import { Engine } from "babylonjs/Engines/engine";
  20905. /**
  20906. * This Helps creating a texture that will be created from a camera in your scene.
  20907. * It is basically a dynamic texture that could be used to create special effects for instance.
  20908. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20909. */
  20910. export class RenderTargetTexture extends Texture {
  20911. isCube: boolean;
  20912. /**
  20913. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20914. */
  20915. static readonly REFRESHRATE_RENDER_ONCE: number;
  20916. /**
  20917. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20918. */
  20919. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20920. /**
  20921. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20922. * the central point of your effect and can save a lot of performances.
  20923. */
  20924. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20925. /**
  20926. * Use this predicate to dynamically define the list of mesh you want to render.
  20927. * If set, the renderList property will be overwritten.
  20928. */
  20929. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20930. private _renderList;
  20931. /**
  20932. * Use this list to define the list of mesh you want to render.
  20933. */
  20934. get renderList(): Nullable<Array<AbstractMesh>>;
  20935. set renderList(value: Nullable<Array<AbstractMesh>>);
  20936. /**
  20937. * Use this function to overload the renderList array at rendering time.
  20938. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20939. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20940. * the cube (if the RTT is a cube, else layerOrFace=0).
  20941. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20942. */
  20943. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20944. private _hookArray;
  20945. /**
  20946. * Define if particles should be rendered in your texture.
  20947. */
  20948. renderParticles: boolean;
  20949. /**
  20950. * Define if sprites should be rendered in your texture.
  20951. */
  20952. renderSprites: boolean;
  20953. /**
  20954. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20955. */
  20956. coordinatesMode: number;
  20957. /**
  20958. * Define the camera used to render the texture.
  20959. */
  20960. activeCamera: Nullable<Camera>;
  20961. /**
  20962. * Override the render function of the texture with your own one.
  20963. */
  20964. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20965. /**
  20966. * Define if camera post processes should be use while rendering the texture.
  20967. */
  20968. useCameraPostProcesses: boolean;
  20969. /**
  20970. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20971. */
  20972. ignoreCameraViewport: boolean;
  20973. private _postProcessManager;
  20974. private _postProcesses;
  20975. private _resizeObserver;
  20976. /**
  20977. * An event triggered when the texture is unbind.
  20978. */
  20979. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20980. /**
  20981. * An event triggered when the texture is unbind.
  20982. */
  20983. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20984. private _onAfterUnbindObserver;
  20985. /**
  20986. * Set a after unbind callback in the texture.
  20987. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20988. */
  20989. set onAfterUnbind(callback: () => void);
  20990. /**
  20991. * An event triggered before rendering the texture
  20992. */
  20993. onBeforeRenderObservable: Observable<number>;
  20994. private _onBeforeRenderObserver;
  20995. /**
  20996. * Set a before render callback in the texture.
  20997. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20998. */
  20999. set onBeforeRender(callback: (faceIndex: number) => void);
  21000. /**
  21001. * An event triggered after rendering the texture
  21002. */
  21003. onAfterRenderObservable: Observable<number>;
  21004. private _onAfterRenderObserver;
  21005. /**
  21006. * Set a after render callback in the texture.
  21007. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21008. */
  21009. set onAfterRender(callback: (faceIndex: number) => void);
  21010. /**
  21011. * An event triggered after the texture clear
  21012. */
  21013. onClearObservable: Observable<Engine>;
  21014. private _onClearObserver;
  21015. /**
  21016. * Set a clear callback in the texture.
  21017. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21018. */
  21019. set onClear(callback: (Engine: Engine) => void);
  21020. /**
  21021. * An event triggered when the texture is resized.
  21022. */
  21023. onResizeObservable: Observable<RenderTargetTexture>;
  21024. /**
  21025. * Define the clear color of the Render Target if it should be different from the scene.
  21026. */
  21027. clearColor: Color4;
  21028. protected _size: number | {
  21029. width: number;
  21030. height: number;
  21031. layers?: number;
  21032. };
  21033. protected _initialSizeParameter: number | {
  21034. width: number;
  21035. height: number;
  21036. } | {
  21037. ratio: number;
  21038. };
  21039. protected _sizeRatio: Nullable<number>;
  21040. /** @hidden */
  21041. _generateMipMaps: boolean;
  21042. protected _renderingManager: RenderingManager;
  21043. /** @hidden */
  21044. _waitingRenderList: string[];
  21045. protected _doNotChangeAspectRatio: boolean;
  21046. protected _currentRefreshId: number;
  21047. protected _refreshRate: number;
  21048. protected _textureMatrix: Matrix;
  21049. protected _samples: number;
  21050. protected _renderTargetOptions: RenderTargetCreationOptions;
  21051. /**
  21052. * Gets render target creation options that were used.
  21053. */
  21054. get renderTargetOptions(): RenderTargetCreationOptions;
  21055. protected _engine: Engine;
  21056. protected _onRatioRescale(): void;
  21057. /**
  21058. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21059. * It must define where the camera used to render the texture is set
  21060. */
  21061. boundingBoxPosition: Vector3;
  21062. private _boundingBoxSize;
  21063. /**
  21064. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21065. * When defined, the cubemap will switch to local mode
  21066. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21067. * @example https://www.babylonjs-playground.com/#RNASML
  21068. */
  21069. set boundingBoxSize(value: Vector3);
  21070. get boundingBoxSize(): Vector3;
  21071. /**
  21072. * In case the RTT has been created with a depth texture, get the associated
  21073. * depth texture.
  21074. * Otherwise, return null.
  21075. */
  21076. get depthStencilTexture(): Nullable<InternalTexture>;
  21077. /**
  21078. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21079. * or used a shadow, depth texture...
  21080. * @param name The friendly name of the texture
  21081. * @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)
  21082. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21083. * @param generateMipMaps True if mip maps need to be generated after render.
  21084. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21085. * @param type The type of the buffer in the RTT (int, half float, float...)
  21086. * @param isCube True if a cube texture needs to be created
  21087. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21088. * @param generateDepthBuffer True to generate a depth buffer
  21089. * @param generateStencilBuffer True to generate a stencil buffer
  21090. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21091. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21092. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21093. */
  21094. constructor(name: string, size: number | {
  21095. width: number;
  21096. height: number;
  21097. layers?: number;
  21098. } | {
  21099. ratio: number;
  21100. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21101. /**
  21102. * Creates a depth stencil texture.
  21103. * This is only available in WebGL 2 or with the depth texture extension available.
  21104. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21105. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21106. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21107. */
  21108. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21109. private _processSizeParameter;
  21110. /**
  21111. * Define the number of samples to use in case of MSAA.
  21112. * It defaults to one meaning no MSAA has been enabled.
  21113. */
  21114. get samples(): number;
  21115. set samples(value: number);
  21116. /**
  21117. * Resets the refresh counter of the texture and start bak from scratch.
  21118. * Could be useful to regenerate the texture if it is setup to render only once.
  21119. */
  21120. resetRefreshCounter(): void;
  21121. /**
  21122. * Define the refresh rate of the texture or the rendering frequency.
  21123. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21124. */
  21125. get refreshRate(): number;
  21126. set refreshRate(value: number);
  21127. /**
  21128. * Adds a post process to the render target rendering passes.
  21129. * @param postProcess define the post process to add
  21130. */
  21131. addPostProcess(postProcess: PostProcess): void;
  21132. /**
  21133. * Clear all the post processes attached to the render target
  21134. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21135. */
  21136. clearPostProcesses(dispose?: boolean): void;
  21137. /**
  21138. * Remove one of the post process from the list of attached post processes to the texture
  21139. * @param postProcess define the post process to remove from the list
  21140. */
  21141. removePostProcess(postProcess: PostProcess): void;
  21142. /** @hidden */
  21143. _shouldRender(): boolean;
  21144. /**
  21145. * Gets the actual render size of the texture.
  21146. * @returns the width of the render size
  21147. */
  21148. getRenderSize(): number;
  21149. /**
  21150. * Gets the actual render width of the texture.
  21151. * @returns the width of the render size
  21152. */
  21153. getRenderWidth(): number;
  21154. /**
  21155. * Gets the actual render height of the texture.
  21156. * @returns the height of the render size
  21157. */
  21158. getRenderHeight(): number;
  21159. /**
  21160. * Gets the actual number of layers of the texture.
  21161. * @returns the number of layers
  21162. */
  21163. getRenderLayers(): number;
  21164. /**
  21165. * Get if the texture can be rescaled or not.
  21166. */
  21167. get canRescale(): boolean;
  21168. /**
  21169. * Resize the texture using a ratio.
  21170. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21171. */
  21172. scale(ratio: number): void;
  21173. /**
  21174. * Get the texture reflection matrix used to rotate/transform the reflection.
  21175. * @returns the reflection matrix
  21176. */
  21177. getReflectionTextureMatrix(): Matrix;
  21178. /**
  21179. * Resize the texture to a new desired size.
  21180. * Be carrefull as it will recreate all the data in the new texture.
  21181. * @param size Define the new size. It can be:
  21182. * - a number for squared texture,
  21183. * - an object containing { width: number, height: number }
  21184. * - or an object containing a ratio { ratio: number }
  21185. */
  21186. resize(size: number | {
  21187. width: number;
  21188. height: number;
  21189. } | {
  21190. ratio: number;
  21191. }): void;
  21192. private _defaultRenderListPrepared;
  21193. /**
  21194. * Renders all the objects from the render list into the texture.
  21195. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21196. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21197. */
  21198. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21199. private _bestReflectionRenderTargetDimension;
  21200. private _prepareRenderingManager;
  21201. /**
  21202. * @hidden
  21203. * @param faceIndex face index to bind to if this is a cubetexture
  21204. * @param layer defines the index of the texture to bind in the array
  21205. */
  21206. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21207. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21208. private renderToTarget;
  21209. /**
  21210. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21211. * This allowed control for front to back rendering or reversly depending of the special needs.
  21212. *
  21213. * @param renderingGroupId The rendering group id corresponding to its index
  21214. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21215. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21216. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21217. */
  21218. 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;
  21219. /**
  21220. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21221. *
  21222. * @param renderingGroupId The rendering group id corresponding to its index
  21223. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21224. */
  21225. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21226. /**
  21227. * Clones the texture.
  21228. * @returns the cloned texture
  21229. */
  21230. clone(): RenderTargetTexture;
  21231. /**
  21232. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21233. * @returns The JSON representation of the texture
  21234. */
  21235. serialize(): any;
  21236. /**
  21237. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21238. */
  21239. disposeFramebufferObjects(): void;
  21240. /**
  21241. * Dispose the texture and release its associated resources.
  21242. */
  21243. dispose(): void;
  21244. /** @hidden */
  21245. _rebuild(): void;
  21246. /**
  21247. * Clear the info related to rendering groups preventing retention point in material dispose.
  21248. */
  21249. freeRenderingGroups(): void;
  21250. /**
  21251. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21252. * @returns the view count
  21253. */
  21254. getViewCount(): number;
  21255. }
  21256. }
  21257. declare module "babylonjs/Materials/material" {
  21258. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21259. import { SmartArray } from "babylonjs/Misc/smartArray";
  21260. import { Observable } from "babylonjs/Misc/observable";
  21261. import { Nullable } from "babylonjs/types";
  21262. import { Scene } from "babylonjs/scene";
  21263. import { Matrix } from "babylonjs/Maths/math.vector";
  21264. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21266. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21267. import { Effect } from "babylonjs/Materials/effect";
  21268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21269. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21270. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21271. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21272. import { Mesh } from "babylonjs/Meshes/mesh";
  21273. import { Animation } from "babylonjs/Animations/animation";
  21274. /**
  21275. * Options for compiling materials.
  21276. */
  21277. export interface IMaterialCompilationOptions {
  21278. /**
  21279. * Defines whether clip planes are enabled.
  21280. */
  21281. clipPlane: boolean;
  21282. /**
  21283. * Defines whether instances are enabled.
  21284. */
  21285. useInstances: boolean;
  21286. }
  21287. /**
  21288. * Base class for the main features of a material in Babylon.js
  21289. */
  21290. export class Material implements IAnimatable {
  21291. /**
  21292. * Returns the triangle fill mode
  21293. */
  21294. static readonly TriangleFillMode: number;
  21295. /**
  21296. * Returns the wireframe mode
  21297. */
  21298. static readonly WireFrameFillMode: number;
  21299. /**
  21300. * Returns the point fill mode
  21301. */
  21302. static readonly PointFillMode: number;
  21303. /**
  21304. * Returns the point list draw mode
  21305. */
  21306. static readonly PointListDrawMode: number;
  21307. /**
  21308. * Returns the line list draw mode
  21309. */
  21310. static readonly LineListDrawMode: number;
  21311. /**
  21312. * Returns the line loop draw mode
  21313. */
  21314. static readonly LineLoopDrawMode: number;
  21315. /**
  21316. * Returns the line strip draw mode
  21317. */
  21318. static readonly LineStripDrawMode: number;
  21319. /**
  21320. * Returns the triangle strip draw mode
  21321. */
  21322. static readonly TriangleStripDrawMode: number;
  21323. /**
  21324. * Returns the triangle fan draw mode
  21325. */
  21326. static readonly TriangleFanDrawMode: number;
  21327. /**
  21328. * Stores the clock-wise side orientation
  21329. */
  21330. static readonly ClockWiseSideOrientation: number;
  21331. /**
  21332. * Stores the counter clock-wise side orientation
  21333. */
  21334. static readonly CounterClockWiseSideOrientation: number;
  21335. /**
  21336. * The dirty texture flag value
  21337. */
  21338. static readonly TextureDirtyFlag: number;
  21339. /**
  21340. * The dirty light flag value
  21341. */
  21342. static readonly LightDirtyFlag: number;
  21343. /**
  21344. * The dirty fresnel flag value
  21345. */
  21346. static readonly FresnelDirtyFlag: number;
  21347. /**
  21348. * The dirty attribute flag value
  21349. */
  21350. static readonly AttributesDirtyFlag: number;
  21351. /**
  21352. * The dirty misc flag value
  21353. */
  21354. static readonly MiscDirtyFlag: number;
  21355. /**
  21356. * The all dirty flag value
  21357. */
  21358. static readonly AllDirtyFlag: number;
  21359. /**
  21360. * The ID of the material
  21361. */
  21362. id: string;
  21363. /**
  21364. * Gets or sets the unique id of the material
  21365. */
  21366. uniqueId: number;
  21367. /**
  21368. * The name of the material
  21369. */
  21370. name: string;
  21371. /**
  21372. * Gets or sets user defined metadata
  21373. */
  21374. metadata: any;
  21375. /**
  21376. * For internal use only. Please do not use.
  21377. */
  21378. reservedDataStore: any;
  21379. /**
  21380. * Specifies if the ready state should be checked on each call
  21381. */
  21382. checkReadyOnEveryCall: boolean;
  21383. /**
  21384. * Specifies if the ready state should be checked once
  21385. */
  21386. checkReadyOnlyOnce: boolean;
  21387. /**
  21388. * The state of the material
  21389. */
  21390. state: string;
  21391. /**
  21392. * The alpha value of the material
  21393. */
  21394. protected _alpha: number;
  21395. /**
  21396. * List of inspectable custom properties (used by the Inspector)
  21397. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21398. */
  21399. inspectableCustomProperties: IInspectable[];
  21400. /**
  21401. * Sets the alpha value of the material
  21402. */
  21403. set alpha(value: number);
  21404. /**
  21405. * Gets the alpha value of the material
  21406. */
  21407. get alpha(): number;
  21408. /**
  21409. * Specifies if back face culling is enabled
  21410. */
  21411. protected _backFaceCulling: boolean;
  21412. /**
  21413. * Sets the back-face culling state
  21414. */
  21415. set backFaceCulling(value: boolean);
  21416. /**
  21417. * Gets the back-face culling state
  21418. */
  21419. get backFaceCulling(): boolean;
  21420. /**
  21421. * Stores the value for side orientation
  21422. */
  21423. sideOrientation: number;
  21424. /**
  21425. * Callback triggered when the material is compiled
  21426. */
  21427. onCompiled: Nullable<(effect: Effect) => void>;
  21428. /**
  21429. * Callback triggered when an error occurs
  21430. */
  21431. onError: Nullable<(effect: Effect, errors: string) => void>;
  21432. /**
  21433. * Callback triggered to get the render target textures
  21434. */
  21435. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21436. /**
  21437. * Gets a boolean indicating that current material needs to register RTT
  21438. */
  21439. get hasRenderTargetTextures(): boolean;
  21440. /**
  21441. * Specifies if the material should be serialized
  21442. */
  21443. doNotSerialize: boolean;
  21444. /**
  21445. * @hidden
  21446. */
  21447. _storeEffectOnSubMeshes: boolean;
  21448. /**
  21449. * Stores the animations for the material
  21450. */
  21451. animations: Nullable<Array<Animation>>;
  21452. /**
  21453. * An event triggered when the material is disposed
  21454. */
  21455. onDisposeObservable: Observable<Material>;
  21456. /**
  21457. * An observer which watches for dispose events
  21458. */
  21459. private _onDisposeObserver;
  21460. private _onUnBindObservable;
  21461. /**
  21462. * Called during a dispose event
  21463. */
  21464. set onDispose(callback: () => void);
  21465. private _onBindObservable;
  21466. /**
  21467. * An event triggered when the material is bound
  21468. */
  21469. get onBindObservable(): Observable<AbstractMesh>;
  21470. /**
  21471. * An observer which watches for bind events
  21472. */
  21473. private _onBindObserver;
  21474. /**
  21475. * Called during a bind event
  21476. */
  21477. set onBind(callback: (Mesh: AbstractMesh) => void);
  21478. /**
  21479. * An event triggered when the material is unbound
  21480. */
  21481. get onUnBindObservable(): Observable<Material>;
  21482. /**
  21483. * Stores the value of the alpha mode
  21484. */
  21485. private _alphaMode;
  21486. /**
  21487. * Sets the value of the alpha mode.
  21488. *
  21489. * | Value | Type | Description |
  21490. * | --- | --- | --- |
  21491. * | 0 | ALPHA_DISABLE | |
  21492. * | 1 | ALPHA_ADD | |
  21493. * | 2 | ALPHA_COMBINE | |
  21494. * | 3 | ALPHA_SUBTRACT | |
  21495. * | 4 | ALPHA_MULTIPLY | |
  21496. * | 5 | ALPHA_MAXIMIZED | |
  21497. * | 6 | ALPHA_ONEONE | |
  21498. * | 7 | ALPHA_PREMULTIPLIED | |
  21499. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21500. * | 9 | ALPHA_INTERPOLATE | |
  21501. * | 10 | ALPHA_SCREENMODE | |
  21502. *
  21503. */
  21504. set alphaMode(value: number);
  21505. /**
  21506. * Gets the value of the alpha mode
  21507. */
  21508. get alphaMode(): number;
  21509. /**
  21510. * Stores the state of the need depth pre-pass value
  21511. */
  21512. private _needDepthPrePass;
  21513. /**
  21514. * Sets the need depth pre-pass value
  21515. */
  21516. set needDepthPrePass(value: boolean);
  21517. /**
  21518. * Gets the depth pre-pass value
  21519. */
  21520. get needDepthPrePass(): boolean;
  21521. /**
  21522. * Specifies if depth writing should be disabled
  21523. */
  21524. disableDepthWrite: boolean;
  21525. /**
  21526. * Specifies if depth writing should be forced
  21527. */
  21528. forceDepthWrite: boolean;
  21529. /**
  21530. * Specifies the depth function that should be used. 0 means the default engine function
  21531. */
  21532. depthFunction: number;
  21533. /**
  21534. * Specifies if there should be a separate pass for culling
  21535. */
  21536. separateCullingPass: boolean;
  21537. /**
  21538. * Stores the state specifing if fog should be enabled
  21539. */
  21540. private _fogEnabled;
  21541. /**
  21542. * Sets the state for enabling fog
  21543. */
  21544. set fogEnabled(value: boolean);
  21545. /**
  21546. * Gets the value of the fog enabled state
  21547. */
  21548. get fogEnabled(): boolean;
  21549. /**
  21550. * Stores the size of points
  21551. */
  21552. pointSize: number;
  21553. /**
  21554. * Stores the z offset value
  21555. */
  21556. zOffset: number;
  21557. /**
  21558. * Gets a value specifying if wireframe mode is enabled
  21559. */
  21560. get wireframe(): boolean;
  21561. /**
  21562. * Sets the state of wireframe mode
  21563. */
  21564. set wireframe(value: boolean);
  21565. /**
  21566. * Gets the value specifying if point clouds are enabled
  21567. */
  21568. get pointsCloud(): boolean;
  21569. /**
  21570. * Sets the state of point cloud mode
  21571. */
  21572. set pointsCloud(value: boolean);
  21573. /**
  21574. * Gets the material fill mode
  21575. */
  21576. get fillMode(): number;
  21577. /**
  21578. * Sets the material fill mode
  21579. */
  21580. set fillMode(value: number);
  21581. /**
  21582. * @hidden
  21583. * Stores the effects for the material
  21584. */
  21585. _effect: Nullable<Effect>;
  21586. /**
  21587. * Specifies if uniform buffers should be used
  21588. */
  21589. private _useUBO;
  21590. /**
  21591. * Stores a reference to the scene
  21592. */
  21593. private _scene;
  21594. /**
  21595. * Stores the fill mode state
  21596. */
  21597. private _fillMode;
  21598. /**
  21599. * Specifies if the depth write state should be cached
  21600. */
  21601. private _cachedDepthWriteState;
  21602. /**
  21603. * Specifies if the depth function state should be cached
  21604. */
  21605. private _cachedDepthFunctionState;
  21606. /**
  21607. * Stores the uniform buffer
  21608. */
  21609. protected _uniformBuffer: UniformBuffer;
  21610. /** @hidden */
  21611. _indexInSceneMaterialArray: number;
  21612. /** @hidden */
  21613. meshMap: Nullable<{
  21614. [id: string]: AbstractMesh | undefined;
  21615. }>;
  21616. /**
  21617. * Creates a material instance
  21618. * @param name defines the name of the material
  21619. * @param scene defines the scene to reference
  21620. * @param doNotAdd specifies if the material should be added to the scene
  21621. */
  21622. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21623. /**
  21624. * Returns a string representation of the current material
  21625. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21626. * @returns a string with material information
  21627. */
  21628. toString(fullDetails?: boolean): string;
  21629. /**
  21630. * Gets the class name of the material
  21631. * @returns a string with the class name of the material
  21632. */
  21633. getClassName(): string;
  21634. /**
  21635. * Specifies if updates for the material been locked
  21636. */
  21637. get isFrozen(): boolean;
  21638. /**
  21639. * Locks updates for the material
  21640. */
  21641. freeze(): void;
  21642. /**
  21643. * Unlocks updates for the material
  21644. */
  21645. unfreeze(): void;
  21646. /**
  21647. * Specifies if the material is ready to be used
  21648. * @param mesh defines the mesh to check
  21649. * @param useInstances specifies if instances should be used
  21650. * @returns a boolean indicating if the material is ready to be used
  21651. */
  21652. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21653. /**
  21654. * Specifies that the submesh is ready to be used
  21655. * @param mesh defines the mesh to check
  21656. * @param subMesh defines which submesh to check
  21657. * @param useInstances specifies that instances should be used
  21658. * @returns a boolean indicating that the submesh is ready or not
  21659. */
  21660. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21661. /**
  21662. * Returns the material effect
  21663. * @returns the effect associated with the material
  21664. */
  21665. getEffect(): Nullable<Effect>;
  21666. /**
  21667. * Returns the current scene
  21668. * @returns a Scene
  21669. */
  21670. getScene(): Scene;
  21671. /**
  21672. * Specifies if the material will require alpha blending
  21673. * @returns a boolean specifying if alpha blending is needed
  21674. */
  21675. needAlphaBlending(): boolean;
  21676. /**
  21677. * Specifies if the mesh will require alpha blending
  21678. * @param mesh defines the mesh to check
  21679. * @returns a boolean specifying if alpha blending is needed for the mesh
  21680. */
  21681. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21682. /**
  21683. * Specifies if this material should be rendered in alpha test mode
  21684. * @returns a boolean specifying if an alpha test is needed.
  21685. */
  21686. needAlphaTesting(): boolean;
  21687. /**
  21688. * Gets the texture used for the alpha test
  21689. * @returns the texture to use for alpha testing
  21690. */
  21691. getAlphaTestTexture(): Nullable<BaseTexture>;
  21692. /**
  21693. * Marks the material to indicate that it needs to be re-calculated
  21694. */
  21695. markDirty(): void;
  21696. /** @hidden */
  21697. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21698. /**
  21699. * Binds the material to the mesh
  21700. * @param world defines the world transformation matrix
  21701. * @param mesh defines the mesh to bind the material to
  21702. */
  21703. bind(world: Matrix, mesh?: Mesh): void;
  21704. /**
  21705. * Binds the submesh to the material
  21706. * @param world defines the world transformation matrix
  21707. * @param mesh defines the mesh containing the submesh
  21708. * @param subMesh defines the submesh to bind the material to
  21709. */
  21710. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21711. /**
  21712. * Binds the world matrix to the material
  21713. * @param world defines the world transformation matrix
  21714. */
  21715. bindOnlyWorldMatrix(world: Matrix): void;
  21716. /**
  21717. * Binds the scene's uniform buffer to the effect.
  21718. * @param effect defines the effect to bind to the scene uniform buffer
  21719. * @param sceneUbo defines the uniform buffer storing scene data
  21720. */
  21721. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21722. /**
  21723. * Binds the view matrix to the effect
  21724. * @param effect defines the effect to bind the view matrix to
  21725. */
  21726. bindView(effect: Effect): void;
  21727. /**
  21728. * Binds the view projection matrix to the effect
  21729. * @param effect defines the effect to bind the view projection matrix to
  21730. */
  21731. bindViewProjection(effect: Effect): void;
  21732. /**
  21733. * Specifies if material alpha testing should be turned on for the mesh
  21734. * @param mesh defines the mesh to check
  21735. */
  21736. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21737. /**
  21738. * Processes to execute after binding the material to a mesh
  21739. * @param mesh defines the rendered mesh
  21740. */
  21741. protected _afterBind(mesh?: Mesh): void;
  21742. /**
  21743. * Unbinds the material from the mesh
  21744. */
  21745. unbind(): void;
  21746. /**
  21747. * Gets the active textures from the material
  21748. * @returns an array of textures
  21749. */
  21750. getActiveTextures(): BaseTexture[];
  21751. /**
  21752. * Specifies if the material uses a texture
  21753. * @param texture defines the texture to check against the material
  21754. * @returns a boolean specifying if the material uses the texture
  21755. */
  21756. hasTexture(texture: BaseTexture): boolean;
  21757. /**
  21758. * Makes a duplicate of the material, and gives it a new name
  21759. * @param name defines the new name for the duplicated material
  21760. * @returns the cloned material
  21761. */
  21762. clone(name: string): Nullable<Material>;
  21763. /**
  21764. * Gets the meshes bound to the material
  21765. * @returns an array of meshes bound to the material
  21766. */
  21767. getBindedMeshes(): AbstractMesh[];
  21768. /**
  21769. * Force shader compilation
  21770. * @param mesh defines the mesh associated with this material
  21771. * @param onCompiled defines a function to execute once the material is compiled
  21772. * @param options defines the options to configure the compilation
  21773. * @param onError defines a function to execute if the material fails compiling
  21774. */
  21775. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21776. /**
  21777. * Force shader compilation
  21778. * @param mesh defines the mesh that will use this material
  21779. * @param options defines additional options for compiling the shaders
  21780. * @returns a promise that resolves when the compilation completes
  21781. */
  21782. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21783. private static readonly _AllDirtyCallBack;
  21784. private static readonly _ImageProcessingDirtyCallBack;
  21785. private static readonly _TextureDirtyCallBack;
  21786. private static readonly _FresnelDirtyCallBack;
  21787. private static readonly _MiscDirtyCallBack;
  21788. private static readonly _LightsDirtyCallBack;
  21789. private static readonly _AttributeDirtyCallBack;
  21790. private static _FresnelAndMiscDirtyCallBack;
  21791. private static _TextureAndMiscDirtyCallBack;
  21792. private static readonly _DirtyCallbackArray;
  21793. private static readonly _RunDirtyCallBacks;
  21794. /**
  21795. * Marks a define in the material to indicate that it needs to be re-computed
  21796. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21797. */
  21798. markAsDirty(flag: number): void;
  21799. /**
  21800. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21801. * @param func defines a function which checks material defines against the submeshes
  21802. */
  21803. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21804. /**
  21805. * Indicates that we need to re-calculated for all submeshes
  21806. */
  21807. protected _markAllSubMeshesAsAllDirty(): void;
  21808. /**
  21809. * Indicates that image processing needs to be re-calculated for all submeshes
  21810. */
  21811. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21812. /**
  21813. * Indicates that textures need to be re-calculated for all submeshes
  21814. */
  21815. protected _markAllSubMeshesAsTexturesDirty(): void;
  21816. /**
  21817. * Indicates that fresnel needs to be re-calculated for all submeshes
  21818. */
  21819. protected _markAllSubMeshesAsFresnelDirty(): void;
  21820. /**
  21821. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21822. */
  21823. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21824. /**
  21825. * Indicates that lights need to be re-calculated for all submeshes
  21826. */
  21827. protected _markAllSubMeshesAsLightsDirty(): void;
  21828. /**
  21829. * Indicates that attributes need to be re-calculated for all submeshes
  21830. */
  21831. protected _markAllSubMeshesAsAttributesDirty(): void;
  21832. /**
  21833. * Indicates that misc needs to be re-calculated for all submeshes
  21834. */
  21835. protected _markAllSubMeshesAsMiscDirty(): void;
  21836. /**
  21837. * Indicates that textures and misc need to be re-calculated for all submeshes
  21838. */
  21839. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21840. /**
  21841. * Disposes the material
  21842. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21843. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21844. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21845. */
  21846. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21847. /** @hidden */
  21848. private releaseVertexArrayObject;
  21849. /**
  21850. * Serializes this material
  21851. * @returns the serialized material object
  21852. */
  21853. serialize(): any;
  21854. /**
  21855. * Creates a material from parsed material data
  21856. * @param parsedMaterial defines parsed material data
  21857. * @param scene defines the hosting scene
  21858. * @param rootUrl defines the root URL to use to load textures
  21859. * @returns a new material
  21860. */
  21861. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21862. }
  21863. }
  21864. declare module "babylonjs/Materials/multiMaterial" {
  21865. import { Nullable } from "babylonjs/types";
  21866. import { Scene } from "babylonjs/scene";
  21867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21868. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21870. import { Material } from "babylonjs/Materials/material";
  21871. /**
  21872. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21873. * separate meshes. This can be use to improve performances.
  21874. * @see http://doc.babylonjs.com/how_to/multi_materials
  21875. */
  21876. export class MultiMaterial extends Material {
  21877. private _subMaterials;
  21878. /**
  21879. * Gets or Sets the list of Materials used within the multi material.
  21880. * They need to be ordered according to the submeshes order in the associated mesh
  21881. */
  21882. get subMaterials(): Nullable<Material>[];
  21883. set subMaterials(value: Nullable<Material>[]);
  21884. /**
  21885. * Function used to align with Node.getChildren()
  21886. * @returns the list of Materials used within the multi material
  21887. */
  21888. getChildren(): Nullable<Material>[];
  21889. /**
  21890. * Instantiates a new Multi Material
  21891. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21892. * separate meshes. This can be use to improve performances.
  21893. * @see http://doc.babylonjs.com/how_to/multi_materials
  21894. * @param name Define the name in the scene
  21895. * @param scene Define the scene the material belongs to
  21896. */
  21897. constructor(name: string, scene: Scene);
  21898. private _hookArray;
  21899. /**
  21900. * Get one of the submaterial by its index in the submaterials array
  21901. * @param index The index to look the sub material at
  21902. * @returns The Material if the index has been defined
  21903. */
  21904. getSubMaterial(index: number): Nullable<Material>;
  21905. /**
  21906. * Get the list of active textures for the whole sub materials list.
  21907. * @returns All the textures that will be used during the rendering
  21908. */
  21909. getActiveTextures(): BaseTexture[];
  21910. /**
  21911. * Gets the current class name of the material e.g. "MultiMaterial"
  21912. * Mainly use in serialization.
  21913. * @returns the class name
  21914. */
  21915. getClassName(): string;
  21916. /**
  21917. * Checks if the material is ready to render the requested sub mesh
  21918. * @param mesh Define the mesh the submesh belongs to
  21919. * @param subMesh Define the sub mesh to look readyness for
  21920. * @param useInstances Define whether or not the material is used with instances
  21921. * @returns true if ready, otherwise false
  21922. */
  21923. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21924. /**
  21925. * Clones the current material and its related sub materials
  21926. * @param name Define the name of the newly cloned material
  21927. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21928. * @returns the cloned material
  21929. */
  21930. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21931. /**
  21932. * Serializes the materials into a JSON representation.
  21933. * @returns the JSON representation
  21934. */
  21935. serialize(): any;
  21936. /**
  21937. * Dispose the material and release its associated resources
  21938. * @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)
  21939. * @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)
  21940. * @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)
  21941. */
  21942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21943. /**
  21944. * Creates a MultiMaterial from parsed MultiMaterial data.
  21945. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21946. * @param scene defines the hosting scene
  21947. * @returns a new MultiMaterial
  21948. */
  21949. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21950. }
  21951. }
  21952. declare module "babylonjs/Meshes/subMesh" {
  21953. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21954. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21955. import { Engine } from "babylonjs/Engines/engine";
  21956. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21957. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21958. import { Effect } from "babylonjs/Materials/effect";
  21959. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21960. import { Plane } from "babylonjs/Maths/math.plane";
  21961. import { Collider } from "babylonjs/Collisions/collider";
  21962. import { Material } from "babylonjs/Materials/material";
  21963. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21965. import { Mesh } from "babylonjs/Meshes/mesh";
  21966. import { Ray } from "babylonjs/Culling/ray";
  21967. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21968. /**
  21969. * Base class for submeshes
  21970. */
  21971. export class BaseSubMesh {
  21972. /** @hidden */
  21973. _materialDefines: Nullable<MaterialDefines>;
  21974. /** @hidden */
  21975. _materialEffect: Nullable<Effect>;
  21976. /**
  21977. * Gets material defines used by the effect associated to the sub mesh
  21978. */
  21979. get materialDefines(): Nullable<MaterialDefines>;
  21980. /**
  21981. * Sets material defines used by the effect associated to the sub mesh
  21982. */
  21983. set materialDefines(defines: Nullable<MaterialDefines>);
  21984. /**
  21985. * Gets associated effect
  21986. */
  21987. get effect(): Nullable<Effect>;
  21988. /**
  21989. * Sets associated effect (effect used to render this submesh)
  21990. * @param effect defines the effect to associate with
  21991. * @param defines defines the set of defines used to compile this effect
  21992. */
  21993. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21994. }
  21995. /**
  21996. * Defines a subdivision inside a mesh
  21997. */
  21998. export class SubMesh extends BaseSubMesh implements ICullable {
  21999. /** the material index to use */
  22000. materialIndex: number;
  22001. /** vertex index start */
  22002. verticesStart: number;
  22003. /** vertices count */
  22004. verticesCount: number;
  22005. /** index start */
  22006. indexStart: number;
  22007. /** indices count */
  22008. indexCount: number;
  22009. /** @hidden */
  22010. _linesIndexCount: number;
  22011. private _mesh;
  22012. private _renderingMesh;
  22013. private _boundingInfo;
  22014. private _linesIndexBuffer;
  22015. /** @hidden */
  22016. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22017. /** @hidden */
  22018. _trianglePlanes: Plane[];
  22019. /** @hidden */
  22020. _lastColliderTransformMatrix: Nullable<Matrix>;
  22021. /** @hidden */
  22022. _renderId: number;
  22023. /** @hidden */
  22024. _alphaIndex: number;
  22025. /** @hidden */
  22026. _distanceToCamera: number;
  22027. /** @hidden */
  22028. _id: number;
  22029. private _currentMaterial;
  22030. /**
  22031. * Add a new submesh to a mesh
  22032. * @param materialIndex defines the material index to use
  22033. * @param verticesStart defines vertex index start
  22034. * @param verticesCount defines vertices count
  22035. * @param indexStart defines index start
  22036. * @param indexCount defines indices count
  22037. * @param mesh defines the parent mesh
  22038. * @param renderingMesh defines an optional rendering mesh
  22039. * @param createBoundingBox defines if bounding box should be created for this submesh
  22040. * @returns the new submesh
  22041. */
  22042. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22043. /**
  22044. * Creates a new submesh
  22045. * @param materialIndex defines the material index to use
  22046. * @param verticesStart defines vertex index start
  22047. * @param verticesCount defines vertices count
  22048. * @param indexStart defines index start
  22049. * @param indexCount defines indices count
  22050. * @param mesh defines the parent mesh
  22051. * @param renderingMesh defines an optional rendering mesh
  22052. * @param createBoundingBox defines if bounding box should be created for this submesh
  22053. */
  22054. constructor(
  22055. /** the material index to use */
  22056. materialIndex: number,
  22057. /** vertex index start */
  22058. verticesStart: number,
  22059. /** vertices count */
  22060. verticesCount: number,
  22061. /** index start */
  22062. indexStart: number,
  22063. /** indices count */
  22064. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22065. /**
  22066. * Returns true if this submesh covers the entire parent mesh
  22067. * @ignorenaming
  22068. */
  22069. get IsGlobal(): boolean;
  22070. /**
  22071. * Returns the submesh BoudingInfo object
  22072. * @returns current bounding info (or mesh's one if the submesh is global)
  22073. */
  22074. getBoundingInfo(): BoundingInfo;
  22075. /**
  22076. * Sets the submesh BoundingInfo
  22077. * @param boundingInfo defines the new bounding info to use
  22078. * @returns the SubMesh
  22079. */
  22080. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22081. /**
  22082. * Returns the mesh of the current submesh
  22083. * @return the parent mesh
  22084. */
  22085. getMesh(): AbstractMesh;
  22086. /**
  22087. * Returns the rendering mesh of the submesh
  22088. * @returns the rendering mesh (could be different from parent mesh)
  22089. */
  22090. getRenderingMesh(): Mesh;
  22091. /**
  22092. * Returns the submesh material
  22093. * @returns null or the current material
  22094. */
  22095. getMaterial(): Nullable<Material>;
  22096. /**
  22097. * Sets a new updated BoundingInfo object to the submesh
  22098. * @param data defines an optional position array to use to determine the bounding info
  22099. * @returns the SubMesh
  22100. */
  22101. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22102. /** @hidden */
  22103. _checkCollision(collider: Collider): boolean;
  22104. /**
  22105. * Updates the submesh BoundingInfo
  22106. * @param world defines the world matrix to use to update the bounding info
  22107. * @returns the submesh
  22108. */
  22109. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22110. /**
  22111. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22112. * @param frustumPlanes defines the frustum planes
  22113. * @returns true if the submesh is intersecting with the frustum
  22114. */
  22115. isInFrustum(frustumPlanes: Plane[]): boolean;
  22116. /**
  22117. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22118. * @param frustumPlanes defines the frustum planes
  22119. * @returns true if the submesh is inside the frustum
  22120. */
  22121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22122. /**
  22123. * Renders the submesh
  22124. * @param enableAlphaMode defines if alpha needs to be used
  22125. * @returns the submesh
  22126. */
  22127. render(enableAlphaMode: boolean): SubMesh;
  22128. /**
  22129. * @hidden
  22130. */
  22131. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22132. /**
  22133. * Checks if the submesh intersects with a ray
  22134. * @param ray defines the ray to test
  22135. * @returns true is the passed ray intersects the submesh bounding box
  22136. */
  22137. canIntersects(ray: Ray): boolean;
  22138. /**
  22139. * Intersects current submesh with a ray
  22140. * @param ray defines the ray to test
  22141. * @param positions defines mesh's positions array
  22142. * @param indices defines mesh's indices array
  22143. * @param fastCheck defines if only bounding info should be used
  22144. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22145. * @returns intersection info or null if no intersection
  22146. */
  22147. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22148. /** @hidden */
  22149. private _intersectLines;
  22150. /** @hidden */
  22151. private _intersectUnIndexedLines;
  22152. /** @hidden */
  22153. private _intersectTriangles;
  22154. /** @hidden */
  22155. private _intersectUnIndexedTriangles;
  22156. /** @hidden */
  22157. _rebuild(): void;
  22158. /**
  22159. * Creates a new submesh from the passed mesh
  22160. * @param newMesh defines the new hosting mesh
  22161. * @param newRenderingMesh defines an optional rendering mesh
  22162. * @returns the new submesh
  22163. */
  22164. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22165. /**
  22166. * Release associated resources
  22167. */
  22168. dispose(): void;
  22169. /**
  22170. * Gets the class name
  22171. * @returns the string "SubMesh".
  22172. */
  22173. getClassName(): string;
  22174. /**
  22175. * Creates a new submesh from indices data
  22176. * @param materialIndex the index of the main mesh material
  22177. * @param startIndex the index where to start the copy in the mesh indices array
  22178. * @param indexCount the number of indices to copy then from the startIndex
  22179. * @param mesh the main mesh to create the submesh from
  22180. * @param renderingMesh the optional rendering mesh
  22181. * @returns a new submesh
  22182. */
  22183. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22184. }
  22185. }
  22186. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22187. /**
  22188. * Class used to represent data loading progression
  22189. */
  22190. export class SceneLoaderFlags {
  22191. private static _ForceFullSceneLoadingForIncremental;
  22192. private static _ShowLoadingScreen;
  22193. private static _CleanBoneMatrixWeights;
  22194. private static _loggingLevel;
  22195. /**
  22196. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22197. */
  22198. static get ForceFullSceneLoadingForIncremental(): boolean;
  22199. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22200. /**
  22201. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22202. */
  22203. static get ShowLoadingScreen(): boolean;
  22204. static set ShowLoadingScreen(value: boolean);
  22205. /**
  22206. * Defines the current logging level (while loading the scene)
  22207. * @ignorenaming
  22208. */
  22209. static get loggingLevel(): number;
  22210. static set loggingLevel(value: number);
  22211. /**
  22212. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22213. */
  22214. static get CleanBoneMatrixWeights(): boolean;
  22215. static set CleanBoneMatrixWeights(value: boolean);
  22216. }
  22217. }
  22218. declare module "babylonjs/Meshes/geometry" {
  22219. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22220. import { Scene } from "babylonjs/scene";
  22221. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22222. import { Engine } from "babylonjs/Engines/engine";
  22223. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22224. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22225. import { Effect } from "babylonjs/Materials/effect";
  22226. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22227. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22228. import { Mesh } from "babylonjs/Meshes/mesh";
  22229. /**
  22230. * Class used to store geometry data (vertex buffers + index buffer)
  22231. */
  22232. export class Geometry implements IGetSetVerticesData {
  22233. /**
  22234. * Gets or sets the ID of the geometry
  22235. */
  22236. id: string;
  22237. /**
  22238. * Gets or sets the unique ID of the geometry
  22239. */
  22240. uniqueId: number;
  22241. /**
  22242. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22243. */
  22244. delayLoadState: number;
  22245. /**
  22246. * Gets the file containing the data to load when running in delay load state
  22247. */
  22248. delayLoadingFile: Nullable<string>;
  22249. /**
  22250. * Callback called when the geometry is updated
  22251. */
  22252. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22253. private _scene;
  22254. private _engine;
  22255. private _meshes;
  22256. private _totalVertices;
  22257. /** @hidden */
  22258. _indices: IndicesArray;
  22259. /** @hidden */
  22260. _vertexBuffers: {
  22261. [key: string]: VertexBuffer;
  22262. };
  22263. private _isDisposed;
  22264. private _extend;
  22265. private _boundingBias;
  22266. /** @hidden */
  22267. _delayInfo: Array<string>;
  22268. private _indexBuffer;
  22269. private _indexBufferIsUpdatable;
  22270. /** @hidden */
  22271. _boundingInfo: Nullable<BoundingInfo>;
  22272. /** @hidden */
  22273. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22274. /** @hidden */
  22275. _softwareSkinningFrameId: number;
  22276. private _vertexArrayObjects;
  22277. private _updatable;
  22278. /** @hidden */
  22279. _positions: Nullable<Vector3[]>;
  22280. /**
  22281. * 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
  22282. */
  22283. get boundingBias(): Vector2;
  22284. /**
  22285. * 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
  22286. */
  22287. set boundingBias(value: Vector2);
  22288. /**
  22289. * Static function used to attach a new empty geometry to a mesh
  22290. * @param mesh defines the mesh to attach the geometry to
  22291. * @returns the new Geometry
  22292. */
  22293. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22294. /**
  22295. * Creates a new geometry
  22296. * @param id defines the unique ID
  22297. * @param scene defines the hosting scene
  22298. * @param vertexData defines the VertexData used to get geometry data
  22299. * @param updatable defines if geometry must be updatable (false by default)
  22300. * @param mesh defines the mesh that will be associated with the geometry
  22301. */
  22302. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22303. /**
  22304. * Gets the current extend of the geometry
  22305. */
  22306. get extend(): {
  22307. minimum: Vector3;
  22308. maximum: Vector3;
  22309. };
  22310. /**
  22311. * Gets the hosting scene
  22312. * @returns the hosting Scene
  22313. */
  22314. getScene(): Scene;
  22315. /**
  22316. * Gets the hosting engine
  22317. * @returns the hosting Engine
  22318. */
  22319. getEngine(): Engine;
  22320. /**
  22321. * Defines if the geometry is ready to use
  22322. * @returns true if the geometry is ready to be used
  22323. */
  22324. isReady(): boolean;
  22325. /**
  22326. * Gets a value indicating that the geometry should not be serialized
  22327. */
  22328. get doNotSerialize(): boolean;
  22329. /** @hidden */
  22330. _rebuild(): void;
  22331. /**
  22332. * Affects all geometry data in one call
  22333. * @param vertexData defines the geometry data
  22334. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22335. */
  22336. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22337. /**
  22338. * Set specific vertex data
  22339. * @param kind defines the data kind (Position, normal, etc...)
  22340. * @param data defines the vertex data to use
  22341. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22342. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22343. */
  22344. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22345. /**
  22346. * Removes a specific vertex data
  22347. * @param kind defines the data kind (Position, normal, etc...)
  22348. */
  22349. removeVerticesData(kind: string): void;
  22350. /**
  22351. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22352. * @param buffer defines the vertex buffer to use
  22353. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22354. */
  22355. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22356. /**
  22357. * Update a specific vertex buffer
  22358. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22359. * It will do nothing if the buffer is not updatable
  22360. * @param kind defines the data kind (Position, normal, etc...)
  22361. * @param data defines the data to use
  22362. * @param offset defines the offset in the target buffer where to store the data
  22363. * @param useBytes set to true if the offset is in bytes
  22364. */
  22365. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22366. /**
  22367. * Update a specific vertex buffer
  22368. * This function will create a new buffer if the current one is not updatable
  22369. * @param kind defines the data kind (Position, normal, etc...)
  22370. * @param data defines the data to use
  22371. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22372. */
  22373. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22374. private _updateBoundingInfo;
  22375. /** @hidden */
  22376. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22377. /**
  22378. * Gets total number of vertices
  22379. * @returns the total number of vertices
  22380. */
  22381. getTotalVertices(): number;
  22382. /**
  22383. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22384. * @param kind defines the data kind (Position, normal, etc...)
  22385. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22386. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22387. * @returns a float array containing vertex data
  22388. */
  22389. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22390. /**
  22391. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22392. * @param kind defines the data kind (Position, normal, etc...)
  22393. * @returns true if the vertex buffer with the specified kind is updatable
  22394. */
  22395. isVertexBufferUpdatable(kind: string): boolean;
  22396. /**
  22397. * Gets a specific vertex buffer
  22398. * @param kind defines the data kind (Position, normal, etc...)
  22399. * @returns a VertexBuffer
  22400. */
  22401. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22402. /**
  22403. * Returns all vertex buffers
  22404. * @return an object holding all vertex buffers indexed by kind
  22405. */
  22406. getVertexBuffers(): Nullable<{
  22407. [key: string]: VertexBuffer;
  22408. }>;
  22409. /**
  22410. * Gets a boolean indicating if specific vertex buffer is present
  22411. * @param kind defines the data kind (Position, normal, etc...)
  22412. * @returns true if data is present
  22413. */
  22414. isVerticesDataPresent(kind: string): boolean;
  22415. /**
  22416. * Gets a list of all attached data kinds (Position, normal, etc...)
  22417. * @returns a list of string containing all kinds
  22418. */
  22419. getVerticesDataKinds(): string[];
  22420. /**
  22421. * Update index buffer
  22422. * @param indices defines the indices to store in the index buffer
  22423. * @param offset defines the offset in the target buffer where to store the data
  22424. * @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)
  22425. */
  22426. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22427. /**
  22428. * Creates a new index buffer
  22429. * @param indices defines the indices to store in the index buffer
  22430. * @param totalVertices defines the total number of vertices (could be null)
  22431. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22432. */
  22433. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22434. /**
  22435. * Return the total number of indices
  22436. * @returns the total number of indices
  22437. */
  22438. getTotalIndices(): number;
  22439. /**
  22440. * Gets the index buffer array
  22441. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22442. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22443. * @returns the index buffer array
  22444. */
  22445. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22446. /**
  22447. * Gets the index buffer
  22448. * @return the index buffer
  22449. */
  22450. getIndexBuffer(): Nullable<DataBuffer>;
  22451. /** @hidden */
  22452. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22453. /**
  22454. * Release the associated resources for a specific mesh
  22455. * @param mesh defines the source mesh
  22456. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22457. */
  22458. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22459. /**
  22460. * Apply current geometry to a given mesh
  22461. * @param mesh defines the mesh to apply geometry to
  22462. */
  22463. applyToMesh(mesh: Mesh): void;
  22464. private _updateExtend;
  22465. private _applyToMesh;
  22466. private notifyUpdate;
  22467. /**
  22468. * Load the geometry if it was flagged as delay loaded
  22469. * @param scene defines the hosting scene
  22470. * @param onLoaded defines a callback called when the geometry is loaded
  22471. */
  22472. load(scene: Scene, onLoaded?: () => void): void;
  22473. private _queueLoad;
  22474. /**
  22475. * Invert the geometry to move from a right handed system to a left handed one.
  22476. */
  22477. toLeftHanded(): void;
  22478. /** @hidden */
  22479. _resetPointsArrayCache(): void;
  22480. /** @hidden */
  22481. _generatePointsArray(): boolean;
  22482. /**
  22483. * Gets a value indicating if the geometry is disposed
  22484. * @returns true if the geometry was disposed
  22485. */
  22486. isDisposed(): boolean;
  22487. private _disposeVertexArrayObjects;
  22488. /**
  22489. * Free all associated resources
  22490. */
  22491. dispose(): void;
  22492. /**
  22493. * Clone the current geometry into a new geometry
  22494. * @param id defines the unique ID of the new geometry
  22495. * @returns a new geometry object
  22496. */
  22497. copy(id: string): Geometry;
  22498. /**
  22499. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22500. * @return a JSON representation of the current geometry data (without the vertices data)
  22501. */
  22502. serialize(): any;
  22503. private toNumberArray;
  22504. /**
  22505. * Serialize all vertices data into a JSON oject
  22506. * @returns a JSON representation of the current geometry data
  22507. */
  22508. serializeVerticeData(): any;
  22509. /**
  22510. * Extracts a clone of a mesh geometry
  22511. * @param mesh defines the source mesh
  22512. * @param id defines the unique ID of the new geometry object
  22513. * @returns the new geometry object
  22514. */
  22515. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22516. /**
  22517. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22518. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22519. * Be aware Math.random() could cause collisions, but:
  22520. * "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"
  22521. * @returns a string containing a new GUID
  22522. */
  22523. static RandomId(): string;
  22524. /** @hidden */
  22525. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22526. private static _CleanMatricesWeights;
  22527. /**
  22528. * Create a new geometry from persisted data (Using .babylon file format)
  22529. * @param parsedVertexData defines the persisted data
  22530. * @param scene defines the hosting scene
  22531. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22532. * @returns the new geometry object
  22533. */
  22534. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22535. }
  22536. }
  22537. declare module "babylonjs/Meshes/mesh.vertexData" {
  22538. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22539. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22540. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22541. import { Geometry } from "babylonjs/Meshes/geometry";
  22542. import { Mesh } from "babylonjs/Meshes/mesh";
  22543. /**
  22544. * Define an interface for all classes that will get and set the data on vertices
  22545. */
  22546. export interface IGetSetVerticesData {
  22547. /**
  22548. * Gets a boolean indicating if specific vertex data is present
  22549. * @param kind defines the vertex data kind to use
  22550. * @returns true is data kind is present
  22551. */
  22552. isVerticesDataPresent(kind: string): boolean;
  22553. /**
  22554. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22555. * @param kind defines the data kind (Position, normal, etc...)
  22556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22558. * @returns a float array containing vertex data
  22559. */
  22560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22561. /**
  22562. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22563. * @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.
  22564. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22565. * @returns the indices array or an empty array if the mesh has no geometry
  22566. */
  22567. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22568. /**
  22569. * Set specific vertex data
  22570. * @param kind defines the data kind (Position, normal, etc...)
  22571. * @param data defines the vertex data to use
  22572. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22573. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22574. */
  22575. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22576. /**
  22577. * Update a specific associated vertex buffer
  22578. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22579. * - VertexBuffer.PositionKind
  22580. * - VertexBuffer.UVKind
  22581. * - VertexBuffer.UV2Kind
  22582. * - VertexBuffer.UV3Kind
  22583. * - VertexBuffer.UV4Kind
  22584. * - VertexBuffer.UV5Kind
  22585. * - VertexBuffer.UV6Kind
  22586. * - VertexBuffer.ColorKind
  22587. * - VertexBuffer.MatricesIndicesKind
  22588. * - VertexBuffer.MatricesIndicesExtraKind
  22589. * - VertexBuffer.MatricesWeightsKind
  22590. * - VertexBuffer.MatricesWeightsExtraKind
  22591. * @param data defines the data source
  22592. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22593. * @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)
  22594. */
  22595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22596. /**
  22597. * Creates a new index buffer
  22598. * @param indices defines the indices to store in the index buffer
  22599. * @param totalVertices defines the total number of vertices (could be null)
  22600. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22601. */
  22602. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22603. }
  22604. /**
  22605. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22606. */
  22607. export class VertexData {
  22608. /**
  22609. * Mesh side orientation : usually the external or front surface
  22610. */
  22611. static readonly FRONTSIDE: number;
  22612. /**
  22613. * Mesh side orientation : usually the internal or back surface
  22614. */
  22615. static readonly BACKSIDE: number;
  22616. /**
  22617. * Mesh side orientation : both internal and external or front and back surfaces
  22618. */
  22619. static readonly DOUBLESIDE: number;
  22620. /**
  22621. * Mesh side orientation : by default, `FRONTSIDE`
  22622. */
  22623. static readonly DEFAULTSIDE: number;
  22624. /**
  22625. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22626. */
  22627. positions: Nullable<FloatArray>;
  22628. /**
  22629. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22630. */
  22631. normals: Nullable<FloatArray>;
  22632. /**
  22633. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22634. */
  22635. tangents: Nullable<FloatArray>;
  22636. /**
  22637. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22638. */
  22639. uvs: Nullable<FloatArray>;
  22640. /**
  22641. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22642. */
  22643. uvs2: Nullable<FloatArray>;
  22644. /**
  22645. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22646. */
  22647. uvs3: Nullable<FloatArray>;
  22648. /**
  22649. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22650. */
  22651. uvs4: Nullable<FloatArray>;
  22652. /**
  22653. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22654. */
  22655. uvs5: Nullable<FloatArray>;
  22656. /**
  22657. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22658. */
  22659. uvs6: Nullable<FloatArray>;
  22660. /**
  22661. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22662. */
  22663. colors: Nullable<FloatArray>;
  22664. /**
  22665. * 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).
  22666. */
  22667. matricesIndices: Nullable<FloatArray>;
  22668. /**
  22669. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22670. */
  22671. matricesWeights: Nullable<FloatArray>;
  22672. /**
  22673. * An array extending the number of possible indices
  22674. */
  22675. matricesIndicesExtra: Nullable<FloatArray>;
  22676. /**
  22677. * An array extending the number of possible weights when the number of indices is extended
  22678. */
  22679. matricesWeightsExtra: Nullable<FloatArray>;
  22680. /**
  22681. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22682. */
  22683. indices: Nullable<IndicesArray>;
  22684. /**
  22685. * Uses the passed data array to set the set the values for the specified kind of data
  22686. * @param data a linear array of floating numbers
  22687. * @param kind the type of data that is being set, eg positions, colors etc
  22688. */
  22689. set(data: FloatArray, kind: string): void;
  22690. /**
  22691. * Associates the vertexData to the passed Mesh.
  22692. * Sets it as updatable or not (default `false`)
  22693. * @param mesh the mesh the vertexData is applied to
  22694. * @param updatable when used and having the value true allows new data to update the vertexData
  22695. * @returns the VertexData
  22696. */
  22697. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22698. /**
  22699. * Associates the vertexData to the passed Geometry.
  22700. * Sets it as updatable or not (default `false`)
  22701. * @param geometry the geometry the vertexData is applied to
  22702. * @param updatable when used and having the value true allows new data to update the vertexData
  22703. * @returns VertexData
  22704. */
  22705. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22706. /**
  22707. * Updates the associated mesh
  22708. * @param mesh the mesh to be updated
  22709. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22710. * @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
  22711. * @returns VertexData
  22712. */
  22713. updateMesh(mesh: Mesh): VertexData;
  22714. /**
  22715. * Updates the associated geometry
  22716. * @param geometry the geometry to be updated
  22717. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22718. * @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
  22719. * @returns VertexData.
  22720. */
  22721. updateGeometry(geometry: Geometry): VertexData;
  22722. private _applyTo;
  22723. private _update;
  22724. /**
  22725. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22726. * @param matrix the transforming matrix
  22727. * @returns the VertexData
  22728. */
  22729. transform(matrix: Matrix): VertexData;
  22730. /**
  22731. * Merges the passed VertexData into the current one
  22732. * @param other the VertexData to be merged into the current one
  22733. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22734. * @returns the modified VertexData
  22735. */
  22736. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22737. private _mergeElement;
  22738. private _validate;
  22739. /**
  22740. * Serializes the VertexData
  22741. * @returns a serialized object
  22742. */
  22743. serialize(): any;
  22744. /**
  22745. * Extracts the vertexData from a mesh
  22746. * @param mesh the mesh from which to extract the VertexData
  22747. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22748. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22749. * @returns the object VertexData associated to the passed mesh
  22750. */
  22751. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22752. /**
  22753. * Extracts the vertexData from the geometry
  22754. * @param geometry the geometry from which to extract the VertexData
  22755. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22756. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22757. * @returns the object VertexData associated to the passed mesh
  22758. */
  22759. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22760. private static _ExtractFrom;
  22761. /**
  22762. * Creates the VertexData for a Ribbon
  22763. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22764. * * pathArray array of paths, each of which an array of successive Vector3
  22765. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22766. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22767. * * 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
  22768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22769. * * 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)
  22770. * * 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)
  22771. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22772. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22773. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22774. * @returns the VertexData of the ribbon
  22775. */
  22776. static CreateRibbon(options: {
  22777. pathArray: Vector3[][];
  22778. closeArray?: boolean;
  22779. closePath?: boolean;
  22780. offset?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. invertUV?: boolean;
  22785. uvs?: Vector2[];
  22786. colors?: Color4[];
  22787. }): VertexData;
  22788. /**
  22789. * Creates the VertexData for a box
  22790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22791. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22792. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22793. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22794. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22795. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22796. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22798. * * 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)
  22799. * * 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)
  22800. * @returns the VertexData of the box
  22801. */
  22802. static CreateBox(options: {
  22803. size?: number;
  22804. width?: number;
  22805. height?: number;
  22806. depth?: number;
  22807. faceUV?: Vector4[];
  22808. faceColors?: Color4[];
  22809. sideOrientation?: number;
  22810. frontUVs?: Vector4;
  22811. backUVs?: Vector4;
  22812. }): VertexData;
  22813. /**
  22814. * Creates the VertexData for a tiled box
  22815. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22816. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22817. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22818. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22820. * @returns the VertexData of the box
  22821. */
  22822. static CreateTiledBox(options: {
  22823. pattern?: number;
  22824. width?: number;
  22825. height?: number;
  22826. depth?: number;
  22827. tileSize?: number;
  22828. tileWidth?: number;
  22829. tileHeight?: number;
  22830. alignHorizontal?: number;
  22831. alignVertical?: number;
  22832. faceUV?: Vector4[];
  22833. faceColors?: Color4[];
  22834. sideOrientation?: number;
  22835. }): VertexData;
  22836. /**
  22837. * Creates the VertexData for a tiled plane
  22838. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22839. * * pattern a limited pattern arrangement depending on the number
  22840. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22841. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22842. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22844. * * 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)
  22845. * * 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)
  22846. * @returns the VertexData of the tiled plane
  22847. */
  22848. static CreateTiledPlane(options: {
  22849. pattern?: number;
  22850. tileSize?: number;
  22851. tileWidth?: number;
  22852. tileHeight?: number;
  22853. size?: number;
  22854. width?: number;
  22855. height?: number;
  22856. alignHorizontal?: number;
  22857. alignVertical?: number;
  22858. sideOrientation?: number;
  22859. frontUVs?: Vector4;
  22860. backUVs?: Vector4;
  22861. }): VertexData;
  22862. /**
  22863. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22864. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22865. * * segments sets the number of horizontal strips optional, default 32
  22866. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22867. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22868. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22869. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22870. * * 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
  22871. * * 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
  22872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22873. * * 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)
  22874. * * 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)
  22875. * @returns the VertexData of the ellipsoid
  22876. */
  22877. static CreateSphere(options: {
  22878. segments?: number;
  22879. diameter?: number;
  22880. diameterX?: number;
  22881. diameterY?: number;
  22882. diameterZ?: number;
  22883. arc?: number;
  22884. slice?: number;
  22885. sideOrientation?: number;
  22886. frontUVs?: Vector4;
  22887. backUVs?: Vector4;
  22888. }): VertexData;
  22889. /**
  22890. * Creates the VertexData for a cylinder, cone or prism
  22891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22892. * * height sets the height (y direction) of the cylinder, optional, default 2
  22893. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22894. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22895. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22896. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22897. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22898. * * 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
  22899. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22900. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22901. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22902. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22904. * * 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)
  22905. * * 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)
  22906. * @returns the VertexData of the cylinder, cone or prism
  22907. */
  22908. static CreateCylinder(options: {
  22909. height?: number;
  22910. diameterTop?: number;
  22911. diameterBottom?: number;
  22912. diameter?: number;
  22913. tessellation?: number;
  22914. subdivisions?: number;
  22915. arc?: number;
  22916. faceColors?: Color4[];
  22917. faceUV?: Vector4[];
  22918. hasRings?: boolean;
  22919. enclose?: boolean;
  22920. sideOrientation?: number;
  22921. frontUVs?: Vector4;
  22922. backUVs?: Vector4;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData for a torus
  22926. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22927. * * diameter the diameter of the torus, optional default 1
  22928. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22929. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22931. * * 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)
  22932. * * 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)
  22933. * @returns the VertexData of the torus
  22934. */
  22935. static CreateTorus(options: {
  22936. diameter?: number;
  22937. thickness?: number;
  22938. tessellation?: number;
  22939. sideOrientation?: number;
  22940. frontUVs?: Vector4;
  22941. backUVs?: Vector4;
  22942. }): VertexData;
  22943. /**
  22944. * Creates the VertexData of the LineSystem
  22945. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22946. * - lines an array of lines, each line being an array of successive Vector3
  22947. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22948. * @returns the VertexData of the LineSystem
  22949. */
  22950. static CreateLineSystem(options: {
  22951. lines: Vector3[][];
  22952. colors?: Nullable<Color4[][]>;
  22953. }): VertexData;
  22954. /**
  22955. * Create the VertexData for a DashedLines
  22956. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22957. * - points an array successive Vector3
  22958. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22959. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22960. * - dashNb the intended total number of dashes, optional, default 200
  22961. * @returns the VertexData for the DashedLines
  22962. */
  22963. static CreateDashedLines(options: {
  22964. points: Vector3[];
  22965. dashSize?: number;
  22966. gapSize?: number;
  22967. dashNb?: number;
  22968. }): VertexData;
  22969. /**
  22970. * Creates the VertexData for a Ground
  22971. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22972. * - width the width (x direction) of the ground, optional, default 1
  22973. * - height the height (z direction) of the ground, optional, default 1
  22974. * - subdivisions the number of subdivisions per side, optional, default 1
  22975. * @returns the VertexData of the Ground
  22976. */
  22977. static CreateGround(options: {
  22978. width?: number;
  22979. height?: number;
  22980. subdivisions?: number;
  22981. subdivisionsX?: number;
  22982. subdivisionsY?: number;
  22983. }): VertexData;
  22984. /**
  22985. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22986. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22987. * * xmin the ground minimum X coordinate, optional, default -1
  22988. * * zmin the ground minimum Z coordinate, optional, default -1
  22989. * * xmax the ground maximum X coordinate, optional, default 1
  22990. * * zmax the ground maximum Z coordinate, optional, default 1
  22991. * * 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}
  22992. * * 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}
  22993. * @returns the VertexData of the TiledGround
  22994. */
  22995. static CreateTiledGround(options: {
  22996. xmin: number;
  22997. zmin: number;
  22998. xmax: number;
  22999. zmax: number;
  23000. subdivisions?: {
  23001. w: number;
  23002. h: number;
  23003. };
  23004. precision?: {
  23005. w: number;
  23006. h: number;
  23007. };
  23008. }): VertexData;
  23009. /**
  23010. * Creates the VertexData of the Ground designed from a heightmap
  23011. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23012. * * width the width (x direction) of the ground
  23013. * * height the height (z direction) of the ground
  23014. * * subdivisions the number of subdivisions per side
  23015. * * minHeight the minimum altitude on the ground, optional, default 0
  23016. * * maxHeight the maximum altitude on the ground, optional default 1
  23017. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23018. * * buffer the array holding the image color data
  23019. * * bufferWidth the width of image
  23020. * * bufferHeight the height of image
  23021. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23022. * @returns the VertexData of the Ground designed from a heightmap
  23023. */
  23024. static CreateGroundFromHeightMap(options: {
  23025. width: number;
  23026. height: number;
  23027. subdivisions: number;
  23028. minHeight: number;
  23029. maxHeight: number;
  23030. colorFilter: Color3;
  23031. buffer: Uint8Array;
  23032. bufferWidth: number;
  23033. bufferHeight: number;
  23034. alphaFilter: number;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData for a Plane
  23038. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23039. * * size sets the width and height of the plane to the value of size, optional default 1
  23040. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23041. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23043. * * 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)
  23044. * * 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)
  23045. * @returns the VertexData of the box
  23046. */
  23047. static CreatePlane(options: {
  23048. size?: number;
  23049. width?: number;
  23050. height?: number;
  23051. sideOrientation?: number;
  23052. frontUVs?: Vector4;
  23053. backUVs?: Vector4;
  23054. }): VertexData;
  23055. /**
  23056. * Creates the VertexData of the Disc or regular Polygon
  23057. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23058. * * radius the radius of the disc, optional default 0.5
  23059. * * tessellation the number of polygon sides, optional, default 64
  23060. * * 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
  23061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23062. * * 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)
  23063. * * 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)
  23064. * @returns the VertexData of the box
  23065. */
  23066. static CreateDisc(options: {
  23067. radius?: number;
  23068. tessellation?: number;
  23069. arc?: number;
  23070. sideOrientation?: number;
  23071. frontUVs?: Vector4;
  23072. backUVs?: Vector4;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23076. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23077. * @param polygon a mesh built from polygonTriangulation.build()
  23078. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23079. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23080. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23081. * @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)
  23082. * @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)
  23083. * @returns the VertexData of the Polygon
  23084. */
  23085. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23086. /**
  23087. * Creates the VertexData of the IcoSphere
  23088. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23089. * * radius the radius of the IcoSphere, optional default 1
  23090. * * radiusX allows stretching in the x direction, optional, default radius
  23091. * * radiusY allows stretching in the y direction, optional, default radius
  23092. * * radiusZ allows stretching in the z direction, optional, default radius
  23093. * * flat when true creates a flat shaded mesh, optional, default true
  23094. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23096. * * 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)
  23097. * * 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)
  23098. * @returns the VertexData of the IcoSphere
  23099. */
  23100. static CreateIcoSphere(options: {
  23101. radius?: number;
  23102. radiusX?: number;
  23103. radiusY?: number;
  23104. radiusZ?: number;
  23105. flat?: boolean;
  23106. subdivisions?: number;
  23107. sideOrientation?: number;
  23108. frontUVs?: Vector4;
  23109. backUVs?: Vector4;
  23110. }): VertexData;
  23111. /**
  23112. * Creates the VertexData for a Polyhedron
  23113. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23114. * * type provided types are:
  23115. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23116. * * 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)
  23117. * * size the size of the IcoSphere, optional default 1
  23118. * * sizeX allows stretching in the x direction, optional, default size
  23119. * * sizeY allows stretching in the y direction, optional, default size
  23120. * * sizeZ allows stretching in the z direction, optional, default size
  23121. * * 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
  23122. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23123. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23124. * * flat when true creates a flat shaded mesh, optional, default true
  23125. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23127. * * 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)
  23128. * * 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)
  23129. * @returns the VertexData of the Polyhedron
  23130. */
  23131. static CreatePolyhedron(options: {
  23132. type?: number;
  23133. size?: number;
  23134. sizeX?: number;
  23135. sizeY?: number;
  23136. sizeZ?: number;
  23137. custom?: any;
  23138. faceUV?: Vector4[];
  23139. faceColors?: Color4[];
  23140. flat?: boolean;
  23141. sideOrientation?: number;
  23142. frontUVs?: Vector4;
  23143. backUVs?: Vector4;
  23144. }): VertexData;
  23145. /**
  23146. * Creates the VertexData for a TorusKnot
  23147. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23148. * * radius the radius of the torus knot, optional, default 2
  23149. * * tube the thickness of the tube, optional, default 0.5
  23150. * * radialSegments the number of sides on each tube segments, optional, default 32
  23151. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23152. * * p the number of windings around the z axis, optional, default 2
  23153. * * q the number of windings around the x axis, optional, default 3
  23154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23155. * * 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)
  23156. * * 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)
  23157. * @returns the VertexData of the Torus Knot
  23158. */
  23159. static CreateTorusKnot(options: {
  23160. radius?: number;
  23161. tube?: number;
  23162. radialSegments?: number;
  23163. tubularSegments?: number;
  23164. p?: number;
  23165. q?: number;
  23166. sideOrientation?: number;
  23167. frontUVs?: Vector4;
  23168. backUVs?: Vector4;
  23169. }): VertexData;
  23170. /**
  23171. * Compute normals for given positions and indices
  23172. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23173. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23174. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23175. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23176. * * facetNormals : optional array of facet normals (vector3)
  23177. * * facetPositions : optional array of facet positions (vector3)
  23178. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23179. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23180. * * bInfo : optional bounding info, required for facetPartitioning computation
  23181. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23182. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23183. * * useRightHandedSystem: optional boolean to for right handed system computation
  23184. * * depthSort : optional boolean to enable the facet depth sort computation
  23185. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23186. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23187. */
  23188. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23189. facetNormals?: any;
  23190. facetPositions?: any;
  23191. facetPartitioning?: any;
  23192. ratio?: number;
  23193. bInfo?: any;
  23194. bbSize?: Vector3;
  23195. subDiv?: any;
  23196. useRightHandedSystem?: boolean;
  23197. depthSort?: boolean;
  23198. distanceTo?: Vector3;
  23199. depthSortedFacets?: any;
  23200. }): void;
  23201. /** @hidden */
  23202. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23203. /**
  23204. * Applies VertexData created from the imported parameters to the geometry
  23205. * @param parsedVertexData the parsed data from an imported file
  23206. * @param geometry the geometry to apply the VertexData to
  23207. */
  23208. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23209. }
  23210. }
  23211. declare module "babylonjs/Morph/morphTarget" {
  23212. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23213. import { Observable } from "babylonjs/Misc/observable";
  23214. import { Nullable, FloatArray } from "babylonjs/types";
  23215. import { Scene } from "babylonjs/scene";
  23216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23217. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23218. /**
  23219. * Defines a target to use with MorphTargetManager
  23220. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23221. */
  23222. export class MorphTarget implements IAnimatable {
  23223. /** defines the name of the target */
  23224. name: string;
  23225. /**
  23226. * Gets or sets the list of animations
  23227. */
  23228. animations: import("babylonjs/Animations/animation").Animation[];
  23229. private _scene;
  23230. private _positions;
  23231. private _normals;
  23232. private _tangents;
  23233. private _uvs;
  23234. private _influence;
  23235. private _uniqueId;
  23236. /**
  23237. * Observable raised when the influence changes
  23238. */
  23239. onInfluenceChanged: Observable<boolean>;
  23240. /** @hidden */
  23241. _onDataLayoutChanged: Observable<void>;
  23242. /**
  23243. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23244. */
  23245. get influence(): number;
  23246. set influence(influence: number);
  23247. /**
  23248. * Gets or sets the id of the morph Target
  23249. */
  23250. id: string;
  23251. private _animationPropertiesOverride;
  23252. /**
  23253. * Gets or sets the animation properties override
  23254. */
  23255. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23256. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23257. /**
  23258. * Creates a new MorphTarget
  23259. * @param name defines the name of the target
  23260. * @param influence defines the influence to use
  23261. * @param scene defines the scene the morphtarget belongs to
  23262. */
  23263. constructor(
  23264. /** defines the name of the target */
  23265. name: string, influence?: number, scene?: Nullable<Scene>);
  23266. /**
  23267. * Gets the unique ID of this manager
  23268. */
  23269. get uniqueId(): number;
  23270. /**
  23271. * Gets a boolean defining if the target contains position data
  23272. */
  23273. get hasPositions(): boolean;
  23274. /**
  23275. * Gets a boolean defining if the target contains normal data
  23276. */
  23277. get hasNormals(): boolean;
  23278. /**
  23279. * Gets a boolean defining if the target contains tangent data
  23280. */
  23281. get hasTangents(): boolean;
  23282. /**
  23283. * Gets a boolean defining if the target contains texture coordinates data
  23284. */
  23285. get hasUVs(): boolean;
  23286. /**
  23287. * Affects position data to this target
  23288. * @param data defines the position data to use
  23289. */
  23290. setPositions(data: Nullable<FloatArray>): void;
  23291. /**
  23292. * Gets the position data stored in this target
  23293. * @returns a FloatArray containing the position data (or null if not present)
  23294. */
  23295. getPositions(): Nullable<FloatArray>;
  23296. /**
  23297. * Affects normal data to this target
  23298. * @param data defines the normal data to use
  23299. */
  23300. setNormals(data: Nullable<FloatArray>): void;
  23301. /**
  23302. * Gets the normal data stored in this target
  23303. * @returns a FloatArray containing the normal data (or null if not present)
  23304. */
  23305. getNormals(): Nullable<FloatArray>;
  23306. /**
  23307. * Affects tangent data to this target
  23308. * @param data defines the tangent data to use
  23309. */
  23310. setTangents(data: Nullable<FloatArray>): void;
  23311. /**
  23312. * Gets the tangent data stored in this target
  23313. * @returns a FloatArray containing the tangent data (or null if not present)
  23314. */
  23315. getTangents(): Nullable<FloatArray>;
  23316. /**
  23317. * Affects texture coordinates data to this target
  23318. * @param data defines the texture coordinates data to use
  23319. */
  23320. setUVs(data: Nullable<FloatArray>): void;
  23321. /**
  23322. * Gets the texture coordinates data stored in this target
  23323. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23324. */
  23325. getUVs(): Nullable<FloatArray>;
  23326. /**
  23327. * Clone the current target
  23328. * @returns a new MorphTarget
  23329. */
  23330. clone(): MorphTarget;
  23331. /**
  23332. * Serializes the current target into a Serialization object
  23333. * @returns the serialized object
  23334. */
  23335. serialize(): any;
  23336. /**
  23337. * Returns the string "MorphTarget"
  23338. * @returns "MorphTarget"
  23339. */
  23340. getClassName(): string;
  23341. /**
  23342. * Creates a new target from serialized data
  23343. * @param serializationObject defines the serialized data to use
  23344. * @returns a new MorphTarget
  23345. */
  23346. static Parse(serializationObject: any): MorphTarget;
  23347. /**
  23348. * Creates a MorphTarget from mesh data
  23349. * @param mesh defines the source mesh
  23350. * @param name defines the name to use for the new target
  23351. * @param influence defines the influence to attach to the target
  23352. * @returns a new MorphTarget
  23353. */
  23354. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23355. }
  23356. }
  23357. declare module "babylonjs/Morph/morphTargetManager" {
  23358. import { Nullable } from "babylonjs/types";
  23359. import { Scene } from "babylonjs/scene";
  23360. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23361. /**
  23362. * This class is used to deform meshes using morphing between different targets
  23363. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23364. */
  23365. export class MorphTargetManager {
  23366. private _targets;
  23367. private _targetInfluenceChangedObservers;
  23368. private _targetDataLayoutChangedObservers;
  23369. private _activeTargets;
  23370. private _scene;
  23371. private _influences;
  23372. private _supportsNormals;
  23373. private _supportsTangents;
  23374. private _supportsUVs;
  23375. private _vertexCount;
  23376. private _uniqueId;
  23377. private _tempInfluences;
  23378. /**
  23379. * Gets or sets a boolean indicating if normals must be morphed
  23380. */
  23381. enableNormalMorphing: boolean;
  23382. /**
  23383. * Gets or sets a boolean indicating if tangents must be morphed
  23384. */
  23385. enableTangentMorphing: boolean;
  23386. /**
  23387. * Gets or sets a boolean indicating if UV must be morphed
  23388. */
  23389. enableUVMorphing: boolean;
  23390. /**
  23391. * Creates a new MorphTargetManager
  23392. * @param scene defines the current scene
  23393. */
  23394. constructor(scene?: Nullable<Scene>);
  23395. /**
  23396. * Gets the unique ID of this manager
  23397. */
  23398. get uniqueId(): number;
  23399. /**
  23400. * Gets the number of vertices handled by this manager
  23401. */
  23402. get vertexCount(): number;
  23403. /**
  23404. * Gets a boolean indicating if this manager supports morphing of normals
  23405. */
  23406. get supportsNormals(): boolean;
  23407. /**
  23408. * Gets a boolean indicating if this manager supports morphing of tangents
  23409. */
  23410. get supportsTangents(): boolean;
  23411. /**
  23412. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23413. */
  23414. get supportsUVs(): boolean;
  23415. /**
  23416. * Gets the number of targets stored in this manager
  23417. */
  23418. get numTargets(): number;
  23419. /**
  23420. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23421. */
  23422. get numInfluencers(): number;
  23423. /**
  23424. * Gets the list of influences (one per target)
  23425. */
  23426. get influences(): Float32Array;
  23427. /**
  23428. * Gets the active target at specified index. An active target is a target with an influence > 0
  23429. * @param index defines the index to check
  23430. * @returns the requested target
  23431. */
  23432. getActiveTarget(index: number): MorphTarget;
  23433. /**
  23434. * Gets the target at specified index
  23435. * @param index defines the index to check
  23436. * @returns the requested target
  23437. */
  23438. getTarget(index: number): MorphTarget;
  23439. /**
  23440. * Add a new target to this manager
  23441. * @param target defines the target to add
  23442. */
  23443. addTarget(target: MorphTarget): void;
  23444. /**
  23445. * Removes a target from the manager
  23446. * @param target defines the target to remove
  23447. */
  23448. removeTarget(target: MorphTarget): void;
  23449. /**
  23450. * Clone the current manager
  23451. * @returns a new MorphTargetManager
  23452. */
  23453. clone(): MorphTargetManager;
  23454. /**
  23455. * Serializes the current manager into a Serialization object
  23456. * @returns the serialized object
  23457. */
  23458. serialize(): any;
  23459. private _syncActiveTargets;
  23460. /**
  23461. * Syncrhonize the targets with all the meshes using this morph target manager
  23462. */
  23463. synchronize(): void;
  23464. /**
  23465. * Creates a new MorphTargetManager from serialized data
  23466. * @param serializationObject defines the serialized data
  23467. * @param scene defines the hosting scene
  23468. * @returns the new MorphTargetManager
  23469. */
  23470. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23471. }
  23472. }
  23473. declare module "babylonjs/Meshes/meshLODLevel" {
  23474. import { Mesh } from "babylonjs/Meshes/mesh";
  23475. import { Nullable } from "babylonjs/types";
  23476. /**
  23477. * Class used to represent a specific level of detail of a mesh
  23478. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23479. */
  23480. export class MeshLODLevel {
  23481. /** Defines the distance where this level should start being displayed */
  23482. distance: number;
  23483. /** Defines the mesh to use to render this level */
  23484. mesh: Nullable<Mesh>;
  23485. /**
  23486. * Creates a new LOD level
  23487. * @param distance defines the distance where this level should star being displayed
  23488. * @param mesh defines the mesh to use to render this level
  23489. */
  23490. constructor(
  23491. /** Defines the distance where this level should start being displayed */
  23492. distance: number,
  23493. /** Defines the mesh to use to render this level */
  23494. mesh: Nullable<Mesh>);
  23495. }
  23496. }
  23497. declare module "babylonjs/Meshes/groundMesh" {
  23498. import { Scene } from "babylonjs/scene";
  23499. import { Vector3 } from "babylonjs/Maths/math.vector";
  23500. import { Mesh } from "babylonjs/Meshes/mesh";
  23501. /**
  23502. * Mesh representing the gorund
  23503. */
  23504. export class GroundMesh extends Mesh {
  23505. /** If octree should be generated */
  23506. generateOctree: boolean;
  23507. private _heightQuads;
  23508. /** @hidden */
  23509. _subdivisionsX: number;
  23510. /** @hidden */
  23511. _subdivisionsY: number;
  23512. /** @hidden */
  23513. _width: number;
  23514. /** @hidden */
  23515. _height: number;
  23516. /** @hidden */
  23517. _minX: number;
  23518. /** @hidden */
  23519. _maxX: number;
  23520. /** @hidden */
  23521. _minZ: number;
  23522. /** @hidden */
  23523. _maxZ: number;
  23524. constructor(name: string, scene: Scene);
  23525. /**
  23526. * "GroundMesh"
  23527. * @returns "GroundMesh"
  23528. */
  23529. getClassName(): string;
  23530. /**
  23531. * The minimum of x and y subdivisions
  23532. */
  23533. get subdivisions(): number;
  23534. /**
  23535. * X subdivisions
  23536. */
  23537. get subdivisionsX(): number;
  23538. /**
  23539. * Y subdivisions
  23540. */
  23541. get subdivisionsY(): number;
  23542. /**
  23543. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23544. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23545. * @param chunksCount the number of subdivisions for x and y
  23546. * @param octreeBlocksSize (Default: 32)
  23547. */
  23548. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23549. /**
  23550. * Returns a height (y) value in the Worl system :
  23551. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23552. * @param x x coordinate
  23553. * @param z z coordinate
  23554. * @returns the ground y position if (x, z) are outside the ground surface.
  23555. */
  23556. getHeightAtCoordinates(x: number, z: number): number;
  23557. /**
  23558. * Returns a normalized vector (Vector3) orthogonal to the ground
  23559. * at the ground coordinates (x, z) expressed in the World system.
  23560. * @param x x coordinate
  23561. * @param z z coordinate
  23562. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23563. */
  23564. getNormalAtCoordinates(x: number, z: number): Vector3;
  23565. /**
  23566. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23567. * at the ground coordinates (x, z) expressed in the World system.
  23568. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23569. * @param x x coordinate
  23570. * @param z z coordinate
  23571. * @param ref vector to store the result
  23572. * @returns the GroundMesh.
  23573. */
  23574. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23575. /**
  23576. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23577. * if the ground has been updated.
  23578. * This can be used in the render loop.
  23579. * @returns the GroundMesh.
  23580. */
  23581. updateCoordinateHeights(): GroundMesh;
  23582. private _getFacetAt;
  23583. private _initHeightQuads;
  23584. private _computeHeightQuads;
  23585. /**
  23586. * Serializes this ground mesh
  23587. * @param serializationObject object to write serialization to
  23588. */
  23589. serialize(serializationObject: any): void;
  23590. /**
  23591. * Parses a serialized ground mesh
  23592. * @param parsedMesh the serialized mesh
  23593. * @param scene the scene to create the ground mesh in
  23594. * @returns the created ground mesh
  23595. */
  23596. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23597. }
  23598. }
  23599. declare module "babylonjs/Physics/physicsJoint" {
  23600. import { Vector3 } from "babylonjs/Maths/math.vector";
  23601. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23602. /**
  23603. * Interface for Physics-Joint data
  23604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23605. */
  23606. export interface PhysicsJointData {
  23607. /**
  23608. * The main pivot of the joint
  23609. */
  23610. mainPivot?: Vector3;
  23611. /**
  23612. * The connected pivot of the joint
  23613. */
  23614. connectedPivot?: Vector3;
  23615. /**
  23616. * The main axis of the joint
  23617. */
  23618. mainAxis?: Vector3;
  23619. /**
  23620. * The connected axis of the joint
  23621. */
  23622. connectedAxis?: Vector3;
  23623. /**
  23624. * The collision of the joint
  23625. */
  23626. collision?: boolean;
  23627. /**
  23628. * Native Oimo/Cannon/Energy data
  23629. */
  23630. nativeParams?: any;
  23631. }
  23632. /**
  23633. * This is a holder class for the physics joint created by the physics plugin
  23634. * It holds a set of functions to control the underlying joint
  23635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23636. */
  23637. export class PhysicsJoint {
  23638. /**
  23639. * The type of the physics joint
  23640. */
  23641. type: number;
  23642. /**
  23643. * The data for the physics joint
  23644. */
  23645. jointData: PhysicsJointData;
  23646. private _physicsJoint;
  23647. protected _physicsPlugin: IPhysicsEnginePlugin;
  23648. /**
  23649. * Initializes the physics joint
  23650. * @param type The type of the physics joint
  23651. * @param jointData The data for the physics joint
  23652. */
  23653. constructor(
  23654. /**
  23655. * The type of the physics joint
  23656. */
  23657. type: number,
  23658. /**
  23659. * The data for the physics joint
  23660. */
  23661. jointData: PhysicsJointData);
  23662. /**
  23663. * Gets the physics joint
  23664. */
  23665. get physicsJoint(): any;
  23666. /**
  23667. * Sets the physics joint
  23668. */
  23669. set physicsJoint(newJoint: any);
  23670. /**
  23671. * Sets the physics plugin
  23672. */
  23673. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23674. /**
  23675. * Execute a function that is physics-plugin specific.
  23676. * @param {Function} func the function that will be executed.
  23677. * It accepts two parameters: the physics world and the physics joint
  23678. */
  23679. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23680. /**
  23681. * Distance-Joint type
  23682. */
  23683. static DistanceJoint: number;
  23684. /**
  23685. * Hinge-Joint type
  23686. */
  23687. static HingeJoint: number;
  23688. /**
  23689. * Ball-and-Socket joint type
  23690. */
  23691. static BallAndSocketJoint: number;
  23692. /**
  23693. * Wheel-Joint type
  23694. */
  23695. static WheelJoint: number;
  23696. /**
  23697. * Slider-Joint type
  23698. */
  23699. static SliderJoint: number;
  23700. /**
  23701. * Prismatic-Joint type
  23702. */
  23703. static PrismaticJoint: number;
  23704. /**
  23705. * Universal-Joint type
  23706. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23707. */
  23708. static UniversalJoint: number;
  23709. /**
  23710. * Hinge-Joint 2 type
  23711. */
  23712. static Hinge2Joint: number;
  23713. /**
  23714. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23715. */
  23716. static PointToPointJoint: number;
  23717. /**
  23718. * Spring-Joint type
  23719. */
  23720. static SpringJoint: number;
  23721. /**
  23722. * Lock-Joint type
  23723. */
  23724. static LockJoint: number;
  23725. }
  23726. /**
  23727. * A class representing a physics distance joint
  23728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23729. */
  23730. export class DistanceJoint extends PhysicsJoint {
  23731. /**
  23732. *
  23733. * @param jointData The data for the Distance-Joint
  23734. */
  23735. constructor(jointData: DistanceJointData);
  23736. /**
  23737. * Update the predefined distance.
  23738. * @param maxDistance The maximum preferred distance
  23739. * @param minDistance The minimum preferred distance
  23740. */
  23741. updateDistance(maxDistance: number, minDistance?: number): void;
  23742. }
  23743. /**
  23744. * Represents a Motor-Enabled Joint
  23745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23746. */
  23747. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23748. /**
  23749. * Initializes the Motor-Enabled Joint
  23750. * @param type The type of the joint
  23751. * @param jointData The physica joint data for the joint
  23752. */
  23753. constructor(type: number, jointData: PhysicsJointData);
  23754. /**
  23755. * Set the motor values.
  23756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23757. * @param force the force to apply
  23758. * @param maxForce max force for this motor.
  23759. */
  23760. setMotor(force?: number, maxForce?: number): void;
  23761. /**
  23762. * Set the motor's limits.
  23763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23764. * @param upperLimit The upper limit of the motor
  23765. * @param lowerLimit The lower limit of the motor
  23766. */
  23767. setLimit(upperLimit: number, lowerLimit?: number): void;
  23768. }
  23769. /**
  23770. * This class represents a single physics Hinge-Joint
  23771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23772. */
  23773. export class HingeJoint extends MotorEnabledJoint {
  23774. /**
  23775. * Initializes the Hinge-Joint
  23776. * @param jointData The joint data for the Hinge-Joint
  23777. */
  23778. constructor(jointData: PhysicsJointData);
  23779. /**
  23780. * Set the motor values.
  23781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23782. * @param {number} force the force to apply
  23783. * @param {number} maxForce max force for this motor.
  23784. */
  23785. setMotor(force?: number, maxForce?: number): void;
  23786. /**
  23787. * Set the motor's limits.
  23788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23789. * @param upperLimit The upper limit of the motor
  23790. * @param lowerLimit The lower limit of the motor
  23791. */
  23792. setLimit(upperLimit: number, lowerLimit?: number): void;
  23793. }
  23794. /**
  23795. * This class represents a dual hinge physics joint (same as wheel joint)
  23796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23797. */
  23798. export class Hinge2Joint extends MotorEnabledJoint {
  23799. /**
  23800. * Initializes the Hinge2-Joint
  23801. * @param jointData The joint data for the Hinge2-Joint
  23802. */
  23803. constructor(jointData: PhysicsJointData);
  23804. /**
  23805. * Set the motor values.
  23806. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23807. * @param {number} targetSpeed the speed the motor is to reach
  23808. * @param {number} maxForce max force for this motor.
  23809. * @param {motorIndex} the motor's index, 0 or 1.
  23810. */
  23811. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23812. /**
  23813. * Set the motor limits.
  23814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23815. * @param {number} upperLimit the upper limit
  23816. * @param {number} lowerLimit lower limit
  23817. * @param {motorIndex} the motor's index, 0 or 1.
  23818. */
  23819. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23820. }
  23821. /**
  23822. * Interface for a motor enabled joint
  23823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23824. */
  23825. export interface IMotorEnabledJoint {
  23826. /**
  23827. * Physics joint
  23828. */
  23829. physicsJoint: any;
  23830. /**
  23831. * Sets the motor of the motor-enabled joint
  23832. * @param force The force of the motor
  23833. * @param maxForce The maximum force of the motor
  23834. * @param motorIndex The index of the motor
  23835. */
  23836. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23837. /**
  23838. * Sets the limit of the motor
  23839. * @param upperLimit The upper limit of the motor
  23840. * @param lowerLimit The lower limit of the motor
  23841. * @param motorIndex The index of the motor
  23842. */
  23843. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23844. }
  23845. /**
  23846. * Joint data for a Distance-Joint
  23847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23848. */
  23849. export interface DistanceJointData extends PhysicsJointData {
  23850. /**
  23851. * Max distance the 2 joint objects can be apart
  23852. */
  23853. maxDistance: number;
  23854. }
  23855. /**
  23856. * Joint data from a spring joint
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export interface SpringJointData extends PhysicsJointData {
  23860. /**
  23861. * Length of the spring
  23862. */
  23863. length: number;
  23864. /**
  23865. * Stiffness of the spring
  23866. */
  23867. stiffness: number;
  23868. /**
  23869. * Damping of the spring
  23870. */
  23871. damping: number;
  23872. /** this callback will be called when applying the force to the impostors. */
  23873. forceApplicationCallback: () => void;
  23874. }
  23875. }
  23876. declare module "babylonjs/Physics/physicsRaycastResult" {
  23877. import { Vector3 } from "babylonjs/Maths/math.vector";
  23878. /**
  23879. * Holds the data for the raycast result
  23880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23881. */
  23882. export class PhysicsRaycastResult {
  23883. private _hasHit;
  23884. private _hitDistance;
  23885. private _hitNormalWorld;
  23886. private _hitPointWorld;
  23887. private _rayFromWorld;
  23888. private _rayToWorld;
  23889. /**
  23890. * Gets if there was a hit
  23891. */
  23892. get hasHit(): boolean;
  23893. /**
  23894. * Gets the distance from the hit
  23895. */
  23896. get hitDistance(): number;
  23897. /**
  23898. * Gets the hit normal/direction in the world
  23899. */
  23900. get hitNormalWorld(): Vector3;
  23901. /**
  23902. * Gets the hit point in the world
  23903. */
  23904. get hitPointWorld(): Vector3;
  23905. /**
  23906. * Gets the ray "start point" of the ray in the world
  23907. */
  23908. get rayFromWorld(): Vector3;
  23909. /**
  23910. * Gets the ray "end point" of the ray in the world
  23911. */
  23912. get rayToWorld(): Vector3;
  23913. /**
  23914. * Sets the hit data (normal & point in world space)
  23915. * @param hitNormalWorld defines the normal in world space
  23916. * @param hitPointWorld defines the point in world space
  23917. */
  23918. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23919. /**
  23920. * Sets the distance from the start point to the hit point
  23921. * @param distance
  23922. */
  23923. setHitDistance(distance: number): void;
  23924. /**
  23925. * Calculates the distance manually
  23926. */
  23927. calculateHitDistance(): void;
  23928. /**
  23929. * Resets all the values to default
  23930. * @param from The from point on world space
  23931. * @param to The to point on world space
  23932. */
  23933. reset(from?: Vector3, to?: Vector3): void;
  23934. }
  23935. /**
  23936. * Interface for the size containing width and height
  23937. */
  23938. interface IXYZ {
  23939. /**
  23940. * X
  23941. */
  23942. x: number;
  23943. /**
  23944. * Y
  23945. */
  23946. y: number;
  23947. /**
  23948. * Z
  23949. */
  23950. z: number;
  23951. }
  23952. }
  23953. declare module "babylonjs/Physics/IPhysicsEngine" {
  23954. import { Nullable } from "babylonjs/types";
  23955. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23957. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23958. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23959. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23960. /**
  23961. * Interface used to describe a physics joint
  23962. */
  23963. export interface PhysicsImpostorJoint {
  23964. /** Defines the main impostor to which the joint is linked */
  23965. mainImpostor: PhysicsImpostor;
  23966. /** Defines the impostor that is connected to the main impostor using this joint */
  23967. connectedImpostor: PhysicsImpostor;
  23968. /** Defines the joint itself */
  23969. joint: PhysicsJoint;
  23970. }
  23971. /** @hidden */
  23972. export interface IPhysicsEnginePlugin {
  23973. world: any;
  23974. name: string;
  23975. setGravity(gravity: Vector3): void;
  23976. setTimeStep(timeStep: number): void;
  23977. getTimeStep(): number;
  23978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23982. removePhysicsBody(impostor: PhysicsImpostor): void;
  23983. generateJoint(joint: PhysicsImpostorJoint): void;
  23984. removeJoint(joint: PhysicsImpostorJoint): void;
  23985. isSupported(): boolean;
  23986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23993. getBodyMass(impostor: PhysicsImpostor): number;
  23994. getBodyFriction(impostor: PhysicsImpostor): number;
  23995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23996. getBodyRestitution(impostor: PhysicsImpostor): number;
  23997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23998. getBodyPressure?(impostor: PhysicsImpostor): number;
  23999. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24000. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24001. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24002. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24003. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24004. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24005. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24006. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24007. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24008. sleepBody(impostor: PhysicsImpostor): void;
  24009. wakeUpBody(impostor: PhysicsImpostor): void;
  24010. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24011. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24012. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24014. getRadius(impostor: PhysicsImpostor): number;
  24015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24016. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24017. dispose(): void;
  24018. }
  24019. /**
  24020. * Interface used to define a physics engine
  24021. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24022. */
  24023. export interface IPhysicsEngine {
  24024. /**
  24025. * Gets the gravity vector used by the simulation
  24026. */
  24027. gravity: Vector3;
  24028. /**
  24029. * Sets the gravity vector used by the simulation
  24030. * @param gravity defines the gravity vector to use
  24031. */
  24032. setGravity(gravity: Vector3): void;
  24033. /**
  24034. * Set the time step of the physics engine.
  24035. * Default is 1/60.
  24036. * To slow it down, enter 1/600 for example.
  24037. * To speed it up, 1/30
  24038. * @param newTimeStep the new timestep to apply to this world.
  24039. */
  24040. setTimeStep(newTimeStep: number): void;
  24041. /**
  24042. * Get the time step of the physics engine.
  24043. * @returns the current time step
  24044. */
  24045. getTimeStep(): number;
  24046. /**
  24047. * Set the sub time step of the physics engine.
  24048. * Default is 0 meaning there is no sub steps
  24049. * To increase physics resolution precision, set a small value (like 1 ms)
  24050. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24051. */
  24052. setSubTimeStep(subTimeStep: number): void;
  24053. /**
  24054. * Get the sub time step of the physics engine.
  24055. * @returns the current sub time step
  24056. */
  24057. getSubTimeStep(): number;
  24058. /**
  24059. * Release all resources
  24060. */
  24061. dispose(): void;
  24062. /**
  24063. * Gets the name of the current physics plugin
  24064. * @returns the name of the plugin
  24065. */
  24066. getPhysicsPluginName(): string;
  24067. /**
  24068. * Adding a new impostor for the impostor tracking.
  24069. * This will be done by the impostor itself.
  24070. * @param impostor the impostor to add
  24071. */
  24072. addImpostor(impostor: PhysicsImpostor): void;
  24073. /**
  24074. * Remove an impostor from the engine.
  24075. * This impostor and its mesh will not longer be updated by the physics engine.
  24076. * @param impostor the impostor to remove
  24077. */
  24078. removeImpostor(impostor: PhysicsImpostor): void;
  24079. /**
  24080. * Add a joint to the physics engine
  24081. * @param mainImpostor defines the main impostor to which the joint is added.
  24082. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24083. * @param joint defines the joint that will connect both impostors.
  24084. */
  24085. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24086. /**
  24087. * Removes a joint from the simulation
  24088. * @param mainImpostor defines the impostor used with the joint
  24089. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24090. * @param joint defines the joint to remove
  24091. */
  24092. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24093. /**
  24094. * Gets the current plugin used to run the simulation
  24095. * @returns current plugin
  24096. */
  24097. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24098. /**
  24099. * Gets the list of physic impostors
  24100. * @returns an array of PhysicsImpostor
  24101. */
  24102. getImpostors(): Array<PhysicsImpostor>;
  24103. /**
  24104. * Gets the impostor for a physics enabled object
  24105. * @param object defines the object impersonated by the impostor
  24106. * @returns the PhysicsImpostor or null if not found
  24107. */
  24108. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24109. /**
  24110. * Gets the impostor for a physics body object
  24111. * @param body defines physics body used by the impostor
  24112. * @returns the PhysicsImpostor or null if not found
  24113. */
  24114. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24115. /**
  24116. * Does a raycast in the physics world
  24117. * @param from when should the ray start?
  24118. * @param to when should the ray end?
  24119. * @returns PhysicsRaycastResult
  24120. */
  24121. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24122. /**
  24123. * Called by the scene. No need to call it.
  24124. * @param delta defines the timespam between frames
  24125. */
  24126. _step(delta: number): void;
  24127. }
  24128. }
  24129. declare module "babylonjs/Physics/physicsImpostor" {
  24130. import { Nullable, IndicesArray } from "babylonjs/types";
  24131. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24132. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24134. import { Scene } from "babylonjs/scene";
  24135. import { Bone } from "babylonjs/Bones/bone";
  24136. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24137. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24138. import { Space } from "babylonjs/Maths/math.axis";
  24139. /**
  24140. * The interface for the physics imposter parameters
  24141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24142. */
  24143. export interface PhysicsImpostorParameters {
  24144. /**
  24145. * The mass of the physics imposter
  24146. */
  24147. mass: number;
  24148. /**
  24149. * The friction of the physics imposter
  24150. */
  24151. friction?: number;
  24152. /**
  24153. * The coefficient of restitution of the physics imposter
  24154. */
  24155. restitution?: number;
  24156. /**
  24157. * The native options of the physics imposter
  24158. */
  24159. nativeOptions?: any;
  24160. /**
  24161. * Specifies if the parent should be ignored
  24162. */
  24163. ignoreParent?: boolean;
  24164. /**
  24165. * Specifies if bi-directional transformations should be disabled
  24166. */
  24167. disableBidirectionalTransformation?: boolean;
  24168. /**
  24169. * The pressure inside the physics imposter, soft object only
  24170. */
  24171. pressure?: number;
  24172. /**
  24173. * The stiffness the physics imposter, soft object only
  24174. */
  24175. stiffness?: number;
  24176. /**
  24177. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24178. */
  24179. velocityIterations?: number;
  24180. /**
  24181. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24182. */
  24183. positionIterations?: number;
  24184. /**
  24185. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24186. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24187. * Add to fix multiple points
  24188. */
  24189. fixedPoints?: number;
  24190. /**
  24191. * The collision margin around a soft object
  24192. */
  24193. margin?: number;
  24194. /**
  24195. * The collision margin around a soft object
  24196. */
  24197. damping?: number;
  24198. /**
  24199. * The path for a rope based on an extrusion
  24200. */
  24201. path?: any;
  24202. /**
  24203. * The shape of an extrusion used for a rope based on an extrusion
  24204. */
  24205. shape?: any;
  24206. }
  24207. /**
  24208. * Interface for a physics-enabled object
  24209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24210. */
  24211. export interface IPhysicsEnabledObject {
  24212. /**
  24213. * The position of the physics-enabled object
  24214. */
  24215. position: Vector3;
  24216. /**
  24217. * The rotation of the physics-enabled object
  24218. */
  24219. rotationQuaternion: Nullable<Quaternion>;
  24220. /**
  24221. * The scale of the physics-enabled object
  24222. */
  24223. scaling: Vector3;
  24224. /**
  24225. * The rotation of the physics-enabled object
  24226. */
  24227. rotation?: Vector3;
  24228. /**
  24229. * The parent of the physics-enabled object
  24230. */
  24231. parent?: any;
  24232. /**
  24233. * The bounding info of the physics-enabled object
  24234. * @returns The bounding info of the physics-enabled object
  24235. */
  24236. getBoundingInfo(): BoundingInfo;
  24237. /**
  24238. * Computes the world matrix
  24239. * @param force Specifies if the world matrix should be computed by force
  24240. * @returns A world matrix
  24241. */
  24242. computeWorldMatrix(force: boolean): Matrix;
  24243. /**
  24244. * Gets the world matrix
  24245. * @returns A world matrix
  24246. */
  24247. getWorldMatrix?(): Matrix;
  24248. /**
  24249. * Gets the child meshes
  24250. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24251. * @returns An array of abstract meshes
  24252. */
  24253. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24254. /**
  24255. * Gets the vertex data
  24256. * @param kind The type of vertex data
  24257. * @returns A nullable array of numbers, or a float32 array
  24258. */
  24259. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24260. /**
  24261. * Gets the indices from the mesh
  24262. * @returns A nullable array of index arrays
  24263. */
  24264. getIndices?(): Nullable<IndicesArray>;
  24265. /**
  24266. * Gets the scene from the mesh
  24267. * @returns the indices array or null
  24268. */
  24269. getScene?(): Scene;
  24270. /**
  24271. * Gets the absolute position from the mesh
  24272. * @returns the absolute position
  24273. */
  24274. getAbsolutePosition(): Vector3;
  24275. /**
  24276. * Gets the absolute pivot point from the mesh
  24277. * @returns the absolute pivot point
  24278. */
  24279. getAbsolutePivotPoint(): Vector3;
  24280. /**
  24281. * Rotates the mesh
  24282. * @param axis The axis of rotation
  24283. * @param amount The amount of rotation
  24284. * @param space The space of the rotation
  24285. * @returns The rotation transform node
  24286. */
  24287. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24288. /**
  24289. * Translates the mesh
  24290. * @param axis The axis of translation
  24291. * @param distance The distance of translation
  24292. * @param space The space of the translation
  24293. * @returns The transform node
  24294. */
  24295. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24296. /**
  24297. * Sets the absolute position of the mesh
  24298. * @param absolutePosition The absolute position of the mesh
  24299. * @returns The transform node
  24300. */
  24301. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24302. /**
  24303. * Gets the class name of the mesh
  24304. * @returns The class name
  24305. */
  24306. getClassName(): string;
  24307. }
  24308. /**
  24309. * Represents a physics imposter
  24310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24311. */
  24312. export class PhysicsImpostor {
  24313. /**
  24314. * The physics-enabled object used as the physics imposter
  24315. */
  24316. object: IPhysicsEnabledObject;
  24317. /**
  24318. * The type of the physics imposter
  24319. */
  24320. type: number;
  24321. private _options;
  24322. private _scene?;
  24323. /**
  24324. * The default object size of the imposter
  24325. */
  24326. static DEFAULT_OBJECT_SIZE: Vector3;
  24327. /**
  24328. * The identity quaternion of the imposter
  24329. */
  24330. static IDENTITY_QUATERNION: Quaternion;
  24331. /** @hidden */
  24332. _pluginData: any;
  24333. private _physicsEngine;
  24334. private _physicsBody;
  24335. private _bodyUpdateRequired;
  24336. private _onBeforePhysicsStepCallbacks;
  24337. private _onAfterPhysicsStepCallbacks;
  24338. /** @hidden */
  24339. _onPhysicsCollideCallbacks: Array<{
  24340. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24341. otherImpostors: Array<PhysicsImpostor>;
  24342. }>;
  24343. private _deltaPosition;
  24344. private _deltaRotation;
  24345. private _deltaRotationConjugated;
  24346. /** @hidden */
  24347. _isFromLine: boolean;
  24348. private _parent;
  24349. private _isDisposed;
  24350. private static _tmpVecs;
  24351. private static _tmpQuat;
  24352. /**
  24353. * Specifies if the physics imposter is disposed
  24354. */
  24355. get isDisposed(): boolean;
  24356. /**
  24357. * Gets the mass of the physics imposter
  24358. */
  24359. get mass(): number;
  24360. set mass(value: number);
  24361. /**
  24362. * Gets the coefficient of friction
  24363. */
  24364. get friction(): number;
  24365. /**
  24366. * Sets the coefficient of friction
  24367. */
  24368. set friction(value: number);
  24369. /**
  24370. * Gets the coefficient of restitution
  24371. */
  24372. get restitution(): number;
  24373. /**
  24374. * Sets the coefficient of restitution
  24375. */
  24376. set restitution(value: number);
  24377. /**
  24378. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24379. */
  24380. get pressure(): number;
  24381. /**
  24382. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24383. */
  24384. set pressure(value: number);
  24385. /**
  24386. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24387. */
  24388. get stiffness(): number;
  24389. /**
  24390. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24391. */
  24392. set stiffness(value: number);
  24393. /**
  24394. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24395. */
  24396. get velocityIterations(): number;
  24397. /**
  24398. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24399. */
  24400. set velocityIterations(value: number);
  24401. /**
  24402. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24403. */
  24404. get positionIterations(): number;
  24405. /**
  24406. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24407. */
  24408. set positionIterations(value: number);
  24409. /**
  24410. * The unique id of the physics imposter
  24411. * set by the physics engine when adding this impostor to the array
  24412. */
  24413. uniqueId: number;
  24414. /**
  24415. * @hidden
  24416. */
  24417. soft: boolean;
  24418. /**
  24419. * @hidden
  24420. */
  24421. segments: number;
  24422. private _joints;
  24423. /**
  24424. * Initializes the physics imposter
  24425. * @param object The physics-enabled object used as the physics imposter
  24426. * @param type The type of the physics imposter
  24427. * @param _options The options for the physics imposter
  24428. * @param _scene The Babylon scene
  24429. */
  24430. constructor(
  24431. /**
  24432. * The physics-enabled object used as the physics imposter
  24433. */
  24434. object: IPhysicsEnabledObject,
  24435. /**
  24436. * The type of the physics imposter
  24437. */
  24438. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24439. /**
  24440. * This function will completly initialize this impostor.
  24441. * It will create a new body - but only if this mesh has no parent.
  24442. * If it has, this impostor will not be used other than to define the impostor
  24443. * of the child mesh.
  24444. * @hidden
  24445. */
  24446. _init(): void;
  24447. private _getPhysicsParent;
  24448. /**
  24449. * Should a new body be generated.
  24450. * @returns boolean specifying if body initialization is required
  24451. */
  24452. isBodyInitRequired(): boolean;
  24453. /**
  24454. * Sets the updated scaling
  24455. * @param updated Specifies if the scaling is updated
  24456. */
  24457. setScalingUpdated(): void;
  24458. /**
  24459. * Force a regeneration of this or the parent's impostor's body.
  24460. * Use under cautious - This will remove all joints already implemented.
  24461. */
  24462. forceUpdate(): void;
  24463. /**
  24464. * Gets the body that holds this impostor. Either its own, or its parent.
  24465. */
  24466. get physicsBody(): any;
  24467. /**
  24468. * Get the parent of the physics imposter
  24469. * @returns Physics imposter or null
  24470. */
  24471. get parent(): Nullable<PhysicsImpostor>;
  24472. /**
  24473. * Sets the parent of the physics imposter
  24474. */
  24475. set parent(value: Nullable<PhysicsImpostor>);
  24476. /**
  24477. * Set the physics body. Used mainly by the physics engine/plugin
  24478. */
  24479. set physicsBody(physicsBody: any);
  24480. /**
  24481. * Resets the update flags
  24482. */
  24483. resetUpdateFlags(): void;
  24484. /**
  24485. * Gets the object extend size
  24486. * @returns the object extend size
  24487. */
  24488. getObjectExtendSize(): Vector3;
  24489. /**
  24490. * Gets the object center
  24491. * @returns The object center
  24492. */
  24493. getObjectCenter(): Vector3;
  24494. /**
  24495. * Get a specific parameter from the options parameters
  24496. * @param paramName The object parameter name
  24497. * @returns The object parameter
  24498. */
  24499. getParam(paramName: string): any;
  24500. /**
  24501. * Sets a specific parameter in the options given to the physics plugin
  24502. * @param paramName The parameter name
  24503. * @param value The value of the parameter
  24504. */
  24505. setParam(paramName: string, value: number): void;
  24506. /**
  24507. * Specifically change the body's mass option. Won't recreate the physics body object
  24508. * @param mass The mass of the physics imposter
  24509. */
  24510. setMass(mass: number): void;
  24511. /**
  24512. * Gets the linear velocity
  24513. * @returns linear velocity or null
  24514. */
  24515. getLinearVelocity(): Nullable<Vector3>;
  24516. /**
  24517. * Sets the linear velocity
  24518. * @param velocity linear velocity or null
  24519. */
  24520. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24521. /**
  24522. * Gets the angular velocity
  24523. * @returns angular velocity or null
  24524. */
  24525. getAngularVelocity(): Nullable<Vector3>;
  24526. /**
  24527. * Sets the angular velocity
  24528. * @param velocity The velocity or null
  24529. */
  24530. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24531. /**
  24532. * Execute a function with the physics plugin native code
  24533. * Provide a function the will have two variables - the world object and the physics body object
  24534. * @param func The function to execute with the physics plugin native code
  24535. */
  24536. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24537. /**
  24538. * Register a function that will be executed before the physics world is stepping forward
  24539. * @param func The function to execute before the physics world is stepped forward
  24540. */
  24541. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24542. /**
  24543. * Unregister a function that will be executed before the physics world is stepping forward
  24544. * @param func The function to execute before the physics world is stepped forward
  24545. */
  24546. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24547. /**
  24548. * Register a function that will be executed after the physics step
  24549. * @param func The function to execute after physics step
  24550. */
  24551. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24552. /**
  24553. * Unregisters a function that will be executed after the physics step
  24554. * @param func The function to execute after physics step
  24555. */
  24556. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24557. /**
  24558. * register a function that will be executed when this impostor collides against a different body
  24559. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24560. * @param func Callback that is executed on collision
  24561. */
  24562. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24563. /**
  24564. * Unregisters the physics imposter on contact
  24565. * @param collideAgainst The physics object to collide against
  24566. * @param func Callback to execute on collision
  24567. */
  24568. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24569. private _tmpQuat;
  24570. private _tmpQuat2;
  24571. /**
  24572. * Get the parent rotation
  24573. * @returns The parent rotation
  24574. */
  24575. getParentsRotation(): Quaternion;
  24576. /**
  24577. * this function is executed by the physics engine.
  24578. */
  24579. beforeStep: () => void;
  24580. /**
  24581. * this function is executed by the physics engine
  24582. */
  24583. afterStep: () => void;
  24584. /**
  24585. * Legacy collision detection event support
  24586. */
  24587. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24588. /**
  24589. * event and body object due to cannon's event-based architecture.
  24590. */
  24591. onCollide: (e: {
  24592. body: any;
  24593. }) => void;
  24594. /**
  24595. * Apply a force
  24596. * @param force The force to apply
  24597. * @param contactPoint The contact point for the force
  24598. * @returns The physics imposter
  24599. */
  24600. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24601. /**
  24602. * Apply an impulse
  24603. * @param force The impulse force
  24604. * @param contactPoint The contact point for the impulse force
  24605. * @returns The physics imposter
  24606. */
  24607. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24608. /**
  24609. * A help function to create a joint
  24610. * @param otherImpostor A physics imposter used to create a joint
  24611. * @param jointType The type of joint
  24612. * @param jointData The data for the joint
  24613. * @returns The physics imposter
  24614. */
  24615. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24616. /**
  24617. * Add a joint to this impostor with a different impostor
  24618. * @param otherImpostor A physics imposter used to add a joint
  24619. * @param joint The joint to add
  24620. * @returns The physics imposter
  24621. */
  24622. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24623. /**
  24624. * Add an anchor to a cloth impostor
  24625. * @param otherImpostor rigid impostor to anchor to
  24626. * @param width ratio across width from 0 to 1
  24627. * @param height ratio up height from 0 to 1
  24628. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24629. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24630. * @returns impostor the soft imposter
  24631. */
  24632. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24633. /**
  24634. * Add a hook to a rope impostor
  24635. * @param otherImpostor rigid impostor to anchor to
  24636. * @param length ratio across rope from 0 to 1
  24637. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24638. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24639. * @returns impostor the rope imposter
  24640. */
  24641. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24642. /**
  24643. * Will keep this body still, in a sleep mode.
  24644. * @returns the physics imposter
  24645. */
  24646. sleep(): PhysicsImpostor;
  24647. /**
  24648. * Wake the body up.
  24649. * @returns The physics imposter
  24650. */
  24651. wakeUp(): PhysicsImpostor;
  24652. /**
  24653. * Clones the physics imposter
  24654. * @param newObject The physics imposter clones to this physics-enabled object
  24655. * @returns A nullable physics imposter
  24656. */
  24657. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24658. /**
  24659. * Disposes the physics imposter
  24660. */
  24661. dispose(): void;
  24662. /**
  24663. * Sets the delta position
  24664. * @param position The delta position amount
  24665. */
  24666. setDeltaPosition(position: Vector3): void;
  24667. /**
  24668. * Sets the delta rotation
  24669. * @param rotation The delta rotation amount
  24670. */
  24671. setDeltaRotation(rotation: Quaternion): void;
  24672. /**
  24673. * Gets the box size of the physics imposter and stores the result in the input parameter
  24674. * @param result Stores the box size
  24675. * @returns The physics imposter
  24676. */
  24677. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24678. /**
  24679. * Gets the radius of the physics imposter
  24680. * @returns Radius of the physics imposter
  24681. */
  24682. getRadius(): number;
  24683. /**
  24684. * Sync a bone with this impostor
  24685. * @param bone The bone to sync to the impostor.
  24686. * @param boneMesh The mesh that the bone is influencing.
  24687. * @param jointPivot The pivot of the joint / bone in local space.
  24688. * @param distToJoint Optional distance from the impostor to the joint.
  24689. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24690. */
  24691. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24692. /**
  24693. * Sync impostor to a bone
  24694. * @param bone The bone that the impostor will be synced to.
  24695. * @param boneMesh The mesh that the bone is influencing.
  24696. * @param jointPivot The pivot of the joint / bone in local space.
  24697. * @param distToJoint Optional distance from the impostor to the joint.
  24698. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24699. * @param boneAxis Optional vector3 axis the bone is aligned with
  24700. */
  24701. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24702. /**
  24703. * No-Imposter type
  24704. */
  24705. static NoImpostor: number;
  24706. /**
  24707. * Sphere-Imposter type
  24708. */
  24709. static SphereImpostor: number;
  24710. /**
  24711. * Box-Imposter type
  24712. */
  24713. static BoxImpostor: number;
  24714. /**
  24715. * Plane-Imposter type
  24716. */
  24717. static PlaneImpostor: number;
  24718. /**
  24719. * Mesh-imposter type
  24720. */
  24721. static MeshImpostor: number;
  24722. /**
  24723. * Capsule-Impostor type (Ammo.js plugin only)
  24724. */
  24725. static CapsuleImpostor: number;
  24726. /**
  24727. * Cylinder-Imposter type
  24728. */
  24729. static CylinderImpostor: number;
  24730. /**
  24731. * Particle-Imposter type
  24732. */
  24733. static ParticleImpostor: number;
  24734. /**
  24735. * Heightmap-Imposter type
  24736. */
  24737. static HeightmapImpostor: number;
  24738. /**
  24739. * ConvexHull-Impostor type (Ammo.js plugin only)
  24740. */
  24741. static ConvexHullImpostor: number;
  24742. /**
  24743. * Custom-Imposter type (Ammo.js plugin only)
  24744. */
  24745. static CustomImpostor: number;
  24746. /**
  24747. * Rope-Imposter type
  24748. */
  24749. static RopeImpostor: number;
  24750. /**
  24751. * Cloth-Imposter type
  24752. */
  24753. static ClothImpostor: number;
  24754. /**
  24755. * Softbody-Imposter type
  24756. */
  24757. static SoftbodyImpostor: number;
  24758. }
  24759. }
  24760. declare module "babylonjs/Meshes/mesh" {
  24761. import { Observable } from "babylonjs/Misc/observable";
  24762. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24763. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24764. import { Camera } from "babylonjs/Cameras/camera";
  24765. import { Scene } from "babylonjs/scene";
  24766. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24767. import { Color4 } from "babylonjs/Maths/math.color";
  24768. import { Engine } from "babylonjs/Engines/engine";
  24769. import { Node } from "babylonjs/node";
  24770. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24771. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24772. import { Buffer } from "babylonjs/Meshes/buffer";
  24773. import { Geometry } from "babylonjs/Meshes/geometry";
  24774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24776. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24777. import { Effect } from "babylonjs/Materials/effect";
  24778. import { Material } from "babylonjs/Materials/material";
  24779. import { Skeleton } from "babylonjs/Bones/skeleton";
  24780. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24781. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24782. import { Path3D } from "babylonjs/Maths/math.path";
  24783. import { Plane } from "babylonjs/Maths/math.plane";
  24784. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24785. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24786. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24787. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24788. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24789. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24790. /**
  24791. * @hidden
  24792. **/
  24793. export class _CreationDataStorage {
  24794. closePath?: boolean;
  24795. closeArray?: boolean;
  24796. idx: number[];
  24797. dashSize: number;
  24798. gapSize: number;
  24799. path3D: Path3D;
  24800. pathArray: Vector3[][];
  24801. arc: number;
  24802. radius: number;
  24803. cap: number;
  24804. tessellation: number;
  24805. }
  24806. /**
  24807. * @hidden
  24808. **/
  24809. class _InstanceDataStorage {
  24810. visibleInstances: any;
  24811. batchCache: _InstancesBatch;
  24812. instancesBufferSize: number;
  24813. instancesBuffer: Nullable<Buffer>;
  24814. instancesData: Float32Array;
  24815. overridenInstanceCount: number;
  24816. isFrozen: boolean;
  24817. previousBatch: Nullable<_InstancesBatch>;
  24818. hardwareInstancedRendering: boolean;
  24819. sideOrientation: number;
  24820. manualUpdate: boolean;
  24821. }
  24822. /**
  24823. * @hidden
  24824. **/
  24825. export class _InstancesBatch {
  24826. mustReturn: boolean;
  24827. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24828. renderSelf: boolean[];
  24829. hardwareInstancedRendering: boolean[];
  24830. }
  24831. /**
  24832. * Class used to represent renderable models
  24833. */
  24834. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24835. /**
  24836. * Mesh side orientation : usually the external or front surface
  24837. */
  24838. static readonly FRONTSIDE: number;
  24839. /**
  24840. * Mesh side orientation : usually the internal or back surface
  24841. */
  24842. static readonly BACKSIDE: number;
  24843. /**
  24844. * Mesh side orientation : both internal and external or front and back surfaces
  24845. */
  24846. static readonly DOUBLESIDE: number;
  24847. /**
  24848. * Mesh side orientation : by default, `FRONTSIDE`
  24849. */
  24850. static readonly DEFAULTSIDE: number;
  24851. /**
  24852. * Mesh cap setting : no cap
  24853. */
  24854. static readonly NO_CAP: number;
  24855. /**
  24856. * Mesh cap setting : one cap at the beginning of the mesh
  24857. */
  24858. static readonly CAP_START: number;
  24859. /**
  24860. * Mesh cap setting : one cap at the end of the mesh
  24861. */
  24862. static readonly CAP_END: number;
  24863. /**
  24864. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24865. */
  24866. static readonly CAP_ALL: number;
  24867. /**
  24868. * Mesh pattern setting : no flip or rotate
  24869. */
  24870. static readonly NO_FLIP: number;
  24871. /**
  24872. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24873. */
  24874. static readonly FLIP_TILE: number;
  24875. /**
  24876. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24877. */
  24878. static readonly ROTATE_TILE: number;
  24879. /**
  24880. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24881. */
  24882. static readonly FLIP_ROW: number;
  24883. /**
  24884. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24885. */
  24886. static readonly ROTATE_ROW: number;
  24887. /**
  24888. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24889. */
  24890. static readonly FLIP_N_ROTATE_TILE: number;
  24891. /**
  24892. * Mesh pattern setting : rotate pattern and rotate
  24893. */
  24894. static readonly FLIP_N_ROTATE_ROW: number;
  24895. /**
  24896. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24897. */
  24898. static readonly CENTER: number;
  24899. /**
  24900. * Mesh tile positioning : part tiles on left
  24901. */
  24902. static readonly LEFT: number;
  24903. /**
  24904. * Mesh tile positioning : part tiles on right
  24905. */
  24906. static readonly RIGHT: number;
  24907. /**
  24908. * Mesh tile positioning : part tiles on top
  24909. */
  24910. static readonly TOP: number;
  24911. /**
  24912. * Mesh tile positioning : part tiles on bottom
  24913. */
  24914. static readonly BOTTOM: number;
  24915. /**
  24916. * Gets the default side orientation.
  24917. * @param orientation the orientation to value to attempt to get
  24918. * @returns the default orientation
  24919. * @hidden
  24920. */
  24921. static _GetDefaultSideOrientation(orientation?: number): number;
  24922. private _internalMeshDataInfo;
  24923. /**
  24924. * An event triggered before rendering the mesh
  24925. */
  24926. get onBeforeRenderObservable(): Observable<Mesh>;
  24927. /**
  24928. * An event triggered before binding the mesh
  24929. */
  24930. get onBeforeBindObservable(): Observable<Mesh>;
  24931. /**
  24932. * An event triggered after rendering the mesh
  24933. */
  24934. get onAfterRenderObservable(): Observable<Mesh>;
  24935. /**
  24936. * An event triggered before drawing the mesh
  24937. */
  24938. get onBeforeDrawObservable(): Observable<Mesh>;
  24939. private _onBeforeDrawObserver;
  24940. /**
  24941. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24942. */
  24943. set onBeforeDraw(callback: () => void);
  24944. get hasInstances(): boolean;
  24945. /**
  24946. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24947. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24948. */
  24949. delayLoadState: number;
  24950. /**
  24951. * Gets the list of instances created from this mesh
  24952. * it is not supposed to be modified manually.
  24953. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24954. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24955. */
  24956. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24957. /**
  24958. * Gets the file containing delay loading data for this mesh
  24959. */
  24960. delayLoadingFile: string;
  24961. /** @hidden */
  24962. _binaryInfo: any;
  24963. /**
  24964. * User defined function used to change how LOD level selection is done
  24965. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24966. */
  24967. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24968. /**
  24969. * Gets or sets the morph target manager
  24970. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24971. */
  24972. get morphTargetManager(): Nullable<MorphTargetManager>;
  24973. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24974. /** @hidden */
  24975. _creationDataStorage: Nullable<_CreationDataStorage>;
  24976. /** @hidden */
  24977. _geometry: Nullable<Geometry>;
  24978. /** @hidden */
  24979. _delayInfo: Array<string>;
  24980. /** @hidden */
  24981. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24982. /** @hidden */
  24983. _instanceDataStorage: _InstanceDataStorage;
  24984. private _effectiveMaterial;
  24985. /** @hidden */
  24986. _shouldGenerateFlatShading: boolean;
  24987. /** @hidden */
  24988. _originalBuilderSideOrientation: number;
  24989. /**
  24990. * Use this property to change the original side orientation defined at construction time
  24991. */
  24992. overrideMaterialSideOrientation: Nullable<number>;
  24993. /**
  24994. * Gets the source mesh (the one used to clone this one from)
  24995. */
  24996. get source(): Nullable<Mesh>;
  24997. /**
  24998. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24999. */
  25000. get isUnIndexed(): boolean;
  25001. set isUnIndexed(value: boolean);
  25002. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25003. get worldMatrixInstancedBuffer(): Float32Array;
  25004. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25005. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25006. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25007. /**
  25008. * @constructor
  25009. * @param name The value used by scene.getMeshByName() to do a lookup.
  25010. * @param scene The scene to add this mesh to.
  25011. * @param parent The parent of this mesh, if it has one
  25012. * @param source An optional Mesh from which geometry is shared, cloned.
  25013. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25014. * When false, achieved by calling a clone(), also passing False.
  25015. * This will make creation of children, recursive.
  25016. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25017. */
  25018. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25019. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25020. doNotInstantiate: boolean;
  25021. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25022. /**
  25023. * Gets the class name
  25024. * @returns the string "Mesh".
  25025. */
  25026. getClassName(): string;
  25027. /** @hidden */
  25028. get _isMesh(): boolean;
  25029. /**
  25030. * Returns a description of this mesh
  25031. * @param fullDetails define if full details about this mesh must be used
  25032. * @returns a descriptive string representing this mesh
  25033. */
  25034. toString(fullDetails?: boolean): string;
  25035. /** @hidden */
  25036. _unBindEffect(): void;
  25037. /**
  25038. * Gets a boolean indicating if this mesh has LOD
  25039. */
  25040. get hasLODLevels(): boolean;
  25041. /**
  25042. * Gets the list of MeshLODLevel associated with the current mesh
  25043. * @returns an array of MeshLODLevel
  25044. */
  25045. getLODLevels(): MeshLODLevel[];
  25046. private _sortLODLevels;
  25047. /**
  25048. * Add a mesh as LOD level triggered at the given distance.
  25049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25050. * @param distance The distance from the center of the object to show this level
  25051. * @param mesh The mesh to be added as LOD level (can be null)
  25052. * @return This mesh (for chaining)
  25053. */
  25054. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25055. /**
  25056. * Returns the LOD level mesh at the passed distance or null if not found.
  25057. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25058. * @param distance The distance from the center of the object to show this level
  25059. * @returns a Mesh or `null`
  25060. */
  25061. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25062. /**
  25063. * Remove a mesh from the LOD array
  25064. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25065. * @param mesh defines the mesh to be removed
  25066. * @return This mesh (for chaining)
  25067. */
  25068. removeLODLevel(mesh: Mesh): Mesh;
  25069. /**
  25070. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25071. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25072. * @param camera defines the camera to use to compute distance
  25073. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25074. * @return This mesh (for chaining)
  25075. */
  25076. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25077. /**
  25078. * Gets the mesh internal Geometry object
  25079. */
  25080. get geometry(): Nullable<Geometry>;
  25081. /**
  25082. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25083. * @returns the total number of vertices
  25084. */
  25085. getTotalVertices(): number;
  25086. /**
  25087. * Returns the content of an associated vertex buffer
  25088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25089. * - VertexBuffer.PositionKind
  25090. * - VertexBuffer.UVKind
  25091. * - VertexBuffer.UV2Kind
  25092. * - VertexBuffer.UV3Kind
  25093. * - VertexBuffer.UV4Kind
  25094. * - VertexBuffer.UV5Kind
  25095. * - VertexBuffer.UV6Kind
  25096. * - VertexBuffer.ColorKind
  25097. * - VertexBuffer.MatricesIndicesKind
  25098. * - VertexBuffer.MatricesIndicesExtraKind
  25099. * - VertexBuffer.MatricesWeightsKind
  25100. * - VertexBuffer.MatricesWeightsExtraKind
  25101. * @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
  25102. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25103. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25104. */
  25105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25106. /**
  25107. * Returns the mesh VertexBuffer object from the requested `kind`
  25108. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25109. * - VertexBuffer.PositionKind
  25110. * - VertexBuffer.NormalKind
  25111. * - VertexBuffer.UVKind
  25112. * - VertexBuffer.UV2Kind
  25113. * - VertexBuffer.UV3Kind
  25114. * - VertexBuffer.UV4Kind
  25115. * - VertexBuffer.UV5Kind
  25116. * - VertexBuffer.UV6Kind
  25117. * - VertexBuffer.ColorKind
  25118. * - VertexBuffer.MatricesIndicesKind
  25119. * - VertexBuffer.MatricesIndicesExtraKind
  25120. * - VertexBuffer.MatricesWeightsKind
  25121. * - VertexBuffer.MatricesWeightsExtraKind
  25122. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25123. */
  25124. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25125. /**
  25126. * Tests if a specific vertex buffer is associated with this mesh
  25127. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25128. * - VertexBuffer.PositionKind
  25129. * - VertexBuffer.NormalKind
  25130. * - VertexBuffer.UVKind
  25131. * - VertexBuffer.UV2Kind
  25132. * - VertexBuffer.UV3Kind
  25133. * - VertexBuffer.UV4Kind
  25134. * - VertexBuffer.UV5Kind
  25135. * - VertexBuffer.UV6Kind
  25136. * - VertexBuffer.ColorKind
  25137. * - VertexBuffer.MatricesIndicesKind
  25138. * - VertexBuffer.MatricesIndicesExtraKind
  25139. * - VertexBuffer.MatricesWeightsKind
  25140. * - VertexBuffer.MatricesWeightsExtraKind
  25141. * @returns a boolean
  25142. */
  25143. isVerticesDataPresent(kind: string): boolean;
  25144. /**
  25145. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25146. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25147. * - VertexBuffer.PositionKind
  25148. * - VertexBuffer.UVKind
  25149. * - VertexBuffer.UV2Kind
  25150. * - VertexBuffer.UV3Kind
  25151. * - VertexBuffer.UV4Kind
  25152. * - VertexBuffer.UV5Kind
  25153. * - VertexBuffer.UV6Kind
  25154. * - VertexBuffer.ColorKind
  25155. * - VertexBuffer.MatricesIndicesKind
  25156. * - VertexBuffer.MatricesIndicesExtraKind
  25157. * - VertexBuffer.MatricesWeightsKind
  25158. * - VertexBuffer.MatricesWeightsExtraKind
  25159. * @returns a boolean
  25160. */
  25161. isVertexBufferUpdatable(kind: string): boolean;
  25162. /**
  25163. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25164. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25165. * - VertexBuffer.PositionKind
  25166. * - VertexBuffer.NormalKind
  25167. * - VertexBuffer.UVKind
  25168. * - VertexBuffer.UV2Kind
  25169. * - VertexBuffer.UV3Kind
  25170. * - VertexBuffer.UV4Kind
  25171. * - VertexBuffer.UV5Kind
  25172. * - VertexBuffer.UV6Kind
  25173. * - VertexBuffer.ColorKind
  25174. * - VertexBuffer.MatricesIndicesKind
  25175. * - VertexBuffer.MatricesIndicesExtraKind
  25176. * - VertexBuffer.MatricesWeightsKind
  25177. * - VertexBuffer.MatricesWeightsExtraKind
  25178. * @returns an array of strings
  25179. */
  25180. getVerticesDataKinds(): string[];
  25181. /**
  25182. * Returns a positive integer : the total number of indices in this mesh geometry.
  25183. * @returns the numner of indices or zero if the mesh has no geometry.
  25184. */
  25185. getTotalIndices(): number;
  25186. /**
  25187. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25188. * @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.
  25189. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25190. * @returns the indices array or an empty array if the mesh has no geometry
  25191. */
  25192. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25193. get isBlocked(): boolean;
  25194. /**
  25195. * Determine if the current mesh is ready to be rendered
  25196. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25197. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25198. * @returns true if all associated assets are ready (material, textures, shaders)
  25199. */
  25200. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25201. /**
  25202. * 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.
  25203. */
  25204. get areNormalsFrozen(): boolean;
  25205. /**
  25206. * 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.
  25207. * @returns the current mesh
  25208. */
  25209. freezeNormals(): Mesh;
  25210. /**
  25211. * 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
  25212. * @returns the current mesh
  25213. */
  25214. unfreezeNormals(): Mesh;
  25215. /**
  25216. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25217. */
  25218. set overridenInstanceCount(count: number);
  25219. /** @hidden */
  25220. _preActivate(): Mesh;
  25221. /** @hidden */
  25222. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25223. /** @hidden */
  25224. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25225. /**
  25226. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25227. * This means the mesh underlying bounding box and sphere are recomputed.
  25228. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25229. * @returns the current mesh
  25230. */
  25231. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25232. /** @hidden */
  25233. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25234. /**
  25235. * This function will subdivide the mesh into multiple submeshes
  25236. * @param count defines the expected number of submeshes
  25237. */
  25238. subdivide(count: number): void;
  25239. /**
  25240. * Copy a FloatArray into a specific associated vertex buffer
  25241. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25242. * - VertexBuffer.PositionKind
  25243. * - VertexBuffer.UVKind
  25244. * - VertexBuffer.UV2Kind
  25245. * - VertexBuffer.UV3Kind
  25246. * - VertexBuffer.UV4Kind
  25247. * - VertexBuffer.UV5Kind
  25248. * - VertexBuffer.UV6Kind
  25249. * - VertexBuffer.ColorKind
  25250. * - VertexBuffer.MatricesIndicesKind
  25251. * - VertexBuffer.MatricesIndicesExtraKind
  25252. * - VertexBuffer.MatricesWeightsKind
  25253. * - VertexBuffer.MatricesWeightsExtraKind
  25254. * @param data defines the data source
  25255. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25256. * @param stride defines the data stride size (can be null)
  25257. * @returns the current mesh
  25258. */
  25259. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25260. /**
  25261. * Delete a vertex buffer associated with this mesh
  25262. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25263. * - VertexBuffer.PositionKind
  25264. * - VertexBuffer.UVKind
  25265. * - VertexBuffer.UV2Kind
  25266. * - VertexBuffer.UV3Kind
  25267. * - VertexBuffer.UV4Kind
  25268. * - VertexBuffer.UV5Kind
  25269. * - VertexBuffer.UV6Kind
  25270. * - VertexBuffer.ColorKind
  25271. * - VertexBuffer.MatricesIndicesKind
  25272. * - VertexBuffer.MatricesIndicesExtraKind
  25273. * - VertexBuffer.MatricesWeightsKind
  25274. * - VertexBuffer.MatricesWeightsExtraKind
  25275. */
  25276. removeVerticesData(kind: string): void;
  25277. /**
  25278. * Flags an associated vertex buffer as updatable
  25279. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25280. * - VertexBuffer.PositionKind
  25281. * - VertexBuffer.UVKind
  25282. * - VertexBuffer.UV2Kind
  25283. * - VertexBuffer.UV3Kind
  25284. * - VertexBuffer.UV4Kind
  25285. * - VertexBuffer.UV5Kind
  25286. * - VertexBuffer.UV6Kind
  25287. * - VertexBuffer.ColorKind
  25288. * - VertexBuffer.MatricesIndicesKind
  25289. * - VertexBuffer.MatricesIndicesExtraKind
  25290. * - VertexBuffer.MatricesWeightsKind
  25291. * - VertexBuffer.MatricesWeightsExtraKind
  25292. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25293. */
  25294. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25295. /**
  25296. * Sets the mesh global Vertex Buffer
  25297. * @param buffer defines the buffer to use
  25298. * @returns the current mesh
  25299. */
  25300. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25301. /**
  25302. * Update a specific associated vertex buffer
  25303. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25304. * - VertexBuffer.PositionKind
  25305. * - VertexBuffer.UVKind
  25306. * - VertexBuffer.UV2Kind
  25307. * - VertexBuffer.UV3Kind
  25308. * - VertexBuffer.UV4Kind
  25309. * - VertexBuffer.UV5Kind
  25310. * - VertexBuffer.UV6Kind
  25311. * - VertexBuffer.ColorKind
  25312. * - VertexBuffer.MatricesIndicesKind
  25313. * - VertexBuffer.MatricesIndicesExtraKind
  25314. * - VertexBuffer.MatricesWeightsKind
  25315. * - VertexBuffer.MatricesWeightsExtraKind
  25316. * @param data defines the data source
  25317. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25318. * @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)
  25319. * @returns the current mesh
  25320. */
  25321. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25322. /**
  25323. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25324. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25325. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25326. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25327. * @returns the current mesh
  25328. */
  25329. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25330. /**
  25331. * Creates a un-shared specific occurence of the geometry for the mesh.
  25332. * @returns the current mesh
  25333. */
  25334. makeGeometryUnique(): Mesh;
  25335. /**
  25336. * Set the index buffer of this mesh
  25337. * @param indices defines the source data
  25338. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25339. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25340. * @returns the current mesh
  25341. */
  25342. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25343. /**
  25344. * Update the current index buffer
  25345. * @param indices defines the source data
  25346. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25347. * @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)
  25348. * @returns the current mesh
  25349. */
  25350. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25351. /**
  25352. * Invert the geometry to move from a right handed system to a left handed one.
  25353. * @returns the current mesh
  25354. */
  25355. toLeftHanded(): Mesh;
  25356. /** @hidden */
  25357. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25358. /** @hidden */
  25359. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25360. /**
  25361. * Registers for this mesh a javascript function called just before the rendering process
  25362. * @param func defines the function to call before rendering this mesh
  25363. * @returns the current mesh
  25364. */
  25365. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25366. /**
  25367. * Disposes a previously registered javascript function called before the rendering
  25368. * @param func defines the function to remove
  25369. * @returns the current mesh
  25370. */
  25371. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25372. /**
  25373. * Registers for this mesh a javascript function called just after the rendering is complete
  25374. * @param func defines the function to call after rendering this mesh
  25375. * @returns the current mesh
  25376. */
  25377. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25378. /**
  25379. * Disposes a previously registered javascript function called after the rendering.
  25380. * @param func defines the function to remove
  25381. * @returns the current mesh
  25382. */
  25383. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25384. /** @hidden */
  25385. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25386. /** @hidden */
  25387. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25388. /** @hidden */
  25389. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25390. /** @hidden */
  25391. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25392. /** @hidden */
  25393. _rebuild(): void;
  25394. /** @hidden */
  25395. _freeze(): void;
  25396. /** @hidden */
  25397. _unFreeze(): void;
  25398. /**
  25399. * 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
  25400. * @param subMesh defines the subMesh to render
  25401. * @param enableAlphaMode defines if alpha mode can be changed
  25402. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25403. * @returns the current mesh
  25404. */
  25405. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25406. private _onBeforeDraw;
  25407. /**
  25408. * Renormalize the mesh and patch it up if there are no weights
  25409. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25410. * However in the case of zero weights then we set just a single influence to 1.
  25411. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25412. */
  25413. cleanMatrixWeights(): void;
  25414. private normalizeSkinFourWeights;
  25415. private normalizeSkinWeightsAndExtra;
  25416. /**
  25417. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25418. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25419. * the user know there was an issue with importing the mesh
  25420. * @returns a validation object with skinned, valid and report string
  25421. */
  25422. validateSkinning(): {
  25423. skinned: boolean;
  25424. valid: boolean;
  25425. report: string;
  25426. };
  25427. /** @hidden */
  25428. _checkDelayState(): Mesh;
  25429. private _queueLoad;
  25430. /**
  25431. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25432. * A mesh is in the frustum if its bounding box intersects the frustum
  25433. * @param frustumPlanes defines the frustum to test
  25434. * @returns true if the mesh is in the frustum planes
  25435. */
  25436. isInFrustum(frustumPlanes: Plane[]): boolean;
  25437. /**
  25438. * Sets the mesh material by the material or multiMaterial `id` property
  25439. * @param id is a string identifying the material or the multiMaterial
  25440. * @returns the current mesh
  25441. */
  25442. setMaterialByID(id: string): Mesh;
  25443. /**
  25444. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25445. * @returns an array of IAnimatable
  25446. */
  25447. getAnimatables(): IAnimatable[];
  25448. /**
  25449. * Modifies the mesh geometry according to the passed transformation matrix.
  25450. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25451. * The mesh normals are modified using the same transformation.
  25452. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25453. * @param transform defines the transform matrix to use
  25454. * @see http://doc.babylonjs.com/resources/baking_transformations
  25455. * @returns the current mesh
  25456. */
  25457. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25458. /**
  25459. * Modifies the mesh geometry according to its own current World Matrix.
  25460. * The mesh World Matrix is then reset.
  25461. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25462. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25463. * @see http://doc.babylonjs.com/resources/baking_transformations
  25464. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25465. * @returns the current mesh
  25466. */
  25467. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25468. /** @hidden */
  25469. get _positions(): Nullable<Vector3[]>;
  25470. /** @hidden */
  25471. _resetPointsArrayCache(): Mesh;
  25472. /** @hidden */
  25473. _generatePointsArray(): boolean;
  25474. /**
  25475. * Returns a new Mesh object generated from the current mesh properties.
  25476. * This method must not get confused with createInstance()
  25477. * @param name is a string, the name given to the new mesh
  25478. * @param newParent can be any Node object (default `null`)
  25479. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25480. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25481. * @returns a new mesh
  25482. */
  25483. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25484. /**
  25485. * Releases resources associated with this mesh.
  25486. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25487. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25488. */
  25489. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25490. /** @hidden */
  25491. _disposeInstanceSpecificData(): void;
  25492. /**
  25493. * Modifies the mesh geometry according to a displacement map.
  25494. * 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.
  25495. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25496. * @param url is a string, the URL from the image file is to be downloaded.
  25497. * @param minHeight is the lower limit of the displacement.
  25498. * @param maxHeight is the upper limit of the displacement.
  25499. * @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.
  25500. * @param uvOffset is an optional vector2 used to offset UV.
  25501. * @param uvScale is an optional vector2 used to scale UV.
  25502. * @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.
  25503. * @returns the Mesh.
  25504. */
  25505. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25506. /**
  25507. * Modifies the mesh geometry according to a displacementMap buffer.
  25508. * 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.
  25509. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25510. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25511. * @param heightMapWidth is the width of the buffer image.
  25512. * @param heightMapHeight is the height of the buffer image.
  25513. * @param minHeight is the lower limit of the displacement.
  25514. * @param maxHeight is the upper limit of the displacement.
  25515. * @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.
  25516. * @param uvOffset is an optional vector2 used to offset UV.
  25517. * @param uvScale is an optional vector2 used to scale UV.
  25518. * @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.
  25519. * @returns the Mesh.
  25520. */
  25521. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25522. /**
  25523. * Modify the mesh to get a flat shading rendering.
  25524. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25525. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25526. * @returns current mesh
  25527. */
  25528. convertToFlatShadedMesh(): Mesh;
  25529. /**
  25530. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25531. * In other words, more vertices, no more indices and a single bigger VBO.
  25532. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25533. * @returns current mesh
  25534. */
  25535. convertToUnIndexedMesh(): Mesh;
  25536. /**
  25537. * Inverses facet orientations.
  25538. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25539. * @param flipNormals will also inverts the normals
  25540. * @returns current mesh
  25541. */
  25542. flipFaces(flipNormals?: boolean): Mesh;
  25543. /**
  25544. * Increase the number of facets and hence vertices in a mesh
  25545. * Vertex normals are interpolated from existing vertex normals
  25546. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25547. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25548. */
  25549. increaseVertices(numberPerEdge: number): void;
  25550. /**
  25551. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25552. * This will undo any application of covertToFlatShadedMesh
  25553. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25554. */
  25555. forceSharedVertices(): void;
  25556. /** @hidden */
  25557. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25558. /** @hidden */
  25559. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25560. /**
  25561. * Creates a new InstancedMesh object from the mesh model.
  25562. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25563. * @param name defines the name of the new instance
  25564. * @returns a new InstancedMesh
  25565. */
  25566. createInstance(name: string): InstancedMesh;
  25567. /**
  25568. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25569. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25570. * @returns the current mesh
  25571. */
  25572. synchronizeInstances(): Mesh;
  25573. /**
  25574. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25575. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25576. * This should be used together with the simplification to avoid disappearing triangles.
  25577. * @param successCallback an optional success callback to be called after the optimization finished.
  25578. * @returns the current mesh
  25579. */
  25580. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25581. /**
  25582. * Serialize current mesh
  25583. * @param serializationObject defines the object which will receive the serialization data
  25584. */
  25585. serialize(serializationObject: any): void;
  25586. /** @hidden */
  25587. _syncGeometryWithMorphTargetManager(): void;
  25588. /** @hidden */
  25589. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25590. /**
  25591. * Returns a new Mesh object parsed from the source provided.
  25592. * @param parsedMesh is the source
  25593. * @param scene defines the hosting scene
  25594. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25595. * @returns a new Mesh
  25596. */
  25597. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25598. /**
  25599. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25600. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25601. * @param name defines the name of the mesh to create
  25602. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25603. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25604. * @param closePath creates a seam between the first and the last points of each path of the path array
  25605. * @param offset is taken in account only if the `pathArray` is containing a single path
  25606. * @param scene defines the hosting scene
  25607. * @param updatable defines if the mesh must be flagged as updatable
  25608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25609. * @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)
  25610. * @returns a new Mesh
  25611. */
  25612. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25613. /**
  25614. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25615. * @param name defines the name of the mesh to create
  25616. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25617. * @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
  25618. * @param scene defines the hosting scene
  25619. * @param updatable defines if the mesh must be flagged as updatable
  25620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25621. * @returns a new Mesh
  25622. */
  25623. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25624. /**
  25625. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25626. * @param name defines the name of the mesh to create
  25627. * @param size sets the size (float) of each box side (default 1)
  25628. * @param scene defines the hosting scene
  25629. * @param updatable defines if the mesh must be flagged as updatable
  25630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25631. * @returns a new Mesh
  25632. */
  25633. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25634. /**
  25635. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25636. * @param name defines the name of the mesh to create
  25637. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25638. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25639. * @param scene defines the hosting scene
  25640. * @param updatable defines if the mesh must be flagged as updatable
  25641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25642. * @returns a new Mesh
  25643. */
  25644. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25645. /**
  25646. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25647. * @param name defines the name of the mesh to create
  25648. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25649. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25650. * @param scene defines the hosting scene
  25651. * @returns a new Mesh
  25652. */
  25653. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25654. /**
  25655. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25656. * @param name defines the name of the mesh to create
  25657. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25658. * @param diameterTop set the top cap diameter (floats, default 1)
  25659. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25660. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25661. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25662. * @param scene defines the hosting scene
  25663. * @param updatable defines if the mesh must be flagged as updatable
  25664. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25665. * @returns a new Mesh
  25666. */
  25667. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25668. /**
  25669. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25670. * @param name defines the name of the mesh to create
  25671. * @param diameter sets the diameter size (float) of the torus (default 1)
  25672. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25673. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25674. * @param scene defines the hosting scene
  25675. * @param updatable defines if the mesh must be flagged as updatable
  25676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25677. * @returns a new Mesh
  25678. */
  25679. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25680. /**
  25681. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25682. * @param name defines the name of the mesh to create
  25683. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25684. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25685. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25686. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25687. * @param p the number of windings on X axis (positive integers, default 2)
  25688. * @param q the number of windings on Y axis (positive integers, default 3)
  25689. * @param scene defines the hosting scene
  25690. * @param updatable defines if the mesh must be flagged as updatable
  25691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25692. * @returns a new Mesh
  25693. */
  25694. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25695. /**
  25696. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25697. * @param name defines the name of the mesh to create
  25698. * @param points is an array successive Vector3
  25699. * @param scene defines the hosting scene
  25700. * @param updatable defines if the mesh must be flagged as updatable
  25701. * @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).
  25702. * @returns a new Mesh
  25703. */
  25704. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25705. /**
  25706. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25707. * @param name defines the name of the mesh to create
  25708. * @param points is an array successive Vector3
  25709. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25710. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25711. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25712. * @param scene defines the hosting scene
  25713. * @param updatable defines if the mesh must be flagged as updatable
  25714. * @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)
  25715. * @returns a new Mesh
  25716. */
  25717. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25718. /**
  25719. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25720. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25721. * 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.
  25722. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25723. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25724. * Remember you can only change the shape positions, not their number when updating a polygon.
  25725. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25726. * @param name defines the name of the mesh to create
  25727. * @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
  25728. * @param scene defines the hosting scene
  25729. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25730. * @param updatable defines if the mesh must be flagged as updatable
  25731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25732. * @param earcutInjection can be used to inject your own earcut reference
  25733. * @returns a new Mesh
  25734. */
  25735. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25736. /**
  25737. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25738. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25739. * @param name defines the name of the mesh to create
  25740. * @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
  25741. * @param depth defines the height of extrusion
  25742. * @param scene defines the hosting scene
  25743. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25744. * @param updatable defines if the mesh must be flagged as updatable
  25745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25746. * @param earcutInjection can be used to inject your own earcut reference
  25747. * @returns a new Mesh
  25748. */
  25749. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25750. /**
  25751. * Creates an extruded shape mesh.
  25752. * 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
  25753. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25754. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25755. * @param name defines the name of the mesh to create
  25756. * @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
  25757. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25758. * @param scale is the value to scale the shape
  25759. * @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
  25760. * @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
  25761. * @param scene defines the hosting scene
  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 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)
  25765. * @returns a new Mesh
  25766. */
  25767. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25768. /**
  25769. * Creates an custom extruded shape mesh.
  25770. * The custom extrusion is a parametric shape.
  25771. * It has no predefined shape. Its final shape will depend on the input parameters.
  25772. * Please consider using the same method from the MeshBuilder class instead
  25773. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25774. * @param name defines the name of the mesh to create
  25775. * @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
  25776. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25777. * @param scaleFunction is a custom Javascript function called on each path point
  25778. * @param rotationFunction is a custom Javascript function called on each path point
  25779. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25780. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25781. * @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
  25782. * @param scene defines the hosting scene
  25783. * @param updatable defines if the mesh must be flagged as updatable
  25784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25785. * @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)
  25786. * @returns a new Mesh
  25787. */
  25788. 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;
  25789. /**
  25790. * Creates lathe mesh.
  25791. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25792. * Please consider using the same method from the MeshBuilder class instead
  25793. * @param name defines the name of the mesh to create
  25794. * @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
  25795. * @param radius is the radius value of the lathe
  25796. * @param tessellation is the side number of the lathe.
  25797. * @param scene defines the hosting scene
  25798. * @param updatable defines if the mesh must be flagged as updatable
  25799. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25800. * @returns a new Mesh
  25801. */
  25802. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25803. /**
  25804. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25805. * @param name defines the name of the mesh to create
  25806. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25807. * @param scene defines the hosting scene
  25808. * @param updatable defines if the mesh must be flagged as updatable
  25809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25810. * @returns a new Mesh
  25811. */
  25812. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25813. /**
  25814. * Creates a ground mesh.
  25815. * Please consider using the same method from the MeshBuilder class instead
  25816. * @param name defines the name of the mesh to create
  25817. * @param width set the width of the ground
  25818. * @param height set the height of the ground
  25819. * @param subdivisions sets the number of subdivisions per side
  25820. * @param scene defines the hosting scene
  25821. * @param updatable defines if the mesh must be flagged as updatable
  25822. * @returns a new Mesh
  25823. */
  25824. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25825. /**
  25826. * Creates a tiled ground mesh.
  25827. * Please consider using the same method from the MeshBuilder class instead
  25828. * @param name defines the name of the mesh to create
  25829. * @param xmin set the ground minimum X coordinate
  25830. * @param zmin set the ground minimum Y coordinate
  25831. * @param xmax set the ground maximum X coordinate
  25832. * @param zmax set the ground maximum Z coordinate
  25833. * @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
  25834. * @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
  25835. * @param scene defines the hosting scene
  25836. * @param updatable defines if the mesh must be flagged as updatable
  25837. * @returns a new Mesh
  25838. */
  25839. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25840. w: number;
  25841. h: number;
  25842. }, precision: {
  25843. w: number;
  25844. h: number;
  25845. }, scene: Scene, updatable?: boolean): Mesh;
  25846. /**
  25847. * Creates a ground mesh from a height map.
  25848. * Please consider using the same method from the MeshBuilder class instead
  25849. * @see http://doc.babylonjs.com/babylon101/height_map
  25850. * @param name defines the name of the mesh to create
  25851. * @param url sets the URL of the height map image resource
  25852. * @param width set the ground width size
  25853. * @param height set the ground height size
  25854. * @param subdivisions sets the number of subdivision per side
  25855. * @param minHeight is the minimum altitude on the ground
  25856. * @param maxHeight is the maximum altitude on the ground
  25857. * @param scene defines the hosting scene
  25858. * @param updatable defines if the mesh must be flagged as updatable
  25859. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25860. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25861. * @returns a new Mesh
  25862. */
  25863. 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;
  25864. /**
  25865. * Creates a tube mesh.
  25866. * The tube is a parametric shape.
  25867. * It has no predefined shape. Its final shape will depend on the input parameters.
  25868. * Please consider using the same method from the MeshBuilder class instead
  25869. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25870. * @param name defines the name of the mesh to create
  25871. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25872. * @param radius sets the tube radius size
  25873. * @param tessellation is the number of sides on the tubular surface
  25874. * @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
  25875. * @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
  25876. * @param scene defines the hosting scene
  25877. * @param updatable defines if the mesh must be flagged as updatable
  25878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25879. * @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)
  25880. * @returns a new Mesh
  25881. */
  25882. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25883. (i: number, distance: number): number;
  25884. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25885. /**
  25886. * Creates a polyhedron mesh.
  25887. * Please consider using the same method from the MeshBuilder class instead.
  25888. * * 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
  25889. * * The parameter `size` (positive float, default 1) sets the polygon size
  25890. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25891. * * 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`
  25892. * * 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
  25893. * * 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)`)
  25894. * * 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
  25895. * * 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
  25896. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25897. * * If you create a double-sided mesh, you can choose what parts of 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
  25898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25899. * @param name defines the name of the mesh to create
  25900. * @param options defines the options used to create the mesh
  25901. * @param scene defines the hosting scene
  25902. * @returns a new Mesh
  25903. */
  25904. static CreatePolyhedron(name: string, options: {
  25905. type?: number;
  25906. size?: number;
  25907. sizeX?: number;
  25908. sizeY?: number;
  25909. sizeZ?: number;
  25910. custom?: any;
  25911. faceUV?: Vector4[];
  25912. faceColors?: Color4[];
  25913. updatable?: boolean;
  25914. sideOrientation?: number;
  25915. }, scene: Scene): Mesh;
  25916. /**
  25917. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25918. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25919. * * 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`)
  25920. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25921. * * 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
  25922. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25923. * * If you create a double-sided mesh, you can choose what parts of 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
  25924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25925. * @param name defines the name of the mesh
  25926. * @param options defines the options used to create the mesh
  25927. * @param scene defines the hosting scene
  25928. * @returns a new Mesh
  25929. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25930. */
  25931. static CreateIcoSphere(name: string, options: {
  25932. radius?: number;
  25933. flat?: boolean;
  25934. subdivisions?: number;
  25935. sideOrientation?: number;
  25936. updatable?: boolean;
  25937. }, scene: Scene): Mesh;
  25938. /**
  25939. * Creates a decal mesh.
  25940. * Please consider using the same method from the MeshBuilder class instead.
  25941. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25942. * @param name defines the name of the mesh
  25943. * @param sourceMesh defines the mesh receiving the decal
  25944. * @param position sets the position of the decal in world coordinates
  25945. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25946. * @param size sets the decal scaling
  25947. * @param angle sets the angle to rotate the decal
  25948. * @returns a new Mesh
  25949. */
  25950. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25951. /**
  25952. * Prepare internal position array for software CPU skinning
  25953. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25954. */
  25955. setPositionsForCPUSkinning(): Float32Array;
  25956. /**
  25957. * Prepare internal normal array for software CPU skinning
  25958. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25959. */
  25960. setNormalsForCPUSkinning(): Float32Array;
  25961. /**
  25962. * Updates the vertex buffer by applying transformation from the bones
  25963. * @param skeleton defines the skeleton to apply to current mesh
  25964. * @returns the current mesh
  25965. */
  25966. applySkeleton(skeleton: Skeleton): Mesh;
  25967. /**
  25968. * 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
  25969. * @param meshes defines the list of meshes to scan
  25970. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25971. */
  25972. static MinMax(meshes: AbstractMesh[]): {
  25973. min: Vector3;
  25974. max: Vector3;
  25975. };
  25976. /**
  25977. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25978. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25979. * @returns a vector3
  25980. */
  25981. static Center(meshesOrMinMaxVector: {
  25982. min: Vector3;
  25983. max: Vector3;
  25984. } | AbstractMesh[]): Vector3;
  25985. /**
  25986. * Merge the array of meshes into a single mesh for performance reasons.
  25987. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25988. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25989. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25990. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25991. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25992. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25993. * @returns a new mesh
  25994. */
  25995. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25996. /** @hidden */
  25997. addInstance(instance: InstancedMesh): void;
  25998. /** @hidden */
  25999. removeInstance(instance: InstancedMesh): void;
  26000. }
  26001. }
  26002. declare module "babylonjs/Cameras/camera" {
  26003. import { SmartArray } from "babylonjs/Misc/smartArray";
  26004. import { Observable } from "babylonjs/Misc/observable";
  26005. import { Nullable } from "babylonjs/types";
  26006. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26007. import { Scene } from "babylonjs/scene";
  26008. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26009. import { Node } from "babylonjs/node";
  26010. import { Mesh } from "babylonjs/Meshes/mesh";
  26011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26012. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26013. import { Viewport } from "babylonjs/Maths/math.viewport";
  26014. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26017. import { Ray } from "babylonjs/Culling/ray";
  26018. /**
  26019. * This is the base class of all the camera used in the application.
  26020. * @see http://doc.babylonjs.com/features/cameras
  26021. */
  26022. export class Camera extends Node {
  26023. /** @hidden */
  26024. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26025. /**
  26026. * This is the default projection mode used by the cameras.
  26027. * It helps recreating a feeling of perspective and better appreciate depth.
  26028. * This is the best way to simulate real life cameras.
  26029. */
  26030. static readonly PERSPECTIVE_CAMERA: number;
  26031. /**
  26032. * This helps creating camera with an orthographic mode.
  26033. * 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.
  26034. */
  26035. static readonly ORTHOGRAPHIC_CAMERA: number;
  26036. /**
  26037. * This is the default FOV mode for perspective cameras.
  26038. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26039. */
  26040. static readonly FOVMODE_VERTICAL_FIXED: number;
  26041. /**
  26042. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26043. */
  26044. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26045. /**
  26046. * This specifies ther is no need for a camera rig.
  26047. * Basically only one eye is rendered corresponding to the camera.
  26048. */
  26049. static readonly RIG_MODE_NONE: number;
  26050. /**
  26051. * Simulates a camera Rig with one blue eye and one red eye.
  26052. * This can be use with 3d blue and red glasses.
  26053. */
  26054. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26055. /**
  26056. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26057. */
  26058. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26059. /**
  26060. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26061. */
  26062. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26063. /**
  26064. * Defines that both eyes of the camera will be rendered over under each other.
  26065. */
  26066. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26067. /**
  26068. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26069. */
  26070. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26071. /**
  26072. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26073. */
  26074. static readonly RIG_MODE_VR: number;
  26075. /**
  26076. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26077. */
  26078. static readonly RIG_MODE_WEBVR: number;
  26079. /**
  26080. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26081. */
  26082. static readonly RIG_MODE_CUSTOM: number;
  26083. /**
  26084. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26085. */
  26086. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26087. /**
  26088. * Define the input manager associated with the camera.
  26089. */
  26090. inputs: CameraInputsManager<Camera>;
  26091. /** @hidden */
  26092. _position: Vector3;
  26093. /**
  26094. * Define the current local position of the camera in the scene
  26095. */
  26096. get position(): Vector3;
  26097. set position(newPosition: Vector3);
  26098. /**
  26099. * The vector the camera should consider as up.
  26100. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26101. */
  26102. upVector: Vector3;
  26103. /**
  26104. * Define the current limit on the left side for an orthographic camera
  26105. * In scene unit
  26106. */
  26107. orthoLeft: Nullable<number>;
  26108. /**
  26109. * Define the current limit on the right side for an orthographic camera
  26110. * In scene unit
  26111. */
  26112. orthoRight: Nullable<number>;
  26113. /**
  26114. * Define the current limit on the bottom side for an orthographic camera
  26115. * In scene unit
  26116. */
  26117. orthoBottom: Nullable<number>;
  26118. /**
  26119. * Define the current limit on the top side for an orthographic camera
  26120. * In scene unit
  26121. */
  26122. orthoTop: Nullable<number>;
  26123. /**
  26124. * Field Of View is set in Radians. (default is 0.8)
  26125. */
  26126. fov: number;
  26127. /**
  26128. * Define the minimum distance the camera can see from.
  26129. * This is important to note that the depth buffer are not infinite and the closer it starts
  26130. * the more your scene might encounter depth fighting issue.
  26131. */
  26132. minZ: number;
  26133. /**
  26134. * Define the maximum distance the camera can see to.
  26135. * This is important to note that the depth buffer are not infinite and the further it end
  26136. * the more your scene might encounter depth fighting issue.
  26137. */
  26138. maxZ: number;
  26139. /**
  26140. * Define the default inertia of the camera.
  26141. * This helps giving a smooth feeling to the camera movement.
  26142. */
  26143. inertia: number;
  26144. /**
  26145. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26146. */
  26147. mode: number;
  26148. /**
  26149. * Define wether the camera is intermediate.
  26150. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26151. */
  26152. isIntermediate: boolean;
  26153. /**
  26154. * Define the viewport of the camera.
  26155. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26156. */
  26157. viewport: Viewport;
  26158. /**
  26159. * Restricts the camera to viewing objects with the same layerMask.
  26160. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26161. */
  26162. layerMask: number;
  26163. /**
  26164. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26165. */
  26166. fovMode: number;
  26167. /**
  26168. * Rig mode of the camera.
  26169. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26170. * This is normally controlled byt the camera themselves as internal use.
  26171. */
  26172. cameraRigMode: number;
  26173. /**
  26174. * Defines the distance between both "eyes" in case of a RIG
  26175. */
  26176. interaxialDistance: number;
  26177. /**
  26178. * Defines if stereoscopic rendering is done side by side or over under.
  26179. */
  26180. isStereoscopicSideBySide: boolean;
  26181. /**
  26182. * 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
  26183. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26184. * else in the scene. (Eg. security camera)
  26185. *
  26186. * 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)
  26187. */
  26188. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26189. /**
  26190. * When set, the camera will render to this render target instead of the default canvas
  26191. *
  26192. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26193. */
  26194. outputRenderTarget: Nullable<RenderTargetTexture>;
  26195. /**
  26196. * Observable triggered when the camera view matrix has changed.
  26197. */
  26198. onViewMatrixChangedObservable: Observable<Camera>;
  26199. /**
  26200. * Observable triggered when the camera Projection matrix has changed.
  26201. */
  26202. onProjectionMatrixChangedObservable: Observable<Camera>;
  26203. /**
  26204. * Observable triggered when the inputs have been processed.
  26205. */
  26206. onAfterCheckInputsObservable: Observable<Camera>;
  26207. /**
  26208. * Observable triggered when reset has been called and applied to the camera.
  26209. */
  26210. onRestoreStateObservable: Observable<Camera>;
  26211. /** @hidden */
  26212. _cameraRigParams: any;
  26213. /** @hidden */
  26214. _rigCameras: Camera[];
  26215. /** @hidden */
  26216. _rigPostProcess: Nullable<PostProcess>;
  26217. protected _webvrViewMatrix: Matrix;
  26218. /** @hidden */
  26219. _skipRendering: boolean;
  26220. /** @hidden */
  26221. _projectionMatrix: Matrix;
  26222. /** @hidden */
  26223. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26224. /** @hidden */
  26225. _activeMeshes: SmartArray<AbstractMesh>;
  26226. protected _globalPosition: Vector3;
  26227. /** @hidden */
  26228. _computedViewMatrix: Matrix;
  26229. private _doNotComputeProjectionMatrix;
  26230. private _transformMatrix;
  26231. private _frustumPlanes;
  26232. private _refreshFrustumPlanes;
  26233. private _storedFov;
  26234. private _stateStored;
  26235. /**
  26236. * Instantiates a new camera object.
  26237. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26238. * @see http://doc.babylonjs.com/features/cameras
  26239. * @param name Defines the name of the camera in the scene
  26240. * @param position Defines the position of the camera
  26241. * @param scene Defines the scene the camera belongs too
  26242. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26243. */
  26244. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26245. /**
  26246. * Store current camera state (fov, position, etc..)
  26247. * @returns the camera
  26248. */
  26249. storeState(): Camera;
  26250. /**
  26251. * Restores the camera state values if it has been stored. You must call storeState() first
  26252. */
  26253. protected _restoreStateValues(): boolean;
  26254. /**
  26255. * Restored camera state. You must call storeState() first.
  26256. * @returns true if restored and false otherwise
  26257. */
  26258. restoreState(): boolean;
  26259. /**
  26260. * Gets the class name of the camera.
  26261. * @returns the class name
  26262. */
  26263. getClassName(): string;
  26264. /** @hidden */
  26265. readonly _isCamera: boolean;
  26266. /**
  26267. * Gets a string representation of the camera useful for debug purpose.
  26268. * @param fullDetails Defines that a more verboe level of logging is required
  26269. * @returns the string representation
  26270. */
  26271. toString(fullDetails?: boolean): string;
  26272. /**
  26273. * Gets the current world space position of the camera.
  26274. */
  26275. get globalPosition(): Vector3;
  26276. /**
  26277. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26278. * @returns the active meshe list
  26279. */
  26280. getActiveMeshes(): SmartArray<AbstractMesh>;
  26281. /**
  26282. * Check wether a mesh is part of the current active mesh list of the camera
  26283. * @param mesh Defines the mesh to check
  26284. * @returns true if active, false otherwise
  26285. */
  26286. isActiveMesh(mesh: Mesh): boolean;
  26287. /**
  26288. * Is this camera ready to be used/rendered
  26289. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26290. * @return true if the camera is ready
  26291. */
  26292. isReady(completeCheck?: boolean): boolean;
  26293. /** @hidden */
  26294. _initCache(): void;
  26295. /** @hidden */
  26296. _updateCache(ignoreParentClass?: boolean): void;
  26297. /** @hidden */
  26298. _isSynchronized(): boolean;
  26299. /** @hidden */
  26300. _isSynchronizedViewMatrix(): boolean;
  26301. /** @hidden */
  26302. _isSynchronizedProjectionMatrix(): boolean;
  26303. /**
  26304. * Attach the input controls to a specific dom element to get the input from.
  26305. * @param element Defines the element the controls should be listened from
  26306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26307. */
  26308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26309. /**
  26310. * Detach the current controls from the specified dom element.
  26311. * @param element Defines the element to stop listening the inputs from
  26312. */
  26313. detachControl(element: HTMLElement): void;
  26314. /**
  26315. * Update the camera state according to the different inputs gathered during the frame.
  26316. */
  26317. update(): void;
  26318. /** @hidden */
  26319. _checkInputs(): void;
  26320. /** @hidden */
  26321. get rigCameras(): Camera[];
  26322. /**
  26323. * Gets the post process used by the rig cameras
  26324. */
  26325. get rigPostProcess(): Nullable<PostProcess>;
  26326. /**
  26327. * Internal, gets the first post proces.
  26328. * @returns the first post process to be run on this camera.
  26329. */
  26330. _getFirstPostProcess(): Nullable<PostProcess>;
  26331. private _cascadePostProcessesToRigCams;
  26332. /**
  26333. * Attach a post process to the camera.
  26334. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26335. * @param postProcess The post process to attach to the camera
  26336. * @param insertAt The position of the post process in case several of them are in use in the scene
  26337. * @returns the position the post process has been inserted at
  26338. */
  26339. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26340. /**
  26341. * Detach a post process to the camera.
  26342. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26343. * @param postProcess The post process to detach from the camera
  26344. */
  26345. detachPostProcess(postProcess: PostProcess): void;
  26346. /**
  26347. * Gets the current world matrix of the camera
  26348. */
  26349. getWorldMatrix(): Matrix;
  26350. /** @hidden */
  26351. _getViewMatrix(): Matrix;
  26352. /**
  26353. * Gets the current view matrix of the camera.
  26354. * @param force forces the camera to recompute the matrix without looking at the cached state
  26355. * @returns the view matrix
  26356. */
  26357. getViewMatrix(force?: boolean): Matrix;
  26358. /**
  26359. * Freeze the projection matrix.
  26360. * It will prevent the cache check of the camera projection compute and can speed up perf
  26361. * if no parameter of the camera are meant to change
  26362. * @param projection Defines manually a projection if necessary
  26363. */
  26364. freezeProjectionMatrix(projection?: Matrix): void;
  26365. /**
  26366. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26367. */
  26368. unfreezeProjectionMatrix(): void;
  26369. /**
  26370. * Gets the current projection matrix of the camera.
  26371. * @param force forces the camera to recompute the matrix without looking at the cached state
  26372. * @returns the projection matrix
  26373. */
  26374. getProjectionMatrix(force?: boolean): Matrix;
  26375. /**
  26376. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26377. * @returns a Matrix
  26378. */
  26379. getTransformationMatrix(): Matrix;
  26380. private _updateFrustumPlanes;
  26381. /**
  26382. * Checks if a cullable object (mesh...) is in the camera frustum
  26383. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26384. * @param target The object to check
  26385. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26386. * @returns true if the object is in frustum otherwise false
  26387. */
  26388. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26389. /**
  26390. * Checks if a cullable object (mesh...) is in the camera frustum
  26391. * Unlike isInFrustum this cheks the full bounding box
  26392. * @param target The object to check
  26393. * @returns true if the object is in frustum otherwise false
  26394. */
  26395. isCompletelyInFrustum(target: ICullable): boolean;
  26396. /**
  26397. * Gets a ray in the forward direction from the camera.
  26398. * @param length Defines the length of the ray to create
  26399. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26400. * @param origin Defines the start point of the ray which defaults to the camera position
  26401. * @returns the forward ray
  26402. */
  26403. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26404. /**
  26405. * Releases resources associated with this node.
  26406. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26407. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26408. */
  26409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26410. /** @hidden */
  26411. _isLeftCamera: boolean;
  26412. /**
  26413. * Gets the left camera of a rig setup in case of Rigged Camera
  26414. */
  26415. get isLeftCamera(): boolean;
  26416. /** @hidden */
  26417. _isRightCamera: boolean;
  26418. /**
  26419. * Gets the right camera of a rig setup in case of Rigged Camera
  26420. */
  26421. get isRightCamera(): boolean;
  26422. /**
  26423. * Gets the left camera of a rig setup in case of Rigged Camera
  26424. */
  26425. get leftCamera(): Nullable<FreeCamera>;
  26426. /**
  26427. * Gets the right camera of a rig setup in case of Rigged Camera
  26428. */
  26429. get rightCamera(): Nullable<FreeCamera>;
  26430. /**
  26431. * Gets the left camera target of a rig setup in case of Rigged Camera
  26432. * @returns the target position
  26433. */
  26434. getLeftTarget(): Nullable<Vector3>;
  26435. /**
  26436. * Gets the right camera target of a rig setup in case of Rigged Camera
  26437. * @returns the target position
  26438. */
  26439. getRightTarget(): Nullable<Vector3>;
  26440. /**
  26441. * @hidden
  26442. */
  26443. setCameraRigMode(mode: number, rigParams: any): void;
  26444. /** @hidden */
  26445. static _setStereoscopicRigMode(camera: Camera): void;
  26446. /** @hidden */
  26447. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26448. /** @hidden */
  26449. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26450. /** @hidden */
  26451. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26452. /** @hidden */
  26453. _getVRProjectionMatrix(): Matrix;
  26454. protected _updateCameraRotationMatrix(): void;
  26455. protected _updateWebVRCameraRotationMatrix(): void;
  26456. /**
  26457. * This function MUST be overwritten by the different WebVR cameras available.
  26458. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26459. * @hidden
  26460. */
  26461. _getWebVRProjectionMatrix(): Matrix;
  26462. /**
  26463. * This function MUST be overwritten by the different WebVR cameras available.
  26464. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26465. * @hidden
  26466. */
  26467. _getWebVRViewMatrix(): Matrix;
  26468. /** @hidden */
  26469. setCameraRigParameter(name: string, value: any): void;
  26470. /**
  26471. * needs to be overridden by children so sub has required properties to be copied
  26472. * @hidden
  26473. */
  26474. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26475. /**
  26476. * May need to be overridden by children
  26477. * @hidden
  26478. */
  26479. _updateRigCameras(): void;
  26480. /** @hidden */
  26481. _setupInputs(): void;
  26482. /**
  26483. * Serialiaze the camera setup to a json represention
  26484. * @returns the JSON representation
  26485. */
  26486. serialize(): any;
  26487. /**
  26488. * Clones the current camera.
  26489. * @param name The cloned camera name
  26490. * @returns the cloned camera
  26491. */
  26492. clone(name: string): Camera;
  26493. /**
  26494. * Gets the direction of the camera relative to a given local axis.
  26495. * @param localAxis Defines the reference axis to provide a relative direction.
  26496. * @return the direction
  26497. */
  26498. getDirection(localAxis: Vector3): Vector3;
  26499. /**
  26500. * Returns the current camera absolute rotation
  26501. */
  26502. get absoluteRotation(): Quaternion;
  26503. /**
  26504. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26505. * @param localAxis Defines the reference axis to provide a relative direction.
  26506. * @param result Defines the vector to store the result in
  26507. */
  26508. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26509. /**
  26510. * Gets a camera constructor for a given camera type
  26511. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26512. * @param name The name of the camera the result will be able to instantiate
  26513. * @param scene The scene the result will construct the camera in
  26514. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26515. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26516. * @returns a factory method to construc the camera
  26517. */
  26518. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26519. /**
  26520. * Compute the world matrix of the camera.
  26521. * @returns the camera world matrix
  26522. */
  26523. computeWorldMatrix(): Matrix;
  26524. /**
  26525. * Parse a JSON and creates the camera from the parsed information
  26526. * @param parsedCamera The JSON to parse
  26527. * @param scene The scene to instantiate the camera in
  26528. * @returns the newly constructed camera
  26529. */
  26530. static Parse(parsedCamera: any, scene: Scene): Camera;
  26531. }
  26532. }
  26533. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26534. import { Nullable } from "babylonjs/types";
  26535. import { Scene } from "babylonjs/scene";
  26536. import { Vector4 } from "babylonjs/Maths/math.vector";
  26537. import { Mesh } from "babylonjs/Meshes/mesh";
  26538. /**
  26539. * Class containing static functions to help procedurally build meshes
  26540. */
  26541. export class DiscBuilder {
  26542. /**
  26543. * Creates a plane polygonal mesh. By default, this is a disc
  26544. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26545. * * 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
  26546. * * 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
  26547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26550. * @param name defines the name of the mesh
  26551. * @param options defines the options used to create the mesh
  26552. * @param scene defines the hosting scene
  26553. * @returns the plane polygonal mesh
  26554. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26555. */
  26556. static CreateDisc(name: string, options: {
  26557. radius?: number;
  26558. tessellation?: number;
  26559. arc?: number;
  26560. updatable?: boolean;
  26561. sideOrientation?: number;
  26562. frontUVs?: Vector4;
  26563. backUVs?: Vector4;
  26564. }, scene?: Nullable<Scene>): Mesh;
  26565. }
  26566. }
  26567. declare module "babylonjs/Materials/fresnelParameters" {
  26568. import { Color3 } from "babylonjs/Maths/math.color";
  26569. /**
  26570. * This represents all the required information to add a fresnel effect on a material:
  26571. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26572. */
  26573. export class FresnelParameters {
  26574. private _isEnabled;
  26575. /**
  26576. * Define if the fresnel effect is enable or not.
  26577. */
  26578. get isEnabled(): boolean;
  26579. set isEnabled(value: boolean);
  26580. /**
  26581. * Define the color used on edges (grazing angle)
  26582. */
  26583. leftColor: Color3;
  26584. /**
  26585. * Define the color used on center
  26586. */
  26587. rightColor: Color3;
  26588. /**
  26589. * Define bias applied to computed fresnel term
  26590. */
  26591. bias: number;
  26592. /**
  26593. * Defined the power exponent applied to fresnel term
  26594. */
  26595. power: number;
  26596. /**
  26597. * Clones the current fresnel and its valuues
  26598. * @returns a clone fresnel configuration
  26599. */
  26600. clone(): FresnelParameters;
  26601. /**
  26602. * Serializes the current fresnel parameters to a JSON representation.
  26603. * @return the JSON serialization
  26604. */
  26605. serialize(): any;
  26606. /**
  26607. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26608. * @param parsedFresnelParameters Define the JSON representation
  26609. * @returns the parsed parameters
  26610. */
  26611. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26612. }
  26613. }
  26614. declare module "babylonjs/Materials/pushMaterial" {
  26615. import { Nullable } from "babylonjs/types";
  26616. import { Scene } from "babylonjs/scene";
  26617. import { Matrix } from "babylonjs/Maths/math.vector";
  26618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26619. import { Mesh } from "babylonjs/Meshes/mesh";
  26620. import { Material } from "babylonjs/Materials/material";
  26621. import { Effect } from "babylonjs/Materials/effect";
  26622. /**
  26623. * Base class of materials working in push mode in babylon JS
  26624. * @hidden
  26625. */
  26626. export class PushMaterial extends Material {
  26627. protected _activeEffect: Effect;
  26628. protected _normalMatrix: Matrix;
  26629. /**
  26630. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26631. * This means that the material can keep using a previous shader while a new one is being compiled.
  26632. * This is mostly used when shader parallel compilation is supported (true by default)
  26633. */
  26634. allowShaderHotSwapping: boolean;
  26635. constructor(name: string, scene: Scene);
  26636. getEffect(): Effect;
  26637. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26638. /**
  26639. * Binds the given world matrix to the active effect
  26640. *
  26641. * @param world the matrix to bind
  26642. */
  26643. bindOnlyWorldMatrix(world: Matrix): void;
  26644. /**
  26645. * Binds the given normal matrix to the active effect
  26646. *
  26647. * @param normalMatrix the matrix to bind
  26648. */
  26649. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26650. bind(world: Matrix, mesh?: Mesh): void;
  26651. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26652. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26653. }
  26654. }
  26655. declare module "babylonjs/Materials/materialFlags" {
  26656. /**
  26657. * This groups all the flags used to control the materials channel.
  26658. */
  26659. export class MaterialFlags {
  26660. private static _DiffuseTextureEnabled;
  26661. /**
  26662. * Are diffuse textures enabled in the application.
  26663. */
  26664. static get DiffuseTextureEnabled(): boolean;
  26665. static set DiffuseTextureEnabled(value: boolean);
  26666. private static _AmbientTextureEnabled;
  26667. /**
  26668. * Are ambient textures enabled in the application.
  26669. */
  26670. static get AmbientTextureEnabled(): boolean;
  26671. static set AmbientTextureEnabled(value: boolean);
  26672. private static _OpacityTextureEnabled;
  26673. /**
  26674. * Are opacity textures enabled in the application.
  26675. */
  26676. static get OpacityTextureEnabled(): boolean;
  26677. static set OpacityTextureEnabled(value: boolean);
  26678. private static _ReflectionTextureEnabled;
  26679. /**
  26680. * Are reflection textures enabled in the application.
  26681. */
  26682. static get ReflectionTextureEnabled(): boolean;
  26683. static set ReflectionTextureEnabled(value: boolean);
  26684. private static _EmissiveTextureEnabled;
  26685. /**
  26686. * Are emissive textures enabled in the application.
  26687. */
  26688. static get EmissiveTextureEnabled(): boolean;
  26689. static set EmissiveTextureEnabled(value: boolean);
  26690. private static _SpecularTextureEnabled;
  26691. /**
  26692. * Are specular textures enabled in the application.
  26693. */
  26694. static get SpecularTextureEnabled(): boolean;
  26695. static set SpecularTextureEnabled(value: boolean);
  26696. private static _BumpTextureEnabled;
  26697. /**
  26698. * Are bump textures enabled in the application.
  26699. */
  26700. static get BumpTextureEnabled(): boolean;
  26701. static set BumpTextureEnabled(value: boolean);
  26702. private static _LightmapTextureEnabled;
  26703. /**
  26704. * Are lightmap textures enabled in the application.
  26705. */
  26706. static get LightmapTextureEnabled(): boolean;
  26707. static set LightmapTextureEnabled(value: boolean);
  26708. private static _RefractionTextureEnabled;
  26709. /**
  26710. * Are refraction textures enabled in the application.
  26711. */
  26712. static get RefractionTextureEnabled(): boolean;
  26713. static set RefractionTextureEnabled(value: boolean);
  26714. private static _ColorGradingTextureEnabled;
  26715. /**
  26716. * Are color grading textures enabled in the application.
  26717. */
  26718. static get ColorGradingTextureEnabled(): boolean;
  26719. static set ColorGradingTextureEnabled(value: boolean);
  26720. private static _FresnelEnabled;
  26721. /**
  26722. * Are fresnels enabled in the application.
  26723. */
  26724. static get FresnelEnabled(): boolean;
  26725. static set FresnelEnabled(value: boolean);
  26726. private static _ClearCoatTextureEnabled;
  26727. /**
  26728. * Are clear coat textures enabled in the application.
  26729. */
  26730. static get ClearCoatTextureEnabled(): boolean;
  26731. static set ClearCoatTextureEnabled(value: boolean);
  26732. private static _ClearCoatBumpTextureEnabled;
  26733. /**
  26734. * Are clear coat bump textures enabled in the application.
  26735. */
  26736. static get ClearCoatBumpTextureEnabled(): boolean;
  26737. static set ClearCoatBumpTextureEnabled(value: boolean);
  26738. private static _ClearCoatTintTextureEnabled;
  26739. /**
  26740. * Are clear coat tint textures enabled in the application.
  26741. */
  26742. static get ClearCoatTintTextureEnabled(): boolean;
  26743. static set ClearCoatTintTextureEnabled(value: boolean);
  26744. private static _SheenTextureEnabled;
  26745. /**
  26746. * Are sheen textures enabled in the application.
  26747. */
  26748. static get SheenTextureEnabled(): boolean;
  26749. static set SheenTextureEnabled(value: boolean);
  26750. private static _AnisotropicTextureEnabled;
  26751. /**
  26752. * Are anisotropic textures enabled in the application.
  26753. */
  26754. static get AnisotropicTextureEnabled(): boolean;
  26755. static set AnisotropicTextureEnabled(value: boolean);
  26756. private static _ThicknessTextureEnabled;
  26757. /**
  26758. * Are thickness textures enabled in the application.
  26759. */
  26760. static get ThicknessTextureEnabled(): boolean;
  26761. static set ThicknessTextureEnabled(value: boolean);
  26762. }
  26763. }
  26764. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26765. /** @hidden */
  26766. export var defaultFragmentDeclaration: {
  26767. name: string;
  26768. shader: string;
  26769. };
  26770. }
  26771. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26772. /** @hidden */
  26773. export var defaultUboDeclaration: {
  26774. name: string;
  26775. shader: string;
  26776. };
  26777. }
  26778. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26779. /** @hidden */
  26780. export var lightFragmentDeclaration: {
  26781. name: string;
  26782. shader: string;
  26783. };
  26784. }
  26785. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26786. /** @hidden */
  26787. export var lightUboDeclaration: {
  26788. name: string;
  26789. shader: string;
  26790. };
  26791. }
  26792. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26793. /** @hidden */
  26794. export var lightsFragmentFunctions: {
  26795. name: string;
  26796. shader: string;
  26797. };
  26798. }
  26799. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26800. /** @hidden */
  26801. export var shadowsFragmentFunctions: {
  26802. name: string;
  26803. shader: string;
  26804. };
  26805. }
  26806. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26807. /** @hidden */
  26808. export var fresnelFunction: {
  26809. name: string;
  26810. shader: string;
  26811. };
  26812. }
  26813. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26814. /** @hidden */
  26815. export var reflectionFunction: {
  26816. name: string;
  26817. shader: string;
  26818. };
  26819. }
  26820. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26821. /** @hidden */
  26822. export var bumpFragmentFunctions: {
  26823. name: string;
  26824. shader: string;
  26825. };
  26826. }
  26827. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26828. /** @hidden */
  26829. export var logDepthDeclaration: {
  26830. name: string;
  26831. shader: string;
  26832. };
  26833. }
  26834. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26835. /** @hidden */
  26836. export var bumpFragment: {
  26837. name: string;
  26838. shader: string;
  26839. };
  26840. }
  26841. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26842. /** @hidden */
  26843. export var depthPrePass: {
  26844. name: string;
  26845. shader: string;
  26846. };
  26847. }
  26848. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26849. /** @hidden */
  26850. export var lightFragment: {
  26851. name: string;
  26852. shader: string;
  26853. };
  26854. }
  26855. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26856. /** @hidden */
  26857. export var logDepthFragment: {
  26858. name: string;
  26859. shader: string;
  26860. };
  26861. }
  26862. declare module "babylonjs/Shaders/default.fragment" {
  26863. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26864. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26866. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26867. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26868. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26869. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26870. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26871. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26872. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26873. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26874. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26875. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26876. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26877. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26878. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26879. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26880. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26881. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26882. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26883. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26884. /** @hidden */
  26885. export var defaultPixelShader: {
  26886. name: string;
  26887. shader: string;
  26888. };
  26889. }
  26890. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26891. /** @hidden */
  26892. export var defaultVertexDeclaration: {
  26893. name: string;
  26894. shader: string;
  26895. };
  26896. }
  26897. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26898. /** @hidden */
  26899. export var bumpVertexDeclaration: {
  26900. name: string;
  26901. shader: string;
  26902. };
  26903. }
  26904. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26905. /** @hidden */
  26906. export var bumpVertex: {
  26907. name: string;
  26908. shader: string;
  26909. };
  26910. }
  26911. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26912. /** @hidden */
  26913. export var fogVertex: {
  26914. name: string;
  26915. shader: string;
  26916. };
  26917. }
  26918. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26919. /** @hidden */
  26920. export var shadowsVertex: {
  26921. name: string;
  26922. shader: string;
  26923. };
  26924. }
  26925. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26926. /** @hidden */
  26927. export var pointCloudVertex: {
  26928. name: string;
  26929. shader: string;
  26930. };
  26931. }
  26932. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26933. /** @hidden */
  26934. export var logDepthVertex: {
  26935. name: string;
  26936. shader: string;
  26937. };
  26938. }
  26939. declare module "babylonjs/Shaders/default.vertex" {
  26940. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26941. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26942. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26943. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26945. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26946. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26947. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26948. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26949. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26951. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26952. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26953. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26954. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26955. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26956. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26957. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26958. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26959. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26960. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26961. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26962. /** @hidden */
  26963. export var defaultVertexShader: {
  26964. name: string;
  26965. shader: string;
  26966. };
  26967. }
  26968. declare module "babylonjs/Materials/standardMaterial" {
  26969. import { SmartArray } from "babylonjs/Misc/smartArray";
  26970. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26971. import { Nullable } from "babylonjs/types";
  26972. import { Scene } from "babylonjs/scene";
  26973. import { Matrix } from "babylonjs/Maths/math.vector";
  26974. import { Color3 } from "babylonjs/Maths/math.color";
  26975. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26977. import { Mesh } from "babylonjs/Meshes/mesh";
  26978. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26979. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26980. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26981. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26982. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26984. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26985. import "babylonjs/Shaders/default.fragment";
  26986. import "babylonjs/Shaders/default.vertex";
  26987. /** @hidden */
  26988. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26989. MAINUV1: boolean;
  26990. MAINUV2: boolean;
  26991. DIFFUSE: boolean;
  26992. DIFFUSEDIRECTUV: number;
  26993. AMBIENT: boolean;
  26994. AMBIENTDIRECTUV: number;
  26995. OPACITY: boolean;
  26996. OPACITYDIRECTUV: number;
  26997. OPACITYRGB: boolean;
  26998. REFLECTION: boolean;
  26999. EMISSIVE: boolean;
  27000. EMISSIVEDIRECTUV: number;
  27001. SPECULAR: boolean;
  27002. SPECULARDIRECTUV: number;
  27003. BUMP: boolean;
  27004. BUMPDIRECTUV: number;
  27005. PARALLAX: boolean;
  27006. PARALLAXOCCLUSION: boolean;
  27007. SPECULAROVERALPHA: boolean;
  27008. CLIPPLANE: boolean;
  27009. CLIPPLANE2: boolean;
  27010. CLIPPLANE3: boolean;
  27011. CLIPPLANE4: boolean;
  27012. CLIPPLANE5: boolean;
  27013. CLIPPLANE6: boolean;
  27014. ALPHATEST: boolean;
  27015. DEPTHPREPASS: boolean;
  27016. ALPHAFROMDIFFUSE: boolean;
  27017. POINTSIZE: boolean;
  27018. FOG: boolean;
  27019. SPECULARTERM: boolean;
  27020. DIFFUSEFRESNEL: boolean;
  27021. OPACITYFRESNEL: boolean;
  27022. REFLECTIONFRESNEL: boolean;
  27023. REFRACTIONFRESNEL: boolean;
  27024. EMISSIVEFRESNEL: boolean;
  27025. FRESNEL: boolean;
  27026. NORMAL: boolean;
  27027. UV1: boolean;
  27028. UV2: boolean;
  27029. VERTEXCOLOR: boolean;
  27030. VERTEXALPHA: boolean;
  27031. NUM_BONE_INFLUENCERS: number;
  27032. BonesPerMesh: number;
  27033. BONETEXTURE: boolean;
  27034. INSTANCES: boolean;
  27035. GLOSSINESS: boolean;
  27036. ROUGHNESS: boolean;
  27037. EMISSIVEASILLUMINATION: boolean;
  27038. LINKEMISSIVEWITHDIFFUSE: boolean;
  27039. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27040. LIGHTMAP: boolean;
  27041. LIGHTMAPDIRECTUV: number;
  27042. OBJECTSPACE_NORMALMAP: boolean;
  27043. USELIGHTMAPASSHADOWMAP: boolean;
  27044. REFLECTIONMAP_3D: boolean;
  27045. REFLECTIONMAP_SPHERICAL: boolean;
  27046. REFLECTIONMAP_PLANAR: boolean;
  27047. REFLECTIONMAP_CUBIC: boolean;
  27048. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27049. REFLECTIONMAP_PROJECTION: boolean;
  27050. REFLECTIONMAP_SKYBOX: boolean;
  27051. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27052. REFLECTIONMAP_EXPLICIT: boolean;
  27053. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27054. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27055. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27056. INVERTCUBICMAP: boolean;
  27057. LOGARITHMICDEPTH: boolean;
  27058. REFRACTION: boolean;
  27059. REFRACTIONMAP_3D: boolean;
  27060. REFLECTIONOVERALPHA: boolean;
  27061. TWOSIDEDLIGHTING: boolean;
  27062. SHADOWFLOAT: boolean;
  27063. MORPHTARGETS: boolean;
  27064. MORPHTARGETS_NORMAL: boolean;
  27065. MORPHTARGETS_TANGENT: boolean;
  27066. MORPHTARGETS_UV: boolean;
  27067. NUM_MORPH_INFLUENCERS: number;
  27068. NONUNIFORMSCALING: boolean;
  27069. PREMULTIPLYALPHA: boolean;
  27070. IMAGEPROCESSING: boolean;
  27071. VIGNETTE: boolean;
  27072. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27073. VIGNETTEBLENDMODEOPAQUE: boolean;
  27074. TONEMAPPING: boolean;
  27075. TONEMAPPING_ACES: boolean;
  27076. CONTRAST: boolean;
  27077. COLORCURVES: boolean;
  27078. COLORGRADING: boolean;
  27079. COLORGRADING3D: boolean;
  27080. SAMPLER3DGREENDEPTH: boolean;
  27081. SAMPLER3DBGRMAP: boolean;
  27082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27083. MULTIVIEW: boolean;
  27084. /**
  27085. * If the reflection texture on this material is in linear color space
  27086. * @hidden
  27087. */
  27088. IS_REFLECTION_LINEAR: boolean;
  27089. /**
  27090. * If the refraction texture on this material is in linear color space
  27091. * @hidden
  27092. */
  27093. IS_REFRACTION_LINEAR: boolean;
  27094. EXPOSURE: boolean;
  27095. constructor();
  27096. setReflectionMode(modeToEnable: string): void;
  27097. }
  27098. /**
  27099. * This is the default material used in Babylon. It is the best trade off between quality
  27100. * and performances.
  27101. * @see http://doc.babylonjs.com/babylon101/materials
  27102. */
  27103. export class StandardMaterial extends PushMaterial {
  27104. private _diffuseTexture;
  27105. /**
  27106. * The basic texture of the material as viewed under a light.
  27107. */
  27108. diffuseTexture: Nullable<BaseTexture>;
  27109. private _ambientTexture;
  27110. /**
  27111. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27112. */
  27113. ambientTexture: Nullable<BaseTexture>;
  27114. private _opacityTexture;
  27115. /**
  27116. * Define the transparency of the material from a texture.
  27117. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27118. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27119. */
  27120. opacityTexture: Nullable<BaseTexture>;
  27121. private _reflectionTexture;
  27122. /**
  27123. * Define the texture used to display the reflection.
  27124. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27125. */
  27126. reflectionTexture: Nullable<BaseTexture>;
  27127. private _emissiveTexture;
  27128. /**
  27129. * Define texture of the material as if self lit.
  27130. * This will be mixed in the final result even in the absence of light.
  27131. */
  27132. emissiveTexture: Nullable<BaseTexture>;
  27133. private _specularTexture;
  27134. /**
  27135. * Define how the color and intensity of the highlight given by the light in the material.
  27136. */
  27137. specularTexture: Nullable<BaseTexture>;
  27138. private _bumpTexture;
  27139. /**
  27140. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27141. * 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.
  27142. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27143. */
  27144. bumpTexture: Nullable<BaseTexture>;
  27145. private _lightmapTexture;
  27146. /**
  27147. * Complex lighting can be computationally expensive to compute at runtime.
  27148. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27149. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27150. */
  27151. lightmapTexture: Nullable<BaseTexture>;
  27152. private _refractionTexture;
  27153. /**
  27154. * Define the texture used to display the refraction.
  27155. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27156. */
  27157. refractionTexture: Nullable<BaseTexture>;
  27158. /**
  27159. * The color of the material lit by the environmental background lighting.
  27160. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27161. */
  27162. ambientColor: Color3;
  27163. /**
  27164. * The basic color of the material as viewed under a light.
  27165. */
  27166. diffuseColor: Color3;
  27167. /**
  27168. * Define how the color and intensity of the highlight given by the light in the material.
  27169. */
  27170. specularColor: Color3;
  27171. /**
  27172. * Define the color of the material as if self lit.
  27173. * This will be mixed in the final result even in the absence of light.
  27174. */
  27175. emissiveColor: Color3;
  27176. /**
  27177. * Defines how sharp are the highlights in the material.
  27178. * The bigger the value the sharper giving a more glossy feeling to the result.
  27179. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27180. */
  27181. specularPower: number;
  27182. private _useAlphaFromDiffuseTexture;
  27183. /**
  27184. * Does the transparency come from the diffuse texture alpha channel.
  27185. */
  27186. useAlphaFromDiffuseTexture: boolean;
  27187. private _useEmissiveAsIllumination;
  27188. /**
  27189. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27190. */
  27191. useEmissiveAsIllumination: boolean;
  27192. private _linkEmissiveWithDiffuse;
  27193. /**
  27194. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27195. * the emissive level when the final color is close to one.
  27196. */
  27197. linkEmissiveWithDiffuse: boolean;
  27198. private _useSpecularOverAlpha;
  27199. /**
  27200. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27201. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27202. */
  27203. useSpecularOverAlpha: boolean;
  27204. private _useReflectionOverAlpha;
  27205. /**
  27206. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27207. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27208. */
  27209. useReflectionOverAlpha: boolean;
  27210. private _disableLighting;
  27211. /**
  27212. * Does lights from the scene impacts this material.
  27213. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27214. */
  27215. disableLighting: boolean;
  27216. private _useObjectSpaceNormalMap;
  27217. /**
  27218. * Allows using an object space normal map (instead of tangent space).
  27219. */
  27220. useObjectSpaceNormalMap: boolean;
  27221. private _useParallax;
  27222. /**
  27223. * Is parallax enabled or not.
  27224. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27225. */
  27226. useParallax: boolean;
  27227. private _useParallaxOcclusion;
  27228. /**
  27229. * Is parallax occlusion enabled or not.
  27230. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27231. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27232. */
  27233. useParallaxOcclusion: boolean;
  27234. /**
  27235. * 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.
  27236. */
  27237. parallaxScaleBias: number;
  27238. private _roughness;
  27239. /**
  27240. * Helps to define how blurry the reflections should appears in the material.
  27241. */
  27242. roughness: number;
  27243. /**
  27244. * In case of refraction, define the value of the index of refraction.
  27245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27246. */
  27247. indexOfRefraction: number;
  27248. /**
  27249. * Invert the refraction texture alongside the y axis.
  27250. * It can be useful with procedural textures or probe for instance.
  27251. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27252. */
  27253. invertRefractionY: boolean;
  27254. /**
  27255. * Defines the alpha limits in alpha test mode.
  27256. */
  27257. alphaCutOff: number;
  27258. private _useLightmapAsShadowmap;
  27259. /**
  27260. * In case of light mapping, define whether the map contains light or shadow informations.
  27261. */
  27262. useLightmapAsShadowmap: boolean;
  27263. private _diffuseFresnelParameters;
  27264. /**
  27265. * Define the diffuse fresnel parameters of the material.
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27267. */
  27268. diffuseFresnelParameters: FresnelParameters;
  27269. private _opacityFresnelParameters;
  27270. /**
  27271. * Define the opacity fresnel parameters of the material.
  27272. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27273. */
  27274. opacityFresnelParameters: FresnelParameters;
  27275. private _reflectionFresnelParameters;
  27276. /**
  27277. * Define the reflection fresnel parameters of the material.
  27278. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27279. */
  27280. reflectionFresnelParameters: FresnelParameters;
  27281. private _refractionFresnelParameters;
  27282. /**
  27283. * Define the refraction fresnel parameters of the material.
  27284. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27285. */
  27286. refractionFresnelParameters: FresnelParameters;
  27287. private _emissiveFresnelParameters;
  27288. /**
  27289. * Define the emissive fresnel parameters of the material.
  27290. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27291. */
  27292. emissiveFresnelParameters: FresnelParameters;
  27293. private _useReflectionFresnelFromSpecular;
  27294. /**
  27295. * If true automatically deducts the fresnels values from the material specularity.
  27296. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27297. */
  27298. useReflectionFresnelFromSpecular: boolean;
  27299. private _useGlossinessFromSpecularMapAlpha;
  27300. /**
  27301. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27302. */
  27303. useGlossinessFromSpecularMapAlpha: boolean;
  27304. private _maxSimultaneousLights;
  27305. /**
  27306. * Defines the maximum number of lights that can be used in the material
  27307. */
  27308. maxSimultaneousLights: number;
  27309. private _invertNormalMapX;
  27310. /**
  27311. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27312. */
  27313. invertNormalMapX: boolean;
  27314. private _invertNormalMapY;
  27315. /**
  27316. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27317. */
  27318. invertNormalMapY: boolean;
  27319. private _twoSidedLighting;
  27320. /**
  27321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27322. */
  27323. twoSidedLighting: boolean;
  27324. /**
  27325. * Default configuration related to image processing available in the standard Material.
  27326. */
  27327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27328. /**
  27329. * Gets the image processing configuration used either in this material.
  27330. */
  27331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27332. /**
  27333. * Sets the Default image processing configuration used either in the this material.
  27334. *
  27335. * If sets to null, the scene one is in use.
  27336. */
  27337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27338. /**
  27339. * Keep track of the image processing observer to allow dispose and replace.
  27340. */
  27341. private _imageProcessingObserver;
  27342. /**
  27343. * Attaches a new image processing configuration to the Standard Material.
  27344. * @param configuration
  27345. */
  27346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27347. /**
  27348. * Gets wether the color curves effect is enabled.
  27349. */
  27350. get cameraColorCurvesEnabled(): boolean;
  27351. /**
  27352. * Sets wether the color curves effect is enabled.
  27353. */
  27354. set cameraColorCurvesEnabled(value: boolean);
  27355. /**
  27356. * Gets wether the color grading effect is enabled.
  27357. */
  27358. get cameraColorGradingEnabled(): boolean;
  27359. /**
  27360. * Gets wether the color grading effect is enabled.
  27361. */
  27362. set cameraColorGradingEnabled(value: boolean);
  27363. /**
  27364. * Gets wether tonemapping is enabled or not.
  27365. */
  27366. get cameraToneMappingEnabled(): boolean;
  27367. /**
  27368. * Sets wether tonemapping is enabled or not
  27369. */
  27370. set cameraToneMappingEnabled(value: boolean);
  27371. /**
  27372. * The camera exposure used on this material.
  27373. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27374. * This corresponds to a photographic exposure.
  27375. */
  27376. get cameraExposure(): number;
  27377. /**
  27378. * The camera exposure used on this material.
  27379. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27380. * This corresponds to a photographic exposure.
  27381. */
  27382. set cameraExposure(value: number);
  27383. /**
  27384. * Gets The camera contrast used on this material.
  27385. */
  27386. get cameraContrast(): number;
  27387. /**
  27388. * Sets The camera contrast used on this material.
  27389. */
  27390. set cameraContrast(value: number);
  27391. /**
  27392. * Gets the Color Grading 2D Lookup Texture.
  27393. */
  27394. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27395. /**
  27396. * Sets the Color Grading 2D Lookup Texture.
  27397. */
  27398. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27399. /**
  27400. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27401. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27402. * 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;
  27403. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27404. */
  27405. get cameraColorCurves(): Nullable<ColorCurves>;
  27406. /**
  27407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27409. * 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;
  27410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27411. */
  27412. set cameraColorCurves(value: Nullable<ColorCurves>);
  27413. /**
  27414. * Custom callback helping to override the default shader used in the material.
  27415. */
  27416. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27417. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27418. protected _worldViewProjectionMatrix: Matrix;
  27419. protected _globalAmbientColor: Color3;
  27420. protected _useLogarithmicDepth: boolean;
  27421. protected _rebuildInParallel: boolean;
  27422. /**
  27423. * Instantiates a new standard material.
  27424. * This is the default material used in Babylon. It is the best trade off between quality
  27425. * and performances.
  27426. * @see http://doc.babylonjs.com/babylon101/materials
  27427. * @param name Define the name of the material in the scene
  27428. * @param scene Define the scene the material belong to
  27429. */
  27430. constructor(name: string, scene: Scene);
  27431. /**
  27432. * Gets a boolean indicating that current material needs to register RTT
  27433. */
  27434. get hasRenderTargetTextures(): boolean;
  27435. /**
  27436. * Gets the current class name of the material e.g. "StandardMaterial"
  27437. * Mainly use in serialization.
  27438. * @returns the class name
  27439. */
  27440. getClassName(): string;
  27441. /**
  27442. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27443. * You can try switching to logarithmic depth.
  27444. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27445. */
  27446. get useLogarithmicDepth(): boolean;
  27447. set useLogarithmicDepth(value: boolean);
  27448. /**
  27449. * Specifies if the material will require alpha blending
  27450. * @returns a boolean specifying if alpha blending is needed
  27451. */
  27452. needAlphaBlending(): boolean;
  27453. /**
  27454. * Specifies if this material should be rendered in alpha test mode
  27455. * @returns a boolean specifying if an alpha test is needed.
  27456. */
  27457. needAlphaTesting(): boolean;
  27458. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27459. /**
  27460. * Get the texture used for alpha test purpose.
  27461. * @returns the diffuse texture in case of the standard material.
  27462. */
  27463. getAlphaTestTexture(): Nullable<BaseTexture>;
  27464. /**
  27465. * Get if the submesh is ready to be used and all its information available.
  27466. * Child classes can use it to update shaders
  27467. * @param mesh defines the mesh to check
  27468. * @param subMesh defines which submesh to check
  27469. * @param useInstances specifies that instances should be used
  27470. * @returns a boolean indicating that the submesh is ready or not
  27471. */
  27472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27473. /**
  27474. * Builds the material UBO layouts.
  27475. * Used internally during the effect preparation.
  27476. */
  27477. buildUniformLayout(): void;
  27478. /**
  27479. * Unbinds the material from the mesh
  27480. */
  27481. unbind(): void;
  27482. /**
  27483. * Binds the submesh to this material by preparing the effect and shader to draw
  27484. * @param world defines the world transformation matrix
  27485. * @param mesh defines the mesh containing the submesh
  27486. * @param subMesh defines the submesh to bind the material to
  27487. */
  27488. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27489. /**
  27490. * Get the list of animatables in the material.
  27491. * @returns the list of animatables object used in the material
  27492. */
  27493. getAnimatables(): IAnimatable[];
  27494. /**
  27495. * Gets the active textures from the material
  27496. * @returns an array of textures
  27497. */
  27498. getActiveTextures(): BaseTexture[];
  27499. /**
  27500. * Specifies if the material uses a texture
  27501. * @param texture defines the texture to check against the material
  27502. * @returns a boolean specifying if the material uses the texture
  27503. */
  27504. hasTexture(texture: BaseTexture): boolean;
  27505. /**
  27506. * Disposes the material
  27507. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27508. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27509. */
  27510. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27511. /**
  27512. * Makes a duplicate of the material, and gives it a new name
  27513. * @param name defines the new name for the duplicated material
  27514. * @returns the cloned material
  27515. */
  27516. clone(name: string): StandardMaterial;
  27517. /**
  27518. * Serializes this material in a JSON representation
  27519. * @returns the serialized material object
  27520. */
  27521. serialize(): any;
  27522. /**
  27523. * Creates a standard material from parsed material data
  27524. * @param source defines the JSON representation of the material
  27525. * @param scene defines the hosting scene
  27526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27527. * @returns a new standard material
  27528. */
  27529. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27530. /**
  27531. * Are diffuse textures enabled in the application.
  27532. */
  27533. static get DiffuseTextureEnabled(): boolean;
  27534. static set DiffuseTextureEnabled(value: boolean);
  27535. /**
  27536. * Are ambient textures enabled in the application.
  27537. */
  27538. static get AmbientTextureEnabled(): boolean;
  27539. static set AmbientTextureEnabled(value: boolean);
  27540. /**
  27541. * Are opacity textures enabled in the application.
  27542. */
  27543. static get OpacityTextureEnabled(): boolean;
  27544. static set OpacityTextureEnabled(value: boolean);
  27545. /**
  27546. * Are reflection textures enabled in the application.
  27547. */
  27548. static get ReflectionTextureEnabled(): boolean;
  27549. static set ReflectionTextureEnabled(value: boolean);
  27550. /**
  27551. * Are emissive textures enabled in the application.
  27552. */
  27553. static get EmissiveTextureEnabled(): boolean;
  27554. static set EmissiveTextureEnabled(value: boolean);
  27555. /**
  27556. * Are specular textures enabled in the application.
  27557. */
  27558. static get SpecularTextureEnabled(): boolean;
  27559. static set SpecularTextureEnabled(value: boolean);
  27560. /**
  27561. * Are bump textures enabled in the application.
  27562. */
  27563. static get BumpTextureEnabled(): boolean;
  27564. static set BumpTextureEnabled(value: boolean);
  27565. /**
  27566. * Are lightmap textures enabled in the application.
  27567. */
  27568. static get LightmapTextureEnabled(): boolean;
  27569. static set LightmapTextureEnabled(value: boolean);
  27570. /**
  27571. * Are refraction textures enabled in the application.
  27572. */
  27573. static get RefractionTextureEnabled(): boolean;
  27574. static set RefractionTextureEnabled(value: boolean);
  27575. /**
  27576. * Are color grading textures enabled in the application.
  27577. */
  27578. static get ColorGradingTextureEnabled(): boolean;
  27579. static set ColorGradingTextureEnabled(value: boolean);
  27580. /**
  27581. * Are fresnels enabled in the application.
  27582. */
  27583. static get FresnelEnabled(): boolean;
  27584. static set FresnelEnabled(value: boolean);
  27585. }
  27586. }
  27587. declare module "babylonjs/Particles/solidParticleSystem" {
  27588. import { Nullable } from "babylonjs/types";
  27589. import { Vector3 } from "babylonjs/Maths/math.vector";
  27590. import { Mesh } from "babylonjs/Meshes/mesh";
  27591. import { Scene, IDisposable } from "babylonjs/scene";
  27592. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27593. import { Material } from "babylonjs/Materials/material";
  27594. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27595. /**
  27596. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27597. *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.
  27598. * The SPS is also a particle system. It provides some methods to manage the particles.
  27599. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27600. *
  27601. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27602. */
  27603. export class SolidParticleSystem implements IDisposable {
  27604. /**
  27605. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27606. * Example : var p = SPS.particles[i];
  27607. */
  27608. particles: SolidParticle[];
  27609. /**
  27610. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27611. */
  27612. nbParticles: number;
  27613. /**
  27614. * If the particles must ever face the camera (default false). Useful for planar particles.
  27615. */
  27616. billboard: boolean;
  27617. /**
  27618. * Recompute normals when adding a shape
  27619. */
  27620. recomputeNormals: boolean;
  27621. /**
  27622. * This a counter ofr your own usage. It's not set by any SPS functions.
  27623. */
  27624. counter: number;
  27625. /**
  27626. * The SPS name. This name is also given to the underlying mesh.
  27627. */
  27628. name: string;
  27629. /**
  27630. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27631. */
  27632. mesh: Mesh;
  27633. /**
  27634. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27635. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27636. */
  27637. vars: any;
  27638. /**
  27639. * This array is populated when the SPS is set as 'pickable'.
  27640. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27641. * Each element of this array is an object `{idx: int, faceId: int}`.
  27642. * `idx` is the picked particle index in the `SPS.particles` array
  27643. * `faceId` is the picked face index counted within this particle.
  27644. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27645. */
  27646. pickedParticles: {
  27647. idx: number;
  27648. faceId: number;
  27649. }[];
  27650. /**
  27651. * This array is populated when `enableDepthSort` is set to true.
  27652. * Each element of this array is an instance of the class DepthSortedParticle.
  27653. */
  27654. depthSortedParticles: DepthSortedParticle[];
  27655. /**
  27656. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27657. * @hidden
  27658. */
  27659. _bSphereOnly: boolean;
  27660. /**
  27661. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27662. * @hidden
  27663. */
  27664. _bSphereRadiusFactor: number;
  27665. private _scene;
  27666. private _positions;
  27667. private _indices;
  27668. private _normals;
  27669. private _colors;
  27670. private _uvs;
  27671. private _indices32;
  27672. private _positions32;
  27673. private _normals32;
  27674. private _fixedNormal32;
  27675. private _colors32;
  27676. private _uvs32;
  27677. private _index;
  27678. private _updatable;
  27679. private _pickable;
  27680. private _isVisibilityBoxLocked;
  27681. private _alwaysVisible;
  27682. private _depthSort;
  27683. private _expandable;
  27684. private _shapeCounter;
  27685. private _copy;
  27686. private _color;
  27687. private _computeParticleColor;
  27688. private _computeParticleTexture;
  27689. private _computeParticleRotation;
  27690. private _computeParticleVertex;
  27691. private _computeBoundingBox;
  27692. private _depthSortParticles;
  27693. private _camera;
  27694. private _mustUnrotateFixedNormals;
  27695. private _particlesIntersect;
  27696. private _needs32Bits;
  27697. private _isNotBuilt;
  27698. private _lastParticleId;
  27699. private _idxOfId;
  27700. private _multimaterialEnabled;
  27701. private _useModelMaterial;
  27702. private _indicesByMaterial;
  27703. private _materialIndexes;
  27704. private _depthSortFunction;
  27705. private _materialSortFunction;
  27706. private _materials;
  27707. private _multimaterial;
  27708. private _materialIndexesById;
  27709. private _defaultMaterial;
  27710. private _autoUpdateSubMeshes;
  27711. /**
  27712. * Creates a SPS (Solid Particle System) object.
  27713. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27714. * @param scene (Scene) is the scene in which the SPS is added.
  27715. * @param options defines the options of the sps e.g.
  27716. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27717. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27718. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27719. * * 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.
  27720. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27721. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27722. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27723. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27724. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27725. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27726. */
  27727. constructor(name: string, scene: Scene, options?: {
  27728. updatable?: boolean;
  27729. isPickable?: boolean;
  27730. enableDepthSort?: boolean;
  27731. particleIntersection?: boolean;
  27732. boundingSphereOnly?: boolean;
  27733. bSphereRadiusFactor?: number;
  27734. expandable?: boolean;
  27735. useModelMaterial?: boolean;
  27736. enableMultiMaterial?: boolean;
  27737. });
  27738. /**
  27739. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27740. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27741. * @returns the created mesh
  27742. */
  27743. buildMesh(): Mesh;
  27744. /**
  27745. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27746. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27747. * Thus the particles generated from `digest()` have their property `position` set yet.
  27748. * @param mesh ( Mesh ) is the mesh to be digested
  27749. * @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
  27750. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27751. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27752. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27753. * @returns the current SPS
  27754. */
  27755. digest(mesh: Mesh, options?: {
  27756. facetNb?: number;
  27757. number?: number;
  27758. delta?: number;
  27759. storage?: [];
  27760. }): SolidParticleSystem;
  27761. /**
  27762. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27763. * @hidden
  27764. */
  27765. private _unrotateFixedNormals;
  27766. /**
  27767. * Resets the temporary working copy particle
  27768. * @hidden
  27769. */
  27770. private _resetCopy;
  27771. /**
  27772. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27773. * @param p the current index in the positions array to be updated
  27774. * @param ind the current index in the indices array
  27775. * @param shape a Vector3 array, the shape geometry
  27776. * @param positions the positions array to be updated
  27777. * @param meshInd the shape indices array
  27778. * @param indices the indices array to be updated
  27779. * @param meshUV the shape uv array
  27780. * @param uvs the uv array to be updated
  27781. * @param meshCol the shape color array
  27782. * @param colors the color array to be updated
  27783. * @param meshNor the shape normals array
  27784. * @param normals the normals array to be updated
  27785. * @param idx the particle index
  27786. * @param idxInShape the particle index in its shape
  27787. * @param options the addShape() method passed options
  27788. * @model the particle model
  27789. * @hidden
  27790. */
  27791. private _meshBuilder;
  27792. /**
  27793. * Returns a shape Vector3 array from positions float array
  27794. * @param positions float array
  27795. * @returns a vector3 array
  27796. * @hidden
  27797. */
  27798. private _posToShape;
  27799. /**
  27800. * Returns a shapeUV array from a float uvs (array deep copy)
  27801. * @param uvs as a float array
  27802. * @returns a shapeUV array
  27803. * @hidden
  27804. */
  27805. private _uvsToShapeUV;
  27806. /**
  27807. * Adds a new particle object in the particles array
  27808. * @param idx particle index in particles array
  27809. * @param id particle id
  27810. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27811. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27812. * @param model particle ModelShape object
  27813. * @param shapeId model shape identifier
  27814. * @param idxInShape index of the particle in the current model
  27815. * @param bInfo model bounding info object
  27816. * @param storage target storage array, if any
  27817. * @hidden
  27818. */
  27819. private _addParticle;
  27820. /**
  27821. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27822. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27823. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27824. * @param nb (positive integer) the number of particles to be created from this model
  27825. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27826. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27827. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27828. * @returns the number of shapes in the system
  27829. */
  27830. addShape(mesh: Mesh, nb: number, options?: {
  27831. positionFunction?: any;
  27832. vertexFunction?: any;
  27833. storage?: [];
  27834. }): number;
  27835. /**
  27836. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27837. * @hidden
  27838. */
  27839. private _rebuildParticle;
  27840. /**
  27841. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27842. * @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.
  27843. * @returns the SPS.
  27844. */
  27845. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27846. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27847. * Returns an array with the removed particles.
  27848. * 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.
  27849. * The SPS can't be empty so at least one particle needs to remain in place.
  27850. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27851. * @param start index of the first particle to remove
  27852. * @param end index of the last particle to remove (included)
  27853. * @returns an array populated with the removed particles
  27854. */
  27855. removeParticles(start: number, end: number): SolidParticle[];
  27856. /**
  27857. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27858. * @param solidParticleArray an array populated with Solid Particles objects
  27859. * @returns the SPS
  27860. */
  27861. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27862. /**
  27863. * Creates a new particle and modifies the SPS mesh geometry :
  27864. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27865. * - calls _addParticle() to populate the particle array
  27866. * factorized code from addShape() and insertParticlesFromArray()
  27867. * @param idx particle index in the particles array
  27868. * @param i particle index in its shape
  27869. * @param modelShape particle ModelShape object
  27870. * @param shape shape vertex array
  27871. * @param meshInd shape indices array
  27872. * @param meshUV shape uv array
  27873. * @param meshCol shape color array
  27874. * @param meshNor shape normals array
  27875. * @param bbInfo shape bounding info
  27876. * @param storage target particle storage
  27877. * @options addShape() passed options
  27878. * @hidden
  27879. */
  27880. private _insertNewParticle;
  27881. /**
  27882. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27883. * This method calls `updateParticle()` for each particle of the SPS.
  27884. * For an animated SPS, it is usually called within the render loop.
  27885. * 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.
  27886. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27887. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27888. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27889. * @returns the SPS.
  27890. */
  27891. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27892. /**
  27893. * Disposes the SPS.
  27894. */
  27895. dispose(): void;
  27896. /**
  27897. * Returns a SolidParticle object from its identifier : particle.id
  27898. * @param id (integer) the particle Id
  27899. * @returns the searched particle or null if not found in the SPS.
  27900. */
  27901. getParticleById(id: number): Nullable<SolidParticle>;
  27902. /**
  27903. * Returns a new array populated with the particles having the passed shapeId.
  27904. * @param shapeId (integer) the shape identifier
  27905. * @returns a new solid particle array
  27906. */
  27907. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27908. /**
  27909. * Populates the passed array "ref" with the particles having the passed shapeId.
  27910. * @param shapeId the shape identifier
  27911. * @returns the SPS
  27912. * @param ref
  27913. */
  27914. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27915. /**
  27916. * Computes the required SubMeshes according the materials assigned to the particles.
  27917. * @returns the solid particle system.
  27918. * Does nothing if called before the SPS mesh is built.
  27919. */
  27920. computeSubMeshes(): SolidParticleSystem;
  27921. /**
  27922. * Sorts the solid particles by material when MultiMaterial is enabled.
  27923. * Updates the indices32 array.
  27924. * Updates the indicesByMaterial array.
  27925. * Updates the mesh indices array.
  27926. * @returns the SPS
  27927. * @hidden
  27928. */
  27929. private _sortParticlesByMaterial;
  27930. /**
  27931. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27932. * @hidden
  27933. */
  27934. private _setMaterialIndexesById;
  27935. /**
  27936. * Returns an array with unique values of Materials from the passed array
  27937. * @param array the material array to be checked and filtered
  27938. * @hidden
  27939. */
  27940. private _filterUniqueMaterialId;
  27941. /**
  27942. * Sets a new Standard Material as _defaultMaterial if not already set.
  27943. * @hidden
  27944. */
  27945. private _setDefaultMaterial;
  27946. /**
  27947. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27948. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27949. * @returns the SPS.
  27950. */
  27951. refreshVisibleSize(): SolidParticleSystem;
  27952. /**
  27953. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27954. * @param size the size (float) of the visibility box
  27955. * note : this doesn't lock the SPS mesh bounding box.
  27956. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27957. */
  27958. setVisibilityBox(size: number): void;
  27959. /**
  27960. * Gets whether the SPS as always visible or not
  27961. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27962. */
  27963. get isAlwaysVisible(): boolean;
  27964. /**
  27965. * Sets the SPS as always visible or not
  27966. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27967. */
  27968. set isAlwaysVisible(val: boolean);
  27969. /**
  27970. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27971. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27972. */
  27973. set isVisibilityBoxLocked(val: boolean);
  27974. /**
  27975. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27976. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27977. */
  27978. get isVisibilityBoxLocked(): boolean;
  27979. /**
  27980. * Tells to `setParticles()` to compute the particle rotations or not.
  27981. * Default value : true. The SPS is faster when it's set to false.
  27982. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27983. */
  27984. set computeParticleRotation(val: boolean);
  27985. /**
  27986. * Tells to `setParticles()` to compute the particle colors or not.
  27987. * Default value : true. The SPS is faster when it's set to false.
  27988. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27989. */
  27990. set computeParticleColor(val: boolean);
  27991. set computeParticleTexture(val: boolean);
  27992. /**
  27993. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27994. * Default value : false. The SPS is faster when it's set to false.
  27995. * Note : the particle custom vertex positions aren't stored values.
  27996. */
  27997. set computeParticleVertex(val: boolean);
  27998. /**
  27999. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28000. */
  28001. set computeBoundingBox(val: boolean);
  28002. /**
  28003. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28004. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28005. * Default : `true`
  28006. */
  28007. set depthSortParticles(val: boolean);
  28008. /**
  28009. * Gets if `setParticles()` computes the particle rotations or not.
  28010. * Default value : true. The SPS is faster when it's set to false.
  28011. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28012. */
  28013. get computeParticleRotation(): boolean;
  28014. /**
  28015. * Gets if `setParticles()` computes the particle colors or not.
  28016. * Default value : true. The SPS is faster when it's set to false.
  28017. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28018. */
  28019. get computeParticleColor(): boolean;
  28020. /**
  28021. * Gets if `setParticles()` computes the particle textures or not.
  28022. * Default value : true. The SPS is faster when it's set to false.
  28023. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28024. */
  28025. get computeParticleTexture(): boolean;
  28026. /**
  28027. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28028. * Default value : false. The SPS is faster when it's set to false.
  28029. * Note : the particle custom vertex positions aren't stored values.
  28030. */
  28031. get computeParticleVertex(): boolean;
  28032. /**
  28033. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28034. */
  28035. get computeBoundingBox(): boolean;
  28036. /**
  28037. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28038. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28039. * Default : `true`
  28040. */
  28041. get depthSortParticles(): boolean;
  28042. /**
  28043. * Gets if the SPS is created as expandable at construction time.
  28044. * Default : `false`
  28045. */
  28046. get expandable(): boolean;
  28047. /**
  28048. * Gets if the SPS supports the Multi Materials
  28049. */
  28050. get multimaterialEnabled(): boolean;
  28051. /**
  28052. * Gets if the SPS uses the model materials for its own multimaterial.
  28053. */
  28054. get useModelMaterial(): boolean;
  28055. /**
  28056. * The SPS used material array.
  28057. */
  28058. get materials(): Material[];
  28059. /**
  28060. * Sets the SPS MultiMaterial from the passed materials.
  28061. * Note : the passed array is internally copied and not used then by reference.
  28062. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28063. */
  28064. setMultiMaterial(materials: Material[]): void;
  28065. /**
  28066. * The SPS computed multimaterial object
  28067. */
  28068. get multimaterial(): MultiMaterial;
  28069. set multimaterial(mm: MultiMaterial);
  28070. /**
  28071. * If the subMeshes must be updated on the next call to setParticles()
  28072. */
  28073. get autoUpdateSubMeshes(): boolean;
  28074. set autoUpdateSubMeshes(val: boolean);
  28075. /**
  28076. * This function does nothing. It may be overwritten to set all the particle first values.
  28077. * The SPS doesn't call this function, you may have to call it by your own.
  28078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28079. */
  28080. initParticles(): void;
  28081. /**
  28082. * This function does nothing. It may be overwritten to recycle a particle.
  28083. * The SPS doesn't call this function, you may have to call it by your own.
  28084. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28085. * @param particle The particle to recycle
  28086. * @returns the recycled particle
  28087. */
  28088. recycleParticle(particle: SolidParticle): SolidParticle;
  28089. /**
  28090. * Updates a particle : this function should be overwritten by the user.
  28091. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28092. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28093. * @example : just set a particle position or velocity and recycle conditions
  28094. * @param particle The particle to update
  28095. * @returns the updated particle
  28096. */
  28097. updateParticle(particle: SolidParticle): SolidParticle;
  28098. /**
  28099. * Updates a vertex of a particle : it can be overwritten by the user.
  28100. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28101. * @param particle the current particle
  28102. * @param vertex the current index of the current particle
  28103. * @param pt the index of the current vertex in the particle shape
  28104. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28105. * @example : just set a vertex particle position
  28106. * @returns the updated vertex
  28107. */
  28108. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28109. /**
  28110. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28111. * This does nothing and may be overwritten by the user.
  28112. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28113. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28114. * @param update the boolean update value actually passed to setParticles()
  28115. */
  28116. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28117. /**
  28118. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28119. * This will be passed three parameters.
  28120. * This does nothing and may be overwritten by the user.
  28121. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28122. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28123. * @param update the boolean update value actually passed to setParticles()
  28124. */
  28125. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28126. }
  28127. }
  28128. declare module "babylonjs/Particles/solidParticle" {
  28129. import { Nullable } from "babylonjs/types";
  28130. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28131. import { Color4 } from "babylonjs/Maths/math.color";
  28132. import { Mesh } from "babylonjs/Meshes/mesh";
  28133. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28134. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28135. import { Plane } from "babylonjs/Maths/math.plane";
  28136. import { Material } from "babylonjs/Materials/material";
  28137. /**
  28138. * Represents one particle of a solid particle system.
  28139. */
  28140. export class SolidParticle {
  28141. /**
  28142. * particle global index
  28143. */
  28144. idx: number;
  28145. /**
  28146. * particle identifier
  28147. */
  28148. id: number;
  28149. /**
  28150. * The color of the particle
  28151. */
  28152. color: Nullable<Color4>;
  28153. /**
  28154. * The world space position of the particle.
  28155. */
  28156. position: Vector3;
  28157. /**
  28158. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28159. */
  28160. rotation: Vector3;
  28161. /**
  28162. * The world space rotation quaternion of the particle.
  28163. */
  28164. rotationQuaternion: Nullable<Quaternion>;
  28165. /**
  28166. * The scaling of the particle.
  28167. */
  28168. scaling: Vector3;
  28169. /**
  28170. * The uvs of the particle.
  28171. */
  28172. uvs: Vector4;
  28173. /**
  28174. * The current speed of the particle.
  28175. */
  28176. velocity: Vector3;
  28177. /**
  28178. * The pivot point in the particle local space.
  28179. */
  28180. pivot: Vector3;
  28181. /**
  28182. * Must the particle be translated from its pivot point in its local space ?
  28183. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28184. * Default : false
  28185. */
  28186. translateFromPivot: boolean;
  28187. /**
  28188. * Is the particle active or not ?
  28189. */
  28190. alive: boolean;
  28191. /**
  28192. * Is the particle visible or not ?
  28193. */
  28194. isVisible: boolean;
  28195. /**
  28196. * Index of this particle in the global "positions" array (Internal use)
  28197. * @hidden
  28198. */
  28199. _pos: number;
  28200. /**
  28201. * @hidden Index of this particle in the global "indices" array (Internal use)
  28202. */
  28203. _ind: number;
  28204. /**
  28205. * @hidden ModelShape of this particle (Internal use)
  28206. */
  28207. _model: ModelShape;
  28208. /**
  28209. * ModelShape id of this particle
  28210. */
  28211. shapeId: number;
  28212. /**
  28213. * Index of the particle in its shape id
  28214. */
  28215. idxInShape: number;
  28216. /**
  28217. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28218. */
  28219. _modelBoundingInfo: BoundingInfo;
  28220. /**
  28221. * @hidden Particle BoundingInfo object (Internal use)
  28222. */
  28223. _boundingInfo: BoundingInfo;
  28224. /**
  28225. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28226. */
  28227. _sps: SolidParticleSystem;
  28228. /**
  28229. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28230. */
  28231. _stillInvisible: boolean;
  28232. /**
  28233. * @hidden Last computed particle rotation matrix
  28234. */
  28235. _rotationMatrix: number[];
  28236. /**
  28237. * Parent particle Id, if any.
  28238. * Default null.
  28239. */
  28240. parentId: Nullable<number>;
  28241. /**
  28242. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28243. */
  28244. materialIndex: Nullable<number>;
  28245. /**
  28246. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28247. * The possible values are :
  28248. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28249. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28250. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28251. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28252. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28253. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28254. * */
  28255. cullingStrategy: number;
  28256. /**
  28257. * @hidden Internal global position in the SPS.
  28258. */
  28259. _globalPosition: Vector3;
  28260. /**
  28261. * Creates a Solid Particle object.
  28262. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28263. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28264. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28265. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28266. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28267. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28268. * @param shapeId (integer) is the model shape identifier in the SPS.
  28269. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28270. * @param sps defines the sps it is associated to
  28271. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28272. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28273. */
  28274. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28275. /**
  28276. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28277. * @param target the particle target
  28278. * @returns the current particle
  28279. */
  28280. copyToRef(target: SolidParticle): SolidParticle;
  28281. /**
  28282. * Legacy support, changed scale to scaling
  28283. */
  28284. get scale(): Vector3;
  28285. /**
  28286. * Legacy support, changed scale to scaling
  28287. */
  28288. set scale(scale: Vector3);
  28289. /**
  28290. * Legacy support, changed quaternion to rotationQuaternion
  28291. */
  28292. get quaternion(): Nullable<Quaternion>;
  28293. /**
  28294. * Legacy support, changed quaternion to rotationQuaternion
  28295. */
  28296. set quaternion(q: Nullable<Quaternion>);
  28297. /**
  28298. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28299. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28300. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28301. * @returns true if it intersects
  28302. */
  28303. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28304. /**
  28305. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28306. * A particle is in the frustum if its bounding box intersects the frustum
  28307. * @param frustumPlanes defines the frustum to test
  28308. * @returns true if the particle is in the frustum planes
  28309. */
  28310. isInFrustum(frustumPlanes: Plane[]): boolean;
  28311. /**
  28312. * get the rotation matrix of the particle
  28313. * @hidden
  28314. */
  28315. getRotationMatrix(m: Matrix): void;
  28316. }
  28317. /**
  28318. * Represents the shape of the model used by one particle of a solid particle system.
  28319. * SPS internal tool, don't use it manually.
  28320. */
  28321. export class ModelShape {
  28322. /**
  28323. * The shape id
  28324. * @hidden
  28325. */
  28326. shapeID: number;
  28327. /**
  28328. * flat array of model positions (internal use)
  28329. * @hidden
  28330. */
  28331. _shape: Vector3[];
  28332. /**
  28333. * flat array of model UVs (internal use)
  28334. * @hidden
  28335. */
  28336. _shapeUV: number[];
  28337. /**
  28338. * color array of the model
  28339. * @hidden
  28340. */
  28341. _shapeColors: number[];
  28342. /**
  28343. * indices array of the model
  28344. * @hidden
  28345. */
  28346. _indices: number[];
  28347. /**
  28348. * normals array of the model
  28349. * @hidden
  28350. */
  28351. _normals: number[];
  28352. /**
  28353. * length of the shape in the model indices array (internal use)
  28354. * @hidden
  28355. */
  28356. _indicesLength: number;
  28357. /**
  28358. * Custom position function (internal use)
  28359. * @hidden
  28360. */
  28361. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28362. /**
  28363. * Custom vertex function (internal use)
  28364. * @hidden
  28365. */
  28366. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28367. /**
  28368. * Model material (internal use)
  28369. * @hidden
  28370. */
  28371. _material: Nullable<Material>;
  28372. /**
  28373. * 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.
  28374. * SPS internal tool, don't use it manually.
  28375. * @hidden
  28376. */
  28377. 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>);
  28378. }
  28379. /**
  28380. * Represents a Depth Sorted Particle in the solid particle system.
  28381. * @hidden
  28382. */
  28383. export class DepthSortedParticle {
  28384. /**
  28385. * Index of the particle in the "indices" array
  28386. */
  28387. ind: number;
  28388. /**
  28389. * Length of the particle shape in the "indices" array
  28390. */
  28391. indicesLength: number;
  28392. /**
  28393. * Squared distance from the particle to the camera
  28394. */
  28395. sqDistance: number;
  28396. /**
  28397. * Material index when used with MultiMaterials
  28398. */
  28399. materialIndex: number;
  28400. /**
  28401. * Creates a new sorted particle
  28402. * @param materialIndex
  28403. */
  28404. constructor(ind: number, indLength: number, materialIndex: number);
  28405. }
  28406. }
  28407. declare module "babylonjs/Collisions/meshCollisionData" {
  28408. import { Collider } from "babylonjs/Collisions/collider";
  28409. import { Vector3 } from "babylonjs/Maths/math.vector";
  28410. import { Nullable } from "babylonjs/types";
  28411. import { Observer } from "babylonjs/Misc/observable";
  28412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28413. /**
  28414. * @hidden
  28415. */
  28416. export class _MeshCollisionData {
  28417. _checkCollisions: boolean;
  28418. _collisionMask: number;
  28419. _collisionGroup: number;
  28420. _collider: Nullable<Collider>;
  28421. _oldPositionForCollisions: Vector3;
  28422. _diffPositionForCollisions: Vector3;
  28423. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28424. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28425. }
  28426. }
  28427. declare module "babylonjs/Meshes/abstractMesh" {
  28428. import { Observable } from "babylonjs/Misc/observable";
  28429. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28430. import { Camera } from "babylonjs/Cameras/camera";
  28431. import { Scene, IDisposable } from "babylonjs/scene";
  28432. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28433. import { Node } from "babylonjs/node";
  28434. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28435. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28436. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28437. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28438. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28439. import { Material } from "babylonjs/Materials/material";
  28440. import { Light } from "babylonjs/Lights/light";
  28441. import { Skeleton } from "babylonjs/Bones/skeleton";
  28442. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28443. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28444. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28445. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28446. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28447. import { Plane } from "babylonjs/Maths/math.plane";
  28448. import { Ray } from "babylonjs/Culling/ray";
  28449. import { Collider } from "babylonjs/Collisions/collider";
  28450. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28451. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28452. /** @hidden */
  28453. class _FacetDataStorage {
  28454. facetPositions: Vector3[];
  28455. facetNormals: Vector3[];
  28456. facetPartitioning: number[][];
  28457. facetNb: number;
  28458. partitioningSubdivisions: number;
  28459. partitioningBBoxRatio: number;
  28460. facetDataEnabled: boolean;
  28461. facetParameters: any;
  28462. bbSize: Vector3;
  28463. subDiv: {
  28464. max: number;
  28465. X: number;
  28466. Y: number;
  28467. Z: number;
  28468. };
  28469. facetDepthSort: boolean;
  28470. facetDepthSortEnabled: boolean;
  28471. depthSortedIndices: IndicesArray;
  28472. depthSortedFacets: {
  28473. ind: number;
  28474. sqDistance: number;
  28475. }[];
  28476. facetDepthSortFunction: (f1: {
  28477. ind: number;
  28478. sqDistance: number;
  28479. }, f2: {
  28480. ind: number;
  28481. sqDistance: number;
  28482. }) => number;
  28483. facetDepthSortFrom: Vector3;
  28484. facetDepthSortOrigin: Vector3;
  28485. invertedMatrix: Matrix;
  28486. }
  28487. /**
  28488. * @hidden
  28489. **/
  28490. class _InternalAbstractMeshDataInfo {
  28491. _hasVertexAlpha: boolean;
  28492. _useVertexColors: boolean;
  28493. _numBoneInfluencers: number;
  28494. _applyFog: boolean;
  28495. _receiveShadows: boolean;
  28496. _facetData: _FacetDataStorage;
  28497. _visibility: number;
  28498. _skeleton: Nullable<Skeleton>;
  28499. _layerMask: number;
  28500. _computeBonesUsingShaders: boolean;
  28501. _isActive: boolean;
  28502. _onlyForInstances: boolean;
  28503. _isActiveIntermediate: boolean;
  28504. _onlyForInstancesIntermediate: boolean;
  28505. _actAsRegularMesh: boolean;
  28506. }
  28507. /**
  28508. * Class used to store all common mesh properties
  28509. */
  28510. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28511. /** No occlusion */
  28512. static OCCLUSION_TYPE_NONE: number;
  28513. /** Occlusion set to optimisitic */
  28514. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28515. /** Occlusion set to strict */
  28516. static OCCLUSION_TYPE_STRICT: number;
  28517. /** Use an accurante occlusion algorithm */
  28518. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28519. /** Use a conservative occlusion algorithm */
  28520. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28521. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28522. * Test order :
  28523. * Is the bounding sphere outside the frustum ?
  28524. * If not, are the bounding box vertices outside the frustum ?
  28525. * It not, then the cullable object is in the frustum.
  28526. */
  28527. static readonly CULLINGSTRATEGY_STANDARD: number;
  28528. /** Culling strategy : Bounding Sphere Only.
  28529. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28530. * It's also less accurate than the standard because some not visible objects can still be selected.
  28531. * Test : is the bounding sphere outside the frustum ?
  28532. * If not, then the cullable object is in the frustum.
  28533. */
  28534. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28535. /** Culling strategy : Optimistic Inclusion.
  28536. * This in an inclusion test first, then the standard exclusion test.
  28537. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28538. * 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.
  28539. * Anyway, it's as accurate as the standard strategy.
  28540. * Test :
  28541. * Is the cullable object bounding sphere center in the frustum ?
  28542. * If not, apply the default culling strategy.
  28543. */
  28544. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28545. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28546. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28547. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28548. * 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.
  28549. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28550. * Test :
  28551. * Is the cullable object bounding sphere center in the frustum ?
  28552. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28553. */
  28554. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28555. /**
  28556. * No billboard
  28557. */
  28558. static get BILLBOARDMODE_NONE(): number;
  28559. /** Billboard on X axis */
  28560. static get BILLBOARDMODE_X(): number;
  28561. /** Billboard on Y axis */
  28562. static get BILLBOARDMODE_Y(): number;
  28563. /** Billboard on Z axis */
  28564. static get BILLBOARDMODE_Z(): number;
  28565. /** Billboard on all axes */
  28566. static get BILLBOARDMODE_ALL(): number;
  28567. /** Billboard on using position instead of orientation */
  28568. static get BILLBOARDMODE_USE_POSITION(): number;
  28569. /** @hidden */
  28570. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28571. /**
  28572. * The culling strategy to use to check whether the mesh must be rendered or not.
  28573. * This value can be changed at any time and will be used on the next render mesh selection.
  28574. * The possible values are :
  28575. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28576. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28577. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28579. * Please read each static variable documentation to get details about the culling process.
  28580. * */
  28581. cullingStrategy: number;
  28582. /**
  28583. * Gets the number of facets in the mesh
  28584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28585. */
  28586. get facetNb(): number;
  28587. /**
  28588. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28590. */
  28591. get partitioningSubdivisions(): number;
  28592. set partitioningSubdivisions(nb: number);
  28593. /**
  28594. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28595. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28597. */
  28598. get partitioningBBoxRatio(): number;
  28599. set partitioningBBoxRatio(ratio: number);
  28600. /**
  28601. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28602. * Works only for updatable meshes.
  28603. * Doesn't work with multi-materials
  28604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28605. */
  28606. get mustDepthSortFacets(): boolean;
  28607. set mustDepthSortFacets(sort: boolean);
  28608. /**
  28609. * The location (Vector3) where the facet depth sort must be computed from.
  28610. * By default, the active camera position.
  28611. * Used only when facet depth sort is enabled
  28612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28613. */
  28614. get facetDepthSortFrom(): Vector3;
  28615. set facetDepthSortFrom(location: Vector3);
  28616. /**
  28617. * gets a boolean indicating if facetData is enabled
  28618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28619. */
  28620. get isFacetDataEnabled(): boolean;
  28621. /** @hidden */
  28622. _updateNonUniformScalingState(value: boolean): boolean;
  28623. /**
  28624. * An event triggered when this mesh collides with another one
  28625. */
  28626. onCollideObservable: Observable<AbstractMesh>;
  28627. /** Set a function to call when this mesh collides with another one */
  28628. set onCollide(callback: () => void);
  28629. /**
  28630. * An event triggered when the collision's position changes
  28631. */
  28632. onCollisionPositionChangeObservable: Observable<Vector3>;
  28633. /** Set a function to call when the collision's position changes */
  28634. set onCollisionPositionChange(callback: () => void);
  28635. /**
  28636. * An event triggered when material is changed
  28637. */
  28638. onMaterialChangedObservable: Observable<AbstractMesh>;
  28639. /**
  28640. * Gets or sets the orientation for POV movement & rotation
  28641. */
  28642. definedFacingForward: boolean;
  28643. /** @hidden */
  28644. _occlusionQuery: Nullable<WebGLQuery>;
  28645. /** @hidden */
  28646. _renderingGroup: Nullable<RenderingGroup>;
  28647. /**
  28648. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28649. */
  28650. get visibility(): number;
  28651. /**
  28652. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28653. */
  28654. set visibility(value: number);
  28655. /** Gets or sets the alpha index used to sort transparent meshes
  28656. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28657. */
  28658. alphaIndex: number;
  28659. /**
  28660. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28661. */
  28662. isVisible: boolean;
  28663. /**
  28664. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28665. */
  28666. isPickable: boolean;
  28667. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28668. showSubMeshesBoundingBox: boolean;
  28669. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28670. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28671. */
  28672. isBlocker: boolean;
  28673. /**
  28674. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28675. */
  28676. enablePointerMoveEvents: boolean;
  28677. /**
  28678. * Specifies the rendering group id for this mesh (0 by default)
  28679. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28680. */
  28681. renderingGroupId: number;
  28682. private _material;
  28683. /** Gets or sets current material */
  28684. get material(): Nullable<Material>;
  28685. set material(value: Nullable<Material>);
  28686. /**
  28687. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28688. * @see http://doc.babylonjs.com/babylon101/shadows
  28689. */
  28690. get receiveShadows(): boolean;
  28691. set receiveShadows(value: boolean);
  28692. /** Defines color to use when rendering outline */
  28693. outlineColor: Color3;
  28694. /** Define width to use when rendering outline */
  28695. outlineWidth: number;
  28696. /** Defines color to use when rendering overlay */
  28697. overlayColor: Color3;
  28698. /** Defines alpha to use when rendering overlay */
  28699. overlayAlpha: number;
  28700. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28701. get hasVertexAlpha(): boolean;
  28702. set hasVertexAlpha(value: boolean);
  28703. /** 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) */
  28704. get useVertexColors(): boolean;
  28705. set useVertexColors(value: boolean);
  28706. /**
  28707. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28708. */
  28709. get computeBonesUsingShaders(): boolean;
  28710. set computeBonesUsingShaders(value: boolean);
  28711. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28712. get numBoneInfluencers(): number;
  28713. set numBoneInfluencers(value: number);
  28714. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28715. get applyFog(): boolean;
  28716. set applyFog(value: boolean);
  28717. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28718. useOctreeForRenderingSelection: boolean;
  28719. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28720. useOctreeForPicking: boolean;
  28721. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28722. useOctreeForCollisions: boolean;
  28723. /**
  28724. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28725. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28726. */
  28727. get layerMask(): number;
  28728. set layerMask(value: number);
  28729. /**
  28730. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28731. */
  28732. alwaysSelectAsActiveMesh: boolean;
  28733. /**
  28734. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28735. */
  28736. doNotSyncBoundingInfo: boolean;
  28737. /**
  28738. * Gets or sets the current action manager
  28739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28740. */
  28741. actionManager: Nullable<AbstractActionManager>;
  28742. private _meshCollisionData;
  28743. /**
  28744. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28746. */
  28747. ellipsoid: Vector3;
  28748. /**
  28749. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28751. */
  28752. ellipsoidOffset: Vector3;
  28753. /**
  28754. * Gets or sets a collision mask used to mask collisions (default is -1).
  28755. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28756. */
  28757. get collisionMask(): number;
  28758. set collisionMask(mask: number);
  28759. /**
  28760. * Gets or sets the current collision group mask (-1 by default).
  28761. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28762. */
  28763. get collisionGroup(): number;
  28764. set collisionGroup(mask: number);
  28765. /**
  28766. * Defines edge width used when edgesRenderer is enabled
  28767. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28768. */
  28769. edgesWidth: number;
  28770. /**
  28771. * Defines edge color used when edgesRenderer is enabled
  28772. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28773. */
  28774. edgesColor: Color4;
  28775. /** @hidden */
  28776. _edgesRenderer: Nullable<IEdgesRenderer>;
  28777. /** @hidden */
  28778. _masterMesh: Nullable<AbstractMesh>;
  28779. /** @hidden */
  28780. _boundingInfo: Nullable<BoundingInfo>;
  28781. /** @hidden */
  28782. _renderId: number;
  28783. /**
  28784. * Gets or sets the list of subMeshes
  28785. * @see http://doc.babylonjs.com/how_to/multi_materials
  28786. */
  28787. subMeshes: SubMesh[];
  28788. /** @hidden */
  28789. _intersectionsInProgress: AbstractMesh[];
  28790. /** @hidden */
  28791. _unIndexed: boolean;
  28792. /** @hidden */
  28793. _lightSources: Light[];
  28794. /** Gets the list of lights affecting that mesh */
  28795. get lightSources(): Light[];
  28796. /** @hidden */
  28797. get _positions(): Nullable<Vector3[]>;
  28798. /** @hidden */
  28799. _waitingData: {
  28800. lods: Nullable<any>;
  28801. actions: Nullable<any>;
  28802. freezeWorldMatrix: Nullable<boolean>;
  28803. };
  28804. /** @hidden */
  28805. _bonesTransformMatrices: Nullable<Float32Array>;
  28806. /** @hidden */
  28807. _transformMatrixTexture: Nullable<RawTexture>;
  28808. /**
  28809. * Gets or sets a skeleton to apply skining transformations
  28810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28811. */
  28812. set skeleton(value: Nullable<Skeleton>);
  28813. get skeleton(): Nullable<Skeleton>;
  28814. /**
  28815. * An event triggered when the mesh is rebuilt.
  28816. */
  28817. onRebuildObservable: Observable<AbstractMesh>;
  28818. /**
  28819. * Creates a new AbstractMesh
  28820. * @param name defines the name of the mesh
  28821. * @param scene defines the hosting scene
  28822. */
  28823. constructor(name: string, scene?: Nullable<Scene>);
  28824. /**
  28825. * Returns the string "AbstractMesh"
  28826. * @returns "AbstractMesh"
  28827. */
  28828. getClassName(): string;
  28829. /**
  28830. * Gets a string representation of the current mesh
  28831. * @param fullDetails defines a boolean indicating if full details must be included
  28832. * @returns a string representation of the current mesh
  28833. */
  28834. toString(fullDetails?: boolean): string;
  28835. /**
  28836. * @hidden
  28837. */
  28838. protected _getEffectiveParent(): Nullable<Node>;
  28839. /** @hidden */
  28840. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28841. /** @hidden */
  28842. _rebuild(): void;
  28843. /** @hidden */
  28844. _resyncLightSources(): void;
  28845. /** @hidden */
  28846. _resyncLightSource(light: Light): void;
  28847. /** @hidden */
  28848. _unBindEffect(): void;
  28849. /** @hidden */
  28850. _removeLightSource(light: Light, dispose: boolean): void;
  28851. private _markSubMeshesAsDirty;
  28852. /** @hidden */
  28853. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28854. /** @hidden */
  28855. _markSubMeshesAsAttributesDirty(): void;
  28856. /** @hidden */
  28857. _markSubMeshesAsMiscDirty(): void;
  28858. /**
  28859. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28860. */
  28861. get scaling(): Vector3;
  28862. set scaling(newScaling: Vector3);
  28863. /**
  28864. * Returns true if the mesh is blocked. Implemented by child classes
  28865. */
  28866. get isBlocked(): boolean;
  28867. /**
  28868. * Returns the mesh itself by default. Implemented by child classes
  28869. * @param camera defines the camera to use to pick the right LOD level
  28870. * @returns the currentAbstractMesh
  28871. */
  28872. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28873. /**
  28874. * Returns 0 by default. Implemented by child classes
  28875. * @returns an integer
  28876. */
  28877. getTotalVertices(): number;
  28878. /**
  28879. * Returns a positive integer : the total number of indices in this mesh geometry.
  28880. * @returns the numner of indices or zero if the mesh has no geometry.
  28881. */
  28882. getTotalIndices(): number;
  28883. /**
  28884. * Returns null by default. Implemented by child classes
  28885. * @returns null
  28886. */
  28887. getIndices(): Nullable<IndicesArray>;
  28888. /**
  28889. * Returns the array of the requested vertex data kind. Implemented by child classes
  28890. * @param kind defines the vertex data kind to use
  28891. * @returns null
  28892. */
  28893. getVerticesData(kind: string): Nullable<FloatArray>;
  28894. /**
  28895. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28896. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28897. * Note that a new underlying VertexBuffer object is created each call.
  28898. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28899. * @param kind defines vertex data kind:
  28900. * * VertexBuffer.PositionKind
  28901. * * VertexBuffer.UVKind
  28902. * * VertexBuffer.UV2Kind
  28903. * * VertexBuffer.UV3Kind
  28904. * * VertexBuffer.UV4Kind
  28905. * * VertexBuffer.UV5Kind
  28906. * * VertexBuffer.UV6Kind
  28907. * * VertexBuffer.ColorKind
  28908. * * VertexBuffer.MatricesIndicesKind
  28909. * * VertexBuffer.MatricesIndicesExtraKind
  28910. * * VertexBuffer.MatricesWeightsKind
  28911. * * VertexBuffer.MatricesWeightsExtraKind
  28912. * @param data defines the data source
  28913. * @param updatable defines if the data must be flagged as updatable (or static)
  28914. * @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
  28915. * @returns the current mesh
  28916. */
  28917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28918. /**
  28919. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28920. * If the mesh has no geometry, it is simply returned as it is.
  28921. * @param kind defines vertex data kind:
  28922. * * VertexBuffer.PositionKind
  28923. * * VertexBuffer.UVKind
  28924. * * VertexBuffer.UV2Kind
  28925. * * VertexBuffer.UV3Kind
  28926. * * VertexBuffer.UV4Kind
  28927. * * VertexBuffer.UV5Kind
  28928. * * VertexBuffer.UV6Kind
  28929. * * VertexBuffer.ColorKind
  28930. * * VertexBuffer.MatricesIndicesKind
  28931. * * VertexBuffer.MatricesIndicesExtraKind
  28932. * * VertexBuffer.MatricesWeightsKind
  28933. * * VertexBuffer.MatricesWeightsExtraKind
  28934. * @param data defines the data source
  28935. * @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
  28936. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28937. * @returns the current mesh
  28938. */
  28939. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28940. /**
  28941. * Sets the mesh indices,
  28942. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28943. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28944. * @param totalVertices Defines the total number of vertices
  28945. * @returns the current mesh
  28946. */
  28947. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28948. /**
  28949. * Gets a boolean indicating if specific vertex data is present
  28950. * @param kind defines the vertex data kind to use
  28951. * @returns true is data kind is present
  28952. */
  28953. isVerticesDataPresent(kind: string): boolean;
  28954. /**
  28955. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28956. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28957. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28958. * @returns a BoundingInfo
  28959. */
  28960. getBoundingInfo(): BoundingInfo;
  28961. /**
  28962. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28963. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28964. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28965. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28966. * @returns the current mesh
  28967. */
  28968. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28969. /**
  28970. * Overwrite the current bounding info
  28971. * @param boundingInfo defines the new bounding info
  28972. * @returns the current mesh
  28973. */
  28974. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28975. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28976. get useBones(): boolean;
  28977. /** @hidden */
  28978. _preActivate(): void;
  28979. /** @hidden */
  28980. _preActivateForIntermediateRendering(renderId: number): void;
  28981. /** @hidden */
  28982. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28983. /** @hidden */
  28984. _postActivate(): void;
  28985. /** @hidden */
  28986. _freeze(): void;
  28987. /** @hidden */
  28988. _unFreeze(): void;
  28989. /**
  28990. * Gets the current world matrix
  28991. * @returns a Matrix
  28992. */
  28993. getWorldMatrix(): Matrix;
  28994. /** @hidden */
  28995. _getWorldMatrixDeterminant(): number;
  28996. /**
  28997. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28998. */
  28999. get isAnInstance(): boolean;
  29000. /**
  29001. * Gets a boolean indicating if this mesh has instances
  29002. */
  29003. get hasInstances(): boolean;
  29004. /**
  29005. * Perform relative position change from the point of view of behind the front of the mesh.
  29006. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29007. * Supports definition of mesh facing forward or backward
  29008. * @param amountRight defines the distance on the right axis
  29009. * @param amountUp defines the distance on the up axis
  29010. * @param amountForward defines the distance on the forward axis
  29011. * @returns the current mesh
  29012. */
  29013. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29014. /**
  29015. * Calculate relative position change from the point of view of behind the front of the mesh.
  29016. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29017. * Supports definition of mesh facing forward or backward
  29018. * @param amountRight defines the distance on the right axis
  29019. * @param amountUp defines the distance on the up axis
  29020. * @param amountForward defines the distance on the forward axis
  29021. * @returns the new displacement vector
  29022. */
  29023. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29024. /**
  29025. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29026. * Supports definition of mesh facing forward or backward
  29027. * @param flipBack defines the flip
  29028. * @param twirlClockwise defines the twirl
  29029. * @param tiltRight defines the tilt
  29030. * @returns the current mesh
  29031. */
  29032. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29033. /**
  29034. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29035. * Supports definition of mesh facing forward or backward.
  29036. * @param flipBack defines the flip
  29037. * @param twirlClockwise defines the twirl
  29038. * @param tiltRight defines the tilt
  29039. * @returns the new rotation vector
  29040. */
  29041. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29042. /**
  29043. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29044. * This means the mesh underlying bounding box and sphere are recomputed.
  29045. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29046. * @returns the current mesh
  29047. */
  29048. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29049. /** @hidden */
  29050. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29051. /** @hidden */
  29052. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29053. /** @hidden */
  29054. _updateBoundingInfo(): AbstractMesh;
  29055. /** @hidden */
  29056. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29057. /** @hidden */
  29058. protected _afterComputeWorldMatrix(): void;
  29059. /** @hidden */
  29060. get _effectiveMesh(): AbstractMesh;
  29061. /**
  29062. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29063. * A mesh is in the frustum if its bounding box intersects the frustum
  29064. * @param frustumPlanes defines the frustum to test
  29065. * @returns true if the mesh is in the frustum planes
  29066. */
  29067. isInFrustum(frustumPlanes: Plane[]): boolean;
  29068. /**
  29069. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29070. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29071. * @param frustumPlanes defines the frustum to test
  29072. * @returns true if the mesh is completely in the frustum planes
  29073. */
  29074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29075. /**
  29076. * True if the mesh intersects another mesh or a SolidParticle object
  29077. * @param mesh defines a target mesh or SolidParticle to test
  29078. * @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)
  29079. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29080. * @returns true if there is an intersection
  29081. */
  29082. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29083. /**
  29084. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29085. * @param point defines the point to test
  29086. * @returns true if there is an intersection
  29087. */
  29088. intersectsPoint(point: Vector3): boolean;
  29089. /**
  29090. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29092. */
  29093. get checkCollisions(): boolean;
  29094. set checkCollisions(collisionEnabled: boolean);
  29095. /**
  29096. * Gets Collider object used to compute collisions (not physics)
  29097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29098. */
  29099. get collider(): Nullable<Collider>;
  29100. /**
  29101. * Move the mesh using collision engine
  29102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29103. * @param displacement defines the requested displacement vector
  29104. * @returns the current mesh
  29105. */
  29106. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29107. private _onCollisionPositionChange;
  29108. /** @hidden */
  29109. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29110. /** @hidden */
  29111. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29112. /** @hidden */
  29113. _checkCollision(collider: Collider): AbstractMesh;
  29114. /** @hidden */
  29115. _generatePointsArray(): boolean;
  29116. /**
  29117. * Checks if the passed Ray intersects with the mesh
  29118. * @param ray defines the ray to use
  29119. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29120. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29121. * @returns the picking info
  29122. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29123. */
  29124. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29125. /**
  29126. * Clones the current mesh
  29127. * @param name defines the mesh name
  29128. * @param newParent defines the new mesh parent
  29129. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29130. * @returns the new mesh
  29131. */
  29132. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29133. /**
  29134. * Disposes all the submeshes of the current meshnp
  29135. * @returns the current mesh
  29136. */
  29137. releaseSubMeshes(): AbstractMesh;
  29138. /**
  29139. * Releases resources associated with this abstract mesh.
  29140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29142. */
  29143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29144. /**
  29145. * Adds the passed mesh as a child to the current mesh
  29146. * @param mesh defines the child mesh
  29147. * @returns the current mesh
  29148. */
  29149. addChild(mesh: AbstractMesh): AbstractMesh;
  29150. /**
  29151. * Removes the passed mesh from the current mesh children list
  29152. * @param mesh defines the child mesh
  29153. * @returns the current mesh
  29154. */
  29155. removeChild(mesh: AbstractMesh): AbstractMesh;
  29156. /** @hidden */
  29157. private _initFacetData;
  29158. /**
  29159. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29160. * This method can be called within the render loop.
  29161. * 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
  29162. * @returns the current mesh
  29163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29164. */
  29165. updateFacetData(): AbstractMesh;
  29166. /**
  29167. * Returns the facetLocalNormals array.
  29168. * The normals are expressed in the mesh local spac
  29169. * @returns an array of Vector3
  29170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29171. */
  29172. getFacetLocalNormals(): Vector3[];
  29173. /**
  29174. * Returns the facetLocalPositions array.
  29175. * The facet positions are expressed in the mesh local space
  29176. * @returns an array of Vector3
  29177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29178. */
  29179. getFacetLocalPositions(): Vector3[];
  29180. /**
  29181. * Returns the facetLocalPartioning array
  29182. * @returns an array of array of numbers
  29183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29184. */
  29185. getFacetLocalPartitioning(): number[][];
  29186. /**
  29187. * Returns the i-th facet position in the world system.
  29188. * This method allocates a new Vector3 per call
  29189. * @param i defines the facet index
  29190. * @returns a new Vector3
  29191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29192. */
  29193. getFacetPosition(i: number): Vector3;
  29194. /**
  29195. * Sets the reference Vector3 with the i-th facet position in the world system
  29196. * @param i defines the facet index
  29197. * @param ref defines the target vector
  29198. * @returns the current mesh
  29199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29200. */
  29201. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29202. /**
  29203. * Returns the i-th facet normal in the world system.
  29204. * This method allocates a new Vector3 per call
  29205. * @param i defines the facet index
  29206. * @returns a new Vector3
  29207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29208. */
  29209. getFacetNormal(i: number): Vector3;
  29210. /**
  29211. * Sets the reference Vector3 with the i-th facet normal in the world system
  29212. * @param i defines the facet index
  29213. * @param ref defines the target vector
  29214. * @returns the current mesh
  29215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29216. */
  29217. getFacetNormalToRef(i: number, ref: Vector3): this;
  29218. /**
  29219. * 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)
  29220. * @param x defines x coordinate
  29221. * @param y defines y coordinate
  29222. * @param z defines z coordinate
  29223. * @returns the array of facet indexes
  29224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29225. */
  29226. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29227. /**
  29228. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29229. * @param projected sets as the (x,y,z) world projection on the facet
  29230. * @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
  29231. * @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
  29232. * @param x defines x coordinate
  29233. * @param y defines y coordinate
  29234. * @param z defines z coordinate
  29235. * @returns the face index if found (or null instead)
  29236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29237. */
  29238. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29239. /**
  29240. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29241. * @param projected sets as the (x,y,z) local projection on the facet
  29242. * @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
  29243. * @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
  29244. * @param x defines x coordinate
  29245. * @param y defines y coordinate
  29246. * @param z defines z coordinate
  29247. * @returns the face index if found (or null instead)
  29248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29249. */
  29250. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29251. /**
  29252. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29253. * @returns the parameters
  29254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29255. */
  29256. getFacetDataParameters(): any;
  29257. /**
  29258. * Disables the feature FacetData and frees the related memory
  29259. * @returns the current mesh
  29260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29261. */
  29262. disableFacetData(): AbstractMesh;
  29263. /**
  29264. * Updates the AbstractMesh indices array
  29265. * @param indices defines the data source
  29266. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29267. * @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)
  29268. * @returns the current mesh
  29269. */
  29270. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29271. /**
  29272. * Creates new normals data for the mesh
  29273. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29274. * @returns the current mesh
  29275. */
  29276. createNormals(updatable: boolean): AbstractMesh;
  29277. /**
  29278. * Align the mesh with a normal
  29279. * @param normal defines the normal to use
  29280. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29281. * @returns the current mesh
  29282. */
  29283. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29284. /** @hidden */
  29285. _checkOcclusionQuery(): boolean;
  29286. /**
  29287. * Disables the mesh edge rendering mode
  29288. * @returns the currentAbstractMesh
  29289. */
  29290. disableEdgesRendering(): AbstractMesh;
  29291. /**
  29292. * Enables the edge rendering mode on the mesh.
  29293. * This mode makes the mesh edges visible
  29294. * @param epsilon defines the maximal distance between two angles to detect a face
  29295. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29296. * @returns the currentAbstractMesh
  29297. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29298. */
  29299. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29300. }
  29301. }
  29302. declare module "babylonjs/Actions/actionEvent" {
  29303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29304. import { Nullable } from "babylonjs/types";
  29305. import { Sprite } from "babylonjs/Sprites/sprite";
  29306. import { Scene } from "babylonjs/scene";
  29307. import { Vector2 } from "babylonjs/Maths/math.vector";
  29308. /**
  29309. * Interface used to define ActionEvent
  29310. */
  29311. export interface IActionEvent {
  29312. /** The mesh or sprite that triggered the action */
  29313. source: any;
  29314. /** The X mouse cursor position at the time of the event */
  29315. pointerX: number;
  29316. /** The Y mouse cursor position at the time of the event */
  29317. pointerY: number;
  29318. /** The mesh that is currently pointed at (can be null) */
  29319. meshUnderPointer: Nullable<AbstractMesh>;
  29320. /** the original (browser) event that triggered the ActionEvent */
  29321. sourceEvent?: any;
  29322. /** additional data for the event */
  29323. additionalData?: any;
  29324. }
  29325. /**
  29326. * ActionEvent is the event being sent when an action is triggered.
  29327. */
  29328. export class ActionEvent implements IActionEvent {
  29329. /** The mesh or sprite that triggered the action */
  29330. source: any;
  29331. /** The X mouse cursor position at the time of the event */
  29332. pointerX: number;
  29333. /** The Y mouse cursor position at the time of the event */
  29334. pointerY: number;
  29335. /** The mesh that is currently pointed at (can be null) */
  29336. meshUnderPointer: Nullable<AbstractMesh>;
  29337. /** the original (browser) event that triggered the ActionEvent */
  29338. sourceEvent?: any;
  29339. /** additional data for the event */
  29340. additionalData?: any;
  29341. /**
  29342. * Creates a new ActionEvent
  29343. * @param source The mesh or sprite that triggered the action
  29344. * @param pointerX The X mouse cursor position at the time of the event
  29345. * @param pointerY The Y mouse cursor position at the time of the event
  29346. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29347. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29348. * @param additionalData additional data for the event
  29349. */
  29350. constructor(
  29351. /** The mesh or sprite that triggered the action */
  29352. source: any,
  29353. /** The X mouse cursor position at the time of the event */
  29354. pointerX: number,
  29355. /** The Y mouse cursor position at the time of the event */
  29356. pointerY: number,
  29357. /** The mesh that is currently pointed at (can be null) */
  29358. meshUnderPointer: Nullable<AbstractMesh>,
  29359. /** the original (browser) event that triggered the ActionEvent */
  29360. sourceEvent?: any,
  29361. /** additional data for the event */
  29362. additionalData?: any);
  29363. /**
  29364. * Helper function to auto-create an ActionEvent from a source mesh.
  29365. * @param source The source mesh that triggered the event
  29366. * @param evt The original (browser) event
  29367. * @param additionalData additional data for the event
  29368. * @returns the new ActionEvent
  29369. */
  29370. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29371. /**
  29372. * Helper function to auto-create an ActionEvent from a source sprite
  29373. * @param source The source sprite that triggered the event
  29374. * @param scene Scene associated with the sprite
  29375. * @param evt The original (browser) event
  29376. * @param additionalData additional data for the event
  29377. * @returns the new ActionEvent
  29378. */
  29379. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29380. /**
  29381. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29382. * @param scene the scene where the event occurred
  29383. * @param evt The original (browser) event
  29384. * @returns the new ActionEvent
  29385. */
  29386. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29387. /**
  29388. * Helper function to auto-create an ActionEvent from a primitive
  29389. * @param prim defines the target primitive
  29390. * @param pointerPos defines the pointer position
  29391. * @param evt The original (browser) event
  29392. * @param additionalData additional data for the event
  29393. * @returns the new ActionEvent
  29394. */
  29395. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29396. }
  29397. }
  29398. declare module "babylonjs/Actions/abstractActionManager" {
  29399. import { IDisposable } from "babylonjs/scene";
  29400. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29401. import { IAction } from "babylonjs/Actions/action";
  29402. import { Nullable } from "babylonjs/types";
  29403. /**
  29404. * Abstract class used to decouple action Manager from scene and meshes.
  29405. * Do not instantiate.
  29406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29407. */
  29408. export abstract class AbstractActionManager implements IDisposable {
  29409. /** Gets the list of active triggers */
  29410. static Triggers: {
  29411. [key: string]: number;
  29412. };
  29413. /** Gets the cursor to use when hovering items */
  29414. hoverCursor: string;
  29415. /** Gets the list of actions */
  29416. actions: IAction[];
  29417. /**
  29418. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29419. */
  29420. isRecursive: boolean;
  29421. /**
  29422. * Releases all associated resources
  29423. */
  29424. abstract dispose(): void;
  29425. /**
  29426. * Does this action manager has pointer triggers
  29427. */
  29428. abstract get hasPointerTriggers(): boolean;
  29429. /**
  29430. * Does this action manager has pick triggers
  29431. */
  29432. abstract get hasPickTriggers(): boolean;
  29433. /**
  29434. * Process a specific trigger
  29435. * @param trigger defines the trigger to process
  29436. * @param evt defines the event details to be processed
  29437. */
  29438. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29439. /**
  29440. * Does this action manager handles actions of any of the given triggers
  29441. * @param triggers defines the triggers to be tested
  29442. * @return a boolean indicating whether one (or more) of the triggers is handled
  29443. */
  29444. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29445. /**
  29446. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29447. * speed.
  29448. * @param triggerA defines the trigger to be tested
  29449. * @param triggerB defines the trigger to be tested
  29450. * @return a boolean indicating whether one (or more) of the triggers is handled
  29451. */
  29452. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29453. /**
  29454. * Does this action manager handles actions of a given trigger
  29455. * @param trigger defines the trigger to be tested
  29456. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29457. * @return whether the trigger is handled
  29458. */
  29459. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29460. /**
  29461. * Serialize this manager to a JSON object
  29462. * @param name defines the property name to store this manager
  29463. * @returns a JSON representation of this manager
  29464. */
  29465. abstract serialize(name: string): any;
  29466. /**
  29467. * Registers an action to this action manager
  29468. * @param action defines the action to be registered
  29469. * @return the action amended (prepared) after registration
  29470. */
  29471. abstract registerAction(action: IAction): Nullable<IAction>;
  29472. /**
  29473. * Unregisters an action to this action manager
  29474. * @param action defines the action to be unregistered
  29475. * @return a boolean indicating whether the action has been unregistered
  29476. */
  29477. abstract unregisterAction(action: IAction): Boolean;
  29478. /**
  29479. * Does exist one action manager with at least one trigger
  29480. **/
  29481. static get HasTriggers(): boolean;
  29482. /**
  29483. * Does exist one action manager with at least one pick trigger
  29484. **/
  29485. static get HasPickTriggers(): boolean;
  29486. /**
  29487. * Does exist one action manager that handles actions of a given trigger
  29488. * @param trigger defines the trigger to be tested
  29489. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29490. **/
  29491. static HasSpecificTrigger(trigger: number): boolean;
  29492. }
  29493. }
  29494. declare module "babylonjs/node" {
  29495. import { Scene } from "babylonjs/scene";
  29496. import { Nullable } from "babylonjs/types";
  29497. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29498. import { Engine } from "babylonjs/Engines/engine";
  29499. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29500. import { Observable } from "babylonjs/Misc/observable";
  29501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29502. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29503. import { Animatable } from "babylonjs/Animations/animatable";
  29504. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29505. import { Animation } from "babylonjs/Animations/animation";
  29506. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29508. /**
  29509. * Defines how a node can be built from a string name.
  29510. */
  29511. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29512. /**
  29513. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29514. */
  29515. export class Node implements IBehaviorAware<Node> {
  29516. /** @hidden */
  29517. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29518. private static _NodeConstructors;
  29519. /**
  29520. * Add a new node constructor
  29521. * @param type defines the type name of the node to construct
  29522. * @param constructorFunc defines the constructor function
  29523. */
  29524. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29525. /**
  29526. * Returns a node constructor based on type name
  29527. * @param type defines the type name
  29528. * @param name defines the new node name
  29529. * @param scene defines the hosting scene
  29530. * @param options defines optional options to transmit to constructors
  29531. * @returns the new constructor or null
  29532. */
  29533. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29534. /**
  29535. * Gets or sets the name of the node
  29536. */
  29537. name: string;
  29538. /**
  29539. * Gets or sets the id of the node
  29540. */
  29541. id: string;
  29542. /**
  29543. * Gets or sets the unique id of the node
  29544. */
  29545. uniqueId: number;
  29546. /**
  29547. * Gets or sets a string used to store user defined state for the node
  29548. */
  29549. state: string;
  29550. /**
  29551. * Gets or sets an object used to store user defined information for the node
  29552. */
  29553. metadata: any;
  29554. /**
  29555. * For internal use only. Please do not use.
  29556. */
  29557. reservedDataStore: any;
  29558. /**
  29559. * List of inspectable custom properties (used by the Inspector)
  29560. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29561. */
  29562. inspectableCustomProperties: IInspectable[];
  29563. private _doNotSerialize;
  29564. /**
  29565. * Gets or sets a boolean used to define if the node must be serialized
  29566. */
  29567. get doNotSerialize(): boolean;
  29568. set doNotSerialize(value: boolean);
  29569. /** @hidden */
  29570. _isDisposed: boolean;
  29571. /**
  29572. * Gets a list of Animations associated with the node
  29573. */
  29574. animations: import("babylonjs/Animations/animation").Animation[];
  29575. protected _ranges: {
  29576. [name: string]: Nullable<AnimationRange>;
  29577. };
  29578. /**
  29579. * Callback raised when the node is ready to be used
  29580. */
  29581. onReady: Nullable<(node: Node) => void>;
  29582. private _isEnabled;
  29583. private _isParentEnabled;
  29584. private _isReady;
  29585. /** @hidden */
  29586. _currentRenderId: number;
  29587. private _parentUpdateId;
  29588. /** @hidden */
  29589. _childUpdateId: number;
  29590. /** @hidden */
  29591. _waitingParentId: Nullable<string>;
  29592. /** @hidden */
  29593. _scene: Scene;
  29594. /** @hidden */
  29595. _cache: any;
  29596. private _parentNode;
  29597. private _children;
  29598. /** @hidden */
  29599. _worldMatrix: Matrix;
  29600. /** @hidden */
  29601. _worldMatrixDeterminant: number;
  29602. /** @hidden */
  29603. _worldMatrixDeterminantIsDirty: boolean;
  29604. /** @hidden */
  29605. private _sceneRootNodesIndex;
  29606. /**
  29607. * Gets a boolean indicating if the node has been disposed
  29608. * @returns true if the node was disposed
  29609. */
  29610. isDisposed(): boolean;
  29611. /**
  29612. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29613. * @see https://doc.babylonjs.com/how_to/parenting
  29614. */
  29615. set parent(parent: Nullable<Node>);
  29616. get parent(): Nullable<Node>;
  29617. /** @hidden */
  29618. _addToSceneRootNodes(): void;
  29619. /** @hidden */
  29620. _removeFromSceneRootNodes(): void;
  29621. private _animationPropertiesOverride;
  29622. /**
  29623. * Gets or sets the animation properties override
  29624. */
  29625. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29626. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29627. /**
  29628. * Gets a string idenfifying the name of the class
  29629. * @returns "Node" string
  29630. */
  29631. getClassName(): string;
  29632. /** @hidden */
  29633. readonly _isNode: boolean;
  29634. /**
  29635. * An event triggered when the mesh is disposed
  29636. */
  29637. onDisposeObservable: Observable<Node>;
  29638. private _onDisposeObserver;
  29639. /**
  29640. * Sets a callback that will be raised when the node will be disposed
  29641. */
  29642. set onDispose(callback: () => void);
  29643. /**
  29644. * Creates a new Node
  29645. * @param name the name and id to be given to this node
  29646. * @param scene the scene this node will be added to
  29647. */
  29648. constructor(name: string, scene?: Nullable<Scene>);
  29649. /**
  29650. * Gets the scene of the node
  29651. * @returns a scene
  29652. */
  29653. getScene(): Scene;
  29654. /**
  29655. * Gets the engine of the node
  29656. * @returns a Engine
  29657. */
  29658. getEngine(): Engine;
  29659. private _behaviors;
  29660. /**
  29661. * Attach a behavior to the node
  29662. * @see http://doc.babylonjs.com/features/behaviour
  29663. * @param behavior defines the behavior to attach
  29664. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29665. * @returns the current Node
  29666. */
  29667. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29668. /**
  29669. * Remove an attached behavior
  29670. * @see http://doc.babylonjs.com/features/behaviour
  29671. * @param behavior defines the behavior to attach
  29672. * @returns the current Node
  29673. */
  29674. removeBehavior(behavior: Behavior<Node>): Node;
  29675. /**
  29676. * Gets the list of attached behaviors
  29677. * @see http://doc.babylonjs.com/features/behaviour
  29678. */
  29679. get behaviors(): Behavior<Node>[];
  29680. /**
  29681. * Gets an attached behavior by name
  29682. * @param name defines the name of the behavior to look for
  29683. * @see http://doc.babylonjs.com/features/behaviour
  29684. * @returns null if behavior was not found else the requested behavior
  29685. */
  29686. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29687. /**
  29688. * Returns the latest update of the World matrix
  29689. * @returns a Matrix
  29690. */
  29691. getWorldMatrix(): Matrix;
  29692. /** @hidden */
  29693. _getWorldMatrixDeterminant(): number;
  29694. /**
  29695. * Returns directly the latest state of the mesh World matrix.
  29696. * A Matrix is returned.
  29697. */
  29698. get worldMatrixFromCache(): Matrix;
  29699. /** @hidden */
  29700. _initCache(): void;
  29701. /** @hidden */
  29702. updateCache(force?: boolean): void;
  29703. /** @hidden */
  29704. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29705. /** @hidden */
  29706. _updateCache(ignoreParentClass?: boolean): void;
  29707. /** @hidden */
  29708. _isSynchronized(): boolean;
  29709. /** @hidden */
  29710. _markSyncedWithParent(): void;
  29711. /** @hidden */
  29712. isSynchronizedWithParent(): boolean;
  29713. /** @hidden */
  29714. isSynchronized(): boolean;
  29715. /**
  29716. * Is this node ready to be used/rendered
  29717. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29718. * @return true if the node is ready
  29719. */
  29720. isReady(completeCheck?: boolean): boolean;
  29721. /**
  29722. * Is this node enabled?
  29723. * 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
  29724. * @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
  29725. * @return whether this node (and its parent) is enabled
  29726. */
  29727. isEnabled(checkAncestors?: boolean): boolean;
  29728. /** @hidden */
  29729. protected _syncParentEnabledState(): void;
  29730. /**
  29731. * Set the enabled state of this node
  29732. * @param value defines the new enabled state
  29733. */
  29734. setEnabled(value: boolean): void;
  29735. /**
  29736. * Is this node a descendant of the given node?
  29737. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29738. * @param ancestor defines the parent node to inspect
  29739. * @returns a boolean indicating if this node is a descendant of the given node
  29740. */
  29741. isDescendantOf(ancestor: Node): boolean;
  29742. /** @hidden */
  29743. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29744. /**
  29745. * Will return all nodes that have this node as ascendant
  29746. * @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
  29747. * @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
  29748. * @return all children nodes of all types
  29749. */
  29750. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29751. /**
  29752. * Get all child-meshes of this node
  29753. * @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)
  29754. * @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
  29755. * @returns an array of AbstractMesh
  29756. */
  29757. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29758. /**
  29759. * Get all direct children of this node
  29760. * @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
  29761. * @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)
  29762. * @returns an array of Node
  29763. */
  29764. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29765. /** @hidden */
  29766. _setReady(state: boolean): void;
  29767. /**
  29768. * Get an animation by name
  29769. * @param name defines the name of the animation to look for
  29770. * @returns null if not found else the requested animation
  29771. */
  29772. getAnimationByName(name: string): Nullable<Animation>;
  29773. /**
  29774. * Creates an animation range for this node
  29775. * @param name defines the name of the range
  29776. * @param from defines the starting key
  29777. * @param to defines the end key
  29778. */
  29779. createAnimationRange(name: string, from: number, to: number): void;
  29780. /**
  29781. * Delete a specific animation range
  29782. * @param name defines the name of the range to delete
  29783. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29784. */
  29785. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29786. /**
  29787. * Get an animation range by name
  29788. * @param name defines the name of the animation range to look for
  29789. * @returns null if not found else the requested animation range
  29790. */
  29791. getAnimationRange(name: string): Nullable<AnimationRange>;
  29792. /**
  29793. * Gets the list of all animation ranges defined on this node
  29794. * @returns an array
  29795. */
  29796. getAnimationRanges(): Nullable<AnimationRange>[];
  29797. /**
  29798. * Will start the animation sequence
  29799. * @param name defines the range frames for animation sequence
  29800. * @param loop defines if the animation should loop (false by default)
  29801. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29802. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29803. * @returns the object created for this animation. If range does not exist, it will return null
  29804. */
  29805. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29806. /**
  29807. * Serialize animation ranges into a JSON compatible object
  29808. * @returns serialization object
  29809. */
  29810. serializeAnimationRanges(): any;
  29811. /**
  29812. * Computes the world matrix of the node
  29813. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29814. * @returns the world matrix
  29815. */
  29816. computeWorldMatrix(force?: boolean): Matrix;
  29817. /**
  29818. * Releases resources associated with this node.
  29819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29821. */
  29822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29823. /**
  29824. * Parse animation range data from a serialization object and store them into a given node
  29825. * @param node defines where to store the animation ranges
  29826. * @param parsedNode defines the serialization object to read data from
  29827. * @param scene defines the hosting scene
  29828. */
  29829. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29830. /**
  29831. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29832. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29833. * @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
  29834. * @returns the new bounding vectors
  29835. */
  29836. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29837. min: Vector3;
  29838. max: Vector3;
  29839. };
  29840. }
  29841. }
  29842. declare module "babylonjs/Animations/animation" {
  29843. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29844. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29845. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29846. import { Nullable } from "babylonjs/types";
  29847. import { Scene } from "babylonjs/scene";
  29848. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29849. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29850. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29851. import { Node } from "babylonjs/node";
  29852. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29853. import { Size } from "babylonjs/Maths/math.size";
  29854. import { Animatable } from "babylonjs/Animations/animatable";
  29855. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29856. /**
  29857. * @hidden
  29858. */
  29859. export class _IAnimationState {
  29860. key: number;
  29861. repeatCount: number;
  29862. workValue?: any;
  29863. loopMode?: number;
  29864. offsetValue?: any;
  29865. highLimitValue?: any;
  29866. }
  29867. /**
  29868. * Class used to store any kind of animation
  29869. */
  29870. export class Animation {
  29871. /**Name of the animation */
  29872. name: string;
  29873. /**Property to animate */
  29874. targetProperty: string;
  29875. /**The frames per second of the animation */
  29876. framePerSecond: number;
  29877. /**The data type of the animation */
  29878. dataType: number;
  29879. /**The loop mode of the animation */
  29880. loopMode?: number | undefined;
  29881. /**Specifies if blending should be enabled */
  29882. enableBlending?: boolean | undefined;
  29883. /**
  29884. * Use matrix interpolation instead of using direct key value when animating matrices
  29885. */
  29886. static AllowMatricesInterpolation: boolean;
  29887. /**
  29888. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29889. */
  29890. static AllowMatrixDecomposeForInterpolation: boolean;
  29891. /**
  29892. * Stores the key frames of the animation
  29893. */
  29894. private _keys;
  29895. /**
  29896. * Stores the easing function of the animation
  29897. */
  29898. private _easingFunction;
  29899. /**
  29900. * @hidden Internal use only
  29901. */
  29902. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29903. /**
  29904. * The set of event that will be linked to this animation
  29905. */
  29906. private _events;
  29907. /**
  29908. * Stores an array of target property paths
  29909. */
  29910. targetPropertyPath: string[];
  29911. /**
  29912. * Stores the blending speed of the animation
  29913. */
  29914. blendingSpeed: number;
  29915. /**
  29916. * Stores the animation ranges for the animation
  29917. */
  29918. private _ranges;
  29919. /**
  29920. * @hidden Internal use
  29921. */
  29922. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29923. /**
  29924. * Sets up an animation
  29925. * @param property The property to animate
  29926. * @param animationType The animation type to apply
  29927. * @param framePerSecond The frames per second of the animation
  29928. * @param easingFunction The easing function used in the animation
  29929. * @returns The created animation
  29930. */
  29931. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29932. /**
  29933. * Create and start an animation on a node
  29934. * @param name defines the name of the global animation that will be run on all nodes
  29935. * @param node defines the root node where the animation will take place
  29936. * @param targetProperty defines property to animate
  29937. * @param framePerSecond defines the number of frame per second yo use
  29938. * @param totalFrame defines the number of frames in total
  29939. * @param from defines the initial value
  29940. * @param to defines the final value
  29941. * @param loopMode defines which loop mode you want to use (off by default)
  29942. * @param easingFunction defines the easing function to use (linear by default)
  29943. * @param onAnimationEnd defines the callback to call when animation end
  29944. * @returns the animatable created for this animation
  29945. */
  29946. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29947. /**
  29948. * Create and start an animation on a node and its descendants
  29949. * @param name defines the name of the global animation that will be run on all nodes
  29950. * @param node defines the root node where the animation will take place
  29951. * @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
  29952. * @param targetProperty defines property to animate
  29953. * @param framePerSecond defines the number of frame per second to use
  29954. * @param totalFrame defines the number of frames in total
  29955. * @param from defines the initial value
  29956. * @param to defines the final value
  29957. * @param loopMode defines which loop mode you want to use (off by default)
  29958. * @param easingFunction defines the easing function to use (linear by default)
  29959. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29960. * @returns the list of animatables created for all nodes
  29961. * @example https://www.babylonjs-playground.com/#MH0VLI
  29962. */
  29963. 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[]>;
  29964. /**
  29965. * Creates a new animation, merges it with the existing animations and starts it
  29966. * @param name Name of the animation
  29967. * @param node Node which contains the scene that begins the animations
  29968. * @param targetProperty Specifies which property to animate
  29969. * @param framePerSecond The frames per second of the animation
  29970. * @param totalFrame The total number of frames
  29971. * @param from The frame at the beginning of the animation
  29972. * @param to The frame at the end of the animation
  29973. * @param loopMode Specifies the loop mode of the animation
  29974. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29975. * @param onAnimationEnd Callback to run once the animation is complete
  29976. * @returns Nullable animation
  29977. */
  29978. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29979. /**
  29980. * Transition property of an host to the target Value
  29981. * @param property The property to transition
  29982. * @param targetValue The target Value of the property
  29983. * @param host The object where the property to animate belongs
  29984. * @param scene Scene used to run the animation
  29985. * @param frameRate Framerate (in frame/s) to use
  29986. * @param transition The transition type we want to use
  29987. * @param duration The duration of the animation, in milliseconds
  29988. * @param onAnimationEnd Callback trigger at the end of the animation
  29989. * @returns Nullable animation
  29990. */
  29991. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29992. /**
  29993. * Return the array of runtime animations currently using this animation
  29994. */
  29995. get runtimeAnimations(): RuntimeAnimation[];
  29996. /**
  29997. * Specifies if any of the runtime animations are currently running
  29998. */
  29999. get hasRunningRuntimeAnimations(): boolean;
  30000. /**
  30001. * Initializes the animation
  30002. * @param name Name of the animation
  30003. * @param targetProperty Property to animate
  30004. * @param framePerSecond The frames per second of the animation
  30005. * @param dataType The data type of the animation
  30006. * @param loopMode The loop mode of the animation
  30007. * @param enableBlending Specifies if blending should be enabled
  30008. */
  30009. constructor(
  30010. /**Name of the animation */
  30011. name: string,
  30012. /**Property to animate */
  30013. targetProperty: string,
  30014. /**The frames per second of the animation */
  30015. framePerSecond: number,
  30016. /**The data type of the animation */
  30017. dataType: number,
  30018. /**The loop mode of the animation */
  30019. loopMode?: number | undefined,
  30020. /**Specifies if blending should be enabled */
  30021. enableBlending?: boolean | undefined);
  30022. /**
  30023. * Converts the animation to a string
  30024. * @param fullDetails support for multiple levels of logging within scene loading
  30025. * @returns String form of the animation
  30026. */
  30027. toString(fullDetails?: boolean): string;
  30028. /**
  30029. * Add an event to this animation
  30030. * @param event Event to add
  30031. */
  30032. addEvent(event: AnimationEvent): void;
  30033. /**
  30034. * Remove all events found at the given frame
  30035. * @param frame The frame to remove events from
  30036. */
  30037. removeEvents(frame: number): void;
  30038. /**
  30039. * Retrieves all the events from the animation
  30040. * @returns Events from the animation
  30041. */
  30042. getEvents(): AnimationEvent[];
  30043. /**
  30044. * Creates an animation range
  30045. * @param name Name of the animation range
  30046. * @param from Starting frame of the animation range
  30047. * @param to Ending frame of the animation
  30048. */
  30049. createRange(name: string, from: number, to: number): void;
  30050. /**
  30051. * Deletes an animation range by name
  30052. * @param name Name of the animation range to delete
  30053. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30054. */
  30055. deleteRange(name: string, deleteFrames?: boolean): void;
  30056. /**
  30057. * Gets the animation range by name, or null if not defined
  30058. * @param name Name of the animation range
  30059. * @returns Nullable animation range
  30060. */
  30061. getRange(name: string): Nullable<AnimationRange>;
  30062. /**
  30063. * Gets the key frames from the animation
  30064. * @returns The key frames of the animation
  30065. */
  30066. getKeys(): Array<IAnimationKey>;
  30067. /**
  30068. * Gets the highest frame rate of the animation
  30069. * @returns Highest frame rate of the animation
  30070. */
  30071. getHighestFrame(): number;
  30072. /**
  30073. * Gets the easing function of the animation
  30074. * @returns Easing function of the animation
  30075. */
  30076. getEasingFunction(): IEasingFunction;
  30077. /**
  30078. * Sets the easing function of the animation
  30079. * @param easingFunction A custom mathematical formula for animation
  30080. */
  30081. setEasingFunction(easingFunction: EasingFunction): void;
  30082. /**
  30083. * Interpolates a scalar linearly
  30084. * @param startValue Start value of the animation curve
  30085. * @param endValue End value of the animation curve
  30086. * @param gradient Scalar amount to interpolate
  30087. * @returns Interpolated scalar value
  30088. */
  30089. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30090. /**
  30091. * Interpolates a scalar cubically
  30092. * @param startValue Start value of the animation curve
  30093. * @param outTangent End tangent of the animation
  30094. * @param endValue End value of the animation curve
  30095. * @param inTangent Start tangent of the animation curve
  30096. * @param gradient Scalar amount to interpolate
  30097. * @returns Interpolated scalar value
  30098. */
  30099. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30100. /**
  30101. * Interpolates a quaternion using a spherical linear interpolation
  30102. * @param startValue Start value of the animation curve
  30103. * @param endValue End value of the animation curve
  30104. * @param gradient Scalar amount to interpolate
  30105. * @returns Interpolated quaternion value
  30106. */
  30107. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30108. /**
  30109. * Interpolates a quaternion cubically
  30110. * @param startValue Start value of the animation curve
  30111. * @param outTangent End tangent of the animation curve
  30112. * @param endValue End value of the animation curve
  30113. * @param inTangent Start tangent of the animation curve
  30114. * @param gradient Scalar amount to interpolate
  30115. * @returns Interpolated quaternion value
  30116. */
  30117. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30118. /**
  30119. * Interpolates a Vector3 linearl
  30120. * @param startValue Start value of the animation curve
  30121. * @param endValue End value of the animation curve
  30122. * @param gradient Scalar amount to interpolate
  30123. * @returns Interpolated scalar value
  30124. */
  30125. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30126. /**
  30127. * Interpolates a Vector3 cubically
  30128. * @param startValue Start value of the animation curve
  30129. * @param outTangent End tangent of the animation
  30130. * @param endValue End value of the animation curve
  30131. * @param inTangent Start tangent of the animation curve
  30132. * @param gradient Scalar amount to interpolate
  30133. * @returns InterpolatedVector3 value
  30134. */
  30135. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30136. /**
  30137. * Interpolates a Vector2 linearly
  30138. * @param startValue Start value of the animation curve
  30139. * @param endValue End value of the animation curve
  30140. * @param gradient Scalar amount to interpolate
  30141. * @returns Interpolated Vector2 value
  30142. */
  30143. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30144. /**
  30145. * Interpolates a Vector2 cubically
  30146. * @param startValue Start value of the animation curve
  30147. * @param outTangent End tangent of the animation
  30148. * @param endValue End value of the animation curve
  30149. * @param inTangent Start tangent of the animation curve
  30150. * @param gradient Scalar amount to interpolate
  30151. * @returns Interpolated Vector2 value
  30152. */
  30153. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30154. /**
  30155. * Interpolates a size linearly
  30156. * @param startValue Start value of the animation curve
  30157. * @param endValue End value of the animation curve
  30158. * @param gradient Scalar amount to interpolate
  30159. * @returns Interpolated Size value
  30160. */
  30161. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30162. /**
  30163. * Interpolates a Color3 linearly
  30164. * @param startValue Start value of the animation curve
  30165. * @param endValue End value of the animation curve
  30166. * @param gradient Scalar amount to interpolate
  30167. * @returns Interpolated Color3 value
  30168. */
  30169. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30170. /**
  30171. * Interpolates a Color4 linearly
  30172. * @param startValue Start value of the animation curve
  30173. * @param endValue End value of the animation curve
  30174. * @param gradient Scalar amount to interpolate
  30175. * @returns Interpolated Color3 value
  30176. */
  30177. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30178. /**
  30179. * @hidden Internal use only
  30180. */
  30181. _getKeyValue(value: any): any;
  30182. /**
  30183. * @hidden Internal use only
  30184. */
  30185. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30186. /**
  30187. * Defines the function to use to interpolate matrices
  30188. * @param startValue defines the start matrix
  30189. * @param endValue defines the end matrix
  30190. * @param gradient defines the gradient between both matrices
  30191. * @param result defines an optional target matrix where to store the interpolation
  30192. * @returns the interpolated matrix
  30193. */
  30194. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30195. /**
  30196. * Makes a copy of the animation
  30197. * @returns Cloned animation
  30198. */
  30199. clone(): Animation;
  30200. /**
  30201. * Sets the key frames of the animation
  30202. * @param values The animation key frames to set
  30203. */
  30204. setKeys(values: Array<IAnimationKey>): void;
  30205. /**
  30206. * Serializes the animation to an object
  30207. * @returns Serialized object
  30208. */
  30209. serialize(): any;
  30210. /**
  30211. * Float animation type
  30212. */
  30213. static readonly ANIMATIONTYPE_FLOAT: number;
  30214. /**
  30215. * Vector3 animation type
  30216. */
  30217. static readonly ANIMATIONTYPE_VECTOR3: number;
  30218. /**
  30219. * Quaternion animation type
  30220. */
  30221. static readonly ANIMATIONTYPE_QUATERNION: number;
  30222. /**
  30223. * Matrix animation type
  30224. */
  30225. static readonly ANIMATIONTYPE_MATRIX: number;
  30226. /**
  30227. * Color3 animation type
  30228. */
  30229. static readonly ANIMATIONTYPE_COLOR3: number;
  30230. /**
  30231. * Color3 animation type
  30232. */
  30233. static readonly ANIMATIONTYPE_COLOR4: number;
  30234. /**
  30235. * Vector2 animation type
  30236. */
  30237. static readonly ANIMATIONTYPE_VECTOR2: number;
  30238. /**
  30239. * Size animation type
  30240. */
  30241. static readonly ANIMATIONTYPE_SIZE: number;
  30242. /**
  30243. * Relative Loop Mode
  30244. */
  30245. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30246. /**
  30247. * Cycle Loop Mode
  30248. */
  30249. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30250. /**
  30251. * Constant Loop Mode
  30252. */
  30253. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30254. /** @hidden */
  30255. static _UniversalLerp(left: any, right: any, amount: number): any;
  30256. /**
  30257. * Parses an animation object and creates an animation
  30258. * @param parsedAnimation Parsed animation object
  30259. * @returns Animation object
  30260. */
  30261. static Parse(parsedAnimation: any): Animation;
  30262. /**
  30263. * Appends the serialized animations from the source animations
  30264. * @param source Source containing the animations
  30265. * @param destination Target to store the animations
  30266. */
  30267. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30268. }
  30269. }
  30270. declare module "babylonjs/Animations/animatable.interface" {
  30271. import { Nullable } from "babylonjs/types";
  30272. import { Animation } from "babylonjs/Animations/animation";
  30273. /**
  30274. * Interface containing an array of animations
  30275. */
  30276. export interface IAnimatable {
  30277. /**
  30278. * Array of animations
  30279. */
  30280. animations: Nullable<Array<Animation>>;
  30281. }
  30282. }
  30283. declare module "babylonjs/Misc/decorators" {
  30284. import { Nullable } from "babylonjs/types";
  30285. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30286. import { Scene } from "babylonjs/scene";
  30287. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30288. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30289. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30290. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30291. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30292. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30293. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30294. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30295. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30296. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30297. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30298. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30299. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30300. /**
  30301. * Decorator used to define property that can be serialized as reference to a camera
  30302. * @param sourceName defines the name of the property to decorate
  30303. */
  30304. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30305. /**
  30306. * Class used to help serialization objects
  30307. */
  30308. export class SerializationHelper {
  30309. /** @hidden */
  30310. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30311. /** @hidden */
  30312. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30313. /** @hidden */
  30314. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30315. /** @hidden */
  30316. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30317. /**
  30318. * Appends the serialized animations from the source animations
  30319. * @param source Source containing the animations
  30320. * @param destination Target to store the animations
  30321. */
  30322. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30323. /**
  30324. * Static function used to serialized a specific entity
  30325. * @param entity defines the entity to serialize
  30326. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30327. * @returns a JSON compatible object representing the serialization of the entity
  30328. */
  30329. static Serialize<T>(entity: T, serializationObject?: any): any;
  30330. /**
  30331. * Creates a new entity from a serialization data object
  30332. * @param creationFunction defines a function used to instanciated the new entity
  30333. * @param source defines the source serialization data
  30334. * @param scene defines the hosting scene
  30335. * @param rootUrl defines the root url for resources
  30336. * @returns a new entity
  30337. */
  30338. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30339. /**
  30340. * Clones an object
  30341. * @param creationFunction defines the function used to instanciate the new object
  30342. * @param source defines the source object
  30343. * @returns the cloned object
  30344. */
  30345. static Clone<T>(creationFunction: () => T, source: T): T;
  30346. /**
  30347. * Instanciates a new object based on a source one (some data will be shared between both object)
  30348. * @param creationFunction defines the function used to instanciate the new object
  30349. * @param source defines the source object
  30350. * @returns the new object
  30351. */
  30352. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30353. }
  30354. }
  30355. declare module "babylonjs/Misc/guid" {
  30356. /**
  30357. * Class used to manipulate GUIDs
  30358. */
  30359. export class GUID {
  30360. /**
  30361. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30362. * Be aware Math.random() could cause collisions, but:
  30363. * "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"
  30364. * @returns a pseudo random id
  30365. */
  30366. static RandomId(): string;
  30367. }
  30368. }
  30369. declare module "babylonjs/Materials/Textures/baseTexture" {
  30370. import { Observable } from "babylonjs/Misc/observable";
  30371. import { Nullable } from "babylonjs/types";
  30372. import { Scene } from "babylonjs/scene";
  30373. import { Matrix } from "babylonjs/Maths/math.vector";
  30374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30375. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30376. import { ISize } from "babylonjs/Maths/math.size";
  30377. import "babylonjs/Misc/fileTools";
  30378. /**
  30379. * Base class of all the textures in babylon.
  30380. * It groups all the common properties the materials, post process, lights... might need
  30381. * in order to make a correct use of the texture.
  30382. */
  30383. export class BaseTexture implements IAnimatable {
  30384. /**
  30385. * Default anisotropic filtering level for the application.
  30386. * It is set to 4 as a good tradeoff between perf and quality.
  30387. */
  30388. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30389. /**
  30390. * Gets or sets the unique id of the texture
  30391. */
  30392. uniqueId: number;
  30393. /**
  30394. * Define the name of the texture.
  30395. */
  30396. name: string;
  30397. /**
  30398. * Gets or sets an object used to store user defined information.
  30399. */
  30400. metadata: any;
  30401. /**
  30402. * For internal use only. Please do not use.
  30403. */
  30404. reservedDataStore: any;
  30405. private _hasAlpha;
  30406. /**
  30407. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30408. */
  30409. set hasAlpha(value: boolean);
  30410. get hasAlpha(): boolean;
  30411. /**
  30412. * Defines if the alpha value should be determined via the rgb values.
  30413. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30414. */
  30415. getAlphaFromRGB: boolean;
  30416. /**
  30417. * Intensity or strength of the texture.
  30418. * It is commonly used by materials to fine tune the intensity of the texture
  30419. */
  30420. level: number;
  30421. /**
  30422. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30423. * This is part of the texture as textures usually maps to one uv set.
  30424. */
  30425. coordinatesIndex: number;
  30426. private _coordinatesMode;
  30427. /**
  30428. * How a texture is mapped.
  30429. *
  30430. * | Value | Type | Description |
  30431. * | ----- | ----------------------------------- | ----------- |
  30432. * | 0 | EXPLICIT_MODE | |
  30433. * | 1 | SPHERICAL_MODE | |
  30434. * | 2 | PLANAR_MODE | |
  30435. * | 3 | CUBIC_MODE | |
  30436. * | 4 | PROJECTION_MODE | |
  30437. * | 5 | SKYBOX_MODE | |
  30438. * | 6 | INVCUBIC_MODE | |
  30439. * | 7 | EQUIRECTANGULAR_MODE | |
  30440. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30441. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30442. */
  30443. set coordinatesMode(value: number);
  30444. get coordinatesMode(): number;
  30445. /**
  30446. * | Value | Type | Description |
  30447. * | ----- | ------------------ | ----------- |
  30448. * | 0 | CLAMP_ADDRESSMODE | |
  30449. * | 1 | WRAP_ADDRESSMODE | |
  30450. * | 2 | MIRROR_ADDRESSMODE | |
  30451. */
  30452. wrapU: number;
  30453. /**
  30454. * | Value | Type | Description |
  30455. * | ----- | ------------------ | ----------- |
  30456. * | 0 | CLAMP_ADDRESSMODE | |
  30457. * | 1 | WRAP_ADDRESSMODE | |
  30458. * | 2 | MIRROR_ADDRESSMODE | |
  30459. */
  30460. wrapV: number;
  30461. /**
  30462. * | Value | Type | Description |
  30463. * | ----- | ------------------ | ----------- |
  30464. * | 0 | CLAMP_ADDRESSMODE | |
  30465. * | 1 | WRAP_ADDRESSMODE | |
  30466. * | 2 | MIRROR_ADDRESSMODE | |
  30467. */
  30468. wrapR: number;
  30469. /**
  30470. * With compliant hardware and browser (supporting anisotropic filtering)
  30471. * this defines the level of anisotropic filtering in the texture.
  30472. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30473. */
  30474. anisotropicFilteringLevel: number;
  30475. /**
  30476. * Define if the texture is a cube texture or if false a 2d texture.
  30477. */
  30478. get isCube(): boolean;
  30479. set isCube(value: boolean);
  30480. /**
  30481. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30482. */
  30483. get is3D(): boolean;
  30484. set is3D(value: boolean);
  30485. /**
  30486. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30487. */
  30488. get is2DArray(): boolean;
  30489. set is2DArray(value: boolean);
  30490. /**
  30491. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30492. * HDR texture are usually stored in linear space.
  30493. * This only impacts the PBR and Background materials
  30494. */
  30495. gammaSpace: boolean;
  30496. /**
  30497. * Gets or sets whether or not the texture contains RGBD data.
  30498. */
  30499. get isRGBD(): boolean;
  30500. set isRGBD(value: boolean);
  30501. /**
  30502. * Is Z inverted in the texture (useful in a cube texture).
  30503. */
  30504. invertZ: boolean;
  30505. /**
  30506. * Are mip maps generated for this texture or not.
  30507. */
  30508. get noMipmap(): boolean;
  30509. /**
  30510. * @hidden
  30511. */
  30512. lodLevelInAlpha: boolean;
  30513. /**
  30514. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30515. */
  30516. get lodGenerationOffset(): number;
  30517. set lodGenerationOffset(value: number);
  30518. /**
  30519. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30520. */
  30521. get lodGenerationScale(): number;
  30522. set lodGenerationScale(value: number);
  30523. /**
  30524. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30525. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30526. * average roughness values.
  30527. */
  30528. get linearSpecularLOD(): boolean;
  30529. set linearSpecularLOD(value: boolean);
  30530. /**
  30531. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30532. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30533. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30534. */
  30535. get irradianceTexture(): Nullable<BaseTexture>;
  30536. set irradianceTexture(value: Nullable<BaseTexture>);
  30537. /**
  30538. * Define if the texture is a render target.
  30539. */
  30540. isRenderTarget: boolean;
  30541. /**
  30542. * Define the unique id of the texture in the scene.
  30543. */
  30544. get uid(): string;
  30545. /**
  30546. * Return a string representation of the texture.
  30547. * @returns the texture as a string
  30548. */
  30549. toString(): string;
  30550. /**
  30551. * Get the class name of the texture.
  30552. * @returns "BaseTexture"
  30553. */
  30554. getClassName(): string;
  30555. /**
  30556. * Define the list of animation attached to the texture.
  30557. */
  30558. animations: import("babylonjs/Animations/animation").Animation[];
  30559. /**
  30560. * An event triggered when the texture is disposed.
  30561. */
  30562. onDisposeObservable: Observable<BaseTexture>;
  30563. private _onDisposeObserver;
  30564. /**
  30565. * Callback triggered when the texture has been disposed.
  30566. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30567. */
  30568. set onDispose(callback: () => void);
  30569. /**
  30570. * Define the current state of the loading sequence when in delayed load mode.
  30571. */
  30572. delayLoadState: number;
  30573. private _scene;
  30574. /** @hidden */
  30575. _texture: Nullable<InternalTexture>;
  30576. private _uid;
  30577. /**
  30578. * Define if the texture is preventinga material to render or not.
  30579. * If not and the texture is not ready, the engine will use a default black texture instead.
  30580. */
  30581. get isBlocking(): boolean;
  30582. /**
  30583. * Instantiates a new BaseTexture.
  30584. * Base class of all the textures in babylon.
  30585. * It groups all the common properties the materials, post process, lights... might need
  30586. * in order to make a correct use of the texture.
  30587. * @param scene Define the scene the texture blongs to
  30588. */
  30589. constructor(scene: Nullable<Scene>);
  30590. /**
  30591. * Get the scene the texture belongs to.
  30592. * @returns the scene or null if undefined
  30593. */
  30594. getScene(): Nullable<Scene>;
  30595. /**
  30596. * Get the texture transform matrix used to offset tile the texture for istance.
  30597. * @returns the transformation matrix
  30598. */
  30599. getTextureMatrix(): Matrix;
  30600. /**
  30601. * Get the texture reflection matrix used to rotate/transform the reflection.
  30602. * @returns the reflection matrix
  30603. */
  30604. getReflectionTextureMatrix(): Matrix;
  30605. /**
  30606. * Get the underlying lower level texture from Babylon.
  30607. * @returns the insternal texture
  30608. */
  30609. getInternalTexture(): Nullable<InternalTexture>;
  30610. /**
  30611. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30612. * @returns true if ready or not blocking
  30613. */
  30614. isReadyOrNotBlocking(): boolean;
  30615. /**
  30616. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30617. * @returns true if fully ready
  30618. */
  30619. isReady(): boolean;
  30620. private _cachedSize;
  30621. /**
  30622. * Get the size of the texture.
  30623. * @returns the texture size.
  30624. */
  30625. getSize(): ISize;
  30626. /**
  30627. * Get the base size of the texture.
  30628. * It can be different from the size if the texture has been resized for POT for instance
  30629. * @returns the base size
  30630. */
  30631. getBaseSize(): ISize;
  30632. /**
  30633. * Update the sampling mode of the texture.
  30634. * Default is Trilinear mode.
  30635. *
  30636. * | Value | Type | Description |
  30637. * | ----- | ------------------ | ----------- |
  30638. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30639. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30640. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30641. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30642. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30643. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30644. * | 7 | NEAREST_LINEAR | |
  30645. * | 8 | NEAREST_NEAREST | |
  30646. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30647. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30648. * | 11 | LINEAR_LINEAR | |
  30649. * | 12 | LINEAR_NEAREST | |
  30650. *
  30651. * > _mag_: magnification filter (close to the viewer)
  30652. * > _min_: minification filter (far from the viewer)
  30653. * > _mip_: filter used between mip map levels
  30654. *@param samplingMode Define the new sampling mode of the texture
  30655. */
  30656. updateSamplingMode(samplingMode: number): void;
  30657. /**
  30658. * Scales the texture if is `canRescale()`
  30659. * @param ratio the resize factor we want to use to rescale
  30660. */
  30661. scale(ratio: number): void;
  30662. /**
  30663. * Get if the texture can rescale.
  30664. */
  30665. get canRescale(): boolean;
  30666. /** @hidden */
  30667. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30668. /** @hidden */
  30669. _rebuild(): void;
  30670. /**
  30671. * Triggers the load sequence in delayed load mode.
  30672. */
  30673. delayLoad(): void;
  30674. /**
  30675. * Clones the texture.
  30676. * @returns the cloned texture
  30677. */
  30678. clone(): Nullable<BaseTexture>;
  30679. /**
  30680. * Get the texture underlying type (INT, FLOAT...)
  30681. */
  30682. get textureType(): number;
  30683. /**
  30684. * Get the texture underlying format (RGB, RGBA...)
  30685. */
  30686. get textureFormat(): number;
  30687. /**
  30688. * Indicates that textures need to be re-calculated for all materials
  30689. */
  30690. protected _markAllSubMeshesAsTexturesDirty(): void;
  30691. /**
  30692. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30693. * This will returns an RGBA array buffer containing either in values (0-255) or
  30694. * float values (0-1) depending of the underlying buffer type.
  30695. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30696. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30697. * @param buffer defines a user defined buffer to fill with data (can be null)
  30698. * @returns The Array buffer containing the pixels data.
  30699. */
  30700. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30701. /**
  30702. * Release and destroy the underlying lower level texture aka internalTexture.
  30703. */
  30704. releaseInternalTexture(): void;
  30705. /** @hidden */
  30706. get _lodTextureHigh(): Nullable<BaseTexture>;
  30707. /** @hidden */
  30708. get _lodTextureMid(): Nullable<BaseTexture>;
  30709. /** @hidden */
  30710. get _lodTextureLow(): Nullable<BaseTexture>;
  30711. /**
  30712. * Dispose the texture and release its associated resources.
  30713. */
  30714. dispose(): void;
  30715. /**
  30716. * Serialize the texture into a JSON representation that can be parsed later on.
  30717. * @returns the JSON representation of the texture
  30718. */
  30719. serialize(): any;
  30720. /**
  30721. * Helper function to be called back once a list of texture contains only ready textures.
  30722. * @param textures Define the list of textures to wait for
  30723. * @param callback Define the callback triggered once the entire list will be ready
  30724. */
  30725. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30726. }
  30727. }
  30728. declare module "babylonjs/Materials/effect" {
  30729. import { Observable } from "babylonjs/Misc/observable";
  30730. import { Nullable } from "babylonjs/types";
  30731. import { IDisposable } from "babylonjs/scene";
  30732. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30733. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30734. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30735. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30736. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30737. import { Engine } from "babylonjs/Engines/engine";
  30738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30741. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30742. /**
  30743. * Options to be used when creating an effect.
  30744. */
  30745. export interface IEffectCreationOptions {
  30746. /**
  30747. * Atrributes that will be used in the shader.
  30748. */
  30749. attributes: string[];
  30750. /**
  30751. * Uniform varible names that will be set in the shader.
  30752. */
  30753. uniformsNames: string[];
  30754. /**
  30755. * Uniform buffer variable names that will be set in the shader.
  30756. */
  30757. uniformBuffersNames: string[];
  30758. /**
  30759. * Sampler texture variable names that will be set in the shader.
  30760. */
  30761. samplers: string[];
  30762. /**
  30763. * Define statements that will be set in the shader.
  30764. */
  30765. defines: any;
  30766. /**
  30767. * Possible fallbacks for this effect to improve performance when needed.
  30768. */
  30769. fallbacks: Nullable<IEffectFallbacks>;
  30770. /**
  30771. * Callback that will be called when the shader is compiled.
  30772. */
  30773. onCompiled: Nullable<(effect: Effect) => void>;
  30774. /**
  30775. * Callback that will be called if an error occurs during shader compilation.
  30776. */
  30777. onError: Nullable<(effect: Effect, errors: string) => void>;
  30778. /**
  30779. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30780. */
  30781. indexParameters?: any;
  30782. /**
  30783. * Max number of lights that can be used in the shader.
  30784. */
  30785. maxSimultaneousLights?: number;
  30786. /**
  30787. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30788. */
  30789. transformFeedbackVaryings?: Nullable<string[]>;
  30790. }
  30791. /**
  30792. * Effect containing vertex and fragment shader that can be executed on an object.
  30793. */
  30794. export class Effect implements IDisposable {
  30795. /**
  30796. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30797. */
  30798. static ShadersRepository: string;
  30799. /**
  30800. * Name of the effect.
  30801. */
  30802. name: any;
  30803. /**
  30804. * String container all the define statements that should be set on the shader.
  30805. */
  30806. defines: string;
  30807. /**
  30808. * Callback that will be called when the shader is compiled.
  30809. */
  30810. onCompiled: Nullable<(effect: Effect) => void>;
  30811. /**
  30812. * Callback that will be called if an error occurs during shader compilation.
  30813. */
  30814. onError: Nullable<(effect: Effect, errors: string) => void>;
  30815. /**
  30816. * Callback that will be called when effect is bound.
  30817. */
  30818. onBind: Nullable<(effect: Effect) => void>;
  30819. /**
  30820. * Unique ID of the effect.
  30821. */
  30822. uniqueId: number;
  30823. /**
  30824. * Observable that will be called when the shader is compiled.
  30825. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30826. */
  30827. onCompileObservable: Observable<Effect>;
  30828. /**
  30829. * Observable that will be called if an error occurs during shader compilation.
  30830. */
  30831. onErrorObservable: Observable<Effect>;
  30832. /** @hidden */
  30833. _onBindObservable: Nullable<Observable<Effect>>;
  30834. /**
  30835. * @hidden
  30836. * Specifies if the effect was previously ready
  30837. */
  30838. _wasPreviouslyReady: boolean;
  30839. /**
  30840. * Observable that will be called when effect is bound.
  30841. */
  30842. get onBindObservable(): Observable<Effect>;
  30843. /** @hidden */
  30844. _bonesComputationForcedToCPU: boolean;
  30845. private static _uniqueIdSeed;
  30846. private _engine;
  30847. private _uniformBuffersNames;
  30848. private _uniformsNames;
  30849. private _samplerList;
  30850. private _samplers;
  30851. private _isReady;
  30852. private _compilationError;
  30853. private _allFallbacksProcessed;
  30854. private _attributesNames;
  30855. private _attributes;
  30856. private _attributeLocationByName;
  30857. private _uniforms;
  30858. /**
  30859. * Key for the effect.
  30860. * @hidden
  30861. */
  30862. _key: string;
  30863. private _indexParameters;
  30864. private _fallbacks;
  30865. private _vertexSourceCode;
  30866. private _fragmentSourceCode;
  30867. private _vertexSourceCodeOverride;
  30868. private _fragmentSourceCodeOverride;
  30869. private _transformFeedbackVaryings;
  30870. /**
  30871. * Compiled shader to webGL program.
  30872. * @hidden
  30873. */
  30874. _pipelineContext: Nullable<IPipelineContext>;
  30875. private _valueCache;
  30876. private static _baseCache;
  30877. /**
  30878. * Instantiates an effect.
  30879. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30880. * @param baseName Name of the effect.
  30881. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30882. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30883. * @param samplers List of sampler variables that will be passed to the shader.
  30884. * @param engine Engine to be used to render the effect
  30885. * @param defines Define statements to be added to the shader.
  30886. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30887. * @param onCompiled Callback that will be called when the shader is compiled.
  30888. * @param onError Callback that will be called if an error occurs during shader compilation.
  30889. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30890. */
  30891. 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);
  30892. private _useFinalCode;
  30893. /**
  30894. * Unique key for this effect
  30895. */
  30896. get key(): string;
  30897. /**
  30898. * If the effect has been compiled and prepared.
  30899. * @returns if the effect is compiled and prepared.
  30900. */
  30901. isReady(): boolean;
  30902. private _isReadyInternal;
  30903. /**
  30904. * The engine the effect was initialized with.
  30905. * @returns the engine.
  30906. */
  30907. getEngine(): Engine;
  30908. /**
  30909. * The pipeline context for this effect
  30910. * @returns the associated pipeline context
  30911. */
  30912. getPipelineContext(): Nullable<IPipelineContext>;
  30913. /**
  30914. * The set of names of attribute variables for the shader.
  30915. * @returns An array of attribute names.
  30916. */
  30917. getAttributesNames(): string[];
  30918. /**
  30919. * Returns the attribute at the given index.
  30920. * @param index The index of the attribute.
  30921. * @returns The location of the attribute.
  30922. */
  30923. getAttributeLocation(index: number): number;
  30924. /**
  30925. * Returns the attribute based on the name of the variable.
  30926. * @param name of the attribute to look up.
  30927. * @returns the attribute location.
  30928. */
  30929. getAttributeLocationByName(name: string): number;
  30930. /**
  30931. * The number of attributes.
  30932. * @returns the numnber of attributes.
  30933. */
  30934. getAttributesCount(): number;
  30935. /**
  30936. * Gets the index of a uniform variable.
  30937. * @param uniformName of the uniform to look up.
  30938. * @returns the index.
  30939. */
  30940. getUniformIndex(uniformName: string): number;
  30941. /**
  30942. * Returns the attribute based on the name of the variable.
  30943. * @param uniformName of the uniform to look up.
  30944. * @returns the location of the uniform.
  30945. */
  30946. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30947. /**
  30948. * Returns an array of sampler variable names
  30949. * @returns The array of sampler variable neames.
  30950. */
  30951. getSamplers(): string[];
  30952. /**
  30953. * The error from the last compilation.
  30954. * @returns the error string.
  30955. */
  30956. getCompilationError(): string;
  30957. /**
  30958. * Gets a boolean indicating that all fallbacks were used during compilation
  30959. * @returns true if all fallbacks were used
  30960. */
  30961. allFallbacksProcessed(): boolean;
  30962. /**
  30963. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30964. * @param func The callback to be used.
  30965. */
  30966. executeWhenCompiled(func: (effect: Effect) => void): void;
  30967. private _checkIsReady;
  30968. private _loadShader;
  30969. /**
  30970. * Recompiles the webGL program
  30971. * @param vertexSourceCode The source code for the vertex shader.
  30972. * @param fragmentSourceCode The source code for the fragment shader.
  30973. * @param onCompiled Callback called when completed.
  30974. * @param onError Callback called on error.
  30975. * @hidden
  30976. */
  30977. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30978. /**
  30979. * Prepares the effect
  30980. * @hidden
  30981. */
  30982. _prepareEffect(): void;
  30983. private _processCompilationErrors;
  30984. /**
  30985. * Checks if the effect is supported. (Must be called after compilation)
  30986. */
  30987. get isSupported(): boolean;
  30988. /**
  30989. * Binds a texture to the engine to be used as output of the shader.
  30990. * @param channel Name of the output variable.
  30991. * @param texture Texture to bind.
  30992. * @hidden
  30993. */
  30994. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30995. /**
  30996. * Sets a texture on the engine to be used in the shader.
  30997. * @param channel Name of the sampler variable.
  30998. * @param texture Texture to set.
  30999. */
  31000. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31001. /**
  31002. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31003. * @param channel Name of the sampler variable.
  31004. * @param texture Texture to set.
  31005. */
  31006. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31007. /**
  31008. * Sets an array of textures on the engine to be used in the shader.
  31009. * @param channel Name of the variable.
  31010. * @param textures Textures to set.
  31011. */
  31012. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31013. /**
  31014. * 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)
  31015. * @param channel Name of the sampler variable.
  31016. * @param postProcess Post process to get the input texture from.
  31017. */
  31018. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31019. /**
  31020. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31021. * 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)
  31022. * @param channel Name of the sampler variable.
  31023. * @param postProcess Post process to get the output texture from.
  31024. */
  31025. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31026. /** @hidden */
  31027. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31028. /** @hidden */
  31029. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31030. /** @hidden */
  31031. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31032. /** @hidden */
  31033. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31034. /**
  31035. * Binds a buffer to a uniform.
  31036. * @param buffer Buffer to bind.
  31037. * @param name Name of the uniform variable to bind to.
  31038. */
  31039. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31040. /**
  31041. * Binds block to a uniform.
  31042. * @param blockName Name of the block to bind.
  31043. * @param index Index to bind.
  31044. */
  31045. bindUniformBlock(blockName: string, index: number): void;
  31046. /**
  31047. * Sets an interger value on a uniform variable.
  31048. * @param uniformName Name of the variable.
  31049. * @param value Value to be set.
  31050. * @returns this effect.
  31051. */
  31052. setInt(uniformName: string, value: number): Effect;
  31053. /**
  31054. * Sets an int array on a uniform variable.
  31055. * @param uniformName Name of the variable.
  31056. * @param array array to be set.
  31057. * @returns this effect.
  31058. */
  31059. setIntArray(uniformName: string, array: Int32Array): Effect;
  31060. /**
  31061. * 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)
  31062. * @param uniformName Name of the variable.
  31063. * @param array array to be set.
  31064. * @returns this effect.
  31065. */
  31066. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31067. /**
  31068. * 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)
  31069. * @param uniformName Name of the variable.
  31070. * @param array array to be set.
  31071. * @returns this effect.
  31072. */
  31073. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31074. /**
  31075. * 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)
  31076. * @param uniformName Name of the variable.
  31077. * @param array array to be set.
  31078. * @returns this effect.
  31079. */
  31080. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31081. /**
  31082. * Sets an float array on a uniform variable.
  31083. * @param uniformName Name of the variable.
  31084. * @param array array to be set.
  31085. * @returns this effect.
  31086. */
  31087. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31088. /**
  31089. * 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)
  31090. * @param uniformName Name of the variable.
  31091. * @param array array to be set.
  31092. * @returns this effect.
  31093. */
  31094. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31095. /**
  31096. * 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)
  31097. * @param uniformName Name of the variable.
  31098. * @param array array to be set.
  31099. * @returns this effect.
  31100. */
  31101. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31102. /**
  31103. * 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)
  31104. * @param uniformName Name of the variable.
  31105. * @param array array to be set.
  31106. * @returns this effect.
  31107. */
  31108. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31109. /**
  31110. * Sets an array on a uniform variable.
  31111. * @param uniformName Name of the variable.
  31112. * @param array array to be set.
  31113. * @returns this effect.
  31114. */
  31115. setArray(uniformName: string, array: number[]): Effect;
  31116. /**
  31117. * 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)
  31118. * @param uniformName Name of the variable.
  31119. * @param array array to be set.
  31120. * @returns this effect.
  31121. */
  31122. setArray2(uniformName: string, array: number[]): Effect;
  31123. /**
  31124. * 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)
  31125. * @param uniformName Name of the variable.
  31126. * @param array array to be set.
  31127. * @returns this effect.
  31128. */
  31129. setArray3(uniformName: string, array: number[]): Effect;
  31130. /**
  31131. * 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)
  31132. * @param uniformName Name of the variable.
  31133. * @param array array to be set.
  31134. * @returns this effect.
  31135. */
  31136. setArray4(uniformName: string, array: number[]): Effect;
  31137. /**
  31138. * Sets matrices on a uniform variable.
  31139. * @param uniformName Name of the variable.
  31140. * @param matrices matrices to be set.
  31141. * @returns this effect.
  31142. */
  31143. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31144. /**
  31145. * Sets matrix on a uniform variable.
  31146. * @param uniformName Name of the variable.
  31147. * @param matrix matrix to be set.
  31148. * @returns this effect.
  31149. */
  31150. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31151. /**
  31152. * 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)
  31153. * @param uniformName Name of the variable.
  31154. * @param matrix matrix to be set.
  31155. * @returns this effect.
  31156. */
  31157. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31158. /**
  31159. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31160. * @param uniformName Name of the variable.
  31161. * @param matrix matrix to be set.
  31162. * @returns this effect.
  31163. */
  31164. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31165. /**
  31166. * Sets a float on a uniform variable.
  31167. * @param uniformName Name of the variable.
  31168. * @param value value to be set.
  31169. * @returns this effect.
  31170. */
  31171. setFloat(uniformName: string, value: number): Effect;
  31172. /**
  31173. * Sets a boolean on a uniform variable.
  31174. * @param uniformName Name of the variable.
  31175. * @param bool value to be set.
  31176. * @returns this effect.
  31177. */
  31178. setBool(uniformName: string, bool: boolean): Effect;
  31179. /**
  31180. * Sets a Vector2 on a uniform variable.
  31181. * @param uniformName Name of the variable.
  31182. * @param vector2 vector2 to be set.
  31183. * @returns this effect.
  31184. */
  31185. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31186. /**
  31187. * Sets a float2 on a uniform variable.
  31188. * @param uniformName Name of the variable.
  31189. * @param x First float in float2.
  31190. * @param y Second float in float2.
  31191. * @returns this effect.
  31192. */
  31193. setFloat2(uniformName: string, x: number, y: number): Effect;
  31194. /**
  31195. * Sets a Vector3 on a uniform variable.
  31196. * @param uniformName Name of the variable.
  31197. * @param vector3 Value to be set.
  31198. * @returns this effect.
  31199. */
  31200. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31201. /**
  31202. * Sets a float3 on a uniform variable.
  31203. * @param uniformName Name of the variable.
  31204. * @param x First float in float3.
  31205. * @param y Second float in float3.
  31206. * @param z Third float in float3.
  31207. * @returns this effect.
  31208. */
  31209. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31210. /**
  31211. * Sets a Vector4 on a uniform variable.
  31212. * @param uniformName Name of the variable.
  31213. * @param vector4 Value to be set.
  31214. * @returns this effect.
  31215. */
  31216. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31217. /**
  31218. * Sets a float4 on a uniform variable.
  31219. * @param uniformName Name of the variable.
  31220. * @param x First float in float4.
  31221. * @param y Second float in float4.
  31222. * @param z Third float in float4.
  31223. * @param w Fourth float in float4.
  31224. * @returns this effect.
  31225. */
  31226. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31227. /**
  31228. * Sets a Color3 on a uniform variable.
  31229. * @param uniformName Name of the variable.
  31230. * @param color3 Value to be set.
  31231. * @returns this effect.
  31232. */
  31233. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31234. /**
  31235. * Sets a Color4 on a uniform variable.
  31236. * @param uniformName Name of the variable.
  31237. * @param color3 Value to be set.
  31238. * @param alpha Alpha value to be set.
  31239. * @returns this effect.
  31240. */
  31241. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31242. /**
  31243. * Sets a Color4 on a uniform variable
  31244. * @param uniformName defines the name of the variable
  31245. * @param color4 defines the value to be set
  31246. * @returns this effect.
  31247. */
  31248. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31249. /** Release all associated resources */
  31250. dispose(): void;
  31251. /**
  31252. * This function will add a new shader to the shader store
  31253. * @param name the name of the shader
  31254. * @param pixelShader optional pixel shader content
  31255. * @param vertexShader optional vertex shader content
  31256. */
  31257. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31258. /**
  31259. * Store of each shader (The can be looked up using effect.key)
  31260. */
  31261. static ShadersStore: {
  31262. [key: string]: string;
  31263. };
  31264. /**
  31265. * Store of each included file for a shader (The can be looked up using effect.key)
  31266. */
  31267. static IncludesShadersStore: {
  31268. [key: string]: string;
  31269. };
  31270. /**
  31271. * Resets the cache of effects.
  31272. */
  31273. static ResetCache(): void;
  31274. }
  31275. }
  31276. declare module "babylonjs/Engines/engineCapabilities" {
  31277. /**
  31278. * Interface used to describe the capabilities of the engine relatively to the current browser
  31279. */
  31280. export interface EngineCapabilities {
  31281. /** Maximum textures units per fragment shader */
  31282. maxTexturesImageUnits: number;
  31283. /** Maximum texture units per vertex shader */
  31284. maxVertexTextureImageUnits: number;
  31285. /** Maximum textures units in the entire pipeline */
  31286. maxCombinedTexturesImageUnits: number;
  31287. /** Maximum texture size */
  31288. maxTextureSize: number;
  31289. /** Maximum texture samples */
  31290. maxSamples?: number;
  31291. /** Maximum cube texture size */
  31292. maxCubemapTextureSize: number;
  31293. /** Maximum render texture size */
  31294. maxRenderTextureSize: number;
  31295. /** Maximum number of vertex attributes */
  31296. maxVertexAttribs: number;
  31297. /** Maximum number of varyings */
  31298. maxVaryingVectors: number;
  31299. /** Maximum number of uniforms per vertex shader */
  31300. maxVertexUniformVectors: number;
  31301. /** Maximum number of uniforms per fragment shader */
  31302. maxFragmentUniformVectors: number;
  31303. /** Defines if standard derivates (dx/dy) are supported */
  31304. standardDerivatives: boolean;
  31305. /** Defines if s3tc texture compression is supported */
  31306. s3tc?: WEBGL_compressed_texture_s3tc;
  31307. /** Defines if pvrtc texture compression is supported */
  31308. pvrtc: any;
  31309. /** Defines if etc1 texture compression is supported */
  31310. etc1: any;
  31311. /** Defines if etc2 texture compression is supported */
  31312. etc2: any;
  31313. /** Defines if astc texture compression is supported */
  31314. astc: any;
  31315. /** Defines if float textures are supported */
  31316. textureFloat: boolean;
  31317. /** Defines if vertex array objects are supported */
  31318. vertexArrayObject: boolean;
  31319. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31320. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31321. /** Gets the maximum level of anisotropy supported */
  31322. maxAnisotropy: number;
  31323. /** Defines if instancing is supported */
  31324. instancedArrays: boolean;
  31325. /** Defines if 32 bits indices are supported */
  31326. uintIndices: boolean;
  31327. /** Defines if high precision shaders are supported */
  31328. highPrecisionShaderSupported: boolean;
  31329. /** Defines if depth reading in the fragment shader is supported */
  31330. fragmentDepthSupported: boolean;
  31331. /** Defines if float texture linear filtering is supported*/
  31332. textureFloatLinearFiltering: boolean;
  31333. /** Defines if rendering to float textures is supported */
  31334. textureFloatRender: boolean;
  31335. /** Defines if half float textures are supported*/
  31336. textureHalfFloat: boolean;
  31337. /** Defines if half float texture linear filtering is supported*/
  31338. textureHalfFloatLinearFiltering: boolean;
  31339. /** Defines if rendering to half float textures is supported */
  31340. textureHalfFloatRender: boolean;
  31341. /** Defines if textureLOD shader command is supported */
  31342. textureLOD: boolean;
  31343. /** Defines if draw buffers extension is supported */
  31344. drawBuffersExtension: boolean;
  31345. /** Defines if depth textures are supported */
  31346. depthTextureExtension: boolean;
  31347. /** Defines if float color buffer are supported */
  31348. colorBufferFloat: boolean;
  31349. /** Gets disjoint timer query extension (null if not supported) */
  31350. timerQuery?: EXT_disjoint_timer_query;
  31351. /** Defines if timestamp can be used with timer query */
  31352. canUseTimestampForTimerQuery: boolean;
  31353. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31354. multiview?: any;
  31355. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31356. oculusMultiview?: any;
  31357. /** Function used to let the system compiles shaders in background */
  31358. parallelShaderCompile?: {
  31359. COMPLETION_STATUS_KHR: number;
  31360. };
  31361. /** Max number of texture samples for MSAA */
  31362. maxMSAASamples: number;
  31363. /** Defines if the blend min max extension is supported */
  31364. blendMinMax: boolean;
  31365. }
  31366. }
  31367. declare module "babylonjs/States/depthCullingState" {
  31368. import { Nullable } from "babylonjs/types";
  31369. /**
  31370. * @hidden
  31371. **/
  31372. export class DepthCullingState {
  31373. private _isDepthTestDirty;
  31374. private _isDepthMaskDirty;
  31375. private _isDepthFuncDirty;
  31376. private _isCullFaceDirty;
  31377. private _isCullDirty;
  31378. private _isZOffsetDirty;
  31379. private _isFrontFaceDirty;
  31380. private _depthTest;
  31381. private _depthMask;
  31382. private _depthFunc;
  31383. private _cull;
  31384. private _cullFace;
  31385. private _zOffset;
  31386. private _frontFace;
  31387. /**
  31388. * Initializes the state.
  31389. */
  31390. constructor();
  31391. get isDirty(): boolean;
  31392. get zOffset(): number;
  31393. set zOffset(value: number);
  31394. get cullFace(): Nullable<number>;
  31395. set cullFace(value: Nullable<number>);
  31396. get cull(): Nullable<boolean>;
  31397. set cull(value: Nullable<boolean>);
  31398. get depthFunc(): Nullable<number>;
  31399. set depthFunc(value: Nullable<number>);
  31400. get depthMask(): boolean;
  31401. set depthMask(value: boolean);
  31402. get depthTest(): boolean;
  31403. set depthTest(value: boolean);
  31404. get frontFace(): Nullable<number>;
  31405. set frontFace(value: Nullable<number>);
  31406. reset(): void;
  31407. apply(gl: WebGLRenderingContext): void;
  31408. }
  31409. }
  31410. declare module "babylonjs/States/stencilState" {
  31411. /**
  31412. * @hidden
  31413. **/
  31414. export class StencilState {
  31415. /** 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 */
  31416. static readonly ALWAYS: number;
  31417. /** Passed to stencilOperation to specify that stencil value must be kept */
  31418. static readonly KEEP: number;
  31419. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31420. static readonly REPLACE: number;
  31421. private _isStencilTestDirty;
  31422. private _isStencilMaskDirty;
  31423. private _isStencilFuncDirty;
  31424. private _isStencilOpDirty;
  31425. private _stencilTest;
  31426. private _stencilMask;
  31427. private _stencilFunc;
  31428. private _stencilFuncRef;
  31429. private _stencilFuncMask;
  31430. private _stencilOpStencilFail;
  31431. private _stencilOpDepthFail;
  31432. private _stencilOpStencilDepthPass;
  31433. get isDirty(): boolean;
  31434. get stencilFunc(): number;
  31435. set stencilFunc(value: number);
  31436. get stencilFuncRef(): number;
  31437. set stencilFuncRef(value: number);
  31438. get stencilFuncMask(): number;
  31439. set stencilFuncMask(value: number);
  31440. get stencilOpStencilFail(): number;
  31441. set stencilOpStencilFail(value: number);
  31442. get stencilOpDepthFail(): number;
  31443. set stencilOpDepthFail(value: number);
  31444. get stencilOpStencilDepthPass(): number;
  31445. set stencilOpStencilDepthPass(value: number);
  31446. get stencilMask(): number;
  31447. set stencilMask(value: number);
  31448. get stencilTest(): boolean;
  31449. set stencilTest(value: boolean);
  31450. constructor();
  31451. reset(): void;
  31452. apply(gl: WebGLRenderingContext): void;
  31453. }
  31454. }
  31455. declare module "babylonjs/States/alphaCullingState" {
  31456. /**
  31457. * @hidden
  31458. **/
  31459. export class AlphaState {
  31460. private _isAlphaBlendDirty;
  31461. private _isBlendFunctionParametersDirty;
  31462. private _isBlendEquationParametersDirty;
  31463. private _isBlendConstantsDirty;
  31464. private _alphaBlend;
  31465. private _blendFunctionParameters;
  31466. private _blendEquationParameters;
  31467. private _blendConstants;
  31468. /**
  31469. * Initializes the state.
  31470. */
  31471. constructor();
  31472. get isDirty(): boolean;
  31473. get alphaBlend(): boolean;
  31474. set alphaBlend(value: boolean);
  31475. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31476. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31477. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31478. reset(): void;
  31479. apply(gl: WebGLRenderingContext): void;
  31480. }
  31481. }
  31482. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31483. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31484. /** @hidden */
  31485. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31486. attributeProcessor(attribute: string): string;
  31487. varyingProcessor(varying: string, isFragment: boolean): string;
  31488. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31489. }
  31490. }
  31491. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31492. /**
  31493. * Interface for attribute information associated with buffer instanciation
  31494. */
  31495. export interface InstancingAttributeInfo {
  31496. /**
  31497. * Name of the GLSL attribute
  31498. * if attribute index is not specified, this is used to retrieve the index from the effect
  31499. */
  31500. attributeName: string;
  31501. /**
  31502. * Index/offset of the attribute in the vertex shader
  31503. * if not specified, this will be computes from the name.
  31504. */
  31505. index?: number;
  31506. /**
  31507. * size of the attribute, 1, 2, 3 or 4
  31508. */
  31509. attributeSize: number;
  31510. /**
  31511. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31512. */
  31513. offset: number;
  31514. /**
  31515. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31516. * default to 1
  31517. */
  31518. divisor?: number;
  31519. /**
  31520. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31521. * default is FLOAT
  31522. */
  31523. attributeType?: number;
  31524. /**
  31525. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31526. */
  31527. normalized?: boolean;
  31528. }
  31529. }
  31530. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31532. import { Nullable } from "babylonjs/types";
  31533. module "babylonjs/Engines/thinEngine" {
  31534. interface ThinEngine {
  31535. /**
  31536. * Update a video texture
  31537. * @param texture defines the texture to update
  31538. * @param video defines the video element to use
  31539. * @param invertY defines if data must be stored with Y axis inverted
  31540. */
  31541. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31542. }
  31543. }
  31544. }
  31545. declare module "babylonjs/Materials/Textures/videoTexture" {
  31546. import { Observable } from "babylonjs/Misc/observable";
  31547. import { Nullable } from "babylonjs/types";
  31548. import { Scene } from "babylonjs/scene";
  31549. import { Texture } from "babylonjs/Materials/Textures/texture";
  31550. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31551. /**
  31552. * Settings for finer control over video usage
  31553. */
  31554. export interface VideoTextureSettings {
  31555. /**
  31556. * Applies `autoplay` to video, if specified
  31557. */
  31558. autoPlay?: boolean;
  31559. /**
  31560. * Applies `loop` to video, if specified
  31561. */
  31562. loop?: boolean;
  31563. /**
  31564. * Automatically updates internal texture from video at every frame in the render loop
  31565. */
  31566. autoUpdateTexture: boolean;
  31567. /**
  31568. * Image src displayed during the video loading or until the user interacts with the video.
  31569. */
  31570. poster?: string;
  31571. }
  31572. /**
  31573. * If you want to display a video in your scene, this is the special texture for that.
  31574. * This special texture works similar to other textures, with the exception of a few parameters.
  31575. * @see https://doc.babylonjs.com/how_to/video_texture
  31576. */
  31577. export class VideoTexture extends Texture {
  31578. /**
  31579. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31580. */
  31581. readonly autoUpdateTexture: boolean;
  31582. /**
  31583. * The video instance used by the texture internally
  31584. */
  31585. readonly video: HTMLVideoElement;
  31586. private _onUserActionRequestedObservable;
  31587. /**
  31588. * Event triggerd when a dom action is required by the user to play the video.
  31589. * This happens due to recent changes in browser policies preventing video to auto start.
  31590. */
  31591. get onUserActionRequestedObservable(): Observable<Texture>;
  31592. private _generateMipMaps;
  31593. private _engine;
  31594. private _stillImageCaptured;
  31595. private _displayingPosterTexture;
  31596. private _settings;
  31597. private _createInternalTextureOnEvent;
  31598. private _frameId;
  31599. private _currentSrc;
  31600. /**
  31601. * Creates a video texture.
  31602. * If you want to display a video in your scene, this is the special texture for that.
  31603. * This special texture works similar to other textures, with the exception of a few parameters.
  31604. * @see https://doc.babylonjs.com/how_to/video_texture
  31605. * @param name optional name, will detect from video source, if not defined
  31606. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31607. * @param scene is obviously the current scene.
  31608. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31609. * @param invertY is false by default but can be used to invert video on Y axis
  31610. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31611. * @param settings allows finer control over video usage
  31612. */
  31613. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31614. private _getName;
  31615. private _getVideo;
  31616. private _createInternalTexture;
  31617. private reset;
  31618. /**
  31619. * @hidden Internal method to initiate `update`.
  31620. */
  31621. _rebuild(): void;
  31622. /**
  31623. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31624. */
  31625. update(): void;
  31626. /**
  31627. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31628. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31629. */
  31630. updateTexture(isVisible: boolean): void;
  31631. protected _updateInternalTexture: () => void;
  31632. /**
  31633. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31634. * @param url New url.
  31635. */
  31636. updateURL(url: string): void;
  31637. /**
  31638. * Clones the texture.
  31639. * @returns the cloned texture
  31640. */
  31641. clone(): VideoTexture;
  31642. /**
  31643. * Dispose the texture and release its associated resources.
  31644. */
  31645. dispose(): void;
  31646. /**
  31647. * Creates a video texture straight from a stream.
  31648. * @param scene Define the scene the texture should be created in
  31649. * @param stream Define the stream the texture should be created from
  31650. * @returns The created video texture as a promise
  31651. */
  31652. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31653. /**
  31654. * Creates a video texture straight from your WebCam video feed.
  31655. * @param scene Define the scene the texture should be created in
  31656. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31657. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31658. * @returns The created video texture as a promise
  31659. */
  31660. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31661. minWidth: number;
  31662. maxWidth: number;
  31663. minHeight: number;
  31664. maxHeight: number;
  31665. deviceId: string;
  31666. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31667. /**
  31668. * Creates a video texture straight from your WebCam video feed.
  31669. * @param scene Define the scene the texture should be created in
  31670. * @param onReady Define a callback to triggered once the texture will be ready
  31671. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31672. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31673. */
  31674. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31675. minWidth: number;
  31676. maxWidth: number;
  31677. minHeight: number;
  31678. maxHeight: number;
  31679. deviceId: string;
  31680. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31681. }
  31682. }
  31683. declare module "babylonjs/Engines/thinEngine" {
  31684. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31685. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31686. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31687. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31688. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31689. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31690. import { Observable } from "babylonjs/Misc/observable";
  31691. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31692. import { StencilState } from "babylonjs/States/stencilState";
  31693. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31694. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31695. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31696. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31697. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31698. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31699. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31700. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31701. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31703. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31704. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31705. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31706. import { WebRequest } from "babylonjs/Misc/webRequest";
  31707. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31708. /**
  31709. * Defines the interface used by objects working like Scene
  31710. * @hidden
  31711. */
  31712. interface ISceneLike {
  31713. _addPendingData(data: any): void;
  31714. _removePendingData(data: any): void;
  31715. offlineProvider: IOfflineProvider;
  31716. }
  31717. /** Interface defining initialization parameters for Engine class */
  31718. export interface EngineOptions extends WebGLContextAttributes {
  31719. /**
  31720. * Defines if the engine should no exceed a specified device ratio
  31721. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31722. */
  31723. limitDeviceRatio?: number;
  31724. /**
  31725. * Defines if webvr should be enabled automatically
  31726. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31727. */
  31728. autoEnableWebVR?: boolean;
  31729. /**
  31730. * Defines if webgl2 should be turned off even if supported
  31731. * @see http://doc.babylonjs.com/features/webgl2
  31732. */
  31733. disableWebGL2Support?: boolean;
  31734. /**
  31735. * Defines if webaudio should be initialized as well
  31736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31737. */
  31738. audioEngine?: boolean;
  31739. /**
  31740. * Defines if animations should run using a deterministic lock step
  31741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31742. */
  31743. deterministicLockstep?: boolean;
  31744. /** Defines the maximum steps to use with deterministic lock step mode */
  31745. lockstepMaxSteps?: number;
  31746. /** Defines the seconds between each deterministic lock step */
  31747. timeStep?: number;
  31748. /**
  31749. * Defines that engine should ignore context lost events
  31750. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31751. */
  31752. doNotHandleContextLost?: boolean;
  31753. /**
  31754. * Defines that engine should ignore modifying touch action attribute and style
  31755. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31756. */
  31757. doNotHandleTouchAction?: boolean;
  31758. /**
  31759. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31760. */
  31761. useHighPrecisionFloats?: boolean;
  31762. }
  31763. /**
  31764. * The base engine class (root of all engines)
  31765. */
  31766. export class ThinEngine {
  31767. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31768. static ExceptionList: ({
  31769. key: string;
  31770. capture: string;
  31771. captureConstraint: number;
  31772. targets: string[];
  31773. } | {
  31774. key: string;
  31775. capture: null;
  31776. captureConstraint: null;
  31777. targets: string[];
  31778. })[];
  31779. /** @hidden */
  31780. static _TextureLoaders: IInternalTextureLoader[];
  31781. /**
  31782. * Returns the current npm package of the sdk
  31783. */
  31784. static get NpmPackage(): string;
  31785. /**
  31786. * Returns the current version of the framework
  31787. */
  31788. static get Version(): string;
  31789. /**
  31790. * Returns a string describing the current engine
  31791. */
  31792. get description(): string;
  31793. /**
  31794. * Gets or sets the epsilon value used by collision engine
  31795. */
  31796. static CollisionsEpsilon: number;
  31797. /**
  31798. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31799. */
  31800. static get ShadersRepository(): string;
  31801. static set ShadersRepository(value: string);
  31802. /**
  31803. * Gets or sets the textures that the engine should not attempt to load as compressed
  31804. */
  31805. protected _excludedCompressedTextures: string[];
  31806. /**
  31807. * Filters the compressed texture formats to only include
  31808. * files that are not included in the skippable list
  31809. *
  31810. * @param url the current extension
  31811. * @param textureFormatInUse the current compressed texture format
  31812. * @returns "format" string
  31813. */
  31814. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31815. /** @hidden */
  31816. _shaderProcessor: IShaderProcessor;
  31817. /**
  31818. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31819. */
  31820. forcePOTTextures: boolean;
  31821. /**
  31822. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31823. */
  31824. isFullscreen: boolean;
  31825. /**
  31826. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31827. */
  31828. cullBackFaces: boolean;
  31829. /**
  31830. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31831. */
  31832. renderEvenInBackground: boolean;
  31833. /**
  31834. * Gets or sets a boolean indicating that cache can be kept between frames
  31835. */
  31836. preventCacheWipeBetweenFrames: boolean;
  31837. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31838. validateShaderPrograms: boolean;
  31839. /**
  31840. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31841. * This can provide greater z depth for distant objects.
  31842. */
  31843. useReverseDepthBuffer: boolean;
  31844. /**
  31845. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31846. */
  31847. disableUniformBuffers: boolean;
  31848. /** @hidden */
  31849. _uniformBuffers: UniformBuffer[];
  31850. /**
  31851. * Gets a boolean indicating that the engine supports uniform buffers
  31852. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31853. */
  31854. get supportsUniformBuffers(): boolean;
  31855. /** @hidden */
  31856. _gl: WebGLRenderingContext;
  31857. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31858. protected _windowIsBackground: boolean;
  31859. protected _webGLVersion: number;
  31860. protected _creationOptions: EngineOptions;
  31861. protected _highPrecisionShadersAllowed: boolean;
  31862. /** @hidden */
  31863. get _shouldUseHighPrecisionShader(): boolean;
  31864. /**
  31865. * Gets a boolean indicating that only power of 2 textures are supported
  31866. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31867. */
  31868. get needPOTTextures(): boolean;
  31869. /** @hidden */
  31870. _badOS: boolean;
  31871. /** @hidden */
  31872. _badDesktopOS: boolean;
  31873. private _hardwareScalingLevel;
  31874. /** @hidden */
  31875. _caps: EngineCapabilities;
  31876. private _isStencilEnable;
  31877. private _glVersion;
  31878. private _glRenderer;
  31879. private _glVendor;
  31880. /** @hidden */
  31881. _videoTextureSupported: boolean;
  31882. protected _renderingQueueLaunched: boolean;
  31883. protected _activeRenderLoops: (() => void)[];
  31884. /**
  31885. * Observable signaled when a context lost event is raised
  31886. */
  31887. onContextLostObservable: Observable<ThinEngine>;
  31888. /**
  31889. * Observable signaled when a context restored event is raised
  31890. */
  31891. onContextRestoredObservable: Observable<ThinEngine>;
  31892. private _onContextLost;
  31893. private _onContextRestored;
  31894. protected _contextWasLost: boolean;
  31895. /** @hidden */
  31896. _doNotHandleContextLost: boolean;
  31897. /**
  31898. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31900. */
  31901. get doNotHandleContextLost(): boolean;
  31902. set doNotHandleContextLost(value: boolean);
  31903. /**
  31904. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31905. */
  31906. disableVertexArrayObjects: boolean;
  31907. /** @hidden */
  31908. protected _colorWrite: boolean;
  31909. /** @hidden */
  31910. protected _colorWriteChanged: boolean;
  31911. /** @hidden */
  31912. protected _depthCullingState: DepthCullingState;
  31913. /** @hidden */
  31914. protected _stencilState: StencilState;
  31915. /** @hidden */
  31916. _alphaState: AlphaState;
  31917. /** @hidden */
  31918. _alphaMode: number;
  31919. /** @hidden */
  31920. _alphaEquation: number;
  31921. /** @hidden */
  31922. _internalTexturesCache: InternalTexture[];
  31923. /** @hidden */
  31924. protected _activeChannel: number;
  31925. private _currentTextureChannel;
  31926. /** @hidden */
  31927. protected _boundTexturesCache: {
  31928. [key: string]: Nullable<InternalTexture>;
  31929. };
  31930. /** @hidden */
  31931. protected _currentEffect: Nullable<Effect>;
  31932. /** @hidden */
  31933. protected _currentProgram: Nullable<WebGLProgram>;
  31934. private _compiledEffects;
  31935. private _vertexAttribArraysEnabled;
  31936. /** @hidden */
  31937. protected _cachedViewport: Nullable<IViewportLike>;
  31938. private _cachedVertexArrayObject;
  31939. /** @hidden */
  31940. protected _cachedVertexBuffers: any;
  31941. /** @hidden */
  31942. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31943. /** @hidden */
  31944. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31945. /** @hidden */
  31946. _currentRenderTarget: Nullable<InternalTexture>;
  31947. private _uintIndicesCurrentlySet;
  31948. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31949. /** @hidden */
  31950. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31951. private _currentBufferPointers;
  31952. private _currentInstanceLocations;
  31953. private _currentInstanceBuffers;
  31954. private _textureUnits;
  31955. /** @hidden */
  31956. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31957. /** @hidden */
  31958. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31959. /** @hidden */
  31960. _boundRenderFunction: any;
  31961. private _vaoRecordInProgress;
  31962. private _mustWipeVertexAttributes;
  31963. private _emptyTexture;
  31964. private _emptyCubeTexture;
  31965. private _emptyTexture3D;
  31966. private _emptyTexture2DArray;
  31967. /** @hidden */
  31968. _frameHandler: number;
  31969. private _nextFreeTextureSlots;
  31970. private _maxSimultaneousTextures;
  31971. private _activeRequests;
  31972. protected _texturesSupported: string[];
  31973. /** @hidden */
  31974. _textureFormatInUse: Nullable<string>;
  31975. protected get _supportsHardwareTextureRescaling(): boolean;
  31976. /**
  31977. * Gets the list of texture formats supported
  31978. */
  31979. get texturesSupported(): Array<string>;
  31980. /**
  31981. * Gets the list of texture formats in use
  31982. */
  31983. get textureFormatInUse(): Nullable<string>;
  31984. /**
  31985. * Gets the current viewport
  31986. */
  31987. get currentViewport(): Nullable<IViewportLike>;
  31988. /**
  31989. * Gets the default empty texture
  31990. */
  31991. get emptyTexture(): InternalTexture;
  31992. /**
  31993. * Gets the default empty 3D texture
  31994. */
  31995. get emptyTexture3D(): InternalTexture;
  31996. /**
  31997. * Gets the default empty 2D array texture
  31998. */
  31999. get emptyTexture2DArray(): InternalTexture;
  32000. /**
  32001. * Gets the default empty cube texture
  32002. */
  32003. get emptyCubeTexture(): InternalTexture;
  32004. /**
  32005. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32006. */
  32007. readonly premultipliedAlpha: boolean;
  32008. /**
  32009. * Observable event triggered before each texture is initialized
  32010. */
  32011. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32012. /**
  32013. * Creates a new engine
  32014. * @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
  32015. * @param antialias defines enable antialiasing (default: false)
  32016. * @param options defines further options to be sent to the getContext() function
  32017. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32018. */
  32019. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32020. private _rebuildInternalTextures;
  32021. private _rebuildEffects;
  32022. /**
  32023. * Gets a boolean indicating if all created effects are ready
  32024. * @returns true if all effects are ready
  32025. */
  32026. areAllEffectsReady(): boolean;
  32027. protected _rebuildBuffers(): void;
  32028. private _initGLContext;
  32029. /**
  32030. * Gets version of the current webGL context
  32031. */
  32032. get webGLVersion(): number;
  32033. /**
  32034. * Gets a string idenfifying the name of the class
  32035. * @returns "Engine" string
  32036. */
  32037. getClassName(): string;
  32038. /**
  32039. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32040. */
  32041. get isStencilEnable(): boolean;
  32042. /** @hidden */
  32043. _prepareWorkingCanvas(): void;
  32044. /**
  32045. * Reset the texture cache to empty state
  32046. */
  32047. resetTextureCache(): void;
  32048. /**
  32049. * Gets an object containing information about the current webGL context
  32050. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32051. */
  32052. getGlInfo(): {
  32053. vendor: string;
  32054. renderer: string;
  32055. version: string;
  32056. };
  32057. /**
  32058. * Defines the hardware scaling level.
  32059. * By default the hardware scaling level is computed from the window device ratio.
  32060. * 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.
  32061. * @param level defines the level to use
  32062. */
  32063. setHardwareScalingLevel(level: number): void;
  32064. /**
  32065. * Gets the current hardware scaling level.
  32066. * By default the hardware scaling level is computed from the window device ratio.
  32067. * 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.
  32068. * @returns a number indicating the current hardware scaling level
  32069. */
  32070. getHardwareScalingLevel(): number;
  32071. /**
  32072. * Gets the list of loaded textures
  32073. * @returns an array containing all loaded textures
  32074. */
  32075. getLoadedTexturesCache(): InternalTexture[];
  32076. /**
  32077. * Gets the object containing all engine capabilities
  32078. * @returns the EngineCapabilities object
  32079. */
  32080. getCaps(): EngineCapabilities;
  32081. /**
  32082. * stop executing a render loop function and remove it from the execution array
  32083. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32084. */
  32085. stopRenderLoop(renderFunction?: () => void): void;
  32086. /** @hidden */
  32087. _renderLoop(): void;
  32088. /**
  32089. * Gets the HTML canvas attached with the current webGL context
  32090. * @returns a HTML canvas
  32091. */
  32092. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32093. /**
  32094. * Gets host window
  32095. * @returns the host window object
  32096. */
  32097. getHostWindow(): Nullable<Window>;
  32098. /**
  32099. * Gets the current render width
  32100. * @param useScreen defines if screen size must be used (or the current render target if any)
  32101. * @returns a number defining the current render width
  32102. */
  32103. getRenderWidth(useScreen?: boolean): number;
  32104. /**
  32105. * Gets the current render height
  32106. * @param useScreen defines if screen size must be used (or the current render target if any)
  32107. * @returns a number defining the current render height
  32108. */
  32109. getRenderHeight(useScreen?: boolean): number;
  32110. /**
  32111. * Can be used to override the current requestAnimationFrame requester.
  32112. * @hidden
  32113. */
  32114. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32115. /**
  32116. * Register and execute a render loop. The engine can have more than one render function
  32117. * @param renderFunction defines the function to continuously execute
  32118. */
  32119. runRenderLoop(renderFunction: () => void): void;
  32120. /**
  32121. * Clear the current render buffer or the current render target (if any is set up)
  32122. * @param color defines the color to use
  32123. * @param backBuffer defines if the back buffer must be cleared
  32124. * @param depth defines if the depth buffer must be cleared
  32125. * @param stencil defines if the stencil buffer must be cleared
  32126. */
  32127. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32128. private _viewportCached;
  32129. /** @hidden */
  32130. _viewport(x: number, y: number, width: number, height: number): void;
  32131. /**
  32132. * Set the WebGL's viewport
  32133. * @param viewport defines the viewport element to be used
  32134. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32135. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32136. */
  32137. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32138. /**
  32139. * Begin a new frame
  32140. */
  32141. beginFrame(): void;
  32142. /**
  32143. * Enf the current frame
  32144. */
  32145. endFrame(): void;
  32146. /**
  32147. * Resize the view according to the canvas' size
  32148. */
  32149. resize(): void;
  32150. /**
  32151. * Force a specific size of the canvas
  32152. * @param width defines the new canvas' width
  32153. * @param height defines the new canvas' height
  32154. */
  32155. setSize(width: number, height: number): void;
  32156. /**
  32157. * Binds the frame buffer to the specified texture.
  32158. * @param texture The texture to render to or null for the default canvas
  32159. * @param faceIndex The face of the texture to render to in case of cube texture
  32160. * @param requiredWidth The width of the target to render to
  32161. * @param requiredHeight The height of the target to render to
  32162. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32163. * @param lodLevel defines the lod level to bind to the frame buffer
  32164. * @param layer defines the 2d array index to bind to frame buffer to
  32165. */
  32166. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32167. /** @hidden */
  32168. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32169. /**
  32170. * Unbind the current render target texture from the webGL context
  32171. * @param texture defines the render target texture to unbind
  32172. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32173. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32174. */
  32175. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32176. /**
  32177. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32178. */
  32179. flushFramebuffer(): void;
  32180. /**
  32181. * Unbind the current render target and bind the default framebuffer
  32182. */
  32183. restoreDefaultFramebuffer(): void;
  32184. /** @hidden */
  32185. protected _resetVertexBufferBinding(): void;
  32186. /**
  32187. * Creates a vertex buffer
  32188. * @param data the data for the vertex buffer
  32189. * @returns the new WebGL static buffer
  32190. */
  32191. createVertexBuffer(data: DataArray): DataBuffer;
  32192. private _createVertexBuffer;
  32193. /**
  32194. * Creates a dynamic vertex buffer
  32195. * @param data the data for the dynamic vertex buffer
  32196. * @returns the new WebGL dynamic buffer
  32197. */
  32198. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32199. protected _resetIndexBufferBinding(): void;
  32200. /**
  32201. * Creates a new index buffer
  32202. * @param indices defines the content of the index buffer
  32203. * @param updatable defines if the index buffer must be updatable
  32204. * @returns a new webGL buffer
  32205. */
  32206. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32207. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32208. /**
  32209. * Bind a webGL buffer to the webGL context
  32210. * @param buffer defines the buffer to bind
  32211. */
  32212. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32213. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32214. private bindBuffer;
  32215. /**
  32216. * update the bound buffer with the given data
  32217. * @param data defines the data to update
  32218. */
  32219. updateArrayBuffer(data: Float32Array): void;
  32220. private _vertexAttribPointer;
  32221. /** @hidden */
  32222. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32223. private _bindVertexBuffersAttributes;
  32224. /**
  32225. * Records a vertex array object
  32226. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32227. * @param vertexBuffers defines the list of vertex buffers to store
  32228. * @param indexBuffer defines the index buffer to store
  32229. * @param effect defines the effect to store
  32230. * @returns the new vertex array object
  32231. */
  32232. recordVertexArrayObject(vertexBuffers: {
  32233. [key: string]: VertexBuffer;
  32234. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32235. /**
  32236. * Bind a specific vertex array object
  32237. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32238. * @param vertexArrayObject defines the vertex array object to bind
  32239. * @param indexBuffer defines the index buffer to bind
  32240. */
  32241. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32242. /**
  32243. * Bind webGl buffers directly to the webGL context
  32244. * @param vertexBuffer defines the vertex buffer to bind
  32245. * @param indexBuffer defines the index buffer to bind
  32246. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32247. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32248. * @param effect defines the effect associated with the vertex buffer
  32249. */
  32250. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32251. private _unbindVertexArrayObject;
  32252. /**
  32253. * Bind a list of vertex buffers to the webGL context
  32254. * @param vertexBuffers defines the list of vertex buffers to bind
  32255. * @param indexBuffer defines the index buffer to bind
  32256. * @param effect defines the effect associated with the vertex buffers
  32257. */
  32258. bindBuffers(vertexBuffers: {
  32259. [key: string]: Nullable<VertexBuffer>;
  32260. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32261. /**
  32262. * Unbind all instance attributes
  32263. */
  32264. unbindInstanceAttributes(): void;
  32265. /**
  32266. * Release and free the memory of a vertex array object
  32267. * @param vao defines the vertex array object to delete
  32268. */
  32269. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32270. /** @hidden */
  32271. _releaseBuffer(buffer: DataBuffer): boolean;
  32272. protected _deleteBuffer(buffer: DataBuffer): void;
  32273. /**
  32274. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32275. * @param instancesBuffer defines the webGL buffer to update and bind
  32276. * @param data defines the data to store in the buffer
  32277. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32278. */
  32279. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32280. /**
  32281. * Bind the content of a webGL buffer used with instanciation
  32282. * @param instancesBuffer defines the webGL buffer to bind
  32283. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32284. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32285. */
  32286. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32287. /**
  32288. * Disable the instance attribute corresponding to the name in parameter
  32289. * @param name defines the name of the attribute to disable
  32290. */
  32291. disableInstanceAttributeByName(name: string): void;
  32292. /**
  32293. * Disable the instance attribute corresponding to the location in parameter
  32294. * @param attributeLocation defines the attribute location of the attribute to disable
  32295. */
  32296. disableInstanceAttribute(attributeLocation: number): void;
  32297. /**
  32298. * Disable the attribute corresponding to the location in parameter
  32299. * @param attributeLocation defines the attribute location of the attribute to disable
  32300. */
  32301. disableAttributeByIndex(attributeLocation: number): void;
  32302. /**
  32303. * Send a draw order
  32304. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32305. * @param indexStart defines the starting index
  32306. * @param indexCount defines the number of index to draw
  32307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32308. */
  32309. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32310. /**
  32311. * Draw a list of points
  32312. * @param verticesStart defines the index of first vertex to draw
  32313. * @param verticesCount defines the count of vertices to draw
  32314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32315. */
  32316. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32317. /**
  32318. * Draw a list of unindexed primitives
  32319. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32320. * @param verticesStart defines the index of first vertex to draw
  32321. * @param verticesCount defines the count of vertices to draw
  32322. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32323. */
  32324. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32325. /**
  32326. * Draw a list of indexed primitives
  32327. * @param fillMode defines the primitive to use
  32328. * @param indexStart defines the starting index
  32329. * @param indexCount defines the number of index to draw
  32330. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32331. */
  32332. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32333. /**
  32334. * Draw a list of unindexed primitives
  32335. * @param fillMode defines the primitive to use
  32336. * @param verticesStart defines the index of first vertex to draw
  32337. * @param verticesCount defines the count of vertices to draw
  32338. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32339. */
  32340. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32341. private _drawMode;
  32342. /** @hidden */
  32343. protected _reportDrawCall(): void;
  32344. /** @hidden */
  32345. _releaseEffect(effect: Effect): void;
  32346. /** @hidden */
  32347. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32348. /**
  32349. * Create a new effect (used to store vertex/fragment shaders)
  32350. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32351. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32352. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32353. * @param samplers defines an array of string used to represent textures
  32354. * @param defines defines the string containing the defines to use to compile the shaders
  32355. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32356. * @param onCompiled defines a function to call when the effect creation is successful
  32357. * @param onError defines a function to call when the effect creation has failed
  32358. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32359. * @returns the new Effect
  32360. */
  32361. 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;
  32362. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32363. private _compileShader;
  32364. private _compileRawShader;
  32365. /**
  32366. * Directly creates a webGL program
  32367. * @param pipelineContext defines the pipeline context to attach to
  32368. * @param vertexCode defines the vertex shader code to use
  32369. * @param fragmentCode defines the fragment shader code to use
  32370. * @param context defines the webGL context to use (if not set, the current one will be used)
  32371. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32372. * @returns the new webGL program
  32373. */
  32374. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32375. /**
  32376. * Creates a webGL program
  32377. * @param pipelineContext defines the pipeline context to attach to
  32378. * @param vertexCode defines the vertex shader code to use
  32379. * @param fragmentCode defines the fragment shader code to use
  32380. * @param defines defines the string containing the defines to use to compile the shaders
  32381. * @param context defines the webGL context to use (if not set, the current one will be used)
  32382. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32383. * @returns the new webGL program
  32384. */
  32385. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32386. /**
  32387. * Creates a new pipeline context
  32388. * @returns the new pipeline
  32389. */
  32390. createPipelineContext(): IPipelineContext;
  32391. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32392. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32393. /** @hidden */
  32394. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32395. /** @hidden */
  32396. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32397. /** @hidden */
  32398. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32399. /**
  32400. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32401. * @param pipelineContext defines the pipeline context to use
  32402. * @param uniformsNames defines the list of uniform names
  32403. * @returns an array of webGL uniform locations
  32404. */
  32405. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32406. /**
  32407. * Gets the lsit of active attributes for a given webGL program
  32408. * @param pipelineContext defines the pipeline context to use
  32409. * @param attributesNames defines the list of attribute names to get
  32410. * @returns an array of indices indicating the offset of each attribute
  32411. */
  32412. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32413. /**
  32414. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32415. * @param effect defines the effect to activate
  32416. */
  32417. enableEffect(effect: Nullable<Effect>): void;
  32418. /**
  32419. * Set the value of an uniform to a number (int)
  32420. * @param uniform defines the webGL uniform location where to store the value
  32421. * @param value defines the int number to store
  32422. */
  32423. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32424. /**
  32425. * Set the value of an uniform to an array of int32
  32426. * @param uniform defines the webGL uniform location where to store the value
  32427. * @param array defines the array of int32 to store
  32428. */
  32429. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32430. /**
  32431. * Set the value of an uniform to an array of int32 (stored as vec2)
  32432. * @param uniform defines the webGL uniform location where to store the value
  32433. * @param array defines the array of int32 to store
  32434. */
  32435. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32436. /**
  32437. * Set the value of an uniform to an array of int32 (stored as vec3)
  32438. * @param uniform defines the webGL uniform location where to store the value
  32439. * @param array defines the array of int32 to store
  32440. */
  32441. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32442. /**
  32443. * Set the value of an uniform to an array of int32 (stored as vec4)
  32444. * @param uniform defines the webGL uniform location where to store the value
  32445. * @param array defines the array of int32 to store
  32446. */
  32447. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32448. /**
  32449. * Set the value of an uniform to an array of number
  32450. * @param uniform defines the webGL uniform location where to store the value
  32451. * @param array defines the array of number to store
  32452. */
  32453. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32454. /**
  32455. * Set the value of an uniform to an array of number (stored as vec2)
  32456. * @param uniform defines the webGL uniform location where to store the value
  32457. * @param array defines the array of number to store
  32458. */
  32459. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32460. /**
  32461. * Set the value of an uniform to an array of number (stored as vec3)
  32462. * @param uniform defines the webGL uniform location where to store the value
  32463. * @param array defines the array of number to store
  32464. */
  32465. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32466. /**
  32467. * Set the value of an uniform to an array of number (stored as vec4)
  32468. * @param uniform defines the webGL uniform location where to store the value
  32469. * @param array defines the array of number to store
  32470. */
  32471. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32472. /**
  32473. * Set the value of an uniform to an array of float32 (stored as matrices)
  32474. * @param uniform defines the webGL uniform location where to store the value
  32475. * @param matrices defines the array of float32 to store
  32476. */
  32477. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32478. /**
  32479. * Set the value of an uniform to a matrix (3x3)
  32480. * @param uniform defines the webGL uniform location where to store the value
  32481. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32482. */
  32483. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32484. /**
  32485. * Set the value of an uniform to a matrix (2x2)
  32486. * @param uniform defines the webGL uniform location where to store the value
  32487. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32488. */
  32489. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32490. /**
  32491. * Set the value of an uniform to a number (float)
  32492. * @param uniform defines the webGL uniform location where to store the value
  32493. * @param value defines the float number to store
  32494. */
  32495. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32496. /**
  32497. * Set the value of an uniform to a vec2
  32498. * @param uniform defines the webGL uniform location where to store the value
  32499. * @param x defines the 1st component of the value
  32500. * @param y defines the 2nd component of the value
  32501. */
  32502. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32503. /**
  32504. * Set the value of an uniform to a vec3
  32505. * @param uniform defines the webGL uniform location where to store the value
  32506. * @param x defines the 1st component of the value
  32507. * @param y defines the 2nd component of the value
  32508. * @param z defines the 3rd component of the value
  32509. */
  32510. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32511. /**
  32512. * Set the value of an uniform to a vec4
  32513. * @param uniform defines the webGL uniform location where to store the value
  32514. * @param x defines the 1st component of the value
  32515. * @param y defines the 2nd component of the value
  32516. * @param z defines the 3rd component of the value
  32517. * @param w defines the 4th component of the value
  32518. */
  32519. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32520. /**
  32521. * Apply all cached states (depth, culling, stencil and alpha)
  32522. */
  32523. applyStates(): void;
  32524. /**
  32525. * Enable or disable color writing
  32526. * @param enable defines the state to set
  32527. */
  32528. setColorWrite(enable: boolean): void;
  32529. /**
  32530. * Gets a boolean indicating if color writing is enabled
  32531. * @returns the current color writing state
  32532. */
  32533. getColorWrite(): boolean;
  32534. /**
  32535. * Gets the depth culling state manager
  32536. */
  32537. get depthCullingState(): DepthCullingState;
  32538. /**
  32539. * Gets the alpha state manager
  32540. */
  32541. get alphaState(): AlphaState;
  32542. /**
  32543. * Gets the stencil state manager
  32544. */
  32545. get stencilState(): StencilState;
  32546. /**
  32547. * Clears the list of texture accessible through engine.
  32548. * This can help preventing texture load conflict due to name collision.
  32549. */
  32550. clearInternalTexturesCache(): void;
  32551. /**
  32552. * Force the entire cache to be cleared
  32553. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32554. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32555. */
  32556. wipeCaches(bruteForce?: boolean): void;
  32557. /** @hidden */
  32558. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32559. min: number;
  32560. mag: number;
  32561. };
  32562. /** @hidden */
  32563. _createTexture(): WebGLTexture;
  32564. /**
  32565. * Usually called from Texture.ts.
  32566. * Passed information to create a WebGLTexture
  32567. * @param urlArg defines a value which contains one of the following:
  32568. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32569. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32570. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32571. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32572. * @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)
  32573. * @param scene needed for loading to the correct scene
  32574. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32575. * @param onLoad optional callback to be called upon successful completion
  32576. * @param onError optional callback to be called upon failure
  32577. * @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
  32578. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32579. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32580. * @param forcedExtension defines the extension to use to pick the right loader
  32581. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32582. * @param mimeType defines an optional mime type
  32583. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32584. */
  32585. 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;
  32586. /**
  32587. * Loads an image as an HTMLImageElement.
  32588. * @param input url string, ArrayBuffer, or Blob to load
  32589. * @param onLoad callback called when the image successfully loads
  32590. * @param onError callback called when the image fails to load
  32591. * @param offlineProvider offline provider for caching
  32592. * @param mimeType optional mime type
  32593. * @returns the HTMLImageElement of the loaded image
  32594. * @hidden
  32595. */
  32596. 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>;
  32597. /**
  32598. * @hidden
  32599. */
  32600. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32601. /**
  32602. * Creates a raw texture
  32603. * @param data defines the data to store in the texture
  32604. * @param width defines the width of the texture
  32605. * @param height defines the height of the texture
  32606. * @param format defines the format of the data
  32607. * @param generateMipMaps defines if the engine should generate the mip levels
  32608. * @param invertY defines if data must be stored with Y axis inverted
  32609. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32610. * @param compression defines the compression used (null by default)
  32611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32612. * @returns the raw texture inside an InternalTexture
  32613. */
  32614. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32615. /**
  32616. * Creates a new raw cube texture
  32617. * @param data defines the array of data to use to create each face
  32618. * @param size defines the size of the textures
  32619. * @param format defines the format of the data
  32620. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32621. * @param generateMipMaps defines if the engine should generate the mip levels
  32622. * @param invertY defines if data must be stored with Y axis inverted
  32623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32624. * @param compression defines the compression used (null by default)
  32625. * @returns the cube texture as an InternalTexture
  32626. */
  32627. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32628. /**
  32629. * Creates a new raw 3D texture
  32630. * @param data defines the data used to create the texture
  32631. * @param width defines the width of the texture
  32632. * @param height defines the height of the texture
  32633. * @param depth defines the depth of the texture
  32634. * @param format defines the format of the texture
  32635. * @param generateMipMaps defines if the engine must generate mip levels
  32636. * @param invertY defines if data must be stored with Y axis inverted
  32637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32638. * @param compression defines the compressed used (can be null)
  32639. * @param textureType defines the compressed used (can be null)
  32640. * @returns a new raw 3D texture (stored in an InternalTexture)
  32641. */
  32642. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32643. /**
  32644. * Creates a new raw 2D array texture
  32645. * @param data defines the data used to create the texture
  32646. * @param width defines the width of the texture
  32647. * @param height defines the height of the texture
  32648. * @param depth defines the number of layers of the texture
  32649. * @param format defines the format of the texture
  32650. * @param generateMipMaps defines if the engine must generate mip levels
  32651. * @param invertY defines if data must be stored with Y axis inverted
  32652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32653. * @param compression defines the compressed used (can be null)
  32654. * @param textureType defines the compressed used (can be null)
  32655. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32656. */
  32657. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32658. private _unpackFlipYCached;
  32659. /**
  32660. * In case you are sharing the context with other applications, it might
  32661. * be interested to not cache the unpack flip y state to ensure a consistent
  32662. * value would be set.
  32663. */
  32664. enableUnpackFlipYCached: boolean;
  32665. /** @hidden */
  32666. _unpackFlipY(value: boolean): void;
  32667. /** @hidden */
  32668. _getUnpackAlignement(): number;
  32669. private _getTextureTarget;
  32670. /**
  32671. * Update the sampling mode of a given texture
  32672. * @param samplingMode defines the required sampling mode
  32673. * @param texture defines the texture to update
  32674. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32675. */
  32676. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32677. /**
  32678. * Update the sampling mode of a given texture
  32679. * @param texture defines the texture to update
  32680. * @param wrapU defines the texture wrap mode of the u coordinates
  32681. * @param wrapV defines the texture wrap mode of the v coordinates
  32682. * @param wrapR defines the texture wrap mode of the r coordinates
  32683. */
  32684. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32685. /** @hidden */
  32686. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32687. width: number;
  32688. height: number;
  32689. layers?: number;
  32690. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32691. /** @hidden */
  32692. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32693. /** @hidden */
  32694. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32695. /**
  32696. * Update a portion of an internal texture
  32697. * @param texture defines the texture to update
  32698. * @param imageData defines the data to store into the texture
  32699. * @param xOffset defines the x coordinates of the update rectangle
  32700. * @param yOffset defines the y coordinates of the update rectangle
  32701. * @param width defines the width of the update rectangle
  32702. * @param height defines the height of the update rectangle
  32703. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32704. * @param lod defines the lod level to update (0 by default)
  32705. */
  32706. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32707. /** @hidden */
  32708. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32709. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32710. private _prepareWebGLTexture;
  32711. /** @hidden */
  32712. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32713. private _getDepthStencilBuffer;
  32714. /** @hidden */
  32715. _releaseFramebufferObjects(texture: InternalTexture): void;
  32716. /** @hidden */
  32717. _releaseTexture(texture: InternalTexture): void;
  32718. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32719. protected _setProgram(program: WebGLProgram): void;
  32720. protected _boundUniforms: {
  32721. [key: number]: WebGLUniformLocation;
  32722. };
  32723. /**
  32724. * Binds an effect to the webGL context
  32725. * @param effect defines the effect to bind
  32726. */
  32727. bindSamplers(effect: Effect): void;
  32728. private _activateCurrentTexture;
  32729. /** @hidden */
  32730. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32731. /** @hidden */
  32732. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32733. /**
  32734. * Unbind all textures from the webGL context
  32735. */
  32736. unbindAllTextures(): void;
  32737. /**
  32738. * Sets a texture to the according uniform.
  32739. * @param channel The texture channel
  32740. * @param uniform The uniform to set
  32741. * @param texture The texture to apply
  32742. */
  32743. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32744. private _bindSamplerUniformToChannel;
  32745. private _getTextureWrapMode;
  32746. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32747. /**
  32748. * Sets an array of texture to the webGL context
  32749. * @param channel defines the channel where the texture array must be set
  32750. * @param uniform defines the associated uniform location
  32751. * @param textures defines the array of textures to bind
  32752. */
  32753. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32754. /** @hidden */
  32755. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32756. private _setTextureParameterFloat;
  32757. private _setTextureParameterInteger;
  32758. /**
  32759. * Unbind all vertex attributes from the webGL context
  32760. */
  32761. unbindAllAttributes(): void;
  32762. /**
  32763. * 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
  32764. */
  32765. releaseEffects(): void;
  32766. /**
  32767. * Dispose and release all associated resources
  32768. */
  32769. dispose(): void;
  32770. /**
  32771. * Attach a new callback raised when context lost event is fired
  32772. * @param callback defines the callback to call
  32773. */
  32774. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32775. /**
  32776. * Attach a new callback raised when context restored event is fired
  32777. * @param callback defines the callback to call
  32778. */
  32779. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32780. /**
  32781. * Get the current error code of the webGL context
  32782. * @returns the error code
  32783. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32784. */
  32785. getError(): number;
  32786. private _canRenderToFloatFramebuffer;
  32787. private _canRenderToHalfFloatFramebuffer;
  32788. private _canRenderToFramebuffer;
  32789. /** @hidden */
  32790. _getWebGLTextureType(type: number): number;
  32791. /** @hidden */
  32792. _getInternalFormat(format: number): number;
  32793. /** @hidden */
  32794. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32795. /** @hidden */
  32796. _getRGBAMultiSampleBufferFormat(type: number): number;
  32797. /** @hidden */
  32798. _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;
  32799. /**
  32800. * Loads a file from a url
  32801. * @param url url to load
  32802. * @param onSuccess callback called when the file successfully loads
  32803. * @param onProgress callback called while file is loading (if the server supports this mode)
  32804. * @param offlineProvider defines the offline provider for caching
  32805. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32806. * @param onError callback called when the file fails to load
  32807. * @returns a file request object
  32808. * @hidden
  32809. */
  32810. 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;
  32811. /**
  32812. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32813. * @param x defines the x coordinate of the rectangle where pixels must be read
  32814. * @param y defines the y coordinate of the rectangle where pixels must be read
  32815. * @param width defines the width of the rectangle where pixels must be read
  32816. * @param height defines the height of the rectangle where pixels must be read
  32817. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32818. * @returns a Uint8Array containing RGBA colors
  32819. */
  32820. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32821. private static _isSupported;
  32822. /**
  32823. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32824. * @returns true if the engine can be created
  32825. * @ignorenaming
  32826. */
  32827. static isSupported(): boolean;
  32828. /**
  32829. * Find the next highest power of two.
  32830. * @param x Number to start search from.
  32831. * @return Next highest power of two.
  32832. */
  32833. static CeilingPOT(x: number): number;
  32834. /**
  32835. * Find the next lowest power of two.
  32836. * @param x Number to start search from.
  32837. * @return Next lowest power of two.
  32838. */
  32839. static FloorPOT(x: number): number;
  32840. /**
  32841. * Find the nearest power of two.
  32842. * @param x Number to start search from.
  32843. * @return Next nearest power of two.
  32844. */
  32845. static NearestPOT(x: number): number;
  32846. /**
  32847. * Get the closest exponent of two
  32848. * @param value defines the value to approximate
  32849. * @param max defines the maximum value to return
  32850. * @param mode defines how to define the closest value
  32851. * @returns closest exponent of two of the given value
  32852. */
  32853. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32854. /**
  32855. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32856. * @param func - the function to be called
  32857. * @param requester - the object that will request the next frame. Falls back to window.
  32858. * @returns frame number
  32859. */
  32860. static QueueNewFrame(func: () => void, requester?: any): number;
  32861. /**
  32862. * Gets host document
  32863. * @returns the host document object
  32864. */
  32865. getHostDocument(): Nullable<Document>;
  32866. }
  32867. }
  32868. declare module "babylonjs/Maths/sphericalPolynomial" {
  32869. import { Vector3 } from "babylonjs/Maths/math.vector";
  32870. import { Color3 } from "babylonjs/Maths/math.color";
  32871. /**
  32872. * Class representing spherical harmonics coefficients to the 3rd degree
  32873. */
  32874. export class SphericalHarmonics {
  32875. /**
  32876. * Defines whether or not the harmonics have been prescaled for rendering.
  32877. */
  32878. preScaled: boolean;
  32879. /**
  32880. * The l0,0 coefficients of the spherical harmonics
  32881. */
  32882. l00: Vector3;
  32883. /**
  32884. * The l1,-1 coefficients of the spherical harmonics
  32885. */
  32886. l1_1: Vector3;
  32887. /**
  32888. * The l1,0 coefficients of the spherical harmonics
  32889. */
  32890. l10: Vector3;
  32891. /**
  32892. * The l1,1 coefficients of the spherical harmonics
  32893. */
  32894. l11: Vector3;
  32895. /**
  32896. * The l2,-2 coefficients of the spherical harmonics
  32897. */
  32898. l2_2: Vector3;
  32899. /**
  32900. * The l2,-1 coefficients of the spherical harmonics
  32901. */
  32902. l2_1: Vector3;
  32903. /**
  32904. * The l2,0 coefficients of the spherical harmonics
  32905. */
  32906. l20: Vector3;
  32907. /**
  32908. * The l2,1 coefficients of the spherical harmonics
  32909. */
  32910. l21: Vector3;
  32911. /**
  32912. * The l2,2 coefficients of the spherical harmonics
  32913. */
  32914. l22: Vector3;
  32915. /**
  32916. * Adds a light to the spherical harmonics
  32917. * @param direction the direction of the light
  32918. * @param color the color of the light
  32919. * @param deltaSolidAngle the delta solid angle of the light
  32920. */
  32921. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32922. /**
  32923. * Scales the spherical harmonics by the given amount
  32924. * @param scale the amount to scale
  32925. */
  32926. scaleInPlace(scale: number): void;
  32927. /**
  32928. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32929. *
  32930. * ```
  32931. * E_lm = A_l * L_lm
  32932. * ```
  32933. *
  32934. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32935. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32936. * the scaling factors are given in equation 9.
  32937. */
  32938. convertIncidentRadianceToIrradiance(): void;
  32939. /**
  32940. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32941. *
  32942. * ```
  32943. * L = (1/pi) * E * rho
  32944. * ```
  32945. *
  32946. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32947. */
  32948. convertIrradianceToLambertianRadiance(): void;
  32949. /**
  32950. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32951. * required operations at run time.
  32952. *
  32953. * This is simply done by scaling back the SH with Ylm constants parameter.
  32954. * The trigonometric part being applied by the shader at run time.
  32955. */
  32956. preScaleForRendering(): void;
  32957. /**
  32958. * Constructs a spherical harmonics from an array.
  32959. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32960. * @returns the spherical harmonics
  32961. */
  32962. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32963. /**
  32964. * Gets the spherical harmonics from polynomial
  32965. * @param polynomial the spherical polynomial
  32966. * @returns the spherical harmonics
  32967. */
  32968. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32969. }
  32970. /**
  32971. * Class representing spherical polynomial coefficients to the 3rd degree
  32972. */
  32973. export class SphericalPolynomial {
  32974. private _harmonics;
  32975. /**
  32976. * The spherical harmonics used to create the polynomials.
  32977. */
  32978. get preScaledHarmonics(): SphericalHarmonics;
  32979. /**
  32980. * The x coefficients of the spherical polynomial
  32981. */
  32982. x: Vector3;
  32983. /**
  32984. * The y coefficients of the spherical polynomial
  32985. */
  32986. y: Vector3;
  32987. /**
  32988. * The z coefficients of the spherical polynomial
  32989. */
  32990. z: Vector3;
  32991. /**
  32992. * The xx coefficients of the spherical polynomial
  32993. */
  32994. xx: Vector3;
  32995. /**
  32996. * The yy coefficients of the spherical polynomial
  32997. */
  32998. yy: Vector3;
  32999. /**
  33000. * The zz coefficients of the spherical polynomial
  33001. */
  33002. zz: Vector3;
  33003. /**
  33004. * The xy coefficients of the spherical polynomial
  33005. */
  33006. xy: Vector3;
  33007. /**
  33008. * The yz coefficients of the spherical polynomial
  33009. */
  33010. yz: Vector3;
  33011. /**
  33012. * The zx coefficients of the spherical polynomial
  33013. */
  33014. zx: Vector3;
  33015. /**
  33016. * Adds an ambient color to the spherical polynomial
  33017. * @param color the color to add
  33018. */
  33019. addAmbient(color: Color3): void;
  33020. /**
  33021. * Scales the spherical polynomial by the given amount
  33022. * @param scale the amount to scale
  33023. */
  33024. scaleInPlace(scale: number): void;
  33025. /**
  33026. * Gets the spherical polynomial from harmonics
  33027. * @param harmonics the spherical harmonics
  33028. * @returns the spherical polynomial
  33029. */
  33030. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33031. /**
  33032. * Constructs a spherical polynomial from an array.
  33033. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33034. * @returns the spherical polynomial
  33035. */
  33036. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33037. }
  33038. }
  33039. declare module "babylonjs/Materials/Textures/internalTexture" {
  33040. import { Observable } from "babylonjs/Misc/observable";
  33041. import { Nullable, int } from "babylonjs/types";
  33042. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33044. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33045. /**
  33046. * Defines the source of the internal texture
  33047. */
  33048. export enum InternalTextureSource {
  33049. /**
  33050. * The source of the texture data is unknown
  33051. */
  33052. Unknown = 0,
  33053. /**
  33054. * Texture data comes from an URL
  33055. */
  33056. Url = 1,
  33057. /**
  33058. * Texture data is only used for temporary storage
  33059. */
  33060. Temp = 2,
  33061. /**
  33062. * Texture data comes from raw data (ArrayBuffer)
  33063. */
  33064. Raw = 3,
  33065. /**
  33066. * Texture content is dynamic (video or dynamic texture)
  33067. */
  33068. Dynamic = 4,
  33069. /**
  33070. * Texture content is generated by rendering to it
  33071. */
  33072. RenderTarget = 5,
  33073. /**
  33074. * Texture content is part of a multi render target process
  33075. */
  33076. MultiRenderTarget = 6,
  33077. /**
  33078. * Texture data comes from a cube data file
  33079. */
  33080. Cube = 7,
  33081. /**
  33082. * Texture data comes from a raw cube data
  33083. */
  33084. CubeRaw = 8,
  33085. /**
  33086. * Texture data come from a prefiltered cube data file
  33087. */
  33088. CubePrefiltered = 9,
  33089. /**
  33090. * Texture content is raw 3D data
  33091. */
  33092. Raw3D = 10,
  33093. /**
  33094. * Texture content is raw 2D array data
  33095. */
  33096. Raw2DArray = 11,
  33097. /**
  33098. * Texture content is a depth texture
  33099. */
  33100. Depth = 12,
  33101. /**
  33102. * Texture data comes from a raw cube data encoded with RGBD
  33103. */
  33104. CubeRawRGBD = 13
  33105. }
  33106. /**
  33107. * Class used to store data associated with WebGL texture data for the engine
  33108. * This class should not be used directly
  33109. */
  33110. export class InternalTexture {
  33111. /** @hidden */
  33112. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33113. /**
  33114. * Defines if the texture is ready
  33115. */
  33116. isReady: boolean;
  33117. /**
  33118. * Defines if the texture is a cube texture
  33119. */
  33120. isCube: boolean;
  33121. /**
  33122. * Defines if the texture contains 3D data
  33123. */
  33124. is3D: boolean;
  33125. /**
  33126. * Defines if the texture contains 2D array data
  33127. */
  33128. is2DArray: boolean;
  33129. /**
  33130. * Defines if the texture contains multiview data
  33131. */
  33132. isMultiview: boolean;
  33133. /**
  33134. * Gets the URL used to load this texture
  33135. */
  33136. url: string;
  33137. /**
  33138. * Gets the sampling mode of the texture
  33139. */
  33140. samplingMode: number;
  33141. /**
  33142. * Gets a boolean indicating if the texture needs mipmaps generation
  33143. */
  33144. generateMipMaps: boolean;
  33145. /**
  33146. * Gets the number of samples used by the texture (WebGL2+ only)
  33147. */
  33148. samples: number;
  33149. /**
  33150. * Gets the type of the texture (int, float...)
  33151. */
  33152. type: number;
  33153. /**
  33154. * Gets the format of the texture (RGB, RGBA...)
  33155. */
  33156. format: number;
  33157. /**
  33158. * Observable called when the texture is loaded
  33159. */
  33160. onLoadedObservable: Observable<InternalTexture>;
  33161. /**
  33162. * Gets the width of the texture
  33163. */
  33164. width: number;
  33165. /**
  33166. * Gets the height of the texture
  33167. */
  33168. height: number;
  33169. /**
  33170. * Gets the depth of the texture
  33171. */
  33172. depth: number;
  33173. /**
  33174. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33175. */
  33176. baseWidth: number;
  33177. /**
  33178. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33179. */
  33180. baseHeight: number;
  33181. /**
  33182. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33183. */
  33184. baseDepth: number;
  33185. /**
  33186. * Gets a boolean indicating if the texture is inverted on Y axis
  33187. */
  33188. invertY: boolean;
  33189. /** @hidden */
  33190. _invertVScale: boolean;
  33191. /** @hidden */
  33192. _associatedChannel: number;
  33193. /** @hidden */
  33194. _source: InternalTextureSource;
  33195. /** @hidden */
  33196. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33197. /** @hidden */
  33198. _bufferView: Nullable<ArrayBufferView>;
  33199. /** @hidden */
  33200. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33201. /** @hidden */
  33202. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33203. /** @hidden */
  33204. _size: number;
  33205. /** @hidden */
  33206. _extension: string;
  33207. /** @hidden */
  33208. _files: Nullable<string[]>;
  33209. /** @hidden */
  33210. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33211. /** @hidden */
  33212. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33213. /** @hidden */
  33214. _framebuffer: Nullable<WebGLFramebuffer>;
  33215. /** @hidden */
  33216. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33217. /** @hidden */
  33218. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33219. /** @hidden */
  33220. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33221. /** @hidden */
  33222. _attachments: Nullable<number[]>;
  33223. /** @hidden */
  33224. _cachedCoordinatesMode: Nullable<number>;
  33225. /** @hidden */
  33226. _cachedWrapU: Nullable<number>;
  33227. /** @hidden */
  33228. _cachedWrapV: Nullable<number>;
  33229. /** @hidden */
  33230. _cachedWrapR: Nullable<number>;
  33231. /** @hidden */
  33232. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33233. /** @hidden */
  33234. _isDisabled: boolean;
  33235. /** @hidden */
  33236. _compression: Nullable<string>;
  33237. /** @hidden */
  33238. _generateStencilBuffer: boolean;
  33239. /** @hidden */
  33240. _generateDepthBuffer: boolean;
  33241. /** @hidden */
  33242. _comparisonFunction: number;
  33243. /** @hidden */
  33244. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33245. /** @hidden */
  33246. _lodGenerationScale: number;
  33247. /** @hidden */
  33248. _lodGenerationOffset: number;
  33249. /** @hidden */
  33250. _depthStencilTexture: Nullable<InternalTexture>;
  33251. /** @hidden */
  33252. _colorTextureArray: Nullable<WebGLTexture>;
  33253. /** @hidden */
  33254. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33255. /** @hidden */
  33256. _lodTextureHigh: Nullable<BaseTexture>;
  33257. /** @hidden */
  33258. _lodTextureMid: Nullable<BaseTexture>;
  33259. /** @hidden */
  33260. _lodTextureLow: Nullable<BaseTexture>;
  33261. /** @hidden */
  33262. _isRGBD: boolean;
  33263. /** @hidden */
  33264. _linearSpecularLOD: boolean;
  33265. /** @hidden */
  33266. _irradianceTexture: Nullable<BaseTexture>;
  33267. /** @hidden */
  33268. _webGLTexture: Nullable<WebGLTexture>;
  33269. /** @hidden */
  33270. _references: number;
  33271. private _engine;
  33272. /**
  33273. * Gets the Engine the texture belongs to.
  33274. * @returns The babylon engine
  33275. */
  33276. getEngine(): ThinEngine;
  33277. /**
  33278. * Gets the data source type of the texture
  33279. */
  33280. get source(): InternalTextureSource;
  33281. /**
  33282. * Creates a new InternalTexture
  33283. * @param engine defines the engine to use
  33284. * @param source defines the type of data that will be used
  33285. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33286. */
  33287. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33288. /**
  33289. * Increments the number of references (ie. the number of Texture that point to it)
  33290. */
  33291. incrementReferences(): void;
  33292. /**
  33293. * Change the size of the texture (not the size of the content)
  33294. * @param width defines the new width
  33295. * @param height defines the new height
  33296. * @param depth defines the new depth (1 by default)
  33297. */
  33298. updateSize(width: int, height: int, depth?: int): void;
  33299. /** @hidden */
  33300. _rebuild(): void;
  33301. /** @hidden */
  33302. _swapAndDie(target: InternalTexture): void;
  33303. /**
  33304. * Dispose the current allocated resources
  33305. */
  33306. dispose(): void;
  33307. }
  33308. }
  33309. declare module "babylonjs/Audio/analyser" {
  33310. import { Scene } from "babylonjs/scene";
  33311. /**
  33312. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33314. */
  33315. export class Analyser {
  33316. /**
  33317. * Gets or sets the smoothing
  33318. * @ignorenaming
  33319. */
  33320. SMOOTHING: number;
  33321. /**
  33322. * Gets or sets the FFT table size
  33323. * @ignorenaming
  33324. */
  33325. FFT_SIZE: number;
  33326. /**
  33327. * Gets or sets the bar graph amplitude
  33328. * @ignorenaming
  33329. */
  33330. BARGRAPHAMPLITUDE: number;
  33331. /**
  33332. * Gets or sets the position of the debug canvas
  33333. * @ignorenaming
  33334. */
  33335. DEBUGCANVASPOS: {
  33336. x: number;
  33337. y: number;
  33338. };
  33339. /**
  33340. * Gets or sets the debug canvas size
  33341. * @ignorenaming
  33342. */
  33343. DEBUGCANVASSIZE: {
  33344. width: number;
  33345. height: number;
  33346. };
  33347. private _byteFreqs;
  33348. private _byteTime;
  33349. private _floatFreqs;
  33350. private _webAudioAnalyser;
  33351. private _debugCanvas;
  33352. private _debugCanvasContext;
  33353. private _scene;
  33354. private _registerFunc;
  33355. private _audioEngine;
  33356. /**
  33357. * Creates a new analyser
  33358. * @param scene defines hosting scene
  33359. */
  33360. constructor(scene: Scene);
  33361. /**
  33362. * Get the number of data values you will have to play with for the visualization
  33363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33364. * @returns a number
  33365. */
  33366. getFrequencyBinCount(): number;
  33367. /**
  33368. * Gets the current frequency data as a byte array
  33369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33370. * @returns a Uint8Array
  33371. */
  33372. getByteFrequencyData(): Uint8Array;
  33373. /**
  33374. * Gets the current waveform as a byte array
  33375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33376. * @returns a Uint8Array
  33377. */
  33378. getByteTimeDomainData(): Uint8Array;
  33379. /**
  33380. * Gets the current frequency data as a float array
  33381. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33382. * @returns a Float32Array
  33383. */
  33384. getFloatFrequencyData(): Float32Array;
  33385. /**
  33386. * Renders the debug canvas
  33387. */
  33388. drawDebugCanvas(): void;
  33389. /**
  33390. * Stops rendering the debug canvas and removes it
  33391. */
  33392. stopDebugCanvas(): void;
  33393. /**
  33394. * Connects two audio nodes
  33395. * @param inputAudioNode defines first node to connect
  33396. * @param outputAudioNode defines second node to connect
  33397. */
  33398. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33399. /**
  33400. * Releases all associated resources
  33401. */
  33402. dispose(): void;
  33403. }
  33404. }
  33405. declare module "babylonjs/Audio/audioEngine" {
  33406. import { IDisposable } from "babylonjs/scene";
  33407. import { Analyser } from "babylonjs/Audio/analyser";
  33408. import { Nullable } from "babylonjs/types";
  33409. import { Observable } from "babylonjs/Misc/observable";
  33410. /**
  33411. * This represents an audio engine and it is responsible
  33412. * to play, synchronize and analyse sounds throughout the application.
  33413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33414. */
  33415. export interface IAudioEngine extends IDisposable {
  33416. /**
  33417. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33418. */
  33419. readonly canUseWebAudio: boolean;
  33420. /**
  33421. * Gets the current AudioContext if available.
  33422. */
  33423. readonly audioContext: Nullable<AudioContext>;
  33424. /**
  33425. * The master gain node defines the global audio volume of your audio engine.
  33426. */
  33427. readonly masterGain: GainNode;
  33428. /**
  33429. * Gets whether or not mp3 are supported by your browser.
  33430. */
  33431. readonly isMP3supported: boolean;
  33432. /**
  33433. * Gets whether or not ogg are supported by your browser.
  33434. */
  33435. readonly isOGGsupported: boolean;
  33436. /**
  33437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33438. * @ignoreNaming
  33439. */
  33440. WarnedWebAudioUnsupported: boolean;
  33441. /**
  33442. * Defines if the audio engine relies on a custom unlocked button.
  33443. * In this case, the embedded button will not be displayed.
  33444. */
  33445. useCustomUnlockedButton: boolean;
  33446. /**
  33447. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33448. */
  33449. readonly unlocked: boolean;
  33450. /**
  33451. * Event raised when audio has been unlocked on the browser.
  33452. */
  33453. onAudioUnlockedObservable: Observable<AudioEngine>;
  33454. /**
  33455. * Event raised when audio has been locked on the browser.
  33456. */
  33457. onAudioLockedObservable: Observable<AudioEngine>;
  33458. /**
  33459. * Flags the audio engine in Locked state.
  33460. * This happens due to new browser policies preventing audio to autoplay.
  33461. */
  33462. lock(): void;
  33463. /**
  33464. * Unlocks the audio engine once a user action has been done on the dom.
  33465. * This is helpful to resume play once browser policies have been satisfied.
  33466. */
  33467. unlock(): void;
  33468. }
  33469. /**
  33470. * This represents the default audio engine used in babylon.
  33471. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33473. */
  33474. export class AudioEngine implements IAudioEngine {
  33475. private _audioContext;
  33476. private _audioContextInitialized;
  33477. private _muteButton;
  33478. private _hostElement;
  33479. /**
  33480. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33481. */
  33482. canUseWebAudio: boolean;
  33483. /**
  33484. * The master gain node defines the global audio volume of your audio engine.
  33485. */
  33486. masterGain: GainNode;
  33487. /**
  33488. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33489. * @ignoreNaming
  33490. */
  33491. WarnedWebAudioUnsupported: boolean;
  33492. /**
  33493. * Gets whether or not mp3 are supported by your browser.
  33494. */
  33495. isMP3supported: boolean;
  33496. /**
  33497. * Gets whether or not ogg are supported by your browser.
  33498. */
  33499. isOGGsupported: boolean;
  33500. /**
  33501. * Gets whether audio has been unlocked on the device.
  33502. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33503. * a user interaction has happened.
  33504. */
  33505. unlocked: boolean;
  33506. /**
  33507. * Defines if the audio engine relies on a custom unlocked button.
  33508. * In this case, the embedded button will not be displayed.
  33509. */
  33510. useCustomUnlockedButton: boolean;
  33511. /**
  33512. * Event raised when audio has been unlocked on the browser.
  33513. */
  33514. onAudioUnlockedObservable: Observable<AudioEngine>;
  33515. /**
  33516. * Event raised when audio has been locked on the browser.
  33517. */
  33518. onAudioLockedObservable: Observable<AudioEngine>;
  33519. /**
  33520. * Gets the current AudioContext if available.
  33521. */
  33522. get audioContext(): Nullable<AudioContext>;
  33523. private _connectedAnalyser;
  33524. /**
  33525. * Instantiates a new audio engine.
  33526. *
  33527. * There should be only one per page as some browsers restrict the number
  33528. * of audio contexts you can create.
  33529. * @param hostElement defines the host element where to display the mute icon if necessary
  33530. */
  33531. constructor(hostElement?: Nullable<HTMLElement>);
  33532. /**
  33533. * Flags the audio engine in Locked state.
  33534. * This happens due to new browser policies preventing audio to autoplay.
  33535. */
  33536. lock(): void;
  33537. /**
  33538. * Unlocks the audio engine once a user action has been done on the dom.
  33539. * This is helpful to resume play once browser policies have been satisfied.
  33540. */
  33541. unlock(): void;
  33542. private _resumeAudioContext;
  33543. private _initializeAudioContext;
  33544. private _tryToRun;
  33545. private _triggerRunningState;
  33546. private _triggerSuspendedState;
  33547. private _displayMuteButton;
  33548. private _moveButtonToTopLeft;
  33549. private _onResize;
  33550. private _hideMuteButton;
  33551. /**
  33552. * Destroy and release the resources associated with the audio ccontext.
  33553. */
  33554. dispose(): void;
  33555. /**
  33556. * Gets the global volume sets on the master gain.
  33557. * @returns the global volume if set or -1 otherwise
  33558. */
  33559. getGlobalVolume(): number;
  33560. /**
  33561. * Sets the global volume of your experience (sets on the master gain).
  33562. * @param newVolume Defines the new global volume of the application
  33563. */
  33564. setGlobalVolume(newVolume: number): void;
  33565. /**
  33566. * Connect the audio engine to an audio analyser allowing some amazing
  33567. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33569. * @param analyser The analyser to connect to the engine
  33570. */
  33571. connectToAnalyser(analyser: Analyser): void;
  33572. }
  33573. }
  33574. declare module "babylonjs/Loading/loadingScreen" {
  33575. /**
  33576. * Interface used to present a loading screen while loading a scene
  33577. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33578. */
  33579. export interface ILoadingScreen {
  33580. /**
  33581. * Function called to display the loading screen
  33582. */
  33583. displayLoadingUI: () => void;
  33584. /**
  33585. * Function called to hide the loading screen
  33586. */
  33587. hideLoadingUI: () => void;
  33588. /**
  33589. * Gets or sets the color to use for the background
  33590. */
  33591. loadingUIBackgroundColor: string;
  33592. /**
  33593. * Gets or sets the text to display while loading
  33594. */
  33595. loadingUIText: string;
  33596. }
  33597. /**
  33598. * Class used for the default loading screen
  33599. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33600. */
  33601. export class DefaultLoadingScreen implements ILoadingScreen {
  33602. private _renderingCanvas;
  33603. private _loadingText;
  33604. private _loadingDivBackgroundColor;
  33605. private _loadingDiv;
  33606. private _loadingTextDiv;
  33607. /** Gets or sets the logo url to use for the default loading screen */
  33608. static DefaultLogoUrl: string;
  33609. /** Gets or sets the spinner url to use for the default loading screen */
  33610. static DefaultSpinnerUrl: string;
  33611. /**
  33612. * Creates a new default loading screen
  33613. * @param _renderingCanvas defines the canvas used to render the scene
  33614. * @param _loadingText defines the default text to display
  33615. * @param _loadingDivBackgroundColor defines the default background color
  33616. */
  33617. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33618. /**
  33619. * Function called to display the loading screen
  33620. */
  33621. displayLoadingUI(): void;
  33622. /**
  33623. * Function called to hide the loading screen
  33624. */
  33625. hideLoadingUI(): void;
  33626. /**
  33627. * Gets or sets the text to display while loading
  33628. */
  33629. set loadingUIText(text: string);
  33630. get loadingUIText(): string;
  33631. /**
  33632. * Gets or sets the color to use for the background
  33633. */
  33634. get loadingUIBackgroundColor(): string;
  33635. set loadingUIBackgroundColor(color: string);
  33636. private _resizeLoadingUI;
  33637. }
  33638. }
  33639. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33640. /**
  33641. * Interface for any object that can request an animation frame
  33642. */
  33643. export interface ICustomAnimationFrameRequester {
  33644. /**
  33645. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33646. */
  33647. renderFunction?: Function;
  33648. /**
  33649. * Called to request the next frame to render to
  33650. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33651. */
  33652. requestAnimationFrame: Function;
  33653. /**
  33654. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33655. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33656. */
  33657. requestID?: number;
  33658. }
  33659. }
  33660. declare module "babylonjs/Misc/performanceMonitor" {
  33661. /**
  33662. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33663. */
  33664. export class PerformanceMonitor {
  33665. private _enabled;
  33666. private _rollingFrameTime;
  33667. private _lastFrameTimeMs;
  33668. /**
  33669. * constructor
  33670. * @param frameSampleSize The number of samples required to saturate the sliding window
  33671. */
  33672. constructor(frameSampleSize?: number);
  33673. /**
  33674. * Samples current frame
  33675. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33676. */
  33677. sampleFrame(timeMs?: number): void;
  33678. /**
  33679. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33680. */
  33681. get averageFrameTime(): number;
  33682. /**
  33683. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33684. */
  33685. get averageFrameTimeVariance(): number;
  33686. /**
  33687. * Returns the frame time of the most recent frame
  33688. */
  33689. get instantaneousFrameTime(): number;
  33690. /**
  33691. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33692. */
  33693. get averageFPS(): number;
  33694. /**
  33695. * Returns the average framerate in frames per second using the most recent frame time
  33696. */
  33697. get instantaneousFPS(): number;
  33698. /**
  33699. * Returns true if enough samples have been taken to completely fill the sliding window
  33700. */
  33701. get isSaturated(): boolean;
  33702. /**
  33703. * Enables contributions to the sliding window sample set
  33704. */
  33705. enable(): void;
  33706. /**
  33707. * Disables contributions to the sliding window sample set
  33708. * Samples will not be interpolated over the disabled period
  33709. */
  33710. disable(): void;
  33711. /**
  33712. * Returns true if sampling is enabled
  33713. */
  33714. get isEnabled(): boolean;
  33715. /**
  33716. * Resets performance monitor
  33717. */
  33718. reset(): void;
  33719. }
  33720. /**
  33721. * RollingAverage
  33722. *
  33723. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33724. */
  33725. export class RollingAverage {
  33726. /**
  33727. * Current average
  33728. */
  33729. average: number;
  33730. /**
  33731. * Current variance
  33732. */
  33733. variance: number;
  33734. protected _samples: Array<number>;
  33735. protected _sampleCount: number;
  33736. protected _pos: number;
  33737. protected _m2: number;
  33738. /**
  33739. * constructor
  33740. * @param length The number of samples required to saturate the sliding window
  33741. */
  33742. constructor(length: number);
  33743. /**
  33744. * Adds a sample to the sample set
  33745. * @param v The sample value
  33746. */
  33747. add(v: number): void;
  33748. /**
  33749. * Returns previously added values or null if outside of history or outside the sliding window domain
  33750. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33751. * @return Value previously recorded with add() or null if outside of range
  33752. */
  33753. history(i: number): number;
  33754. /**
  33755. * Returns true if enough samples have been taken to completely fill the sliding window
  33756. * @return true if sample-set saturated
  33757. */
  33758. isSaturated(): boolean;
  33759. /**
  33760. * Resets the rolling average (equivalent to 0 samples taken so far)
  33761. */
  33762. reset(): void;
  33763. /**
  33764. * Wraps a value around the sample range boundaries
  33765. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33766. * @return Wrapped position in sample range
  33767. */
  33768. protected _wrapPosition(i: number): number;
  33769. }
  33770. }
  33771. declare module "babylonjs/Misc/perfCounter" {
  33772. /**
  33773. * This class is used to track a performance counter which is number based.
  33774. * The user has access to many properties which give statistics of different nature.
  33775. *
  33776. * The implementer can track two kinds of Performance Counter: time and count.
  33777. * 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.
  33778. * 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.
  33779. */
  33780. export class PerfCounter {
  33781. /**
  33782. * Gets or sets a global boolean to turn on and off all the counters
  33783. */
  33784. static Enabled: boolean;
  33785. /**
  33786. * Returns the smallest value ever
  33787. */
  33788. get min(): number;
  33789. /**
  33790. * Returns the biggest value ever
  33791. */
  33792. get max(): number;
  33793. /**
  33794. * Returns the average value since the performance counter is running
  33795. */
  33796. get average(): number;
  33797. /**
  33798. * Returns the average value of the last second the counter was monitored
  33799. */
  33800. get lastSecAverage(): number;
  33801. /**
  33802. * Returns the current value
  33803. */
  33804. get current(): number;
  33805. /**
  33806. * Gets the accumulated total
  33807. */
  33808. get total(): number;
  33809. /**
  33810. * Gets the total value count
  33811. */
  33812. get count(): number;
  33813. /**
  33814. * Creates a new counter
  33815. */
  33816. constructor();
  33817. /**
  33818. * Call this method to start monitoring a new frame.
  33819. * 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.
  33820. */
  33821. fetchNewFrame(): void;
  33822. /**
  33823. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33824. * @param newCount the count value to add to the monitored count
  33825. * @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.
  33826. */
  33827. addCount(newCount: number, fetchResult: boolean): void;
  33828. /**
  33829. * Start monitoring this performance counter
  33830. */
  33831. beginMonitoring(): void;
  33832. /**
  33833. * Compute the time lapsed since the previous beginMonitoring() call.
  33834. * @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
  33835. */
  33836. endMonitoring(newFrame?: boolean): void;
  33837. private _fetchResult;
  33838. private _startMonitoringTime;
  33839. private _min;
  33840. private _max;
  33841. private _average;
  33842. private _current;
  33843. private _totalValueCount;
  33844. private _totalAccumulated;
  33845. private _lastSecAverage;
  33846. private _lastSecAccumulated;
  33847. private _lastSecTime;
  33848. private _lastSecValueCount;
  33849. }
  33850. }
  33851. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33852. module "babylonjs/Engines/thinEngine" {
  33853. interface ThinEngine {
  33854. /**
  33855. * Sets alpha constants used by some alpha blending modes
  33856. * @param r defines the red component
  33857. * @param g defines the green component
  33858. * @param b defines the blue component
  33859. * @param a defines the alpha component
  33860. */
  33861. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33862. /**
  33863. * Sets the current alpha mode
  33864. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33865. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33867. */
  33868. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33869. /**
  33870. * Gets the current alpha mode
  33871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33872. * @returns the current alpha mode
  33873. */
  33874. getAlphaMode(): number;
  33875. /**
  33876. * Sets the current alpha equation
  33877. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33878. */
  33879. setAlphaEquation(equation: number): void;
  33880. /**
  33881. * Gets the current alpha equation.
  33882. * @returns the current alpha equation
  33883. */
  33884. getAlphaEquation(): number;
  33885. }
  33886. }
  33887. }
  33888. declare module "babylonjs/Engines/engine" {
  33889. import { Observable } from "babylonjs/Misc/observable";
  33890. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33891. import { Scene } from "babylonjs/scene";
  33892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33893. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33894. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33895. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33896. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33897. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33898. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33899. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33900. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33902. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33903. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33904. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33905. import "babylonjs/Engines/Extensions/engine.alpha";
  33906. import { Material } from "babylonjs/Materials/material";
  33907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33908. /**
  33909. * Defines the interface used by display changed events
  33910. */
  33911. export interface IDisplayChangedEventArgs {
  33912. /** Gets the vrDisplay object (if any) */
  33913. vrDisplay: Nullable<any>;
  33914. /** Gets a boolean indicating if webVR is supported */
  33915. vrSupported: boolean;
  33916. }
  33917. /**
  33918. * Defines the interface used by objects containing a viewport (like a camera)
  33919. */
  33920. interface IViewportOwnerLike {
  33921. /**
  33922. * Gets or sets the viewport
  33923. */
  33924. viewport: IViewportLike;
  33925. }
  33926. /**
  33927. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33928. */
  33929. export class Engine extends ThinEngine {
  33930. /** Defines that alpha blending is disabled */
  33931. static readonly ALPHA_DISABLE: number;
  33932. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33933. static readonly ALPHA_ADD: number;
  33934. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33935. static readonly ALPHA_COMBINE: number;
  33936. /** Defines that alpha blending to DEST - SRC * DEST */
  33937. static readonly ALPHA_SUBTRACT: number;
  33938. /** Defines that alpha blending to SRC * DEST */
  33939. static readonly ALPHA_MULTIPLY: number;
  33940. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33941. static readonly ALPHA_MAXIMIZED: number;
  33942. /** Defines that alpha blending to SRC + DEST */
  33943. static readonly ALPHA_ONEONE: number;
  33944. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33945. static readonly ALPHA_PREMULTIPLIED: number;
  33946. /**
  33947. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33948. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33949. */
  33950. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33951. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33952. static readonly ALPHA_INTERPOLATE: number;
  33953. /**
  33954. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33955. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33956. */
  33957. static readonly ALPHA_SCREENMODE: number;
  33958. /** Defines that the ressource is not delayed*/
  33959. static readonly DELAYLOADSTATE_NONE: number;
  33960. /** Defines that the ressource was successfully delay loaded */
  33961. static readonly DELAYLOADSTATE_LOADED: number;
  33962. /** Defines that the ressource is currently delay loading */
  33963. static readonly DELAYLOADSTATE_LOADING: number;
  33964. /** Defines that the ressource is delayed and has not started loading */
  33965. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33966. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33967. static readonly NEVER: number;
  33968. /** 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 */
  33969. static readonly ALWAYS: number;
  33970. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33971. static readonly LESS: number;
  33972. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33973. static readonly EQUAL: number;
  33974. /** 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 */
  33975. static readonly LEQUAL: number;
  33976. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33977. static readonly GREATER: number;
  33978. /** 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 */
  33979. static readonly GEQUAL: number;
  33980. /** 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 */
  33981. static readonly NOTEQUAL: number;
  33982. /** Passed to stencilOperation to specify that stencil value must be kept */
  33983. static readonly KEEP: number;
  33984. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33985. static readonly REPLACE: number;
  33986. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33987. static readonly INCR: number;
  33988. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33989. static readonly DECR: number;
  33990. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33991. static readonly INVERT: number;
  33992. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33993. static readonly INCR_WRAP: number;
  33994. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33995. static readonly DECR_WRAP: number;
  33996. /** Texture is not repeating outside of 0..1 UVs */
  33997. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33998. /** Texture is repeating outside of 0..1 UVs */
  33999. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34000. /** Texture is repeating and mirrored */
  34001. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34002. /** ALPHA */
  34003. static readonly TEXTUREFORMAT_ALPHA: number;
  34004. /** LUMINANCE */
  34005. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34006. /** LUMINANCE_ALPHA */
  34007. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34008. /** RGB */
  34009. static readonly TEXTUREFORMAT_RGB: number;
  34010. /** RGBA */
  34011. static readonly TEXTUREFORMAT_RGBA: number;
  34012. /** RED */
  34013. static readonly TEXTUREFORMAT_RED: number;
  34014. /** RED (2nd reference) */
  34015. static readonly TEXTUREFORMAT_R: number;
  34016. /** RG */
  34017. static readonly TEXTUREFORMAT_RG: number;
  34018. /** RED_INTEGER */
  34019. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34020. /** RED_INTEGER (2nd reference) */
  34021. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34022. /** RG_INTEGER */
  34023. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34024. /** RGB_INTEGER */
  34025. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34026. /** RGBA_INTEGER */
  34027. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34028. /** UNSIGNED_BYTE */
  34029. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34030. /** UNSIGNED_BYTE (2nd reference) */
  34031. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34032. /** FLOAT */
  34033. static readonly TEXTURETYPE_FLOAT: number;
  34034. /** HALF_FLOAT */
  34035. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34036. /** BYTE */
  34037. static readonly TEXTURETYPE_BYTE: number;
  34038. /** SHORT */
  34039. static readonly TEXTURETYPE_SHORT: number;
  34040. /** UNSIGNED_SHORT */
  34041. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34042. /** INT */
  34043. static readonly TEXTURETYPE_INT: number;
  34044. /** UNSIGNED_INT */
  34045. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34046. /** UNSIGNED_SHORT_4_4_4_4 */
  34047. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34048. /** UNSIGNED_SHORT_5_5_5_1 */
  34049. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34050. /** UNSIGNED_SHORT_5_6_5 */
  34051. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34052. /** UNSIGNED_INT_2_10_10_10_REV */
  34053. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34054. /** UNSIGNED_INT_24_8 */
  34055. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34056. /** UNSIGNED_INT_10F_11F_11F_REV */
  34057. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34058. /** UNSIGNED_INT_5_9_9_9_REV */
  34059. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34060. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34061. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34062. /** nearest is mag = nearest and min = nearest and mip = linear */
  34063. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34064. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34065. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34066. /** Trilinear is mag = linear and min = linear and mip = linear */
  34067. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34068. /** nearest is mag = nearest and min = nearest and mip = linear */
  34069. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34070. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34071. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34072. /** Trilinear is mag = linear and min = linear and mip = linear */
  34073. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34074. /** mag = nearest and min = nearest and mip = nearest */
  34075. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34076. /** mag = nearest and min = linear and mip = nearest */
  34077. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34078. /** mag = nearest and min = linear and mip = linear */
  34079. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34080. /** mag = nearest and min = linear and mip = none */
  34081. static readonly TEXTURE_NEAREST_LINEAR: number;
  34082. /** mag = nearest and min = nearest and mip = none */
  34083. static readonly TEXTURE_NEAREST_NEAREST: number;
  34084. /** mag = linear and min = nearest and mip = nearest */
  34085. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34086. /** mag = linear and min = nearest and mip = linear */
  34087. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34088. /** mag = linear and min = linear and mip = none */
  34089. static readonly TEXTURE_LINEAR_LINEAR: number;
  34090. /** mag = linear and min = nearest and mip = none */
  34091. static readonly TEXTURE_LINEAR_NEAREST: number;
  34092. /** Explicit coordinates mode */
  34093. static readonly TEXTURE_EXPLICIT_MODE: number;
  34094. /** Spherical coordinates mode */
  34095. static readonly TEXTURE_SPHERICAL_MODE: number;
  34096. /** Planar coordinates mode */
  34097. static readonly TEXTURE_PLANAR_MODE: number;
  34098. /** Cubic coordinates mode */
  34099. static readonly TEXTURE_CUBIC_MODE: number;
  34100. /** Projection coordinates mode */
  34101. static readonly TEXTURE_PROJECTION_MODE: number;
  34102. /** Skybox coordinates mode */
  34103. static readonly TEXTURE_SKYBOX_MODE: number;
  34104. /** Inverse Cubic coordinates mode */
  34105. static readonly TEXTURE_INVCUBIC_MODE: number;
  34106. /** Equirectangular coordinates mode */
  34107. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34108. /** Equirectangular Fixed coordinates mode */
  34109. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34110. /** Equirectangular Fixed Mirrored coordinates mode */
  34111. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34112. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34113. static readonly SCALEMODE_FLOOR: number;
  34114. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34115. static readonly SCALEMODE_NEAREST: number;
  34116. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34117. static readonly SCALEMODE_CEILING: number;
  34118. /**
  34119. * Returns the current npm package of the sdk
  34120. */
  34121. static get NpmPackage(): string;
  34122. /**
  34123. * Returns the current version of the framework
  34124. */
  34125. static get Version(): string;
  34126. /** Gets the list of created engines */
  34127. static get Instances(): Engine[];
  34128. /**
  34129. * Gets the latest created engine
  34130. */
  34131. static get LastCreatedEngine(): Nullable<Engine>;
  34132. /**
  34133. * Gets the latest created scene
  34134. */
  34135. static get LastCreatedScene(): Nullable<Scene>;
  34136. /**
  34137. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34138. * @param flag defines which part of the materials must be marked as dirty
  34139. * @param predicate defines a predicate used to filter which materials should be affected
  34140. */
  34141. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34142. /**
  34143. * Method called to create the default loading screen.
  34144. * This can be overriden in your own app.
  34145. * @param canvas The rendering canvas element
  34146. * @returns The loading screen
  34147. */
  34148. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34149. /**
  34150. * Method called to create the default rescale post process on each engine.
  34151. */
  34152. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34153. /**
  34154. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34155. **/
  34156. enableOfflineSupport: boolean;
  34157. /**
  34158. * 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)
  34159. **/
  34160. disableManifestCheck: boolean;
  34161. /**
  34162. * Gets the list of created scenes
  34163. */
  34164. scenes: Scene[];
  34165. /**
  34166. * Event raised when a new scene is created
  34167. */
  34168. onNewSceneAddedObservable: Observable<Scene>;
  34169. /**
  34170. * Gets the list of created postprocesses
  34171. */
  34172. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34173. /**
  34174. * Gets a boolean indicating if the pointer is currently locked
  34175. */
  34176. isPointerLock: boolean;
  34177. /**
  34178. * Observable event triggered each time the rendering canvas is resized
  34179. */
  34180. onResizeObservable: Observable<Engine>;
  34181. /**
  34182. * Observable event triggered each time the canvas loses focus
  34183. */
  34184. onCanvasBlurObservable: Observable<Engine>;
  34185. /**
  34186. * Observable event triggered each time the canvas gains focus
  34187. */
  34188. onCanvasFocusObservable: Observable<Engine>;
  34189. /**
  34190. * Observable event triggered each time the canvas receives pointerout event
  34191. */
  34192. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34193. /**
  34194. * Observable raised when the engine begins a new frame
  34195. */
  34196. onBeginFrameObservable: Observable<Engine>;
  34197. /**
  34198. * If set, will be used to request the next animation frame for the render loop
  34199. */
  34200. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34201. /**
  34202. * Observable raised when the engine ends the current frame
  34203. */
  34204. onEndFrameObservable: Observable<Engine>;
  34205. /**
  34206. * Observable raised when the engine is about to compile a shader
  34207. */
  34208. onBeforeShaderCompilationObservable: Observable<Engine>;
  34209. /**
  34210. * Observable raised when the engine has jsut compiled a shader
  34211. */
  34212. onAfterShaderCompilationObservable: Observable<Engine>;
  34213. /**
  34214. * Gets the audio engine
  34215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34216. * @ignorenaming
  34217. */
  34218. static audioEngine: IAudioEngine;
  34219. /**
  34220. * Default AudioEngine factory responsible of creating the Audio Engine.
  34221. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34222. */
  34223. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34224. /**
  34225. * Default offline support factory responsible of creating a tool used to store data locally.
  34226. * By default, this will create a Database object if the workload has been embedded.
  34227. */
  34228. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34229. private _loadingScreen;
  34230. private _pointerLockRequested;
  34231. private _dummyFramebuffer;
  34232. private _rescalePostProcess;
  34233. private _deterministicLockstep;
  34234. private _lockstepMaxSteps;
  34235. private _timeStep;
  34236. protected get _supportsHardwareTextureRescaling(): boolean;
  34237. private _fps;
  34238. private _deltaTime;
  34239. /** @hidden */
  34240. _drawCalls: PerfCounter;
  34241. /** 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 */
  34242. canvasTabIndex: number;
  34243. /**
  34244. * Turn this value on if you want to pause FPS computation when in background
  34245. */
  34246. disablePerformanceMonitorInBackground: boolean;
  34247. private _performanceMonitor;
  34248. /**
  34249. * Gets the performance monitor attached to this engine
  34250. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34251. */
  34252. get performanceMonitor(): PerformanceMonitor;
  34253. private _onFocus;
  34254. private _onBlur;
  34255. private _onCanvasPointerOut;
  34256. private _onCanvasBlur;
  34257. private _onCanvasFocus;
  34258. private _onFullscreenChange;
  34259. private _onPointerLockChange;
  34260. /**
  34261. * Gets the HTML element used to attach event listeners
  34262. * @returns a HTML element
  34263. */
  34264. getInputElement(): Nullable<HTMLElement>;
  34265. /**
  34266. * Creates a new engine
  34267. * @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
  34268. * @param antialias defines enable antialiasing (default: false)
  34269. * @param options defines further options to be sent to the getContext() function
  34270. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34271. */
  34272. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34273. /**
  34274. * Gets current aspect ratio
  34275. * @param viewportOwner defines the camera to use to get the aspect ratio
  34276. * @param useScreen defines if screen size must be used (or the current render target if any)
  34277. * @returns a number defining the aspect ratio
  34278. */
  34279. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34280. /**
  34281. * Gets current screen aspect ratio
  34282. * @returns a number defining the aspect ratio
  34283. */
  34284. getScreenAspectRatio(): number;
  34285. /**
  34286. * Gets the client rect of the HTML canvas attached with the current webGL context
  34287. * @returns a client rectanglee
  34288. */
  34289. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34290. /**
  34291. * Gets the client rect of the HTML element used for events
  34292. * @returns a client rectanglee
  34293. */
  34294. getInputElementClientRect(): Nullable<ClientRect>;
  34295. /**
  34296. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34298. * @returns true if engine is in deterministic lock step mode
  34299. */
  34300. isDeterministicLockStep(): boolean;
  34301. /**
  34302. * Gets the max steps when engine is running in deterministic lock step
  34303. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34304. * @returns the max steps
  34305. */
  34306. getLockstepMaxSteps(): number;
  34307. /**
  34308. * Returns the time in ms between steps when using deterministic lock step.
  34309. * @returns time step in (ms)
  34310. */
  34311. getTimeStep(): number;
  34312. /**
  34313. * Force the mipmap generation for the given render target texture
  34314. * @param texture defines the render target texture to use
  34315. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34316. */
  34317. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34318. /** States */
  34319. /**
  34320. * Set various states to the webGL context
  34321. * @param culling defines backface culling state
  34322. * @param zOffset defines the value to apply to zOffset (0 by default)
  34323. * @param force defines if states must be applied even if cache is up to date
  34324. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34325. */
  34326. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34327. /**
  34328. * Set the z offset to apply to current rendering
  34329. * @param value defines the offset to apply
  34330. */
  34331. setZOffset(value: number): void;
  34332. /**
  34333. * Gets the current value of the zOffset
  34334. * @returns the current zOffset state
  34335. */
  34336. getZOffset(): number;
  34337. /**
  34338. * Enable or disable depth buffering
  34339. * @param enable defines the state to set
  34340. */
  34341. setDepthBuffer(enable: boolean): void;
  34342. /**
  34343. * Gets a boolean indicating if depth writing is enabled
  34344. * @returns the current depth writing state
  34345. */
  34346. getDepthWrite(): boolean;
  34347. /**
  34348. * Enable or disable depth writing
  34349. * @param enable defines the state to set
  34350. */
  34351. setDepthWrite(enable: boolean): void;
  34352. /**
  34353. * Gets a boolean indicating if stencil buffer is enabled
  34354. * @returns the current stencil buffer state
  34355. */
  34356. getStencilBuffer(): boolean;
  34357. /**
  34358. * Enable or disable the stencil buffer
  34359. * @param enable defines if the stencil buffer must be enabled or disabled
  34360. */
  34361. setStencilBuffer(enable: boolean): void;
  34362. /**
  34363. * Gets the current stencil mask
  34364. * @returns a number defining the new stencil mask to use
  34365. */
  34366. getStencilMask(): number;
  34367. /**
  34368. * Sets the current stencil mask
  34369. * @param mask defines the new stencil mask to use
  34370. */
  34371. setStencilMask(mask: number): void;
  34372. /**
  34373. * Gets the current stencil function
  34374. * @returns a number defining the stencil function to use
  34375. */
  34376. getStencilFunction(): number;
  34377. /**
  34378. * Gets the current stencil reference value
  34379. * @returns a number defining the stencil reference value to use
  34380. */
  34381. getStencilFunctionReference(): number;
  34382. /**
  34383. * Gets the current stencil mask
  34384. * @returns a number defining the stencil mask to use
  34385. */
  34386. getStencilFunctionMask(): number;
  34387. /**
  34388. * Sets the current stencil function
  34389. * @param stencilFunc defines the new stencil function to use
  34390. */
  34391. setStencilFunction(stencilFunc: number): void;
  34392. /**
  34393. * Sets the current stencil reference
  34394. * @param reference defines the new stencil reference to use
  34395. */
  34396. setStencilFunctionReference(reference: number): void;
  34397. /**
  34398. * Sets the current stencil mask
  34399. * @param mask defines the new stencil mask to use
  34400. */
  34401. setStencilFunctionMask(mask: number): void;
  34402. /**
  34403. * Gets the current stencil operation when stencil fails
  34404. * @returns a number defining stencil operation to use when stencil fails
  34405. */
  34406. getStencilOperationFail(): number;
  34407. /**
  34408. * Gets the current stencil operation when depth fails
  34409. * @returns a number defining stencil operation to use when depth fails
  34410. */
  34411. getStencilOperationDepthFail(): number;
  34412. /**
  34413. * Gets the current stencil operation when stencil passes
  34414. * @returns a number defining stencil operation to use when stencil passes
  34415. */
  34416. getStencilOperationPass(): number;
  34417. /**
  34418. * Sets the stencil operation to use when stencil fails
  34419. * @param operation defines the stencil operation to use when stencil fails
  34420. */
  34421. setStencilOperationFail(operation: number): void;
  34422. /**
  34423. * Sets the stencil operation to use when depth fails
  34424. * @param operation defines the stencil operation to use when depth fails
  34425. */
  34426. setStencilOperationDepthFail(operation: number): void;
  34427. /**
  34428. * Sets the stencil operation to use when stencil passes
  34429. * @param operation defines the stencil operation to use when stencil passes
  34430. */
  34431. setStencilOperationPass(operation: number): void;
  34432. /**
  34433. * Sets a boolean indicating if the dithering state is enabled or disabled
  34434. * @param value defines the dithering state
  34435. */
  34436. setDitheringState(value: boolean): void;
  34437. /**
  34438. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34439. * @param value defines the rasterizer state
  34440. */
  34441. setRasterizerState(value: boolean): void;
  34442. /**
  34443. * Gets the current depth function
  34444. * @returns a number defining the depth function
  34445. */
  34446. getDepthFunction(): Nullable<number>;
  34447. /**
  34448. * Sets the current depth function
  34449. * @param depthFunc defines the function to use
  34450. */
  34451. setDepthFunction(depthFunc: number): void;
  34452. /**
  34453. * Sets the current depth function to GREATER
  34454. */
  34455. setDepthFunctionToGreater(): void;
  34456. /**
  34457. * Sets the current depth function to GEQUAL
  34458. */
  34459. setDepthFunctionToGreaterOrEqual(): void;
  34460. /**
  34461. * Sets the current depth function to LESS
  34462. */
  34463. setDepthFunctionToLess(): void;
  34464. /**
  34465. * Sets the current depth function to LEQUAL
  34466. */
  34467. setDepthFunctionToLessOrEqual(): void;
  34468. private _cachedStencilBuffer;
  34469. private _cachedStencilFunction;
  34470. private _cachedStencilMask;
  34471. private _cachedStencilOperationPass;
  34472. private _cachedStencilOperationFail;
  34473. private _cachedStencilOperationDepthFail;
  34474. private _cachedStencilReference;
  34475. /**
  34476. * Caches the the state of the stencil buffer
  34477. */
  34478. cacheStencilState(): void;
  34479. /**
  34480. * Restores the state of the stencil buffer
  34481. */
  34482. restoreStencilState(): void;
  34483. /**
  34484. * Directly set the WebGL Viewport
  34485. * @param x defines the x coordinate of the viewport (in screen space)
  34486. * @param y defines the y coordinate of the viewport (in screen space)
  34487. * @param width defines the width of the viewport (in screen space)
  34488. * @param height defines the height of the viewport (in screen space)
  34489. * @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
  34490. */
  34491. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34492. /**
  34493. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34494. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34495. * @param y defines the y-coordinate of the corner of the clear rectangle
  34496. * @param width defines the width of the clear rectangle
  34497. * @param height defines the height of the clear rectangle
  34498. * @param clearColor defines the clear color
  34499. */
  34500. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34501. /**
  34502. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34503. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34504. * @param y defines the y-coordinate of the corner of the clear rectangle
  34505. * @param width defines the width of the clear rectangle
  34506. * @param height defines the height of the clear rectangle
  34507. */
  34508. enableScissor(x: number, y: number, width: number, height: number): void;
  34509. /**
  34510. * Disable previously set scissor test rectangle
  34511. */
  34512. disableScissor(): void;
  34513. protected _reportDrawCall(): void;
  34514. /**
  34515. * Initializes a webVR display and starts listening to display change events
  34516. * The onVRDisplayChangedObservable will be notified upon these changes
  34517. * @returns The onVRDisplayChangedObservable
  34518. */
  34519. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34520. /** @hidden */
  34521. _prepareVRComponent(): void;
  34522. /** @hidden */
  34523. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34524. /** @hidden */
  34525. _submitVRFrame(): void;
  34526. /**
  34527. * Call this function to leave webVR mode
  34528. * Will do nothing if webVR is not supported or if there is no webVR device
  34529. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34530. */
  34531. disableVR(): void;
  34532. /**
  34533. * Gets a boolean indicating that the system is in VR mode and is presenting
  34534. * @returns true if VR mode is engaged
  34535. */
  34536. isVRPresenting(): boolean;
  34537. /** @hidden */
  34538. _requestVRFrame(): void;
  34539. /** @hidden */
  34540. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34541. /**
  34542. * Gets the source code of the vertex shader associated with a specific webGL program
  34543. * @param program defines the program to use
  34544. * @returns a string containing the source code of the vertex shader associated with the program
  34545. */
  34546. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34547. /**
  34548. * Gets the source code of the fragment shader associated with a specific webGL program
  34549. * @param program defines the program to use
  34550. * @returns a string containing the source code of the fragment shader associated with the program
  34551. */
  34552. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34553. /**
  34554. * Sets a depth stencil texture from a render target to the according uniform.
  34555. * @param channel The texture channel
  34556. * @param uniform The uniform to set
  34557. * @param texture The render target texture containing the depth stencil texture to apply
  34558. */
  34559. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34560. /**
  34561. * Sets a texture to the webGL context from a postprocess
  34562. * @param channel defines the channel to use
  34563. * @param postProcess defines the source postprocess
  34564. */
  34565. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34566. /**
  34567. * Binds the output of the passed in post process to the texture channel specified
  34568. * @param channel The channel the texture should be bound to
  34569. * @param postProcess The post process which's output should be bound
  34570. */
  34571. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34572. /** @hidden */
  34573. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34574. protected _rebuildBuffers(): void;
  34575. /** @hidden */
  34576. _renderFrame(): void;
  34577. _renderLoop(): void;
  34578. /** @hidden */
  34579. _renderViews(): boolean;
  34580. /**
  34581. * Toggle full screen mode
  34582. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34583. */
  34584. switchFullscreen(requestPointerLock: boolean): void;
  34585. /**
  34586. * Enters full screen mode
  34587. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34588. */
  34589. enterFullscreen(requestPointerLock: boolean): void;
  34590. /**
  34591. * Exits full screen mode
  34592. */
  34593. exitFullscreen(): void;
  34594. /**
  34595. * Enters Pointerlock mode
  34596. */
  34597. enterPointerlock(): void;
  34598. /**
  34599. * Exits Pointerlock mode
  34600. */
  34601. exitPointerlock(): void;
  34602. /**
  34603. * Begin a new frame
  34604. */
  34605. beginFrame(): void;
  34606. /**
  34607. * Enf the current frame
  34608. */
  34609. endFrame(): void;
  34610. resize(): void;
  34611. /**
  34612. * Set the compressed texture format to use, based on the formats you have, and the formats
  34613. * supported by the hardware / browser.
  34614. *
  34615. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34616. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34617. * to API arguments needed to compressed textures. This puts the burden on the container
  34618. * generator to house the arcane code for determining these for current & future formats.
  34619. *
  34620. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34621. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34622. *
  34623. * Note: The result of this call is not taken into account when a texture is base64.
  34624. *
  34625. * @param formatsAvailable defines the list of those format families you have created
  34626. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34627. *
  34628. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34629. * @returns The extension selected.
  34630. */
  34631. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34632. /**
  34633. * Set the compressed texture extensions or file names to skip.
  34634. *
  34635. * @param skippedFiles defines the list of those texture files you want to skip
  34636. * Example: [".dds", ".env", "myfile.png"]
  34637. */
  34638. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34639. /**
  34640. * Force a specific size of the canvas
  34641. * @param width defines the new canvas' width
  34642. * @param height defines the new canvas' height
  34643. */
  34644. setSize(width: number, height: number): void;
  34645. /**
  34646. * Updates a dynamic vertex buffer.
  34647. * @param vertexBuffer the vertex buffer to update
  34648. * @param data the data used to update the vertex buffer
  34649. * @param byteOffset the byte offset of the data
  34650. * @param byteLength the byte length of the data
  34651. */
  34652. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34653. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34654. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34655. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34656. _releaseTexture(texture: InternalTexture): void;
  34657. /**
  34658. * @hidden
  34659. * Rescales a texture
  34660. * @param source input texutre
  34661. * @param destination destination texture
  34662. * @param scene scene to use to render the resize
  34663. * @param internalFormat format to use when resizing
  34664. * @param onComplete callback to be called when resize has completed
  34665. */
  34666. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34667. /**
  34668. * Gets the current framerate
  34669. * @returns a number representing the framerate
  34670. */
  34671. getFps(): number;
  34672. /**
  34673. * Gets the time spent between current and previous frame
  34674. * @returns a number representing the delta time in ms
  34675. */
  34676. getDeltaTime(): number;
  34677. private _measureFps;
  34678. /** @hidden */
  34679. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34680. /**
  34681. * Update a dynamic index buffer
  34682. * @param indexBuffer defines the target index buffer
  34683. * @param indices defines the data to update
  34684. * @param offset defines the offset in the target index buffer where update should start
  34685. */
  34686. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34687. /**
  34688. * Updates the sample count of a render target texture
  34689. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34690. * @param texture defines the texture to update
  34691. * @param samples defines the sample count to set
  34692. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34693. */
  34694. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34695. /**
  34696. * Updates a depth texture Comparison Mode and Function.
  34697. * If the comparison Function is equal to 0, the mode will be set to none.
  34698. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34699. * @param texture The texture to set the comparison function for
  34700. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34701. */
  34702. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34703. /**
  34704. * Creates a webGL buffer to use with instanciation
  34705. * @param capacity defines the size of the buffer
  34706. * @returns the webGL buffer
  34707. */
  34708. createInstancesBuffer(capacity: number): DataBuffer;
  34709. /**
  34710. * Delete a webGL buffer used with instanciation
  34711. * @param buffer defines the webGL buffer to delete
  34712. */
  34713. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34714. /** @hidden */
  34715. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34716. dispose(): void;
  34717. private _disableTouchAction;
  34718. /**
  34719. * Display the loading screen
  34720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34721. */
  34722. displayLoadingUI(): void;
  34723. /**
  34724. * Hide the loading screen
  34725. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34726. */
  34727. hideLoadingUI(): void;
  34728. /**
  34729. * Gets the current loading screen object
  34730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34731. */
  34732. get loadingScreen(): ILoadingScreen;
  34733. /**
  34734. * Sets the current loading screen object
  34735. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34736. */
  34737. set loadingScreen(loadingScreen: ILoadingScreen);
  34738. /**
  34739. * Sets the current loading screen text
  34740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34741. */
  34742. set loadingUIText(text: string);
  34743. /**
  34744. * Sets the current loading screen background color
  34745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34746. */
  34747. set loadingUIBackgroundColor(color: string);
  34748. /** Pointerlock and fullscreen */
  34749. /**
  34750. * Ask the browser to promote the current element to pointerlock mode
  34751. * @param element defines the DOM element to promote
  34752. */
  34753. static _RequestPointerlock(element: HTMLElement): void;
  34754. /**
  34755. * Asks the browser to exit pointerlock mode
  34756. */
  34757. static _ExitPointerlock(): void;
  34758. /**
  34759. * Ask the browser to promote the current element to fullscreen rendering mode
  34760. * @param element defines the DOM element to promote
  34761. */
  34762. static _RequestFullscreen(element: HTMLElement): void;
  34763. /**
  34764. * Asks the browser to exit fullscreen mode
  34765. */
  34766. static _ExitFullscreen(): void;
  34767. }
  34768. }
  34769. declare module "babylonjs/Engines/engineStore" {
  34770. import { Nullable } from "babylonjs/types";
  34771. import { Engine } from "babylonjs/Engines/engine";
  34772. import { Scene } from "babylonjs/scene";
  34773. /**
  34774. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34775. * during the life time of the application.
  34776. */
  34777. export class EngineStore {
  34778. /** Gets the list of created engines */
  34779. static Instances: import("babylonjs/Engines/engine").Engine[];
  34780. /** @hidden */
  34781. static _LastCreatedScene: Nullable<Scene>;
  34782. /**
  34783. * Gets the latest created engine
  34784. */
  34785. static get LastCreatedEngine(): Nullable<Engine>;
  34786. /**
  34787. * Gets the latest created scene
  34788. */
  34789. static get LastCreatedScene(): Nullable<Scene>;
  34790. /**
  34791. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34792. * @ignorenaming
  34793. */
  34794. static UseFallbackTexture: boolean;
  34795. /**
  34796. * Texture content used if a texture cannot loaded
  34797. * @ignorenaming
  34798. */
  34799. static FallbackTexture: string;
  34800. }
  34801. }
  34802. declare module "babylonjs/Misc/promise" {
  34803. /**
  34804. * Helper class that provides a small promise polyfill
  34805. */
  34806. export class PromisePolyfill {
  34807. /**
  34808. * Static function used to check if the polyfill is required
  34809. * If this is the case then the function will inject the polyfill to window.Promise
  34810. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34811. */
  34812. static Apply(force?: boolean): void;
  34813. }
  34814. }
  34815. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34816. /**
  34817. * Interface for screenshot methods with describe argument called `size` as object with options
  34818. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34819. */
  34820. export interface IScreenshotSize {
  34821. /**
  34822. * number in pixels for canvas height
  34823. */
  34824. height?: number;
  34825. /**
  34826. * multiplier allowing render at a higher or lower resolution
  34827. * If value is defined then height and width will be ignored and taken from camera
  34828. */
  34829. precision?: number;
  34830. /**
  34831. * number in pixels for canvas width
  34832. */
  34833. width?: number;
  34834. }
  34835. }
  34836. declare module "babylonjs/Misc/tools" {
  34837. import { Nullable, float } from "babylonjs/types";
  34838. import { DomManagement } from "babylonjs/Misc/domManagement";
  34839. import { WebRequest } from "babylonjs/Misc/webRequest";
  34840. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34841. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34842. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34843. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34844. import { Camera } from "babylonjs/Cameras/camera";
  34845. import { Engine } from "babylonjs/Engines/engine";
  34846. interface IColor4Like {
  34847. r: float;
  34848. g: float;
  34849. b: float;
  34850. a: float;
  34851. }
  34852. /**
  34853. * Class containing a set of static utilities functions
  34854. */
  34855. export class Tools {
  34856. /**
  34857. * Gets or sets the base URL to use to load assets
  34858. */
  34859. static get BaseUrl(): string;
  34860. static set BaseUrl(value: string);
  34861. /**
  34862. * Enable/Disable Custom HTTP Request Headers globally.
  34863. * default = false
  34864. * @see CustomRequestHeaders
  34865. */
  34866. static UseCustomRequestHeaders: boolean;
  34867. /**
  34868. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34869. * i.e. when loading files, where the server/service expects an Authorization header
  34870. */
  34871. static CustomRequestHeaders: {
  34872. [key: string]: string;
  34873. };
  34874. /**
  34875. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34876. */
  34877. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34878. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34879. /**
  34880. * Default behaviour for cors in the application.
  34881. * It can be a string if the expected behavior is identical in the entire app.
  34882. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34883. */
  34884. static CorsBehavior: string | ((url: string | string[]) => string);
  34885. /**
  34886. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34887. * @ignorenaming
  34888. */
  34889. static get UseFallbackTexture(): boolean;
  34890. static set UseFallbackTexture(value: boolean);
  34891. /**
  34892. * Use this object to register external classes like custom textures or material
  34893. * to allow the laoders to instantiate them
  34894. */
  34895. static get RegisteredExternalClasses(): {
  34896. [key: string]: Object;
  34897. };
  34898. static set RegisteredExternalClasses(classes: {
  34899. [key: string]: Object;
  34900. });
  34901. /**
  34902. * Texture content used if a texture cannot loaded
  34903. * @ignorenaming
  34904. */
  34905. static get fallbackTexture(): string;
  34906. static set fallbackTexture(value: string);
  34907. /**
  34908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34909. * @param u defines the coordinate on X axis
  34910. * @param v defines the coordinate on Y axis
  34911. * @param width defines the width of the source data
  34912. * @param height defines the height of the source data
  34913. * @param pixels defines the source byte array
  34914. * @param color defines the output color
  34915. */
  34916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34917. /**
  34918. * Interpolates between a and b via alpha
  34919. * @param a The lower value (returned when alpha = 0)
  34920. * @param b The upper value (returned when alpha = 1)
  34921. * @param alpha The interpolation-factor
  34922. * @return The mixed value
  34923. */
  34924. static Mix(a: number, b: number, alpha: number): number;
  34925. /**
  34926. * Tries to instantiate a new object from a given class name
  34927. * @param className defines the class name to instantiate
  34928. * @returns the new object or null if the system was not able to do the instantiation
  34929. */
  34930. static Instantiate(className: string): any;
  34931. /**
  34932. * Provides a slice function that will work even on IE
  34933. * @param data defines the array to slice
  34934. * @param start defines the start of the data (optional)
  34935. * @param end defines the end of the data (optional)
  34936. * @returns the new sliced array
  34937. */
  34938. static Slice<T>(data: T, start?: number, end?: number): T;
  34939. /**
  34940. * Polyfill for setImmediate
  34941. * @param action defines the action to execute after the current execution block
  34942. */
  34943. static SetImmediate(action: () => void): void;
  34944. /**
  34945. * Function indicating if a number is an exponent of 2
  34946. * @param value defines the value to test
  34947. * @returns true if the value is an exponent of 2
  34948. */
  34949. static IsExponentOfTwo(value: number): boolean;
  34950. private static _tmpFloatArray;
  34951. /**
  34952. * Returns the nearest 32-bit single precision float representation of a Number
  34953. * @param value A Number. If the parameter is of a different type, it will get converted
  34954. * to a number or to NaN if it cannot be converted
  34955. * @returns number
  34956. */
  34957. static FloatRound(value: number): number;
  34958. /**
  34959. * Extracts the filename from a path
  34960. * @param path defines the path to use
  34961. * @returns the filename
  34962. */
  34963. static GetFilename(path: string): string;
  34964. /**
  34965. * Extracts the "folder" part of a path (everything before the filename).
  34966. * @param uri The URI to extract the info from
  34967. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34968. * @returns The "folder" part of the path
  34969. */
  34970. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34971. /**
  34972. * Extracts text content from a DOM element hierarchy
  34973. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34974. */
  34975. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34976. /**
  34977. * Convert an angle in radians to degrees
  34978. * @param angle defines the angle to convert
  34979. * @returns the angle in degrees
  34980. */
  34981. static ToDegrees(angle: number): number;
  34982. /**
  34983. * Convert an angle in degrees to radians
  34984. * @param angle defines the angle to convert
  34985. * @returns the angle in radians
  34986. */
  34987. static ToRadians(angle: number): number;
  34988. /**
  34989. * Returns an array if obj is not an array
  34990. * @param obj defines the object to evaluate as an array
  34991. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34992. * @returns either obj directly if obj is an array or a new array containing obj
  34993. */
  34994. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34995. /**
  34996. * Gets the pointer prefix to use
  34997. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34998. */
  34999. static GetPointerPrefix(): string;
  35000. /**
  35001. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35002. * @param url define the url we are trying
  35003. * @param element define the dom element where to configure the cors policy
  35004. */
  35005. static SetCorsBehavior(url: string | string[], element: {
  35006. crossOrigin: string | null;
  35007. }): void;
  35008. /**
  35009. * Removes unwanted characters from an url
  35010. * @param url defines the url to clean
  35011. * @returns the cleaned url
  35012. */
  35013. static CleanUrl(url: string): string;
  35014. /**
  35015. * Gets or sets a function used to pre-process url before using them to load assets
  35016. */
  35017. static get PreprocessUrl(): (url: string) => string;
  35018. static set PreprocessUrl(processor: (url: string) => string);
  35019. /**
  35020. * Loads an image as an HTMLImageElement.
  35021. * @param input url string, ArrayBuffer, or Blob to load
  35022. * @param onLoad callback called when the image successfully loads
  35023. * @param onError callback called when the image fails to load
  35024. * @param offlineProvider offline provider for caching
  35025. * @param mimeType optional mime type
  35026. * @returns the HTMLImageElement of the loaded image
  35027. */
  35028. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35029. /**
  35030. * Loads a file from a url
  35031. * @param url url string, ArrayBuffer, or Blob to load
  35032. * @param onSuccess callback called when the file successfully loads
  35033. * @param onProgress callback called while file is loading (if the server supports this mode)
  35034. * @param offlineProvider defines the offline provider for caching
  35035. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35036. * @param onError callback called when the file fails to load
  35037. * @returns a file request object
  35038. */
  35039. 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;
  35040. /**
  35041. * Loads a file from a url
  35042. * @param url the file url to load
  35043. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  35044. */
  35045. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  35046. /**
  35047. * Load a script (identified by an url). When the url returns, the
  35048. * content of this file is added into a new script element, attached to the DOM (body element)
  35049. * @param scriptUrl defines the url of the script to laod
  35050. * @param onSuccess defines the callback called when the script is loaded
  35051. * @param onError defines the callback to call if an error occurs
  35052. * @param scriptId defines the id of the script element
  35053. */
  35054. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35055. /**
  35056. * Load an asynchronous script (identified by an url). When the url returns, the
  35057. * content of this file is added into a new script element, attached to the DOM (body element)
  35058. * @param scriptUrl defines the url of the script to laod
  35059. * @param scriptId defines the id of the script element
  35060. * @returns a promise request object
  35061. */
  35062. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35063. /**
  35064. * Loads a file from a blob
  35065. * @param fileToLoad defines the blob to use
  35066. * @param callback defines the callback to call when data is loaded
  35067. * @param progressCallback defines the callback to call during loading process
  35068. * @returns a file request object
  35069. */
  35070. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35071. /**
  35072. * Reads a file from a File object
  35073. * @param file defines the file to load
  35074. * @param onSuccess defines the callback to call when data is loaded
  35075. * @param onProgress defines the callback to call during loading process
  35076. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35077. * @param onError defines the callback to call when an error occurs
  35078. * @returns a file request object
  35079. */
  35080. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35081. /**
  35082. * Creates a data url from a given string content
  35083. * @param content defines the content to convert
  35084. * @returns the new data url link
  35085. */
  35086. static FileAsURL(content: string): string;
  35087. /**
  35088. * Format the given number to a specific decimal format
  35089. * @param value defines the number to format
  35090. * @param decimals defines the number of decimals to use
  35091. * @returns the formatted string
  35092. */
  35093. static Format(value: number, decimals?: number): string;
  35094. /**
  35095. * Tries to copy an object by duplicating every property
  35096. * @param source defines the source object
  35097. * @param destination defines the target object
  35098. * @param doNotCopyList defines a list of properties to avoid
  35099. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35100. */
  35101. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35102. /**
  35103. * Gets a boolean indicating if the given object has no own property
  35104. * @param obj defines the object to test
  35105. * @returns true if object has no own property
  35106. */
  35107. static IsEmpty(obj: any): boolean;
  35108. /**
  35109. * Function used to register events at window level
  35110. * @param windowElement defines the Window object to use
  35111. * @param events defines the events to register
  35112. */
  35113. static RegisterTopRootEvents(windowElement: Window, events: {
  35114. name: string;
  35115. handler: Nullable<(e: FocusEvent) => any>;
  35116. }[]): void;
  35117. /**
  35118. * Function used to unregister events from window level
  35119. * @param windowElement defines the Window object to use
  35120. * @param events defines the events to unregister
  35121. */
  35122. static UnregisterTopRootEvents(windowElement: Window, events: {
  35123. name: string;
  35124. handler: Nullable<(e: FocusEvent) => any>;
  35125. }[]): void;
  35126. /**
  35127. * @ignore
  35128. */
  35129. static _ScreenshotCanvas: HTMLCanvasElement;
  35130. /**
  35131. * Dumps the current bound framebuffer
  35132. * @param width defines the rendering width
  35133. * @param height defines the rendering height
  35134. * @param engine defines the hosting engine
  35135. * @param successCallback defines the callback triggered once the data are available
  35136. * @param mimeType defines the mime type of the result
  35137. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35138. */
  35139. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35140. /**
  35141. * Converts the canvas data to blob.
  35142. * This acts as a polyfill for browsers not supporting the to blob function.
  35143. * @param canvas Defines the canvas to extract the data from
  35144. * @param successCallback Defines the callback triggered once the data are available
  35145. * @param mimeType Defines the mime type of the result
  35146. */
  35147. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35148. /**
  35149. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35150. * @param successCallback defines the callback triggered once the data are available
  35151. * @param mimeType defines the mime type of the result
  35152. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35153. */
  35154. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35155. /**
  35156. * Downloads a blob in the browser
  35157. * @param blob defines the blob to download
  35158. * @param fileName defines the name of the downloaded file
  35159. */
  35160. static Download(blob: Blob, fileName: string): void;
  35161. /**
  35162. * Captures a screenshot of the current rendering
  35163. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35164. * @param engine defines the rendering engine
  35165. * @param camera defines the source camera
  35166. * @param size This parameter can be set to a single number or to an object with the
  35167. * following (optional) properties: precision, width, height. If a single number is passed,
  35168. * it will be used for both width and height. If an object is passed, the screenshot size
  35169. * will be derived from the parameters. The precision property is a multiplier allowing
  35170. * rendering at a higher or lower resolution
  35171. * @param successCallback defines the callback receives a single parameter which contains the
  35172. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35173. * src parameter of an <img> to display it
  35174. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35175. * Check your browser for supported MIME types
  35176. */
  35177. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35178. /**
  35179. * Captures a screenshot of the current rendering
  35180. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35181. * @param engine defines the rendering engine
  35182. * @param camera defines the source camera
  35183. * @param size This parameter can be set to a single number or to an object with the
  35184. * following (optional) properties: precision, width, height. If a single number is passed,
  35185. * it will be used for both width and height. If an object is passed, the screenshot size
  35186. * will be derived from the parameters. The precision property is a multiplier allowing
  35187. * rendering at a higher or lower resolution
  35188. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35189. * Check your browser for supported MIME types
  35190. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35191. * to the src parameter of an <img> to display it
  35192. */
  35193. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35194. /**
  35195. * Generates an image screenshot from the specified camera.
  35196. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35197. * @param engine The engine to use for rendering
  35198. * @param camera The camera to use for rendering
  35199. * @param size This parameter can be set to a single number or to an object with the
  35200. * following (optional) properties: precision, width, height. If a single number is passed,
  35201. * it will be used for both width and height. If an object is passed, the screenshot size
  35202. * will be derived from the parameters. The precision property is a multiplier allowing
  35203. * rendering at a higher or lower resolution
  35204. * @param successCallback The callback receives a single parameter which contains the
  35205. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35206. * src parameter of an <img> to display it
  35207. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35208. * Check your browser for supported MIME types
  35209. * @param samples Texture samples (default: 1)
  35210. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35211. * @param fileName A name for for the downloaded file.
  35212. */
  35213. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35214. /**
  35215. * Generates an image screenshot from the specified camera.
  35216. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35217. * @param engine The engine to use for rendering
  35218. * @param camera The camera to use for rendering
  35219. * @param size This parameter can be set to a single number or to an object with the
  35220. * following (optional) properties: precision, width, height. If a single number is passed,
  35221. * it will be used for both width and height. If an object is passed, the screenshot size
  35222. * will be derived from the parameters. The precision property is a multiplier allowing
  35223. * rendering at a higher or lower resolution
  35224. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35225. * Check your browser for supported MIME types
  35226. * @param samples Texture samples (default: 1)
  35227. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35228. * @param fileName A name for for the downloaded file.
  35229. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35230. * to the src parameter of an <img> to display it
  35231. */
  35232. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35233. /**
  35234. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35235. * Be aware Math.random() could cause collisions, but:
  35236. * "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"
  35237. * @returns a pseudo random id
  35238. */
  35239. static RandomId(): string;
  35240. /**
  35241. * Test if the given uri is a base64 string
  35242. * @param uri The uri to test
  35243. * @return True if the uri is a base64 string or false otherwise
  35244. */
  35245. static IsBase64(uri: string): boolean;
  35246. /**
  35247. * Decode the given base64 uri.
  35248. * @param uri The uri to decode
  35249. * @return The decoded base64 data.
  35250. */
  35251. static DecodeBase64(uri: string): ArrayBuffer;
  35252. /**
  35253. * Gets the absolute url.
  35254. * @param url the input url
  35255. * @return the absolute url
  35256. */
  35257. static GetAbsoluteUrl(url: string): string;
  35258. /**
  35259. * No log
  35260. */
  35261. static readonly NoneLogLevel: number;
  35262. /**
  35263. * Only message logs
  35264. */
  35265. static readonly MessageLogLevel: number;
  35266. /**
  35267. * Only warning logs
  35268. */
  35269. static readonly WarningLogLevel: number;
  35270. /**
  35271. * Only error logs
  35272. */
  35273. static readonly ErrorLogLevel: number;
  35274. /**
  35275. * All logs
  35276. */
  35277. static readonly AllLogLevel: number;
  35278. /**
  35279. * Gets a value indicating the number of loading errors
  35280. * @ignorenaming
  35281. */
  35282. static get errorsCount(): number;
  35283. /**
  35284. * Callback called when a new log is added
  35285. */
  35286. static OnNewCacheEntry: (entry: string) => void;
  35287. /**
  35288. * Log a message to the console
  35289. * @param message defines the message to log
  35290. */
  35291. static Log(message: string): void;
  35292. /**
  35293. * Write a warning message to the console
  35294. * @param message defines the message to log
  35295. */
  35296. static Warn(message: string): void;
  35297. /**
  35298. * Write an error message to the console
  35299. * @param message defines the message to log
  35300. */
  35301. static Error(message: string): void;
  35302. /**
  35303. * Gets current log cache (list of logs)
  35304. */
  35305. static get LogCache(): string;
  35306. /**
  35307. * Clears the log cache
  35308. */
  35309. static ClearLogCache(): void;
  35310. /**
  35311. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35312. */
  35313. static set LogLevels(level: number);
  35314. /**
  35315. * Checks if the window object exists
  35316. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35317. */
  35318. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35319. /**
  35320. * No performance log
  35321. */
  35322. static readonly PerformanceNoneLogLevel: number;
  35323. /**
  35324. * Use user marks to log performance
  35325. */
  35326. static readonly PerformanceUserMarkLogLevel: number;
  35327. /**
  35328. * Log performance to the console
  35329. */
  35330. static readonly PerformanceConsoleLogLevel: number;
  35331. private static _performance;
  35332. /**
  35333. * Sets the current performance log level
  35334. */
  35335. static set PerformanceLogLevel(level: number);
  35336. private static _StartPerformanceCounterDisabled;
  35337. private static _EndPerformanceCounterDisabled;
  35338. private static _StartUserMark;
  35339. private static _EndUserMark;
  35340. private static _StartPerformanceConsole;
  35341. private static _EndPerformanceConsole;
  35342. /**
  35343. * Starts a performance counter
  35344. */
  35345. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35346. /**
  35347. * Ends a specific performance coutner
  35348. */
  35349. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35350. /**
  35351. * Gets either window.performance.now() if supported or Date.now() else
  35352. */
  35353. static get Now(): number;
  35354. /**
  35355. * This method will return the name of the class used to create the instance of the given object.
  35356. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35357. * @param object the object to get the class name from
  35358. * @param isType defines if the object is actually a type
  35359. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35360. */
  35361. static GetClassName(object: any, isType?: boolean): string;
  35362. /**
  35363. * Gets the first element of an array satisfying a given predicate
  35364. * @param array defines the array to browse
  35365. * @param predicate defines the predicate to use
  35366. * @returns null if not found or the element
  35367. */
  35368. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35369. /**
  35370. * This method will return the name of the full name of the class, including its owning module (if any).
  35371. * 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).
  35372. * @param object the object to get the class name from
  35373. * @param isType defines if the object is actually a type
  35374. * @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.
  35375. * @ignorenaming
  35376. */
  35377. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35378. /**
  35379. * Returns a promise that resolves after the given amount of time.
  35380. * @param delay Number of milliseconds to delay
  35381. * @returns Promise that resolves after the given amount of time
  35382. */
  35383. static DelayAsync(delay: number): Promise<void>;
  35384. /**
  35385. * Utility function to detect if the current user agent is Safari
  35386. * @returns whether or not the current user agent is safari
  35387. */
  35388. static IsSafari(): boolean;
  35389. }
  35390. /**
  35391. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35392. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35393. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35394. * @param name The name of the class, case should be preserved
  35395. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35396. */
  35397. export function className(name: string, module?: string): (target: Object) => void;
  35398. /**
  35399. * An implementation of a loop for asynchronous functions.
  35400. */
  35401. export class AsyncLoop {
  35402. /**
  35403. * Defines the number of iterations for the loop
  35404. */
  35405. iterations: number;
  35406. /**
  35407. * Defines the current index of the loop.
  35408. */
  35409. index: number;
  35410. private _done;
  35411. private _fn;
  35412. private _successCallback;
  35413. /**
  35414. * Constructor.
  35415. * @param iterations the number of iterations.
  35416. * @param func the function to run each iteration
  35417. * @param successCallback the callback that will be called upon succesful execution
  35418. * @param offset starting offset.
  35419. */
  35420. constructor(
  35421. /**
  35422. * Defines the number of iterations for the loop
  35423. */
  35424. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35425. /**
  35426. * Execute the next iteration. Must be called after the last iteration was finished.
  35427. */
  35428. executeNext(): void;
  35429. /**
  35430. * Break the loop and run the success callback.
  35431. */
  35432. breakLoop(): void;
  35433. /**
  35434. * Create and run an async loop.
  35435. * @param iterations the number of iterations.
  35436. * @param fn the function to run each iteration
  35437. * @param successCallback the callback that will be called upon succesful execution
  35438. * @param offset starting offset.
  35439. * @returns the created async loop object
  35440. */
  35441. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35442. /**
  35443. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35444. * @param iterations total number of iterations
  35445. * @param syncedIterations number of synchronous iterations in each async iteration.
  35446. * @param fn the function to call each iteration.
  35447. * @param callback a success call back that will be called when iterating stops.
  35448. * @param breakFunction a break condition (optional)
  35449. * @param timeout timeout settings for the setTimeout function. default - 0.
  35450. * @returns the created async loop object
  35451. */
  35452. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35453. }
  35454. }
  35455. declare module "babylonjs/Misc/stringDictionary" {
  35456. import { Nullable } from "babylonjs/types";
  35457. /**
  35458. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35459. * The underlying implementation relies on an associative array to ensure the best performances.
  35460. * The value can be anything including 'null' but except 'undefined'
  35461. */
  35462. export class StringDictionary<T> {
  35463. /**
  35464. * This will clear this dictionary and copy the content from the 'source' one.
  35465. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35466. * @param source the dictionary to take the content from and copy to this dictionary
  35467. */
  35468. copyFrom(source: StringDictionary<T>): void;
  35469. /**
  35470. * Get a value based from its key
  35471. * @param key the given key to get the matching value from
  35472. * @return the value if found, otherwise undefined is returned
  35473. */
  35474. get(key: string): T | undefined;
  35475. /**
  35476. * Get a value from its key or add it if it doesn't exist.
  35477. * This method will ensure you that a given key/data will be present in the dictionary.
  35478. * @param key the given key to get the matching value from
  35479. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35480. * The factory will only be invoked if there's no data for the given key.
  35481. * @return the value corresponding to the key.
  35482. */
  35483. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35484. /**
  35485. * Get a value from its key if present in the dictionary otherwise add it
  35486. * @param key the key to get the value from
  35487. * @param val if there's no such key/value pair in the dictionary add it with this value
  35488. * @return the value corresponding to the key
  35489. */
  35490. getOrAdd(key: string, val: T): T;
  35491. /**
  35492. * Check if there's a given key in the dictionary
  35493. * @param key the key to check for
  35494. * @return true if the key is present, false otherwise
  35495. */
  35496. contains(key: string): boolean;
  35497. /**
  35498. * Add a new key and its corresponding value
  35499. * @param key the key to add
  35500. * @param value the value corresponding to the key
  35501. * @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
  35502. */
  35503. add(key: string, value: T): boolean;
  35504. /**
  35505. * Update a specific value associated to a key
  35506. * @param key defines the key to use
  35507. * @param value defines the value to store
  35508. * @returns true if the value was updated (or false if the key was not found)
  35509. */
  35510. set(key: string, value: T): boolean;
  35511. /**
  35512. * Get the element of the given key and remove it from the dictionary
  35513. * @param key defines the key to search
  35514. * @returns the value associated with the key or null if not found
  35515. */
  35516. getAndRemove(key: string): Nullable<T>;
  35517. /**
  35518. * Remove a key/value from the dictionary.
  35519. * @param key the key to remove
  35520. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35521. */
  35522. remove(key: string): boolean;
  35523. /**
  35524. * Clear the whole content of the dictionary
  35525. */
  35526. clear(): void;
  35527. /**
  35528. * Gets the current count
  35529. */
  35530. get count(): number;
  35531. /**
  35532. * Execute a callback on each key/val of the dictionary.
  35533. * Note that you can remove any element in this dictionary in the callback implementation
  35534. * @param callback the callback to execute on a given key/value pair
  35535. */
  35536. forEach(callback: (key: string, val: T) => void): void;
  35537. /**
  35538. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35539. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35540. * Note that you can remove any element in this dictionary in the callback implementation
  35541. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35542. * @returns the first item
  35543. */
  35544. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35545. private _count;
  35546. private _data;
  35547. }
  35548. }
  35549. declare module "babylonjs/Collisions/collisionCoordinator" {
  35550. import { Nullable } from "babylonjs/types";
  35551. import { Scene } from "babylonjs/scene";
  35552. import { Vector3 } from "babylonjs/Maths/math.vector";
  35553. import { Collider } from "babylonjs/Collisions/collider";
  35554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35555. /** @hidden */
  35556. export interface ICollisionCoordinator {
  35557. createCollider(): Collider;
  35558. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35559. init(scene: Scene): void;
  35560. }
  35561. /** @hidden */
  35562. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35563. private _scene;
  35564. private _scaledPosition;
  35565. private _scaledVelocity;
  35566. private _finalPosition;
  35567. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35568. createCollider(): Collider;
  35569. init(scene: Scene): void;
  35570. private _collideWithWorld;
  35571. }
  35572. }
  35573. declare module "babylonjs/Inputs/scene.inputManager" {
  35574. import { Nullable } from "babylonjs/types";
  35575. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35576. import { Vector2 } from "babylonjs/Maths/math.vector";
  35577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35578. import { Scene } from "babylonjs/scene";
  35579. /**
  35580. * Class used to manage all inputs for the scene.
  35581. */
  35582. export class InputManager {
  35583. /** The distance in pixel that you have to move to prevent some events */
  35584. static DragMovementThreshold: number;
  35585. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35586. static LongPressDelay: number;
  35587. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35588. static DoubleClickDelay: number;
  35589. /** If you need to check double click without raising a single click at first click, enable this flag */
  35590. static ExclusiveDoubleClickMode: boolean;
  35591. private _wheelEventName;
  35592. private _onPointerMove;
  35593. private _onPointerDown;
  35594. private _onPointerUp;
  35595. private _initClickEvent;
  35596. private _initActionManager;
  35597. private _delayedSimpleClick;
  35598. private _delayedSimpleClickTimeout;
  35599. private _previousDelayedSimpleClickTimeout;
  35600. private _meshPickProceed;
  35601. private _previousButtonPressed;
  35602. private _currentPickResult;
  35603. private _previousPickResult;
  35604. private _totalPointersPressed;
  35605. private _doubleClickOccured;
  35606. private _pointerOverMesh;
  35607. private _pickedDownMesh;
  35608. private _pickedUpMesh;
  35609. private _pointerX;
  35610. private _pointerY;
  35611. private _unTranslatedPointerX;
  35612. private _unTranslatedPointerY;
  35613. private _startingPointerPosition;
  35614. private _previousStartingPointerPosition;
  35615. private _startingPointerTime;
  35616. private _previousStartingPointerTime;
  35617. private _pointerCaptures;
  35618. private _onKeyDown;
  35619. private _onKeyUp;
  35620. private _onCanvasFocusObserver;
  35621. private _onCanvasBlurObserver;
  35622. private _scene;
  35623. /**
  35624. * Creates a new InputManager
  35625. * @param scene defines the hosting scene
  35626. */
  35627. constructor(scene: Scene);
  35628. /**
  35629. * Gets the mesh that is currently under the pointer
  35630. */
  35631. get meshUnderPointer(): Nullable<AbstractMesh>;
  35632. /**
  35633. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35634. */
  35635. get unTranslatedPointer(): Vector2;
  35636. /**
  35637. * Gets or sets the current on-screen X position of the pointer
  35638. */
  35639. get pointerX(): number;
  35640. set pointerX(value: number);
  35641. /**
  35642. * Gets or sets the current on-screen Y position of the pointer
  35643. */
  35644. get pointerY(): number;
  35645. set pointerY(value: number);
  35646. private _updatePointerPosition;
  35647. private _processPointerMove;
  35648. private _setRayOnPointerInfo;
  35649. private _checkPrePointerObservable;
  35650. /**
  35651. * Use this method to simulate a pointer move on a mesh
  35652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35655. */
  35656. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35657. /**
  35658. * Use this method to simulate a pointer down on a mesh
  35659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35662. */
  35663. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35664. private _processPointerDown;
  35665. /** @hidden */
  35666. _isPointerSwiping(): boolean;
  35667. /**
  35668. * Use this method to simulate a pointer up on a mesh
  35669. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35670. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35671. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35672. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35673. */
  35674. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35675. private _processPointerUp;
  35676. /**
  35677. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35678. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35679. * @returns true if the pointer was captured
  35680. */
  35681. isPointerCaptured(pointerId?: number): boolean;
  35682. /**
  35683. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35684. * @param attachUp defines if you want to attach events to pointerup
  35685. * @param attachDown defines if you want to attach events to pointerdown
  35686. * @param attachMove defines if you want to attach events to pointermove
  35687. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35688. */
  35689. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35690. /**
  35691. * Detaches all event handlers
  35692. */
  35693. detachControl(): void;
  35694. /**
  35695. * Force the value of meshUnderPointer
  35696. * @param mesh defines the mesh to use
  35697. */
  35698. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35699. /**
  35700. * Gets the mesh under the pointer
  35701. * @returns a Mesh or null if no mesh is under the pointer
  35702. */
  35703. getPointerOverMesh(): Nullable<AbstractMesh>;
  35704. }
  35705. }
  35706. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35707. /**
  35708. * Helper class used to generate session unique ID
  35709. */
  35710. export class UniqueIdGenerator {
  35711. private static _UniqueIdCounter;
  35712. /**
  35713. * Gets an unique (relatively to the current scene) Id
  35714. */
  35715. static get UniqueId(): number;
  35716. }
  35717. }
  35718. declare module "babylonjs/Animations/animationGroup" {
  35719. import { Animatable } from "babylonjs/Animations/animatable";
  35720. import { Animation } from "babylonjs/Animations/animation";
  35721. import { Scene, IDisposable } from "babylonjs/scene";
  35722. import { Observable } from "babylonjs/Misc/observable";
  35723. import { Nullable } from "babylonjs/types";
  35724. import "babylonjs/Animations/animatable";
  35725. /**
  35726. * This class defines the direct association between an animation and a target
  35727. */
  35728. export class TargetedAnimation {
  35729. /**
  35730. * Animation to perform
  35731. */
  35732. animation: Animation;
  35733. /**
  35734. * Target to animate
  35735. */
  35736. target: any;
  35737. /**
  35738. * Serialize the object
  35739. * @returns the JSON object representing the current entity
  35740. */
  35741. serialize(): any;
  35742. }
  35743. /**
  35744. * Use this class to create coordinated animations on multiple targets
  35745. */
  35746. export class AnimationGroup implements IDisposable {
  35747. /** The name of the animation group */
  35748. name: string;
  35749. private _scene;
  35750. private _targetedAnimations;
  35751. private _animatables;
  35752. private _from;
  35753. private _to;
  35754. private _isStarted;
  35755. private _isPaused;
  35756. private _speedRatio;
  35757. private _loopAnimation;
  35758. /**
  35759. * Gets or sets the unique id of the node
  35760. */
  35761. uniqueId: number;
  35762. /**
  35763. * This observable will notify when one animation have ended
  35764. */
  35765. onAnimationEndObservable: Observable<TargetedAnimation>;
  35766. /**
  35767. * Observer raised when one animation loops
  35768. */
  35769. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35770. /**
  35771. * Observer raised when all animations have looped
  35772. */
  35773. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35774. /**
  35775. * This observable will notify when all animations have ended.
  35776. */
  35777. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35778. /**
  35779. * This observable will notify when all animations have paused.
  35780. */
  35781. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35782. /**
  35783. * This observable will notify when all animations are playing.
  35784. */
  35785. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35786. /**
  35787. * Gets the first frame
  35788. */
  35789. get from(): number;
  35790. /**
  35791. * Gets the last frame
  35792. */
  35793. get to(): number;
  35794. /**
  35795. * Define if the animations are started
  35796. */
  35797. get isStarted(): boolean;
  35798. /**
  35799. * Gets a value indicating that the current group is playing
  35800. */
  35801. get isPlaying(): boolean;
  35802. /**
  35803. * Gets or sets the speed ratio to use for all animations
  35804. */
  35805. get speedRatio(): number;
  35806. /**
  35807. * Gets or sets the speed ratio to use for all animations
  35808. */
  35809. set speedRatio(value: number);
  35810. /**
  35811. * Gets or sets if all animations should loop or not
  35812. */
  35813. get loopAnimation(): boolean;
  35814. set loopAnimation(value: boolean);
  35815. /**
  35816. * Gets the targeted animations for this animation group
  35817. */
  35818. get targetedAnimations(): Array<TargetedAnimation>;
  35819. /**
  35820. * returning the list of animatables controlled by this animation group.
  35821. */
  35822. get animatables(): Array<Animatable>;
  35823. /**
  35824. * Instantiates a new Animation Group.
  35825. * This helps managing several animations at once.
  35826. * @see http://doc.babylonjs.com/how_to/group
  35827. * @param name Defines the name of the group
  35828. * @param scene Defines the scene the group belongs to
  35829. */
  35830. constructor(
  35831. /** The name of the animation group */
  35832. name: string, scene?: Nullable<Scene>);
  35833. /**
  35834. * Add an animation (with its target) in the group
  35835. * @param animation defines the animation we want to add
  35836. * @param target defines the target of the animation
  35837. * @returns the TargetedAnimation object
  35838. */
  35839. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35840. /**
  35841. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35842. * It can add constant keys at begin or end
  35843. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35844. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35845. * @returns the animation group
  35846. */
  35847. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35848. private _animationLoopCount;
  35849. private _animationLoopFlags;
  35850. private _processLoop;
  35851. /**
  35852. * Start all animations on given targets
  35853. * @param loop defines if animations must loop
  35854. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35855. * @param from defines the from key (optional)
  35856. * @param to defines the to key (optional)
  35857. * @returns the current animation group
  35858. */
  35859. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35860. /**
  35861. * Pause all animations
  35862. * @returns the animation group
  35863. */
  35864. pause(): AnimationGroup;
  35865. /**
  35866. * Play all animations to initial state
  35867. * This function will start() the animations if they were not started or will restart() them if they were paused
  35868. * @param loop defines if animations must loop
  35869. * @returns the animation group
  35870. */
  35871. play(loop?: boolean): AnimationGroup;
  35872. /**
  35873. * Reset all animations to initial state
  35874. * @returns the animation group
  35875. */
  35876. reset(): AnimationGroup;
  35877. /**
  35878. * Restart animations from key 0
  35879. * @returns the animation group
  35880. */
  35881. restart(): AnimationGroup;
  35882. /**
  35883. * Stop all animations
  35884. * @returns the animation group
  35885. */
  35886. stop(): AnimationGroup;
  35887. /**
  35888. * Set animation weight for all animatables
  35889. * @param weight defines the weight to use
  35890. * @return the animationGroup
  35891. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35892. */
  35893. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35894. /**
  35895. * Synchronize and normalize all animatables with a source animatable
  35896. * @param root defines the root animatable to synchronize with
  35897. * @return the animationGroup
  35898. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35899. */
  35900. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35901. /**
  35902. * Goes to a specific frame in this animation group
  35903. * @param frame the frame number to go to
  35904. * @return the animationGroup
  35905. */
  35906. goToFrame(frame: number): AnimationGroup;
  35907. /**
  35908. * Dispose all associated resources
  35909. */
  35910. dispose(): void;
  35911. private _checkAnimationGroupEnded;
  35912. /**
  35913. * Clone the current animation group and returns a copy
  35914. * @param newName defines the name of the new group
  35915. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35916. * @returns the new aniamtion group
  35917. */
  35918. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35919. /**
  35920. * Serializes the animationGroup to an object
  35921. * @returns Serialized object
  35922. */
  35923. serialize(): any;
  35924. /**
  35925. * Returns a new AnimationGroup object parsed from the source provided.
  35926. * @param parsedAnimationGroup defines the source
  35927. * @param scene defines the scene that will receive the animationGroup
  35928. * @returns a new AnimationGroup
  35929. */
  35930. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35931. /**
  35932. * Returns the string "AnimationGroup"
  35933. * @returns "AnimationGroup"
  35934. */
  35935. getClassName(): string;
  35936. /**
  35937. * Creates a detailled string about the object
  35938. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35939. * @returns a string representing the object
  35940. */
  35941. toString(fullDetails?: boolean): string;
  35942. }
  35943. }
  35944. declare module "babylonjs/scene" {
  35945. import { Nullable } from "babylonjs/types";
  35946. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35947. import { Observable } from "babylonjs/Misc/observable";
  35948. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35949. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35950. import { Geometry } from "babylonjs/Meshes/geometry";
  35951. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35954. import { Mesh } from "babylonjs/Meshes/mesh";
  35955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35956. import { Bone } from "babylonjs/Bones/bone";
  35957. import { Skeleton } from "babylonjs/Bones/skeleton";
  35958. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35959. import { Camera } from "babylonjs/Cameras/camera";
  35960. import { AbstractScene } from "babylonjs/abstractScene";
  35961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35962. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35963. import { Material } from "babylonjs/Materials/material";
  35964. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35965. import { Effect } from "babylonjs/Materials/effect";
  35966. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35967. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35968. import { Light } from "babylonjs/Lights/light";
  35969. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35970. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35971. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35972. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35974. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35975. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35976. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35977. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35978. import { Engine } from "babylonjs/Engines/engine";
  35979. import { Node } from "babylonjs/node";
  35980. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35981. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35982. import { WebRequest } from "babylonjs/Misc/webRequest";
  35983. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35984. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35985. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35986. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35987. import { Plane } from "babylonjs/Maths/math.plane";
  35988. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35989. import { Ray } from "babylonjs/Culling/ray";
  35990. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35991. import { Animation } from "babylonjs/Animations/animation";
  35992. import { Animatable } from "babylonjs/Animations/animatable";
  35993. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35994. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35995. import { Collider } from "babylonjs/Collisions/collider";
  35996. /**
  35997. * Define an interface for all classes that will hold resources
  35998. */
  35999. export interface IDisposable {
  36000. /**
  36001. * Releases all held resources
  36002. */
  36003. dispose(): void;
  36004. }
  36005. /** Interface defining initialization parameters for Scene class */
  36006. export interface SceneOptions {
  36007. /**
  36008. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36009. * It will improve performance when the number of geometries becomes important.
  36010. */
  36011. useGeometryUniqueIdsMap?: boolean;
  36012. /**
  36013. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36014. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36015. */
  36016. useMaterialMeshMap?: boolean;
  36017. /**
  36018. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36019. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36020. */
  36021. useClonedMeshMap?: boolean;
  36022. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36023. virtual?: boolean;
  36024. }
  36025. /**
  36026. * Represents a scene to be rendered by the engine.
  36027. * @see http://doc.babylonjs.com/features/scene
  36028. */
  36029. export class Scene extends AbstractScene implements IAnimatable {
  36030. /** The fog is deactivated */
  36031. static readonly FOGMODE_NONE: number;
  36032. /** The fog density is following an exponential function */
  36033. static readonly FOGMODE_EXP: number;
  36034. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36035. static readonly FOGMODE_EXP2: number;
  36036. /** The fog density is following a linear function. */
  36037. static readonly FOGMODE_LINEAR: number;
  36038. /**
  36039. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36041. */
  36042. static MinDeltaTime: number;
  36043. /**
  36044. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36045. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36046. */
  36047. static MaxDeltaTime: number;
  36048. /**
  36049. * Factory used to create the default material.
  36050. * @param name The name of the material to create
  36051. * @param scene The scene to create the material for
  36052. * @returns The default material
  36053. */
  36054. static DefaultMaterialFactory(scene: Scene): Material;
  36055. /**
  36056. * Factory used to create the a collision coordinator.
  36057. * @returns The collision coordinator
  36058. */
  36059. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36060. /** @hidden */
  36061. _inputManager: InputManager;
  36062. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36063. cameraToUseForPointers: Nullable<Camera>;
  36064. /** @hidden */
  36065. readonly _isScene: boolean;
  36066. /**
  36067. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36068. */
  36069. autoClear: boolean;
  36070. /**
  36071. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36072. */
  36073. autoClearDepthAndStencil: boolean;
  36074. /**
  36075. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36076. */
  36077. clearColor: Color4;
  36078. /**
  36079. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36080. */
  36081. ambientColor: Color3;
  36082. /**
  36083. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36084. * It should only be one of the following (if not the default embedded one):
  36085. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36086. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36087. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36088. * The material properties need to be setup according to the type of texture in use.
  36089. */
  36090. environmentBRDFTexture: BaseTexture;
  36091. /** @hidden */
  36092. protected _environmentTexture: Nullable<BaseTexture>;
  36093. /**
  36094. * Texture used in all pbr material as the reflection texture.
  36095. * As in the majority of the scene they are the same (exception for multi room and so on),
  36096. * this is easier to reference from here than from all the materials.
  36097. */
  36098. get environmentTexture(): Nullable<BaseTexture>;
  36099. /**
  36100. * Texture used in all pbr material as the reflection texture.
  36101. * As in the majority of the scene they are the same (exception for multi room and so on),
  36102. * this is easier to set here than in all the materials.
  36103. */
  36104. set environmentTexture(value: Nullable<BaseTexture>);
  36105. /** @hidden */
  36106. protected _environmentIntensity: number;
  36107. /**
  36108. * Intensity of the environment in all pbr material.
  36109. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36110. * As in the majority of the scene they are the same (exception for multi room and so on),
  36111. * this is easier to reference from here than from all the materials.
  36112. */
  36113. get environmentIntensity(): number;
  36114. /**
  36115. * Intensity of the environment in all pbr material.
  36116. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36117. * As in the majority of the scene they are the same (exception for multi room and so on),
  36118. * this is easier to set here than in all the materials.
  36119. */
  36120. set environmentIntensity(value: number);
  36121. /** @hidden */
  36122. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36123. /**
  36124. * Default image processing configuration used either in the rendering
  36125. * Forward main pass or through the imageProcessingPostProcess if present.
  36126. * As in the majority of the scene they are the same (exception for multi camera),
  36127. * this is easier to reference from here than from all the materials and post process.
  36128. *
  36129. * No setter as we it is a shared configuration, you can set the values instead.
  36130. */
  36131. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36132. private _forceWireframe;
  36133. /**
  36134. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36135. */
  36136. set forceWireframe(value: boolean);
  36137. get forceWireframe(): boolean;
  36138. private _skipFrustumClipping;
  36139. /**
  36140. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36141. */
  36142. set skipFrustumClipping(value: boolean);
  36143. get skipFrustumClipping(): boolean;
  36144. private _forcePointsCloud;
  36145. /**
  36146. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36147. */
  36148. set forcePointsCloud(value: boolean);
  36149. get forcePointsCloud(): boolean;
  36150. /**
  36151. * Gets or sets the active clipplane 1
  36152. */
  36153. clipPlane: Nullable<Plane>;
  36154. /**
  36155. * Gets or sets the active clipplane 2
  36156. */
  36157. clipPlane2: Nullable<Plane>;
  36158. /**
  36159. * Gets or sets the active clipplane 3
  36160. */
  36161. clipPlane3: Nullable<Plane>;
  36162. /**
  36163. * Gets or sets the active clipplane 4
  36164. */
  36165. clipPlane4: Nullable<Plane>;
  36166. /**
  36167. * Gets or sets the active clipplane 5
  36168. */
  36169. clipPlane5: Nullable<Plane>;
  36170. /**
  36171. * Gets or sets the active clipplane 6
  36172. */
  36173. clipPlane6: Nullable<Plane>;
  36174. /**
  36175. * Gets or sets a boolean indicating if animations are enabled
  36176. */
  36177. animationsEnabled: boolean;
  36178. private _animationPropertiesOverride;
  36179. /**
  36180. * Gets or sets the animation properties override
  36181. */
  36182. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36183. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36184. /**
  36185. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36186. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36187. */
  36188. useConstantAnimationDeltaTime: boolean;
  36189. /**
  36190. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36191. * Please note that it requires to run a ray cast through the scene on every frame
  36192. */
  36193. constantlyUpdateMeshUnderPointer: boolean;
  36194. /**
  36195. * Defines the HTML cursor to use when hovering over interactive elements
  36196. */
  36197. hoverCursor: string;
  36198. /**
  36199. * Defines the HTML default cursor to use (empty by default)
  36200. */
  36201. defaultCursor: string;
  36202. /**
  36203. * Defines wether cursors are handled by the scene.
  36204. */
  36205. doNotHandleCursors: boolean;
  36206. /**
  36207. * This is used to call preventDefault() on pointer down
  36208. * in order to block unwanted artifacts like system double clicks
  36209. */
  36210. preventDefaultOnPointerDown: boolean;
  36211. /**
  36212. * This is used to call preventDefault() on pointer up
  36213. * in order to block unwanted artifacts like system double clicks
  36214. */
  36215. preventDefaultOnPointerUp: boolean;
  36216. /**
  36217. * Gets or sets user defined metadata
  36218. */
  36219. metadata: any;
  36220. /**
  36221. * For internal use only. Please do not use.
  36222. */
  36223. reservedDataStore: any;
  36224. /**
  36225. * Gets the name of the plugin used to load this scene (null by default)
  36226. */
  36227. loadingPluginName: string;
  36228. /**
  36229. * Use this array to add regular expressions used to disable offline support for specific urls
  36230. */
  36231. disableOfflineSupportExceptionRules: RegExp[];
  36232. /**
  36233. * An event triggered when the scene is disposed.
  36234. */
  36235. onDisposeObservable: Observable<Scene>;
  36236. private _onDisposeObserver;
  36237. /** Sets a function to be executed when this scene is disposed. */
  36238. set onDispose(callback: () => void);
  36239. /**
  36240. * An event triggered before rendering the scene (right after animations and physics)
  36241. */
  36242. onBeforeRenderObservable: Observable<Scene>;
  36243. private _onBeforeRenderObserver;
  36244. /** Sets a function to be executed before rendering this scene */
  36245. set beforeRender(callback: Nullable<() => void>);
  36246. /**
  36247. * An event triggered after rendering the scene
  36248. */
  36249. onAfterRenderObservable: Observable<Scene>;
  36250. /**
  36251. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36252. */
  36253. onAfterRenderCameraObservable: Observable<Camera>;
  36254. private _onAfterRenderObserver;
  36255. /** Sets a function to be executed after rendering this scene */
  36256. set afterRender(callback: Nullable<() => void>);
  36257. /**
  36258. * An event triggered before animating the scene
  36259. */
  36260. onBeforeAnimationsObservable: Observable<Scene>;
  36261. /**
  36262. * An event triggered after animations processing
  36263. */
  36264. onAfterAnimationsObservable: Observable<Scene>;
  36265. /**
  36266. * An event triggered before draw calls are ready to be sent
  36267. */
  36268. onBeforeDrawPhaseObservable: Observable<Scene>;
  36269. /**
  36270. * An event triggered after draw calls have been sent
  36271. */
  36272. onAfterDrawPhaseObservable: Observable<Scene>;
  36273. /**
  36274. * An event triggered when the scene is ready
  36275. */
  36276. onReadyObservable: Observable<Scene>;
  36277. /**
  36278. * An event triggered before rendering a camera
  36279. */
  36280. onBeforeCameraRenderObservable: Observable<Camera>;
  36281. private _onBeforeCameraRenderObserver;
  36282. /** Sets a function to be executed before rendering a camera*/
  36283. set beforeCameraRender(callback: () => void);
  36284. /**
  36285. * An event triggered after rendering a camera
  36286. */
  36287. onAfterCameraRenderObservable: Observable<Camera>;
  36288. private _onAfterCameraRenderObserver;
  36289. /** Sets a function to be executed after rendering a camera*/
  36290. set afterCameraRender(callback: () => void);
  36291. /**
  36292. * An event triggered when active meshes evaluation is about to start
  36293. */
  36294. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36295. /**
  36296. * An event triggered when active meshes evaluation is done
  36297. */
  36298. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36299. /**
  36300. * An event triggered when particles rendering is about to start
  36301. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36302. */
  36303. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36304. /**
  36305. * An event triggered when particles rendering is done
  36306. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36307. */
  36308. onAfterParticlesRenderingObservable: Observable<Scene>;
  36309. /**
  36310. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36311. */
  36312. onDataLoadedObservable: Observable<Scene>;
  36313. /**
  36314. * An event triggered when a camera is created
  36315. */
  36316. onNewCameraAddedObservable: Observable<Camera>;
  36317. /**
  36318. * An event triggered when a camera is removed
  36319. */
  36320. onCameraRemovedObservable: Observable<Camera>;
  36321. /**
  36322. * An event triggered when a light is created
  36323. */
  36324. onNewLightAddedObservable: Observable<Light>;
  36325. /**
  36326. * An event triggered when a light is removed
  36327. */
  36328. onLightRemovedObservable: Observable<Light>;
  36329. /**
  36330. * An event triggered when a geometry is created
  36331. */
  36332. onNewGeometryAddedObservable: Observable<Geometry>;
  36333. /**
  36334. * An event triggered when a geometry is removed
  36335. */
  36336. onGeometryRemovedObservable: Observable<Geometry>;
  36337. /**
  36338. * An event triggered when a transform node is created
  36339. */
  36340. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36341. /**
  36342. * An event triggered when a transform node is removed
  36343. */
  36344. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36345. /**
  36346. * An event triggered when a mesh is created
  36347. */
  36348. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36349. /**
  36350. * An event triggered when a mesh is removed
  36351. */
  36352. onMeshRemovedObservable: Observable<AbstractMesh>;
  36353. /**
  36354. * An event triggered when a skeleton is created
  36355. */
  36356. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36357. /**
  36358. * An event triggered when a skeleton is removed
  36359. */
  36360. onSkeletonRemovedObservable: Observable<Skeleton>;
  36361. /**
  36362. * An event triggered when a material is created
  36363. */
  36364. onNewMaterialAddedObservable: Observable<Material>;
  36365. /**
  36366. * An event triggered when a material is removed
  36367. */
  36368. onMaterialRemovedObservable: Observable<Material>;
  36369. /**
  36370. * An event triggered when a texture is created
  36371. */
  36372. onNewTextureAddedObservable: Observable<BaseTexture>;
  36373. /**
  36374. * An event triggered when a texture is removed
  36375. */
  36376. onTextureRemovedObservable: Observable<BaseTexture>;
  36377. /**
  36378. * An event triggered when render targets are about to be rendered
  36379. * Can happen multiple times per frame.
  36380. */
  36381. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36382. /**
  36383. * An event triggered when render targets were rendered.
  36384. * Can happen multiple times per frame.
  36385. */
  36386. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36387. /**
  36388. * An event triggered before calculating deterministic simulation step
  36389. */
  36390. onBeforeStepObservable: Observable<Scene>;
  36391. /**
  36392. * An event triggered after calculating deterministic simulation step
  36393. */
  36394. onAfterStepObservable: Observable<Scene>;
  36395. /**
  36396. * An event triggered when the activeCamera property is updated
  36397. */
  36398. onActiveCameraChanged: Observable<Scene>;
  36399. /**
  36400. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36401. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36402. * 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)
  36403. */
  36404. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36405. /**
  36406. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36407. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36408. * 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)
  36409. */
  36410. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36411. /**
  36412. * This Observable will when a mesh has been imported into the scene.
  36413. */
  36414. onMeshImportedObservable: Observable<AbstractMesh>;
  36415. /**
  36416. * This Observable will when an animation file has been imported into the scene.
  36417. */
  36418. onAnimationFileImportedObservable: Observable<Scene>;
  36419. /**
  36420. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36421. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36422. */
  36423. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36424. /** @hidden */
  36425. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36426. /**
  36427. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36428. */
  36429. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36430. /**
  36431. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36432. */
  36433. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36434. /**
  36435. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36436. */
  36437. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36438. /** Callback called when a pointer move is detected */
  36439. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36440. /** Callback called when a pointer down is detected */
  36441. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36442. /** Callback called when a pointer up is detected */
  36443. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36444. /** Callback called when a pointer pick is detected */
  36445. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36446. /**
  36447. * 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).
  36448. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36449. */
  36450. onPrePointerObservable: Observable<PointerInfoPre>;
  36451. /**
  36452. * Observable event triggered each time an input event is received from the rendering canvas
  36453. */
  36454. onPointerObservable: Observable<PointerInfo>;
  36455. /**
  36456. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36457. */
  36458. get unTranslatedPointer(): Vector2;
  36459. /**
  36460. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36461. */
  36462. static get DragMovementThreshold(): number;
  36463. static set DragMovementThreshold(value: number);
  36464. /**
  36465. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36466. */
  36467. static get LongPressDelay(): number;
  36468. static set LongPressDelay(value: number);
  36469. /**
  36470. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36471. */
  36472. static get DoubleClickDelay(): number;
  36473. static set DoubleClickDelay(value: number);
  36474. /** If you need to check double click without raising a single click at first click, enable this flag */
  36475. static get ExclusiveDoubleClickMode(): boolean;
  36476. static set ExclusiveDoubleClickMode(value: boolean);
  36477. /** @hidden */
  36478. _mirroredCameraPosition: Nullable<Vector3>;
  36479. /**
  36480. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36481. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36482. */
  36483. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36484. /**
  36485. * Observable event triggered each time an keyboard event is received from the hosting window
  36486. */
  36487. onKeyboardObservable: Observable<KeyboardInfo>;
  36488. private _useRightHandedSystem;
  36489. /**
  36490. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36491. */
  36492. set useRightHandedSystem(value: boolean);
  36493. get useRightHandedSystem(): boolean;
  36494. private _timeAccumulator;
  36495. private _currentStepId;
  36496. private _currentInternalStep;
  36497. /**
  36498. * Sets the step Id used by deterministic lock step
  36499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36500. * @param newStepId defines the step Id
  36501. */
  36502. setStepId(newStepId: number): void;
  36503. /**
  36504. * Gets the step Id used by deterministic lock step
  36505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36506. * @returns the step Id
  36507. */
  36508. getStepId(): number;
  36509. /**
  36510. * Gets the internal step used by deterministic lock step
  36511. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36512. * @returns the internal step
  36513. */
  36514. getInternalStep(): number;
  36515. private _fogEnabled;
  36516. /**
  36517. * Gets or sets a boolean indicating if fog is enabled on this scene
  36518. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36519. * (Default is true)
  36520. */
  36521. set fogEnabled(value: boolean);
  36522. get fogEnabled(): boolean;
  36523. private _fogMode;
  36524. /**
  36525. * Gets or sets the fog mode to use
  36526. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36527. * | mode | value |
  36528. * | --- | --- |
  36529. * | FOGMODE_NONE | 0 |
  36530. * | FOGMODE_EXP | 1 |
  36531. * | FOGMODE_EXP2 | 2 |
  36532. * | FOGMODE_LINEAR | 3 |
  36533. */
  36534. set fogMode(value: number);
  36535. get fogMode(): number;
  36536. /**
  36537. * Gets or sets the fog color to use
  36538. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36539. * (Default is Color3(0.2, 0.2, 0.3))
  36540. */
  36541. fogColor: Color3;
  36542. /**
  36543. * Gets or sets the fog density to use
  36544. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36545. * (Default is 0.1)
  36546. */
  36547. fogDensity: number;
  36548. /**
  36549. * Gets or sets the fog start distance to use
  36550. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36551. * (Default is 0)
  36552. */
  36553. fogStart: number;
  36554. /**
  36555. * Gets or sets the fog end distance to use
  36556. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36557. * (Default is 1000)
  36558. */
  36559. fogEnd: number;
  36560. private _shadowsEnabled;
  36561. /**
  36562. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36563. */
  36564. set shadowsEnabled(value: boolean);
  36565. get shadowsEnabled(): boolean;
  36566. private _lightsEnabled;
  36567. /**
  36568. * Gets or sets a boolean indicating if lights are enabled on this scene
  36569. */
  36570. set lightsEnabled(value: boolean);
  36571. get lightsEnabled(): boolean;
  36572. /** All of the active cameras added to this scene. */
  36573. activeCameras: Camera[];
  36574. /** @hidden */
  36575. _activeCamera: Nullable<Camera>;
  36576. /** Gets or sets the current active camera */
  36577. get activeCamera(): Nullable<Camera>;
  36578. set activeCamera(value: Nullable<Camera>);
  36579. private _defaultMaterial;
  36580. /** The default material used on meshes when no material is affected */
  36581. get defaultMaterial(): Material;
  36582. /** The default material used on meshes when no material is affected */
  36583. set defaultMaterial(value: Material);
  36584. private _texturesEnabled;
  36585. /**
  36586. * Gets or sets a boolean indicating if textures are enabled on this scene
  36587. */
  36588. set texturesEnabled(value: boolean);
  36589. get texturesEnabled(): boolean;
  36590. /**
  36591. * Gets or sets a boolean indicating if particles are enabled on this scene
  36592. */
  36593. particlesEnabled: boolean;
  36594. /**
  36595. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36596. */
  36597. spritesEnabled: boolean;
  36598. private _skeletonsEnabled;
  36599. /**
  36600. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36601. */
  36602. set skeletonsEnabled(value: boolean);
  36603. get skeletonsEnabled(): boolean;
  36604. /**
  36605. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36606. */
  36607. lensFlaresEnabled: boolean;
  36608. /**
  36609. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36610. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36611. */
  36612. collisionsEnabled: boolean;
  36613. private _collisionCoordinator;
  36614. /** @hidden */
  36615. get collisionCoordinator(): ICollisionCoordinator;
  36616. /**
  36617. * Defines the gravity applied to this scene (used only for collisions)
  36618. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36619. */
  36620. gravity: Vector3;
  36621. /**
  36622. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36623. */
  36624. postProcessesEnabled: boolean;
  36625. /**
  36626. * The list of postprocesses added to the scene
  36627. */
  36628. postProcesses: PostProcess[];
  36629. /**
  36630. * Gets the current postprocess manager
  36631. */
  36632. postProcessManager: PostProcessManager;
  36633. /**
  36634. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36635. */
  36636. renderTargetsEnabled: boolean;
  36637. /**
  36638. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36639. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36640. */
  36641. dumpNextRenderTargets: boolean;
  36642. /**
  36643. * The list of user defined render targets added to the scene
  36644. */
  36645. customRenderTargets: RenderTargetTexture[];
  36646. /**
  36647. * Defines if texture loading must be delayed
  36648. * If true, textures will only be loaded when they need to be rendered
  36649. */
  36650. useDelayedTextureLoading: boolean;
  36651. /**
  36652. * Gets the list of meshes imported to the scene through SceneLoader
  36653. */
  36654. importedMeshesFiles: String[];
  36655. /**
  36656. * Gets or sets a boolean indicating if probes are enabled on this scene
  36657. */
  36658. probesEnabled: boolean;
  36659. /**
  36660. * Gets or sets the current offline provider to use to store scene data
  36661. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36662. */
  36663. offlineProvider: IOfflineProvider;
  36664. /**
  36665. * Gets or sets the action manager associated with the scene
  36666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36667. */
  36668. actionManager: AbstractActionManager;
  36669. private _meshesForIntersections;
  36670. /**
  36671. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36672. */
  36673. proceduralTexturesEnabled: boolean;
  36674. private _engine;
  36675. private _totalVertices;
  36676. /** @hidden */
  36677. _activeIndices: PerfCounter;
  36678. /** @hidden */
  36679. _activeParticles: PerfCounter;
  36680. /** @hidden */
  36681. _activeBones: PerfCounter;
  36682. private _animationRatio;
  36683. /** @hidden */
  36684. _animationTimeLast: number;
  36685. /** @hidden */
  36686. _animationTime: number;
  36687. /**
  36688. * Gets or sets a general scale for animation speed
  36689. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36690. */
  36691. animationTimeScale: number;
  36692. /** @hidden */
  36693. _cachedMaterial: Nullable<Material>;
  36694. /** @hidden */
  36695. _cachedEffect: Nullable<Effect>;
  36696. /** @hidden */
  36697. _cachedVisibility: Nullable<number>;
  36698. private _renderId;
  36699. private _frameId;
  36700. private _executeWhenReadyTimeoutId;
  36701. private _intermediateRendering;
  36702. private _viewUpdateFlag;
  36703. private _projectionUpdateFlag;
  36704. /** @hidden */
  36705. _toBeDisposed: Nullable<IDisposable>[];
  36706. private _activeRequests;
  36707. /** @hidden */
  36708. _pendingData: any[];
  36709. private _isDisposed;
  36710. /**
  36711. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36712. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36713. */
  36714. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36715. private _activeMeshes;
  36716. private _processedMaterials;
  36717. private _renderTargets;
  36718. /** @hidden */
  36719. _activeParticleSystems: SmartArray<IParticleSystem>;
  36720. private _activeSkeletons;
  36721. private _softwareSkinnedMeshes;
  36722. private _renderingManager;
  36723. /** @hidden */
  36724. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36725. private _transformMatrix;
  36726. private _sceneUbo;
  36727. /** @hidden */
  36728. _viewMatrix: Matrix;
  36729. private _projectionMatrix;
  36730. /** @hidden */
  36731. _forcedViewPosition: Nullable<Vector3>;
  36732. /** @hidden */
  36733. _frustumPlanes: Plane[];
  36734. /**
  36735. * Gets the list of frustum planes (built from the active camera)
  36736. */
  36737. get frustumPlanes(): Plane[];
  36738. /**
  36739. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36740. * This is useful if there are more lights that the maximum simulteanous authorized
  36741. */
  36742. requireLightSorting: boolean;
  36743. /** @hidden */
  36744. readonly useMaterialMeshMap: boolean;
  36745. /** @hidden */
  36746. readonly useClonedMeshMap: boolean;
  36747. private _externalData;
  36748. private _uid;
  36749. /**
  36750. * @hidden
  36751. * Backing store of defined scene components.
  36752. */
  36753. _components: ISceneComponent[];
  36754. /**
  36755. * @hidden
  36756. * Backing store of defined scene components.
  36757. */
  36758. _serializableComponents: ISceneSerializableComponent[];
  36759. /**
  36760. * List of components to register on the next registration step.
  36761. */
  36762. private _transientComponents;
  36763. /**
  36764. * Registers the transient components if needed.
  36765. */
  36766. private _registerTransientComponents;
  36767. /**
  36768. * @hidden
  36769. * Add a component to the scene.
  36770. * Note that the ccomponent could be registered on th next frame if this is called after
  36771. * the register component stage.
  36772. * @param component Defines the component to add to the scene
  36773. */
  36774. _addComponent(component: ISceneComponent): void;
  36775. /**
  36776. * @hidden
  36777. * Gets a component from the scene.
  36778. * @param name defines the name of the component to retrieve
  36779. * @returns the component or null if not present
  36780. */
  36781. _getComponent(name: string): Nullable<ISceneComponent>;
  36782. /**
  36783. * @hidden
  36784. * Defines the actions happening before camera updates.
  36785. */
  36786. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36787. /**
  36788. * @hidden
  36789. * Defines the actions happening before clear the canvas.
  36790. */
  36791. _beforeClearStage: Stage<SimpleStageAction>;
  36792. /**
  36793. * @hidden
  36794. * Defines the actions when collecting render targets for the frame.
  36795. */
  36796. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36797. /**
  36798. * @hidden
  36799. * Defines the actions happening for one camera in the frame.
  36800. */
  36801. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36802. /**
  36803. * @hidden
  36804. * Defines the actions happening during the per mesh ready checks.
  36805. */
  36806. _isReadyForMeshStage: Stage<MeshStageAction>;
  36807. /**
  36808. * @hidden
  36809. * Defines the actions happening before evaluate active mesh checks.
  36810. */
  36811. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36812. /**
  36813. * @hidden
  36814. * Defines the actions happening during the evaluate sub mesh checks.
  36815. */
  36816. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36817. /**
  36818. * @hidden
  36819. * Defines the actions happening during the active mesh stage.
  36820. */
  36821. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36822. /**
  36823. * @hidden
  36824. * Defines the actions happening during the per camera render target step.
  36825. */
  36826. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36827. /**
  36828. * @hidden
  36829. * Defines the actions happening just before the active camera is drawing.
  36830. */
  36831. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36832. /**
  36833. * @hidden
  36834. * Defines the actions happening just before a render target is drawing.
  36835. */
  36836. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36837. /**
  36838. * @hidden
  36839. * Defines the actions happening just before a rendering group is drawing.
  36840. */
  36841. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36842. /**
  36843. * @hidden
  36844. * Defines the actions happening just before a mesh is drawing.
  36845. */
  36846. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36847. /**
  36848. * @hidden
  36849. * Defines the actions happening just after a mesh has been drawn.
  36850. */
  36851. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36852. /**
  36853. * @hidden
  36854. * Defines the actions happening just after a rendering group has been drawn.
  36855. */
  36856. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36857. /**
  36858. * @hidden
  36859. * Defines the actions happening just after the active camera has been drawn.
  36860. */
  36861. _afterCameraDrawStage: Stage<CameraStageAction>;
  36862. /**
  36863. * @hidden
  36864. * Defines the actions happening just after a render target has been drawn.
  36865. */
  36866. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36867. /**
  36868. * @hidden
  36869. * Defines the actions happening just after rendering all cameras and computing intersections.
  36870. */
  36871. _afterRenderStage: Stage<SimpleStageAction>;
  36872. /**
  36873. * @hidden
  36874. * Defines the actions happening when a pointer move event happens.
  36875. */
  36876. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36877. /**
  36878. * @hidden
  36879. * Defines the actions happening when a pointer down event happens.
  36880. */
  36881. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36882. /**
  36883. * @hidden
  36884. * Defines the actions happening when a pointer up event happens.
  36885. */
  36886. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36887. /**
  36888. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36889. */
  36890. private geometriesByUniqueId;
  36891. /**
  36892. * Creates a new Scene
  36893. * @param engine defines the engine to use to render this scene
  36894. * @param options defines the scene options
  36895. */
  36896. constructor(engine: Engine, options?: SceneOptions);
  36897. /**
  36898. * Gets a string idenfifying the name of the class
  36899. * @returns "Scene" string
  36900. */
  36901. getClassName(): string;
  36902. private _defaultMeshCandidates;
  36903. /**
  36904. * @hidden
  36905. */
  36906. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36907. private _defaultSubMeshCandidates;
  36908. /**
  36909. * @hidden
  36910. */
  36911. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36912. /**
  36913. * Sets the default candidate providers for the scene.
  36914. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36915. * and getCollidingSubMeshCandidates to their default function
  36916. */
  36917. setDefaultCandidateProviders(): void;
  36918. /**
  36919. * Gets the mesh that is currently under the pointer
  36920. */
  36921. get meshUnderPointer(): Nullable<AbstractMesh>;
  36922. /**
  36923. * Gets or sets the current on-screen X position of the pointer
  36924. */
  36925. get pointerX(): number;
  36926. set pointerX(value: number);
  36927. /**
  36928. * Gets or sets the current on-screen Y position of the pointer
  36929. */
  36930. get pointerY(): number;
  36931. set pointerY(value: number);
  36932. /**
  36933. * Gets the cached material (ie. the latest rendered one)
  36934. * @returns the cached material
  36935. */
  36936. getCachedMaterial(): Nullable<Material>;
  36937. /**
  36938. * Gets the cached effect (ie. the latest rendered one)
  36939. * @returns the cached effect
  36940. */
  36941. getCachedEffect(): Nullable<Effect>;
  36942. /**
  36943. * Gets the cached visibility state (ie. the latest rendered one)
  36944. * @returns the cached visibility state
  36945. */
  36946. getCachedVisibility(): Nullable<number>;
  36947. /**
  36948. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36949. * @param material defines the current material
  36950. * @param effect defines the current effect
  36951. * @param visibility defines the current visibility state
  36952. * @returns true if one parameter is not cached
  36953. */
  36954. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36955. /**
  36956. * Gets the engine associated with the scene
  36957. * @returns an Engine
  36958. */
  36959. getEngine(): Engine;
  36960. /**
  36961. * Gets the total number of vertices rendered per frame
  36962. * @returns the total number of vertices rendered per frame
  36963. */
  36964. getTotalVertices(): number;
  36965. /**
  36966. * Gets the performance counter for total vertices
  36967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36968. */
  36969. get totalVerticesPerfCounter(): PerfCounter;
  36970. /**
  36971. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36972. * @returns the total number of active indices rendered per frame
  36973. */
  36974. getActiveIndices(): number;
  36975. /**
  36976. * Gets the performance counter for active indices
  36977. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36978. */
  36979. get totalActiveIndicesPerfCounter(): PerfCounter;
  36980. /**
  36981. * Gets the total number of active particles rendered per frame
  36982. * @returns the total number of active particles rendered per frame
  36983. */
  36984. getActiveParticles(): number;
  36985. /**
  36986. * Gets the performance counter for active particles
  36987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36988. */
  36989. get activeParticlesPerfCounter(): PerfCounter;
  36990. /**
  36991. * Gets the total number of active bones rendered per frame
  36992. * @returns the total number of active bones rendered per frame
  36993. */
  36994. getActiveBones(): number;
  36995. /**
  36996. * Gets the performance counter for active bones
  36997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36998. */
  36999. get activeBonesPerfCounter(): PerfCounter;
  37000. /**
  37001. * Gets the array of active meshes
  37002. * @returns an array of AbstractMesh
  37003. */
  37004. getActiveMeshes(): SmartArray<AbstractMesh>;
  37005. /**
  37006. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37007. * @returns a number
  37008. */
  37009. getAnimationRatio(): number;
  37010. /**
  37011. * Gets an unique Id for the current render phase
  37012. * @returns a number
  37013. */
  37014. getRenderId(): number;
  37015. /**
  37016. * Gets an unique Id for the current frame
  37017. * @returns a number
  37018. */
  37019. getFrameId(): number;
  37020. /** Call this function if you want to manually increment the render Id*/
  37021. incrementRenderId(): void;
  37022. private _createUbo;
  37023. /**
  37024. * Use this method to simulate a pointer move on a mesh
  37025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37028. * @returns the current scene
  37029. */
  37030. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37031. /**
  37032. * Use this method to simulate a pointer down on a mesh
  37033. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37034. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37035. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37036. * @returns the current scene
  37037. */
  37038. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37039. /**
  37040. * Use this method to simulate a pointer up on a mesh
  37041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37044. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37045. * @returns the current scene
  37046. */
  37047. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37048. /**
  37049. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37050. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37051. * @returns true if the pointer was captured
  37052. */
  37053. isPointerCaptured(pointerId?: number): boolean;
  37054. /**
  37055. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37056. * @param attachUp defines if you want to attach events to pointerup
  37057. * @param attachDown defines if you want to attach events to pointerdown
  37058. * @param attachMove defines if you want to attach events to pointermove
  37059. */
  37060. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37061. /** Detaches all event handlers*/
  37062. detachControl(): void;
  37063. /**
  37064. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37065. * Delay loaded resources are not taking in account
  37066. * @return true if all required resources are ready
  37067. */
  37068. isReady(): boolean;
  37069. /** Resets all cached information relative to material (including effect and visibility) */
  37070. resetCachedMaterial(): void;
  37071. /**
  37072. * Registers a function to be called before every frame render
  37073. * @param func defines the function to register
  37074. */
  37075. registerBeforeRender(func: () => void): void;
  37076. /**
  37077. * Unregisters a function called before every frame render
  37078. * @param func defines the function to unregister
  37079. */
  37080. unregisterBeforeRender(func: () => void): void;
  37081. /**
  37082. * Registers a function to be called after every frame render
  37083. * @param func defines the function to register
  37084. */
  37085. registerAfterRender(func: () => void): void;
  37086. /**
  37087. * Unregisters a function called after every frame render
  37088. * @param func defines the function to unregister
  37089. */
  37090. unregisterAfterRender(func: () => void): void;
  37091. private _executeOnceBeforeRender;
  37092. /**
  37093. * The provided function will run before render once and will be disposed afterwards.
  37094. * A timeout delay can be provided so that the function will be executed in N ms.
  37095. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37096. * @param func The function to be executed.
  37097. * @param timeout optional delay in ms
  37098. */
  37099. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37100. /** @hidden */
  37101. _addPendingData(data: any): void;
  37102. /** @hidden */
  37103. _removePendingData(data: any): void;
  37104. /**
  37105. * Returns the number of items waiting to be loaded
  37106. * @returns the number of items waiting to be loaded
  37107. */
  37108. getWaitingItemsCount(): number;
  37109. /**
  37110. * Returns a boolean indicating if the scene is still loading data
  37111. */
  37112. get isLoading(): boolean;
  37113. /**
  37114. * Registers a function to be executed when the scene is ready
  37115. * @param {Function} func - the function to be executed
  37116. */
  37117. executeWhenReady(func: () => void): void;
  37118. /**
  37119. * Returns a promise that resolves when the scene is ready
  37120. * @returns A promise that resolves when the scene is ready
  37121. */
  37122. whenReadyAsync(): Promise<void>;
  37123. /** @hidden */
  37124. _checkIsReady(): void;
  37125. /**
  37126. * Gets all animatable attached to the scene
  37127. */
  37128. get animatables(): Animatable[];
  37129. /**
  37130. * Resets the last animation time frame.
  37131. * Useful to override when animations start running when loading a scene for the first time.
  37132. */
  37133. resetLastAnimationTimeFrame(): void;
  37134. /**
  37135. * Gets the current view matrix
  37136. * @returns a Matrix
  37137. */
  37138. getViewMatrix(): Matrix;
  37139. /**
  37140. * Gets the current projection matrix
  37141. * @returns a Matrix
  37142. */
  37143. getProjectionMatrix(): Matrix;
  37144. /**
  37145. * Gets the current transform matrix
  37146. * @returns a Matrix made of View * Projection
  37147. */
  37148. getTransformMatrix(): Matrix;
  37149. /**
  37150. * Sets the current transform matrix
  37151. * @param viewL defines the View matrix to use
  37152. * @param projectionL defines the Projection matrix to use
  37153. * @param viewR defines the right View matrix to use (if provided)
  37154. * @param projectionR defines the right Projection matrix to use (if provided)
  37155. */
  37156. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37157. /**
  37158. * Gets the uniform buffer used to store scene data
  37159. * @returns a UniformBuffer
  37160. */
  37161. getSceneUniformBuffer(): UniformBuffer;
  37162. /**
  37163. * Gets an unique (relatively to the current scene) Id
  37164. * @returns an unique number for the scene
  37165. */
  37166. getUniqueId(): number;
  37167. /**
  37168. * Add a mesh to the list of scene's meshes
  37169. * @param newMesh defines the mesh to add
  37170. * @param recursive if all child meshes should also be added to the scene
  37171. */
  37172. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37173. /**
  37174. * Remove a mesh for the list of scene's meshes
  37175. * @param toRemove defines the mesh to remove
  37176. * @param recursive if all child meshes should also be removed from the scene
  37177. * @returns the index where the mesh was in the mesh list
  37178. */
  37179. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37180. /**
  37181. * Add a transform node to the list of scene's transform nodes
  37182. * @param newTransformNode defines the transform node to add
  37183. */
  37184. addTransformNode(newTransformNode: TransformNode): void;
  37185. /**
  37186. * Remove a transform node for the list of scene's transform nodes
  37187. * @param toRemove defines the transform node to remove
  37188. * @returns the index where the transform node was in the transform node list
  37189. */
  37190. removeTransformNode(toRemove: TransformNode): number;
  37191. /**
  37192. * Remove a skeleton for the list of scene's skeletons
  37193. * @param toRemove defines the skeleton to remove
  37194. * @returns the index where the skeleton was in the skeleton list
  37195. */
  37196. removeSkeleton(toRemove: Skeleton): number;
  37197. /**
  37198. * Remove a morph target for the list of scene's morph targets
  37199. * @param toRemove defines the morph target to remove
  37200. * @returns the index where the morph target was in the morph target list
  37201. */
  37202. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37203. /**
  37204. * Remove a light for the list of scene's lights
  37205. * @param toRemove defines the light to remove
  37206. * @returns the index where the light was in the light list
  37207. */
  37208. removeLight(toRemove: Light): number;
  37209. /**
  37210. * Remove a camera for the list of scene's cameras
  37211. * @param toRemove defines the camera to remove
  37212. * @returns the index where the camera was in the camera list
  37213. */
  37214. removeCamera(toRemove: Camera): number;
  37215. /**
  37216. * Remove a particle system for the list of scene's particle systems
  37217. * @param toRemove defines the particle system to remove
  37218. * @returns the index where the particle system was in the particle system list
  37219. */
  37220. removeParticleSystem(toRemove: IParticleSystem): number;
  37221. /**
  37222. * Remove a animation for the list of scene's animations
  37223. * @param toRemove defines the animation to remove
  37224. * @returns the index where the animation was in the animation list
  37225. */
  37226. removeAnimation(toRemove: Animation): number;
  37227. /**
  37228. * Will stop the animation of the given target
  37229. * @param target - the target
  37230. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37231. * @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)
  37232. */
  37233. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37234. /**
  37235. * Removes the given animation group from this scene.
  37236. * @param toRemove The animation group to remove
  37237. * @returns The index of the removed animation group
  37238. */
  37239. removeAnimationGroup(toRemove: AnimationGroup): number;
  37240. /**
  37241. * Removes the given multi-material from this scene.
  37242. * @param toRemove The multi-material to remove
  37243. * @returns The index of the removed multi-material
  37244. */
  37245. removeMultiMaterial(toRemove: MultiMaterial): number;
  37246. /**
  37247. * Removes the given material from this scene.
  37248. * @param toRemove The material to remove
  37249. * @returns The index of the removed material
  37250. */
  37251. removeMaterial(toRemove: Material): number;
  37252. /**
  37253. * Removes the given action manager from this scene.
  37254. * @param toRemove The action manager to remove
  37255. * @returns The index of the removed action manager
  37256. */
  37257. removeActionManager(toRemove: AbstractActionManager): number;
  37258. /**
  37259. * Removes the given texture from this scene.
  37260. * @param toRemove The texture to remove
  37261. * @returns The index of the removed texture
  37262. */
  37263. removeTexture(toRemove: BaseTexture): number;
  37264. /**
  37265. * Adds the given light to this scene
  37266. * @param newLight The light to add
  37267. */
  37268. addLight(newLight: Light): void;
  37269. /**
  37270. * Sorts the list list based on light priorities
  37271. */
  37272. sortLightsByPriority(): void;
  37273. /**
  37274. * Adds the given camera to this scene
  37275. * @param newCamera The camera to add
  37276. */
  37277. addCamera(newCamera: Camera): void;
  37278. /**
  37279. * Adds the given skeleton to this scene
  37280. * @param newSkeleton The skeleton to add
  37281. */
  37282. addSkeleton(newSkeleton: Skeleton): void;
  37283. /**
  37284. * Adds the given particle system to this scene
  37285. * @param newParticleSystem The particle system to add
  37286. */
  37287. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37288. /**
  37289. * Adds the given animation to this scene
  37290. * @param newAnimation The animation to add
  37291. */
  37292. addAnimation(newAnimation: Animation): void;
  37293. /**
  37294. * Adds the given animation group to this scene.
  37295. * @param newAnimationGroup The animation group to add
  37296. */
  37297. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37298. /**
  37299. * Adds the given multi-material to this scene
  37300. * @param newMultiMaterial The multi-material to add
  37301. */
  37302. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37303. /**
  37304. * Adds the given material to this scene
  37305. * @param newMaterial The material to add
  37306. */
  37307. addMaterial(newMaterial: Material): void;
  37308. /**
  37309. * Adds the given morph target to this scene
  37310. * @param newMorphTargetManager The morph target to add
  37311. */
  37312. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37313. /**
  37314. * Adds the given geometry to this scene
  37315. * @param newGeometry The geometry to add
  37316. */
  37317. addGeometry(newGeometry: Geometry): void;
  37318. /**
  37319. * Adds the given action manager to this scene
  37320. * @param newActionManager The action manager to add
  37321. */
  37322. addActionManager(newActionManager: AbstractActionManager): void;
  37323. /**
  37324. * Adds the given texture to this scene.
  37325. * @param newTexture The texture to add
  37326. */
  37327. addTexture(newTexture: BaseTexture): void;
  37328. /**
  37329. * Switch active camera
  37330. * @param newCamera defines the new active camera
  37331. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37332. */
  37333. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37334. /**
  37335. * sets the active camera of the scene using its ID
  37336. * @param id defines the camera's ID
  37337. * @return the new active camera or null if none found.
  37338. */
  37339. setActiveCameraByID(id: string): Nullable<Camera>;
  37340. /**
  37341. * sets the active camera of the scene using its name
  37342. * @param name defines the camera's name
  37343. * @returns the new active camera or null if none found.
  37344. */
  37345. setActiveCameraByName(name: string): Nullable<Camera>;
  37346. /**
  37347. * get an animation group using its name
  37348. * @param name defines the material's name
  37349. * @return the animation group or null if none found.
  37350. */
  37351. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37352. /**
  37353. * Get a material using its unique id
  37354. * @param uniqueId defines the material's unique id
  37355. * @return the material or null if none found.
  37356. */
  37357. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37358. /**
  37359. * get a material using its id
  37360. * @param id defines the material's ID
  37361. * @return the material or null if none found.
  37362. */
  37363. getMaterialByID(id: string): Nullable<Material>;
  37364. /**
  37365. * Gets a the last added material using a given id
  37366. * @param id defines the material's ID
  37367. * @return the last material with the given id or null if none found.
  37368. */
  37369. getLastMaterialByID(id: string): Nullable<Material>;
  37370. /**
  37371. * Gets a material using its name
  37372. * @param name defines the material's name
  37373. * @return the material or null if none found.
  37374. */
  37375. getMaterialByName(name: string): Nullable<Material>;
  37376. /**
  37377. * Get a texture using its unique id
  37378. * @param uniqueId defines the texture's unique id
  37379. * @return the texture or null if none found.
  37380. */
  37381. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37382. /**
  37383. * Gets a camera using its id
  37384. * @param id defines the id to look for
  37385. * @returns the camera or null if not found
  37386. */
  37387. getCameraByID(id: string): Nullable<Camera>;
  37388. /**
  37389. * Gets a camera using its unique id
  37390. * @param uniqueId defines the unique id to look for
  37391. * @returns the camera or null if not found
  37392. */
  37393. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37394. /**
  37395. * Gets a camera using its name
  37396. * @param name defines the camera's name
  37397. * @return the camera or null if none found.
  37398. */
  37399. getCameraByName(name: string): Nullable<Camera>;
  37400. /**
  37401. * Gets a bone using its id
  37402. * @param id defines the bone's id
  37403. * @return the bone or null if not found
  37404. */
  37405. getBoneByID(id: string): Nullable<Bone>;
  37406. /**
  37407. * Gets a bone using its id
  37408. * @param name defines the bone's name
  37409. * @return the bone or null if not found
  37410. */
  37411. getBoneByName(name: string): Nullable<Bone>;
  37412. /**
  37413. * Gets a light node using its name
  37414. * @param name defines the the light's name
  37415. * @return the light or null if none found.
  37416. */
  37417. getLightByName(name: string): Nullable<Light>;
  37418. /**
  37419. * Gets a light node using its id
  37420. * @param id defines the light's id
  37421. * @return the light or null if none found.
  37422. */
  37423. getLightByID(id: string): Nullable<Light>;
  37424. /**
  37425. * Gets a light node using its scene-generated unique ID
  37426. * @param uniqueId defines the light's unique id
  37427. * @return the light or null if none found.
  37428. */
  37429. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37430. /**
  37431. * Gets a particle system by id
  37432. * @param id defines the particle system id
  37433. * @return the corresponding system or null if none found
  37434. */
  37435. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37436. /**
  37437. * Gets a geometry using its ID
  37438. * @param id defines the geometry's id
  37439. * @return the geometry or null if none found.
  37440. */
  37441. getGeometryByID(id: string): Nullable<Geometry>;
  37442. private _getGeometryByUniqueID;
  37443. /**
  37444. * Add a new geometry to this scene
  37445. * @param geometry defines the geometry to be added to the scene.
  37446. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37447. * @return a boolean defining if the geometry was added or not
  37448. */
  37449. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37450. /**
  37451. * Removes an existing geometry
  37452. * @param geometry defines the geometry to be removed from the scene
  37453. * @return a boolean defining if the geometry was removed or not
  37454. */
  37455. removeGeometry(geometry: Geometry): boolean;
  37456. /**
  37457. * Gets the list of geometries attached to the scene
  37458. * @returns an array of Geometry
  37459. */
  37460. getGeometries(): Geometry[];
  37461. /**
  37462. * Gets the first added mesh found of a given ID
  37463. * @param id defines the id to search for
  37464. * @return the mesh found or null if not found at all
  37465. */
  37466. getMeshByID(id: string): Nullable<AbstractMesh>;
  37467. /**
  37468. * Gets a list of meshes using their id
  37469. * @param id defines the id to search for
  37470. * @returns a list of meshes
  37471. */
  37472. getMeshesByID(id: string): Array<AbstractMesh>;
  37473. /**
  37474. * Gets the first added transform node found of a given ID
  37475. * @param id defines the id to search for
  37476. * @return the found transform node or null if not found at all.
  37477. */
  37478. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37479. /**
  37480. * Gets a transform node with its auto-generated unique id
  37481. * @param uniqueId efines the unique id to search for
  37482. * @return the found transform node or null if not found at all.
  37483. */
  37484. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37485. /**
  37486. * Gets a list of transform nodes using their id
  37487. * @param id defines the id to search for
  37488. * @returns a list of transform nodes
  37489. */
  37490. getTransformNodesByID(id: string): Array<TransformNode>;
  37491. /**
  37492. * Gets a mesh with its auto-generated unique id
  37493. * @param uniqueId defines the unique id to search for
  37494. * @return the found mesh or null if not found at all.
  37495. */
  37496. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37497. /**
  37498. * Gets a the last added mesh using a given id
  37499. * @param id defines the id to search for
  37500. * @return the found mesh or null if not found at all.
  37501. */
  37502. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37503. /**
  37504. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37505. * @param id defines the id to search for
  37506. * @return the found node or null if not found at all
  37507. */
  37508. getLastEntryByID(id: string): Nullable<Node>;
  37509. /**
  37510. * Gets a node (Mesh, Camera, Light) using a given id
  37511. * @param id defines the id to search for
  37512. * @return the found node or null if not found at all
  37513. */
  37514. getNodeByID(id: string): Nullable<Node>;
  37515. /**
  37516. * Gets a node (Mesh, Camera, Light) using a given name
  37517. * @param name defines the name to search for
  37518. * @return the found node or null if not found at all.
  37519. */
  37520. getNodeByName(name: string): Nullable<Node>;
  37521. /**
  37522. * Gets a mesh using a given name
  37523. * @param name defines the name to search for
  37524. * @return the found mesh or null if not found at all.
  37525. */
  37526. getMeshByName(name: string): Nullable<AbstractMesh>;
  37527. /**
  37528. * Gets a transform node using a given name
  37529. * @param name defines the name to search for
  37530. * @return the found transform node or null if not found at all.
  37531. */
  37532. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37533. /**
  37534. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37535. * @param id defines the id to search for
  37536. * @return the found skeleton or null if not found at all.
  37537. */
  37538. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37539. /**
  37540. * Gets a skeleton using a given auto generated unique id
  37541. * @param uniqueId defines the unique id to search for
  37542. * @return the found skeleton or null if not found at all.
  37543. */
  37544. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37545. /**
  37546. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37547. * @param id defines the id to search for
  37548. * @return the found skeleton or null if not found at all.
  37549. */
  37550. getSkeletonById(id: string): Nullable<Skeleton>;
  37551. /**
  37552. * Gets a skeleton using a given name
  37553. * @param name defines the name to search for
  37554. * @return the found skeleton or null if not found at all.
  37555. */
  37556. getSkeletonByName(name: string): Nullable<Skeleton>;
  37557. /**
  37558. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37559. * @param id defines the id to search for
  37560. * @return the found morph target manager or null if not found at all.
  37561. */
  37562. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37563. /**
  37564. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37565. * @param id defines the id to search for
  37566. * @return the found morph target or null if not found at all.
  37567. */
  37568. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37569. /**
  37570. * Gets a boolean indicating if the given mesh is active
  37571. * @param mesh defines the mesh to look for
  37572. * @returns true if the mesh is in the active list
  37573. */
  37574. isActiveMesh(mesh: AbstractMesh): boolean;
  37575. /**
  37576. * Return a unique id as a string which can serve as an identifier for the scene
  37577. */
  37578. get uid(): string;
  37579. /**
  37580. * Add an externaly attached data from its key.
  37581. * This method call will fail and return false, if such key already exists.
  37582. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37583. * @param key the unique key that identifies the data
  37584. * @param data the data object to associate to the key for this Engine instance
  37585. * @return true if no such key were already present and the data was added successfully, false otherwise
  37586. */
  37587. addExternalData<T>(key: string, data: T): boolean;
  37588. /**
  37589. * Get an externaly attached data from its key
  37590. * @param key the unique key that identifies the data
  37591. * @return the associated data, if present (can be null), or undefined if not present
  37592. */
  37593. getExternalData<T>(key: string): Nullable<T>;
  37594. /**
  37595. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37596. * @param key the unique key that identifies the data
  37597. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37598. * @return the associated data, can be null if the factory returned null.
  37599. */
  37600. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37601. /**
  37602. * Remove an externaly attached data from the Engine instance
  37603. * @param key the unique key that identifies the data
  37604. * @return true if the data was successfully removed, false if it doesn't exist
  37605. */
  37606. removeExternalData(key: string): boolean;
  37607. private _evaluateSubMesh;
  37608. /**
  37609. * Clear the processed materials smart array preventing retention point in material dispose.
  37610. */
  37611. freeProcessedMaterials(): void;
  37612. private _preventFreeActiveMeshesAndRenderingGroups;
  37613. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37614. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37615. * when disposing several meshes in a row or a hierarchy of meshes.
  37616. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37617. */
  37618. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37619. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37620. /**
  37621. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37622. */
  37623. freeActiveMeshes(): void;
  37624. /**
  37625. * Clear the info related to rendering groups preventing retention points during dispose.
  37626. */
  37627. freeRenderingGroups(): void;
  37628. /** @hidden */
  37629. _isInIntermediateRendering(): boolean;
  37630. /**
  37631. * Lambda returning the list of potentially active meshes.
  37632. */
  37633. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37634. /**
  37635. * Lambda returning the list of potentially active sub meshes.
  37636. */
  37637. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37638. /**
  37639. * Lambda returning the list of potentially intersecting sub meshes.
  37640. */
  37641. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37642. /**
  37643. * Lambda returning the list of potentially colliding sub meshes.
  37644. */
  37645. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37646. private _activeMeshesFrozen;
  37647. private _skipEvaluateActiveMeshesCompletely;
  37648. /**
  37649. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37650. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37651. * @returns the current scene
  37652. */
  37653. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37654. /**
  37655. * Use this function to restart evaluating active meshes on every frame
  37656. * @returns the current scene
  37657. */
  37658. unfreezeActiveMeshes(): Scene;
  37659. private _evaluateActiveMeshes;
  37660. private _activeMesh;
  37661. /**
  37662. * Update the transform matrix to update from the current active camera
  37663. * @param force defines a boolean used to force the update even if cache is up to date
  37664. */
  37665. updateTransformMatrix(force?: boolean): void;
  37666. private _bindFrameBuffer;
  37667. /** @hidden */
  37668. _allowPostProcessClearColor: boolean;
  37669. /** @hidden */
  37670. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37671. private _processSubCameras;
  37672. private _checkIntersections;
  37673. /** @hidden */
  37674. _advancePhysicsEngineStep(step: number): void;
  37675. /**
  37676. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37677. */
  37678. getDeterministicFrameTime: () => number;
  37679. /** @hidden */
  37680. _animate(): void;
  37681. /** Execute all animations (for a frame) */
  37682. animate(): void;
  37683. /**
  37684. * Render the scene
  37685. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37686. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37687. */
  37688. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37689. /**
  37690. * Freeze all materials
  37691. * A frozen material will not be updatable but should be faster to render
  37692. */
  37693. freezeMaterials(): void;
  37694. /**
  37695. * Unfreeze all materials
  37696. * A frozen material will not be updatable but should be faster to render
  37697. */
  37698. unfreezeMaterials(): void;
  37699. /**
  37700. * Releases all held ressources
  37701. */
  37702. dispose(): void;
  37703. /**
  37704. * Gets if the scene is already disposed
  37705. */
  37706. get isDisposed(): boolean;
  37707. /**
  37708. * Call this function to reduce memory footprint of the scene.
  37709. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37710. */
  37711. clearCachedVertexData(): void;
  37712. /**
  37713. * This function will remove the local cached buffer data from texture.
  37714. * It will save memory but will prevent the texture from being rebuilt
  37715. */
  37716. cleanCachedTextureBuffer(): void;
  37717. /**
  37718. * Get the world extend vectors with an optional filter
  37719. *
  37720. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37721. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37722. */
  37723. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37724. min: Vector3;
  37725. max: Vector3;
  37726. };
  37727. /**
  37728. * Creates a ray that can be used to pick in the scene
  37729. * @param x defines the x coordinate of the origin (on-screen)
  37730. * @param y defines the y coordinate of the origin (on-screen)
  37731. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37732. * @param camera defines the camera to use for the picking
  37733. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37734. * @returns a Ray
  37735. */
  37736. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37737. /**
  37738. * Creates a ray that can be used to pick in the scene
  37739. * @param x defines the x coordinate of the origin (on-screen)
  37740. * @param y defines the y coordinate of the origin (on-screen)
  37741. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37742. * @param result defines the ray where to store the picking ray
  37743. * @param camera defines the camera to use for the picking
  37744. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37745. * @returns the current scene
  37746. */
  37747. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37748. /**
  37749. * Creates a ray that can be used to pick in the scene
  37750. * @param x defines the x coordinate of the origin (on-screen)
  37751. * @param y defines the y coordinate of the origin (on-screen)
  37752. * @param camera defines the camera to use for the picking
  37753. * @returns a Ray
  37754. */
  37755. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37756. /**
  37757. * Creates a ray that can be used to pick in the scene
  37758. * @param x defines the x coordinate of the origin (on-screen)
  37759. * @param y defines the y coordinate of the origin (on-screen)
  37760. * @param result defines the ray where to store the picking ray
  37761. * @param camera defines the camera to use for the picking
  37762. * @returns the current scene
  37763. */
  37764. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37765. /** Launch a ray to try to pick a mesh in the scene
  37766. * @param x position on screen
  37767. * @param y position on screen
  37768. * @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
  37769. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37770. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37771. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37772. * @returns a PickingInfo
  37773. */
  37774. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37775. /** Use the given ray to pick a mesh in the scene
  37776. * @param ray The ray to use to pick meshes
  37777. * @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
  37778. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37779. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37780. * @returns a PickingInfo
  37781. */
  37782. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37783. /**
  37784. * Launch a ray to try to pick a mesh in the scene
  37785. * @param x X position on screen
  37786. * @param y Y position on screen
  37787. * @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
  37788. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37790. * @returns an array of PickingInfo
  37791. */
  37792. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37793. /**
  37794. * Launch a ray to try to pick a mesh in the scene
  37795. * @param ray Ray to use
  37796. * @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
  37797. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37798. * @returns an array of PickingInfo
  37799. */
  37800. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37801. /**
  37802. * Force the value of meshUnderPointer
  37803. * @param mesh defines the mesh to use
  37804. */
  37805. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37806. /**
  37807. * Gets the mesh under the pointer
  37808. * @returns a Mesh or null if no mesh is under the pointer
  37809. */
  37810. getPointerOverMesh(): Nullable<AbstractMesh>;
  37811. /** @hidden */
  37812. _rebuildGeometries(): void;
  37813. /** @hidden */
  37814. _rebuildTextures(): void;
  37815. private _getByTags;
  37816. /**
  37817. * Get a list of meshes by tags
  37818. * @param tagsQuery defines the tags query to use
  37819. * @param forEach defines a predicate used to filter results
  37820. * @returns an array of Mesh
  37821. */
  37822. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37823. /**
  37824. * Get a list of cameras by tags
  37825. * @param tagsQuery defines the tags query to use
  37826. * @param forEach defines a predicate used to filter results
  37827. * @returns an array of Camera
  37828. */
  37829. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37830. /**
  37831. * Get a list of lights by tags
  37832. * @param tagsQuery defines the tags query to use
  37833. * @param forEach defines a predicate used to filter results
  37834. * @returns an array of Light
  37835. */
  37836. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37837. /**
  37838. * Get a list of materials by tags
  37839. * @param tagsQuery defines the tags query to use
  37840. * @param forEach defines a predicate used to filter results
  37841. * @returns an array of Material
  37842. */
  37843. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37844. /**
  37845. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37846. * This allowed control for front to back rendering or reversly depending of the special needs.
  37847. *
  37848. * @param renderingGroupId The rendering group id corresponding to its index
  37849. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37850. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37851. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37852. */
  37853. 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;
  37854. /**
  37855. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37856. *
  37857. * @param renderingGroupId The rendering group id corresponding to its index
  37858. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37859. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37860. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37861. */
  37862. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37863. /**
  37864. * Gets the current auto clear configuration for one rendering group of the rendering
  37865. * manager.
  37866. * @param index the rendering group index to get the information for
  37867. * @returns The auto clear setup for the requested rendering group
  37868. */
  37869. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37870. private _blockMaterialDirtyMechanism;
  37871. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37872. get blockMaterialDirtyMechanism(): boolean;
  37873. set blockMaterialDirtyMechanism(value: boolean);
  37874. /**
  37875. * Will flag all materials as dirty to trigger new shader compilation
  37876. * @param flag defines the flag used to specify which material part must be marked as dirty
  37877. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37878. */
  37879. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37880. /** @hidden */
  37881. _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;
  37882. /** @hidden */
  37883. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37884. /** @hidden */
  37885. _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;
  37886. /** @hidden */
  37887. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37888. /** @hidden */
  37889. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37890. /** @hidden */
  37891. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37892. }
  37893. }
  37894. declare module "babylonjs/assetContainer" {
  37895. import { AbstractScene } from "babylonjs/abstractScene";
  37896. import { Scene } from "babylonjs/scene";
  37897. import { Mesh } from "babylonjs/Meshes/mesh";
  37898. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37899. import { Skeleton } from "babylonjs/Bones/skeleton";
  37900. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37901. import { Animatable } from "babylonjs/Animations/animatable";
  37902. import { Nullable } from "babylonjs/types";
  37903. import { Node } from "babylonjs/node";
  37904. /**
  37905. * Set of assets to keep when moving a scene into an asset container.
  37906. */
  37907. export class KeepAssets extends AbstractScene {
  37908. }
  37909. /**
  37910. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37911. */
  37912. export class InstantiatedEntries {
  37913. /**
  37914. * List of new root nodes (eg. nodes with no parent)
  37915. */
  37916. rootNodes: TransformNode[];
  37917. /**
  37918. * List of new skeletons
  37919. */
  37920. skeletons: Skeleton[];
  37921. /**
  37922. * List of new animation groups
  37923. */
  37924. animationGroups: AnimationGroup[];
  37925. }
  37926. /**
  37927. * Container with a set of assets that can be added or removed from a scene.
  37928. */
  37929. export class AssetContainer extends AbstractScene {
  37930. /**
  37931. * The scene the AssetContainer belongs to.
  37932. */
  37933. scene: Scene;
  37934. /**
  37935. * Instantiates an AssetContainer.
  37936. * @param scene The scene the AssetContainer belongs to.
  37937. */
  37938. constructor(scene: Scene);
  37939. /**
  37940. * Instantiate or clone all meshes and add the new ones to the scene.
  37941. * Skeletons and animation groups will all be cloned
  37942. * @param nameFunction defines an optional function used to get new names for clones
  37943. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37944. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37945. */
  37946. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37947. /**
  37948. * Adds all the assets from the container to the scene.
  37949. */
  37950. addAllToScene(): void;
  37951. /**
  37952. * Removes all the assets in the container from the scene
  37953. */
  37954. removeAllFromScene(): void;
  37955. /**
  37956. * Disposes all the assets in the container
  37957. */
  37958. dispose(): void;
  37959. private _moveAssets;
  37960. /**
  37961. * Removes all the assets contained in the scene and adds them to the container.
  37962. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37963. */
  37964. moveAllFromScene(keepAssets?: KeepAssets): void;
  37965. /**
  37966. * 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.
  37967. * @returns the root mesh
  37968. */
  37969. createRootMesh(): Mesh;
  37970. /**
  37971. * Merge animations from this asset container into a scene
  37972. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37973. * @param animatables set of animatables to retarget to a node from the scene
  37974. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37975. */
  37976. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37977. }
  37978. }
  37979. declare module "babylonjs/abstractScene" {
  37980. import { Scene } from "babylonjs/scene";
  37981. import { Nullable } from "babylonjs/types";
  37982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37983. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37984. import { Geometry } from "babylonjs/Meshes/geometry";
  37985. import { Skeleton } from "babylonjs/Bones/skeleton";
  37986. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37987. import { AssetContainer } from "babylonjs/assetContainer";
  37988. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37989. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37991. import { Material } from "babylonjs/Materials/material";
  37992. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37993. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37994. import { Camera } from "babylonjs/Cameras/camera";
  37995. import { Light } from "babylonjs/Lights/light";
  37996. import { Node } from "babylonjs/node";
  37997. import { Animation } from "babylonjs/Animations/animation";
  37998. /**
  37999. * Defines how the parser contract is defined.
  38000. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38001. */
  38002. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38003. /**
  38004. * Defines how the individual parser contract is defined.
  38005. * These parser can parse an individual asset
  38006. */
  38007. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38008. /**
  38009. * Base class of the scene acting as a container for the different elements composing a scene.
  38010. * This class is dynamically extended by the different components of the scene increasing
  38011. * flexibility and reducing coupling
  38012. */
  38013. export abstract class AbstractScene {
  38014. /**
  38015. * Stores the list of available parsers in the application.
  38016. */
  38017. private static _BabylonFileParsers;
  38018. /**
  38019. * Stores the list of available individual parsers in the application.
  38020. */
  38021. private static _IndividualBabylonFileParsers;
  38022. /**
  38023. * Adds a parser in the list of available ones
  38024. * @param name Defines the name of the parser
  38025. * @param parser Defines the parser to add
  38026. */
  38027. static AddParser(name: string, parser: BabylonFileParser): void;
  38028. /**
  38029. * Gets a general parser from the list of avaialble ones
  38030. * @param name Defines the name of the parser
  38031. * @returns the requested parser or null
  38032. */
  38033. static GetParser(name: string): Nullable<BabylonFileParser>;
  38034. /**
  38035. * Adds n individual parser in the list of available ones
  38036. * @param name Defines the name of the parser
  38037. * @param parser Defines the parser to add
  38038. */
  38039. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38040. /**
  38041. * Gets an individual parser from the list of avaialble ones
  38042. * @param name Defines the name of the parser
  38043. * @returns the requested parser or null
  38044. */
  38045. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38046. /**
  38047. * Parser json data and populate both a scene and its associated container object
  38048. * @param jsonData Defines the data to parse
  38049. * @param scene Defines the scene to parse the data for
  38050. * @param container Defines the container attached to the parsing sequence
  38051. * @param rootUrl Defines the root url of the data
  38052. */
  38053. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38054. /**
  38055. * Gets the list of root nodes (ie. nodes with no parent)
  38056. */
  38057. rootNodes: Node[];
  38058. /** All of the cameras added to this scene
  38059. * @see http://doc.babylonjs.com/babylon101/cameras
  38060. */
  38061. cameras: Camera[];
  38062. /**
  38063. * All of the lights added to this scene
  38064. * @see http://doc.babylonjs.com/babylon101/lights
  38065. */
  38066. lights: Light[];
  38067. /**
  38068. * All of the (abstract) meshes added to this scene
  38069. */
  38070. meshes: AbstractMesh[];
  38071. /**
  38072. * The list of skeletons added to the scene
  38073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38074. */
  38075. skeletons: Skeleton[];
  38076. /**
  38077. * All of the particle systems added to this scene
  38078. * @see http://doc.babylonjs.com/babylon101/particles
  38079. */
  38080. particleSystems: IParticleSystem[];
  38081. /**
  38082. * Gets a list of Animations associated with the scene
  38083. */
  38084. animations: Animation[];
  38085. /**
  38086. * All of the animation groups added to this scene
  38087. * @see http://doc.babylonjs.com/how_to/group
  38088. */
  38089. animationGroups: AnimationGroup[];
  38090. /**
  38091. * All of the multi-materials added to this scene
  38092. * @see http://doc.babylonjs.com/how_to/multi_materials
  38093. */
  38094. multiMaterials: MultiMaterial[];
  38095. /**
  38096. * All of the materials added to this scene
  38097. * In the context of a Scene, it is not supposed to be modified manually.
  38098. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38099. * Note also that the order of the Material within the array is not significant and might change.
  38100. * @see http://doc.babylonjs.com/babylon101/materials
  38101. */
  38102. materials: Material[];
  38103. /**
  38104. * The list of morph target managers added to the scene
  38105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38106. */
  38107. morphTargetManagers: MorphTargetManager[];
  38108. /**
  38109. * The list of geometries used in the scene.
  38110. */
  38111. geometries: Geometry[];
  38112. /**
  38113. * All of the tranform nodes added to this scene
  38114. * In the context of a Scene, it is not supposed to be modified manually.
  38115. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38116. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38117. * @see http://doc.babylonjs.com/how_to/transformnode
  38118. */
  38119. transformNodes: TransformNode[];
  38120. /**
  38121. * ActionManagers available on the scene.
  38122. */
  38123. actionManagers: AbstractActionManager[];
  38124. /**
  38125. * Textures to keep.
  38126. */
  38127. textures: BaseTexture[];
  38128. /**
  38129. * Environment texture for the scene
  38130. */
  38131. environmentTexture: Nullable<BaseTexture>;
  38132. /**
  38133. * @returns all meshes, lights, cameras, transformNodes and bones
  38134. */
  38135. getNodes(): Array<Node>;
  38136. }
  38137. }
  38138. declare module "babylonjs/Audio/sound" {
  38139. import { Observable } from "babylonjs/Misc/observable";
  38140. import { Vector3 } from "babylonjs/Maths/math.vector";
  38141. import { Nullable } from "babylonjs/types";
  38142. import { Scene } from "babylonjs/scene";
  38143. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38144. /**
  38145. * Interface used to define options for Sound class
  38146. */
  38147. export interface ISoundOptions {
  38148. /**
  38149. * Does the sound autoplay once loaded.
  38150. */
  38151. autoplay?: boolean;
  38152. /**
  38153. * Does the sound loop after it finishes playing once.
  38154. */
  38155. loop?: boolean;
  38156. /**
  38157. * Sound's volume
  38158. */
  38159. volume?: number;
  38160. /**
  38161. * Is it a spatial sound?
  38162. */
  38163. spatialSound?: boolean;
  38164. /**
  38165. * Maximum distance to hear that sound
  38166. */
  38167. maxDistance?: number;
  38168. /**
  38169. * Uses user defined attenuation function
  38170. */
  38171. useCustomAttenuation?: boolean;
  38172. /**
  38173. * Define the roll off factor of spatial sounds.
  38174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38175. */
  38176. rolloffFactor?: number;
  38177. /**
  38178. * Define the reference distance the sound should be heard perfectly.
  38179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38180. */
  38181. refDistance?: number;
  38182. /**
  38183. * Define the distance attenuation model the sound will follow.
  38184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38185. */
  38186. distanceModel?: string;
  38187. /**
  38188. * Defines the playback speed (1 by default)
  38189. */
  38190. playbackRate?: number;
  38191. /**
  38192. * Defines if the sound is from a streaming source
  38193. */
  38194. streaming?: boolean;
  38195. /**
  38196. * Defines an optional length (in seconds) inside the sound file
  38197. */
  38198. length?: number;
  38199. /**
  38200. * Defines an optional offset (in seconds) inside the sound file
  38201. */
  38202. offset?: number;
  38203. /**
  38204. * If true, URLs will not be required to state the audio file codec to use.
  38205. */
  38206. skipCodecCheck?: boolean;
  38207. }
  38208. /**
  38209. * Defines a sound that can be played in the application.
  38210. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38212. */
  38213. export class Sound {
  38214. /**
  38215. * The name of the sound in the scene.
  38216. */
  38217. name: string;
  38218. /**
  38219. * Does the sound autoplay once loaded.
  38220. */
  38221. autoplay: boolean;
  38222. /**
  38223. * Does the sound loop after it finishes playing once.
  38224. */
  38225. loop: boolean;
  38226. /**
  38227. * Does the sound use a custom attenuation curve to simulate the falloff
  38228. * happening when the source gets further away from the camera.
  38229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38230. */
  38231. useCustomAttenuation: boolean;
  38232. /**
  38233. * The sound track id this sound belongs to.
  38234. */
  38235. soundTrackId: number;
  38236. /**
  38237. * Is this sound currently played.
  38238. */
  38239. isPlaying: boolean;
  38240. /**
  38241. * Is this sound currently paused.
  38242. */
  38243. isPaused: boolean;
  38244. /**
  38245. * Does this sound enables spatial sound.
  38246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38247. */
  38248. spatialSound: boolean;
  38249. /**
  38250. * Define the reference distance the sound should be heard perfectly.
  38251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38252. */
  38253. refDistance: number;
  38254. /**
  38255. * Define the roll off factor of spatial sounds.
  38256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38257. */
  38258. rolloffFactor: number;
  38259. /**
  38260. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38262. */
  38263. maxDistance: number;
  38264. /**
  38265. * Define the distance attenuation model the sound will follow.
  38266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38267. */
  38268. distanceModel: string;
  38269. /**
  38270. * @hidden
  38271. * Back Compat
  38272. **/
  38273. onended: () => any;
  38274. /**
  38275. * Observable event when the current playing sound finishes.
  38276. */
  38277. onEndedObservable: Observable<Sound>;
  38278. private _panningModel;
  38279. private _playbackRate;
  38280. private _streaming;
  38281. private _startTime;
  38282. private _startOffset;
  38283. private _position;
  38284. /** @hidden */
  38285. _positionInEmitterSpace: boolean;
  38286. private _localDirection;
  38287. private _volume;
  38288. private _isReadyToPlay;
  38289. private _isDirectional;
  38290. private _readyToPlayCallback;
  38291. private _audioBuffer;
  38292. private _soundSource;
  38293. private _streamingSource;
  38294. private _soundPanner;
  38295. private _soundGain;
  38296. private _inputAudioNode;
  38297. private _outputAudioNode;
  38298. private _coneInnerAngle;
  38299. private _coneOuterAngle;
  38300. private _coneOuterGain;
  38301. private _scene;
  38302. private _connectedTransformNode;
  38303. private _customAttenuationFunction;
  38304. private _registerFunc;
  38305. private _isOutputConnected;
  38306. private _htmlAudioElement;
  38307. private _urlType;
  38308. private _length?;
  38309. private _offset?;
  38310. /** @hidden */
  38311. static _SceneComponentInitialization: (scene: Scene) => void;
  38312. /**
  38313. * Create a sound and attach it to a scene
  38314. * @param name Name of your sound
  38315. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38316. * @param scene defines the scene the sound belongs to
  38317. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38318. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38319. */
  38320. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38321. /**
  38322. * Release the sound and its associated resources
  38323. */
  38324. dispose(): void;
  38325. /**
  38326. * Gets if the sounds is ready to be played or not.
  38327. * @returns true if ready, otherwise false
  38328. */
  38329. isReady(): boolean;
  38330. private _soundLoaded;
  38331. /**
  38332. * Sets the data of the sound from an audiobuffer
  38333. * @param audioBuffer The audioBuffer containing the data
  38334. */
  38335. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38336. /**
  38337. * Updates the current sounds options such as maxdistance, loop...
  38338. * @param options A JSON object containing values named as the object properties
  38339. */
  38340. updateOptions(options: ISoundOptions): void;
  38341. private _createSpatialParameters;
  38342. private _updateSpatialParameters;
  38343. /**
  38344. * Switch the panning model to HRTF:
  38345. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38347. */
  38348. switchPanningModelToHRTF(): void;
  38349. /**
  38350. * Switch the panning model to Equal Power:
  38351. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38353. */
  38354. switchPanningModelToEqualPower(): void;
  38355. private _switchPanningModel;
  38356. /**
  38357. * Connect this sound to a sound track audio node like gain...
  38358. * @param soundTrackAudioNode the sound track audio node to connect to
  38359. */
  38360. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38361. /**
  38362. * Transform this sound into a directional source
  38363. * @param coneInnerAngle Size of the inner cone in degree
  38364. * @param coneOuterAngle Size of the outer cone in degree
  38365. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38366. */
  38367. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38368. /**
  38369. * Gets or sets the inner angle for the directional cone.
  38370. */
  38371. get directionalConeInnerAngle(): number;
  38372. /**
  38373. * Gets or sets the inner angle for the directional cone.
  38374. */
  38375. set directionalConeInnerAngle(value: number);
  38376. /**
  38377. * Gets or sets the outer angle for the directional cone.
  38378. */
  38379. get directionalConeOuterAngle(): number;
  38380. /**
  38381. * Gets or sets the outer angle for the directional cone.
  38382. */
  38383. set directionalConeOuterAngle(value: number);
  38384. /**
  38385. * Sets the position of the emitter if spatial sound is enabled
  38386. * @param newPosition Defines the new posisiton
  38387. */
  38388. setPosition(newPosition: Vector3): void;
  38389. /**
  38390. * Sets the local direction of the emitter if spatial sound is enabled
  38391. * @param newLocalDirection Defines the new local direction
  38392. */
  38393. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38394. private _updateDirection;
  38395. /** @hidden */
  38396. updateDistanceFromListener(): void;
  38397. /**
  38398. * Sets a new custom attenuation function for the sound.
  38399. * @param callback Defines the function used for the attenuation
  38400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38401. */
  38402. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38403. /**
  38404. * Play the sound
  38405. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38406. * @param offset (optional) Start the sound at a specific time in seconds
  38407. * @param length (optional) Sound duration (in seconds)
  38408. */
  38409. play(time?: number, offset?: number, length?: number): void;
  38410. private _onended;
  38411. /**
  38412. * Stop the sound
  38413. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38414. */
  38415. stop(time?: number): void;
  38416. /**
  38417. * Put the sound in pause
  38418. */
  38419. pause(): void;
  38420. /**
  38421. * Sets a dedicated volume for this sounds
  38422. * @param newVolume Define the new volume of the sound
  38423. * @param time Define time for gradual change to new volume
  38424. */
  38425. setVolume(newVolume: number, time?: number): void;
  38426. /**
  38427. * Set the sound play back rate
  38428. * @param newPlaybackRate Define the playback rate the sound should be played at
  38429. */
  38430. setPlaybackRate(newPlaybackRate: number): void;
  38431. /**
  38432. * Gets the volume of the sound.
  38433. * @returns the volume of the sound
  38434. */
  38435. getVolume(): number;
  38436. /**
  38437. * Attach the sound to a dedicated mesh
  38438. * @param transformNode The transform node to connect the sound with
  38439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38440. */
  38441. attachToMesh(transformNode: TransformNode): void;
  38442. /**
  38443. * Detach the sound from the previously attached mesh
  38444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38445. */
  38446. detachFromMesh(): void;
  38447. private _onRegisterAfterWorldMatrixUpdate;
  38448. /**
  38449. * Clone the current sound in the scene.
  38450. * @returns the new sound clone
  38451. */
  38452. clone(): Nullable<Sound>;
  38453. /**
  38454. * Gets the current underlying audio buffer containing the data
  38455. * @returns the audio buffer
  38456. */
  38457. getAudioBuffer(): Nullable<AudioBuffer>;
  38458. /**
  38459. * Serializes the Sound in a JSON representation
  38460. * @returns the JSON representation of the sound
  38461. */
  38462. serialize(): any;
  38463. /**
  38464. * Parse a JSON representation of a sound to innstantiate in a given scene
  38465. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38466. * @param scene Define the scene the new parsed sound should be created in
  38467. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38468. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38469. * @returns the newly parsed sound
  38470. */
  38471. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38472. }
  38473. }
  38474. declare module "babylonjs/Actions/directAudioActions" {
  38475. import { Action } from "babylonjs/Actions/action";
  38476. import { Condition } from "babylonjs/Actions/condition";
  38477. import { Sound } from "babylonjs/Audio/sound";
  38478. /**
  38479. * This defines an action helpful to play a defined sound on a triggered action.
  38480. */
  38481. export class PlaySoundAction extends Action {
  38482. private _sound;
  38483. /**
  38484. * Instantiate the action
  38485. * @param triggerOptions defines the trigger options
  38486. * @param sound defines the sound to play
  38487. * @param condition defines the trigger related conditions
  38488. */
  38489. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38490. /** @hidden */
  38491. _prepare(): void;
  38492. /**
  38493. * Execute the action and play the sound.
  38494. */
  38495. execute(): void;
  38496. /**
  38497. * Serializes the actions and its related information.
  38498. * @param parent defines the object to serialize in
  38499. * @returns the serialized object
  38500. */
  38501. serialize(parent: any): any;
  38502. }
  38503. /**
  38504. * This defines an action helpful to stop a defined sound on a triggered action.
  38505. */
  38506. export class StopSoundAction extends Action {
  38507. private _sound;
  38508. /**
  38509. * Instantiate the action
  38510. * @param triggerOptions defines the trigger options
  38511. * @param sound defines the sound to stop
  38512. * @param condition defines the trigger related conditions
  38513. */
  38514. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38515. /** @hidden */
  38516. _prepare(): void;
  38517. /**
  38518. * Execute the action and stop the sound.
  38519. */
  38520. execute(): void;
  38521. /**
  38522. * Serializes the actions and its related information.
  38523. * @param parent defines the object to serialize in
  38524. * @returns the serialized object
  38525. */
  38526. serialize(parent: any): any;
  38527. }
  38528. }
  38529. declare module "babylonjs/Actions/interpolateValueAction" {
  38530. import { Action } from "babylonjs/Actions/action";
  38531. import { Condition } from "babylonjs/Actions/condition";
  38532. import { Observable } from "babylonjs/Misc/observable";
  38533. /**
  38534. * This defines an action responsible to change the value of a property
  38535. * by interpolating between its current value and the newly set one once triggered.
  38536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38537. */
  38538. export class InterpolateValueAction extends Action {
  38539. /**
  38540. * Defines the path of the property where the value should be interpolated
  38541. */
  38542. propertyPath: string;
  38543. /**
  38544. * Defines the target value at the end of the interpolation.
  38545. */
  38546. value: any;
  38547. /**
  38548. * Defines the time it will take for the property to interpolate to the value.
  38549. */
  38550. duration: number;
  38551. /**
  38552. * Defines if the other scene animations should be stopped when the action has been triggered
  38553. */
  38554. stopOtherAnimations?: boolean;
  38555. /**
  38556. * Defines a callback raised once the interpolation animation has been done.
  38557. */
  38558. onInterpolationDone?: () => void;
  38559. /**
  38560. * Observable triggered once the interpolation animation has been done.
  38561. */
  38562. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38563. private _target;
  38564. private _effectiveTarget;
  38565. private _property;
  38566. /**
  38567. * Instantiate the action
  38568. * @param triggerOptions defines the trigger options
  38569. * @param target defines the object containing the value to interpolate
  38570. * @param propertyPath defines the path to the property in the target object
  38571. * @param value defines the target value at the end of the interpolation
  38572. * @param duration deines the time it will take for the property to interpolate to the value.
  38573. * @param condition defines the trigger related conditions
  38574. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38575. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38576. */
  38577. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38578. /** @hidden */
  38579. _prepare(): void;
  38580. /**
  38581. * Execute the action starts the value interpolation.
  38582. */
  38583. execute(): void;
  38584. /**
  38585. * Serializes the actions and its related information.
  38586. * @param parent defines the object to serialize in
  38587. * @returns the serialized object
  38588. */
  38589. serialize(parent: any): any;
  38590. }
  38591. }
  38592. declare module "babylonjs/Actions/index" {
  38593. export * from "babylonjs/Actions/abstractActionManager";
  38594. export * from "babylonjs/Actions/action";
  38595. export * from "babylonjs/Actions/actionEvent";
  38596. export * from "babylonjs/Actions/actionManager";
  38597. export * from "babylonjs/Actions/condition";
  38598. export * from "babylonjs/Actions/directActions";
  38599. export * from "babylonjs/Actions/directAudioActions";
  38600. export * from "babylonjs/Actions/interpolateValueAction";
  38601. }
  38602. declare module "babylonjs/Animations/index" {
  38603. export * from "babylonjs/Animations/animatable";
  38604. export * from "babylonjs/Animations/animation";
  38605. export * from "babylonjs/Animations/animationGroup";
  38606. export * from "babylonjs/Animations/animationPropertiesOverride";
  38607. export * from "babylonjs/Animations/easing";
  38608. export * from "babylonjs/Animations/runtimeAnimation";
  38609. export * from "babylonjs/Animations/animationEvent";
  38610. export * from "babylonjs/Animations/animationGroup";
  38611. export * from "babylonjs/Animations/animationKey";
  38612. export * from "babylonjs/Animations/animationRange";
  38613. export * from "babylonjs/Animations/animatable.interface";
  38614. }
  38615. declare module "babylonjs/Audio/soundTrack" {
  38616. import { Sound } from "babylonjs/Audio/sound";
  38617. import { Analyser } from "babylonjs/Audio/analyser";
  38618. import { Scene } from "babylonjs/scene";
  38619. /**
  38620. * Options allowed during the creation of a sound track.
  38621. */
  38622. export interface ISoundTrackOptions {
  38623. /**
  38624. * The volume the sound track should take during creation
  38625. */
  38626. volume?: number;
  38627. /**
  38628. * Define if the sound track is the main sound track of the scene
  38629. */
  38630. mainTrack?: boolean;
  38631. }
  38632. /**
  38633. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38634. * It will be also used in a future release to apply effects on a specific track.
  38635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38636. */
  38637. export class SoundTrack {
  38638. /**
  38639. * The unique identifier of the sound track in the scene.
  38640. */
  38641. id: number;
  38642. /**
  38643. * The list of sounds included in the sound track.
  38644. */
  38645. soundCollection: Array<Sound>;
  38646. private _outputAudioNode;
  38647. private _scene;
  38648. private _connectedAnalyser;
  38649. private _options;
  38650. private _isInitialized;
  38651. /**
  38652. * Creates a new sound track.
  38653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38654. * @param scene Define the scene the sound track belongs to
  38655. * @param options
  38656. */
  38657. constructor(scene: Scene, options?: ISoundTrackOptions);
  38658. private _initializeSoundTrackAudioGraph;
  38659. /**
  38660. * Release the sound track and its associated resources
  38661. */
  38662. dispose(): void;
  38663. /**
  38664. * Adds a sound to this sound track
  38665. * @param sound define the cound to add
  38666. * @ignoreNaming
  38667. */
  38668. AddSound(sound: Sound): void;
  38669. /**
  38670. * Removes a sound to this sound track
  38671. * @param sound define the cound to remove
  38672. * @ignoreNaming
  38673. */
  38674. RemoveSound(sound: Sound): void;
  38675. /**
  38676. * Set a global volume for the full sound track.
  38677. * @param newVolume Define the new volume of the sound track
  38678. */
  38679. setVolume(newVolume: number): void;
  38680. /**
  38681. * Switch the panning model to HRTF:
  38682. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38684. */
  38685. switchPanningModelToHRTF(): void;
  38686. /**
  38687. * Switch the panning model to Equal Power:
  38688. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38690. */
  38691. switchPanningModelToEqualPower(): void;
  38692. /**
  38693. * Connect the sound track to an audio analyser allowing some amazing
  38694. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38696. * @param analyser The analyser to connect to the engine
  38697. */
  38698. connectToAnalyser(analyser: Analyser): void;
  38699. }
  38700. }
  38701. declare module "babylonjs/Audio/audioSceneComponent" {
  38702. import { Sound } from "babylonjs/Audio/sound";
  38703. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38704. import { Nullable } from "babylonjs/types";
  38705. import { Vector3 } from "babylonjs/Maths/math.vector";
  38706. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38707. import { Scene } from "babylonjs/scene";
  38708. import { AbstractScene } from "babylonjs/abstractScene";
  38709. import "babylonjs/Audio/audioEngine";
  38710. module "babylonjs/abstractScene" {
  38711. interface AbstractScene {
  38712. /**
  38713. * The list of sounds used in the scene.
  38714. */
  38715. sounds: Nullable<Array<Sound>>;
  38716. }
  38717. }
  38718. module "babylonjs/scene" {
  38719. interface Scene {
  38720. /**
  38721. * @hidden
  38722. * Backing field
  38723. */
  38724. _mainSoundTrack: SoundTrack;
  38725. /**
  38726. * The main sound track played by the scene.
  38727. * It cotains your primary collection of sounds.
  38728. */
  38729. mainSoundTrack: SoundTrack;
  38730. /**
  38731. * The list of sound tracks added to the scene
  38732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38733. */
  38734. soundTracks: Nullable<Array<SoundTrack>>;
  38735. /**
  38736. * Gets a sound using a given name
  38737. * @param name defines the name to search for
  38738. * @return the found sound or null if not found at all.
  38739. */
  38740. getSoundByName(name: string): Nullable<Sound>;
  38741. /**
  38742. * Gets or sets if audio support is enabled
  38743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38744. */
  38745. audioEnabled: boolean;
  38746. /**
  38747. * Gets or sets if audio will be output to headphones
  38748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38749. */
  38750. headphone: boolean;
  38751. /**
  38752. * Gets or sets custom audio listener position provider
  38753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38754. */
  38755. audioListenerPositionProvider: Nullable<() => Vector3>;
  38756. /**
  38757. * Gets or sets a refresh rate when using 3D audio positioning
  38758. */
  38759. audioPositioningRefreshRate: number;
  38760. }
  38761. }
  38762. /**
  38763. * Defines the sound scene component responsible to manage any sounds
  38764. * in a given scene.
  38765. */
  38766. export class AudioSceneComponent implements ISceneSerializableComponent {
  38767. /**
  38768. * The component name helpfull to identify the component in the list of scene components.
  38769. */
  38770. readonly name: string;
  38771. /**
  38772. * The scene the component belongs to.
  38773. */
  38774. scene: Scene;
  38775. private _audioEnabled;
  38776. /**
  38777. * Gets whether audio is enabled or not.
  38778. * Please use related enable/disable method to switch state.
  38779. */
  38780. get audioEnabled(): boolean;
  38781. private _headphone;
  38782. /**
  38783. * Gets whether audio is outputing to headphone or not.
  38784. * Please use the according Switch methods to change output.
  38785. */
  38786. get headphone(): boolean;
  38787. /**
  38788. * Gets or sets a refresh rate when using 3D audio positioning
  38789. */
  38790. audioPositioningRefreshRate: number;
  38791. private _audioListenerPositionProvider;
  38792. /**
  38793. * Gets the current audio listener position provider
  38794. */
  38795. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38796. /**
  38797. * Sets a custom listener position for all sounds in the scene
  38798. * By default, this is the position of the first active camera
  38799. */
  38800. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38801. /**
  38802. * Creates a new instance of the component for the given scene
  38803. * @param scene Defines the scene to register the component in
  38804. */
  38805. constructor(scene: Scene);
  38806. /**
  38807. * Registers the component in a given scene
  38808. */
  38809. register(): void;
  38810. /**
  38811. * Rebuilds the elements related to this component in case of
  38812. * context lost for instance.
  38813. */
  38814. rebuild(): void;
  38815. /**
  38816. * Serializes the component data to the specified json object
  38817. * @param serializationObject The object to serialize to
  38818. */
  38819. serialize(serializationObject: any): void;
  38820. /**
  38821. * Adds all the elements from the container to the scene
  38822. * @param container the container holding the elements
  38823. */
  38824. addFromContainer(container: AbstractScene): void;
  38825. /**
  38826. * Removes all the elements in the container from the scene
  38827. * @param container contains the elements to remove
  38828. * @param dispose if the removed element should be disposed (default: false)
  38829. */
  38830. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38831. /**
  38832. * Disposes the component and the associated ressources.
  38833. */
  38834. dispose(): void;
  38835. /**
  38836. * Disables audio in the associated scene.
  38837. */
  38838. disableAudio(): void;
  38839. /**
  38840. * Enables audio in the associated scene.
  38841. */
  38842. enableAudio(): void;
  38843. /**
  38844. * Switch audio to headphone output.
  38845. */
  38846. switchAudioModeForHeadphones(): void;
  38847. /**
  38848. * Switch audio to normal speakers.
  38849. */
  38850. switchAudioModeForNormalSpeakers(): void;
  38851. private _cachedCameraDirection;
  38852. private _cachedCameraPosition;
  38853. private _lastCheck;
  38854. private _afterRender;
  38855. }
  38856. }
  38857. declare module "babylonjs/Audio/weightedsound" {
  38858. import { Sound } from "babylonjs/Audio/sound";
  38859. /**
  38860. * Wraps one or more Sound objects and selects one with random weight for playback.
  38861. */
  38862. export class WeightedSound {
  38863. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38864. loop: boolean;
  38865. private _coneInnerAngle;
  38866. private _coneOuterAngle;
  38867. private _volume;
  38868. /** A Sound is currently playing. */
  38869. isPlaying: boolean;
  38870. /** A Sound is currently paused. */
  38871. isPaused: boolean;
  38872. private _sounds;
  38873. private _weights;
  38874. private _currentIndex?;
  38875. /**
  38876. * Creates a new WeightedSound from the list of sounds given.
  38877. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38878. * @param sounds Array of Sounds that will be selected from.
  38879. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38880. */
  38881. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38882. /**
  38883. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38884. */
  38885. get directionalConeInnerAngle(): number;
  38886. /**
  38887. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38888. */
  38889. set directionalConeInnerAngle(value: number);
  38890. /**
  38891. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38892. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38893. */
  38894. get directionalConeOuterAngle(): number;
  38895. /**
  38896. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38897. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38898. */
  38899. set directionalConeOuterAngle(value: number);
  38900. /**
  38901. * Playback volume.
  38902. */
  38903. get volume(): number;
  38904. /**
  38905. * Playback volume.
  38906. */
  38907. set volume(value: number);
  38908. private _onended;
  38909. /**
  38910. * Suspend playback
  38911. */
  38912. pause(): void;
  38913. /**
  38914. * Stop playback
  38915. */
  38916. stop(): void;
  38917. /**
  38918. * Start playback.
  38919. * @param startOffset Position the clip head at a specific time in seconds.
  38920. */
  38921. play(startOffset?: number): void;
  38922. }
  38923. }
  38924. declare module "babylonjs/Audio/index" {
  38925. export * from "babylonjs/Audio/analyser";
  38926. export * from "babylonjs/Audio/audioEngine";
  38927. export * from "babylonjs/Audio/audioSceneComponent";
  38928. export * from "babylonjs/Audio/sound";
  38929. export * from "babylonjs/Audio/soundTrack";
  38930. export * from "babylonjs/Audio/weightedsound";
  38931. }
  38932. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38933. import { Behavior } from "babylonjs/Behaviors/behavior";
  38934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38935. import { BackEase } from "babylonjs/Animations/easing";
  38936. /**
  38937. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38938. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38939. */
  38940. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38941. /**
  38942. * Gets the name of the behavior.
  38943. */
  38944. get name(): string;
  38945. /**
  38946. * The easing function used by animations
  38947. */
  38948. static EasingFunction: BackEase;
  38949. /**
  38950. * The easing mode used by animations
  38951. */
  38952. static EasingMode: number;
  38953. /**
  38954. * The duration of the animation, in milliseconds
  38955. */
  38956. transitionDuration: number;
  38957. /**
  38958. * Length of the distance animated by the transition when lower radius is reached
  38959. */
  38960. lowerRadiusTransitionRange: number;
  38961. /**
  38962. * Length of the distance animated by the transition when upper radius is reached
  38963. */
  38964. upperRadiusTransitionRange: number;
  38965. private _autoTransitionRange;
  38966. /**
  38967. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38968. */
  38969. get autoTransitionRange(): boolean;
  38970. /**
  38971. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38972. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38973. */
  38974. set autoTransitionRange(value: boolean);
  38975. private _attachedCamera;
  38976. private _onAfterCheckInputsObserver;
  38977. private _onMeshTargetChangedObserver;
  38978. /**
  38979. * Initializes the behavior.
  38980. */
  38981. init(): void;
  38982. /**
  38983. * Attaches the behavior to its arc rotate camera.
  38984. * @param camera Defines the camera to attach the behavior to
  38985. */
  38986. attach(camera: ArcRotateCamera): void;
  38987. /**
  38988. * Detaches the behavior from its current arc rotate camera.
  38989. */
  38990. detach(): void;
  38991. private _radiusIsAnimating;
  38992. private _radiusBounceTransition;
  38993. private _animatables;
  38994. private _cachedWheelPrecision;
  38995. /**
  38996. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38997. * @param radiusLimit The limit to check against.
  38998. * @return Bool to indicate if at limit.
  38999. */
  39000. private _isRadiusAtLimit;
  39001. /**
  39002. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39003. * @param radiusDelta The delta by which to animate to. Can be negative.
  39004. */
  39005. private _applyBoundRadiusAnimation;
  39006. /**
  39007. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39008. */
  39009. protected _clearAnimationLocks(): void;
  39010. /**
  39011. * Stops and removes all animations that have been applied to the camera
  39012. */
  39013. stopAllAnimations(): void;
  39014. }
  39015. }
  39016. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39017. import { Behavior } from "babylonjs/Behaviors/behavior";
  39018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39019. import { ExponentialEase } from "babylonjs/Animations/easing";
  39020. import { Nullable } from "babylonjs/types";
  39021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39022. import { Vector3 } from "babylonjs/Maths/math.vector";
  39023. /**
  39024. * 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.
  39025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39026. */
  39027. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39028. /**
  39029. * Gets the name of the behavior.
  39030. */
  39031. get name(): string;
  39032. private _mode;
  39033. private _radiusScale;
  39034. private _positionScale;
  39035. private _defaultElevation;
  39036. private _elevationReturnTime;
  39037. private _elevationReturnWaitTime;
  39038. private _zoomStopsAnimation;
  39039. private _framingTime;
  39040. /**
  39041. * The easing function used by animations
  39042. */
  39043. static EasingFunction: ExponentialEase;
  39044. /**
  39045. * The easing mode used by animations
  39046. */
  39047. static EasingMode: number;
  39048. /**
  39049. * Sets the current mode used by the behavior
  39050. */
  39051. set mode(mode: number);
  39052. /**
  39053. * Gets current mode used by the behavior.
  39054. */
  39055. get mode(): number;
  39056. /**
  39057. * Sets the scale applied to the radius (1 by default)
  39058. */
  39059. set radiusScale(radius: number);
  39060. /**
  39061. * Gets the scale applied to the radius
  39062. */
  39063. get radiusScale(): number;
  39064. /**
  39065. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39066. */
  39067. set positionScale(scale: number);
  39068. /**
  39069. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39070. */
  39071. get positionScale(): number;
  39072. /**
  39073. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39074. * behaviour is triggered, in radians.
  39075. */
  39076. set defaultElevation(elevation: number);
  39077. /**
  39078. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39079. * behaviour is triggered, in radians.
  39080. */
  39081. get defaultElevation(): number;
  39082. /**
  39083. * Sets the time (in milliseconds) taken to return to the default beta position.
  39084. * Negative value indicates camera should not return to default.
  39085. */
  39086. set elevationReturnTime(speed: number);
  39087. /**
  39088. * Gets the time (in milliseconds) taken to return to the default beta position.
  39089. * Negative value indicates camera should not return to default.
  39090. */
  39091. get elevationReturnTime(): number;
  39092. /**
  39093. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39094. */
  39095. set elevationReturnWaitTime(time: number);
  39096. /**
  39097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39098. */
  39099. get elevationReturnWaitTime(): number;
  39100. /**
  39101. * Sets the flag that indicates if user zooming should stop animation.
  39102. */
  39103. set zoomStopsAnimation(flag: boolean);
  39104. /**
  39105. * Gets the flag that indicates if user zooming should stop animation.
  39106. */
  39107. get zoomStopsAnimation(): boolean;
  39108. /**
  39109. * Sets the transition time when framing the mesh, in milliseconds
  39110. */
  39111. set framingTime(time: number);
  39112. /**
  39113. * Gets the transition time when framing the mesh, in milliseconds
  39114. */
  39115. get framingTime(): number;
  39116. /**
  39117. * Define if the behavior should automatically change the configured
  39118. * camera limits and sensibilities.
  39119. */
  39120. autoCorrectCameraLimitsAndSensibility: boolean;
  39121. private _onPrePointerObservableObserver;
  39122. private _onAfterCheckInputsObserver;
  39123. private _onMeshTargetChangedObserver;
  39124. private _attachedCamera;
  39125. private _isPointerDown;
  39126. private _lastInteractionTime;
  39127. /**
  39128. * Initializes the behavior.
  39129. */
  39130. init(): void;
  39131. /**
  39132. * Attaches the behavior to its arc rotate camera.
  39133. * @param camera Defines the camera to attach the behavior to
  39134. */
  39135. attach(camera: ArcRotateCamera): void;
  39136. /**
  39137. * Detaches the behavior from its current arc rotate camera.
  39138. */
  39139. detach(): void;
  39140. private _animatables;
  39141. private _betaIsAnimating;
  39142. private _betaTransition;
  39143. private _radiusTransition;
  39144. private _vectorTransition;
  39145. /**
  39146. * Targets the given mesh and updates zoom level accordingly.
  39147. * @param mesh The mesh to target.
  39148. * @param radius Optional. If a cached radius position already exists, overrides default.
  39149. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39150. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39151. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39152. */
  39153. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39154. /**
  39155. * Targets the given mesh with its children and updates zoom level accordingly.
  39156. * @param mesh The mesh to target.
  39157. * @param radius Optional. If a cached radius position already exists, overrides default.
  39158. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39161. */
  39162. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39163. /**
  39164. * Targets the given meshes with their children and updates zoom level accordingly.
  39165. * @param meshes The mesh to target.
  39166. * @param radius Optional. If a cached radius position already exists, overrides default.
  39167. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39170. */
  39171. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39172. /**
  39173. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39174. * @param minimumWorld Determines the smaller position of the bounding box extend
  39175. * @param maximumWorld Determines the bigger position of the bounding box extend
  39176. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39177. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39178. */
  39179. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39180. /**
  39181. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39182. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39183. * frustum width.
  39184. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39185. * to fully enclose the mesh in the viewing frustum.
  39186. */
  39187. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39188. /**
  39189. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39190. * is automatically returned to its default position (expected to be above ground plane).
  39191. */
  39192. private _maintainCameraAboveGround;
  39193. /**
  39194. * Returns the frustum slope based on the canvas ratio and camera FOV
  39195. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39196. */
  39197. private _getFrustumSlope;
  39198. /**
  39199. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39200. */
  39201. private _clearAnimationLocks;
  39202. /**
  39203. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39204. */
  39205. private _applyUserInteraction;
  39206. /**
  39207. * Stops and removes all animations that have been applied to the camera
  39208. */
  39209. stopAllAnimations(): void;
  39210. /**
  39211. * Gets a value indicating if the user is moving the camera
  39212. */
  39213. get isUserIsMoving(): boolean;
  39214. /**
  39215. * The camera can move all the way towards the mesh.
  39216. */
  39217. static IgnoreBoundsSizeMode: number;
  39218. /**
  39219. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39220. */
  39221. static FitFrustumSidesMode: number;
  39222. }
  39223. }
  39224. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39225. import { Nullable } from "babylonjs/types";
  39226. import { Camera } from "babylonjs/Cameras/camera";
  39227. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39228. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39229. /**
  39230. * Base class for Camera Pointer Inputs.
  39231. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39232. * for example usage.
  39233. */
  39234. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39235. /**
  39236. * Defines the camera the input is attached to.
  39237. */
  39238. abstract camera: Camera;
  39239. /**
  39240. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39241. */
  39242. protected _altKey: boolean;
  39243. protected _ctrlKey: boolean;
  39244. protected _metaKey: boolean;
  39245. protected _shiftKey: boolean;
  39246. /**
  39247. * Which mouse buttons were pressed at time of last mouse event.
  39248. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39249. */
  39250. protected _buttonsPressed: number;
  39251. /**
  39252. * Defines the buttons associated with the input to handle camera move.
  39253. */
  39254. buttons: number[];
  39255. /**
  39256. * Attach the input controls to a specific dom element to get the input from.
  39257. * @param element Defines the element the controls should be listened from
  39258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39259. */
  39260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39261. /**
  39262. * Detach the current controls from the specified dom element.
  39263. * @param element Defines the element to stop listening the inputs from
  39264. */
  39265. detachControl(element: Nullable<HTMLElement>): void;
  39266. /**
  39267. * Gets the class name of the current input.
  39268. * @returns the class name
  39269. */
  39270. getClassName(): string;
  39271. /**
  39272. * Get the friendly name associated with the input class.
  39273. * @returns the input friendly name
  39274. */
  39275. getSimpleName(): string;
  39276. /**
  39277. * Called on pointer POINTERDOUBLETAP event.
  39278. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39279. */
  39280. protected onDoubleTap(type: string): void;
  39281. /**
  39282. * Called on pointer POINTERMOVE event if only a single touch is active.
  39283. * Override this method to provide functionality.
  39284. */
  39285. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39286. /**
  39287. * Called on pointer POINTERMOVE event if multiple touches are active.
  39288. * Override this method to provide functionality.
  39289. */
  39290. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39291. /**
  39292. * Called on JS contextmenu event.
  39293. * Override this method to provide functionality.
  39294. */
  39295. protected onContextMenu(evt: PointerEvent): void;
  39296. /**
  39297. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39298. * press.
  39299. * Override this method to provide functionality.
  39300. */
  39301. protected onButtonDown(evt: PointerEvent): void;
  39302. /**
  39303. * Called each time a new POINTERUP event occurs. Ie, for each button
  39304. * release.
  39305. * Override this method to provide functionality.
  39306. */
  39307. protected onButtonUp(evt: PointerEvent): void;
  39308. /**
  39309. * Called when window becomes inactive.
  39310. * Override this method to provide functionality.
  39311. */
  39312. protected onLostFocus(): void;
  39313. private _pointerInput;
  39314. private _observer;
  39315. private _onLostFocus;
  39316. private pointA;
  39317. private pointB;
  39318. }
  39319. }
  39320. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39321. import { Nullable } from "babylonjs/types";
  39322. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39323. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39324. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39325. /**
  39326. * Manage the pointers inputs to control an arc rotate camera.
  39327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39328. */
  39329. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39330. /**
  39331. * Defines the camera the input is attached to.
  39332. */
  39333. camera: ArcRotateCamera;
  39334. /**
  39335. * Gets the class name of the current input.
  39336. * @returns the class name
  39337. */
  39338. getClassName(): string;
  39339. /**
  39340. * Defines the buttons associated with the input to handle camera move.
  39341. */
  39342. buttons: number[];
  39343. /**
  39344. * Defines the pointer angular sensibility along the X axis or how fast is
  39345. * the camera rotating.
  39346. */
  39347. angularSensibilityX: number;
  39348. /**
  39349. * Defines the pointer angular sensibility along the Y axis or how fast is
  39350. * the camera rotating.
  39351. */
  39352. angularSensibilityY: number;
  39353. /**
  39354. * Defines the pointer pinch precision or how fast is the camera zooming.
  39355. */
  39356. pinchPrecision: number;
  39357. /**
  39358. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39359. * from 0.
  39360. * It defines the percentage of current camera.radius to use as delta when
  39361. * pinch zoom is used.
  39362. */
  39363. pinchDeltaPercentage: number;
  39364. /**
  39365. * Defines the pointer panning sensibility or how fast is the camera moving.
  39366. */
  39367. panningSensibility: number;
  39368. /**
  39369. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39370. */
  39371. multiTouchPanning: boolean;
  39372. /**
  39373. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39374. * zoom (pinch) through multitouch.
  39375. */
  39376. multiTouchPanAndZoom: boolean;
  39377. /**
  39378. * Revers pinch action direction.
  39379. */
  39380. pinchInwards: boolean;
  39381. private _isPanClick;
  39382. private _twoFingerActivityCount;
  39383. private _isPinching;
  39384. /**
  39385. * Called on pointer POINTERMOVE event if only a single touch is active.
  39386. */
  39387. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39388. /**
  39389. * Called on pointer POINTERDOUBLETAP event.
  39390. */
  39391. protected onDoubleTap(type: string): void;
  39392. /**
  39393. * Called on pointer POINTERMOVE event if multiple touches are active.
  39394. */
  39395. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39396. /**
  39397. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39398. * press.
  39399. */
  39400. protected onButtonDown(evt: PointerEvent): void;
  39401. /**
  39402. * Called each time a new POINTERUP event occurs. Ie, for each button
  39403. * release.
  39404. */
  39405. protected onButtonUp(evt: PointerEvent): void;
  39406. /**
  39407. * Called when window becomes inactive.
  39408. */
  39409. protected onLostFocus(): void;
  39410. }
  39411. }
  39412. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39413. import { Nullable } from "babylonjs/types";
  39414. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39415. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39416. /**
  39417. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39419. */
  39420. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39421. /**
  39422. * Defines the camera the input is attached to.
  39423. */
  39424. camera: ArcRotateCamera;
  39425. /**
  39426. * Defines the list of key codes associated with the up action (increase alpha)
  39427. */
  39428. keysUp: number[];
  39429. /**
  39430. * Defines the list of key codes associated with the down action (decrease alpha)
  39431. */
  39432. keysDown: number[];
  39433. /**
  39434. * Defines the list of key codes associated with the left action (increase beta)
  39435. */
  39436. keysLeft: number[];
  39437. /**
  39438. * Defines the list of key codes associated with the right action (decrease beta)
  39439. */
  39440. keysRight: number[];
  39441. /**
  39442. * Defines the list of key codes associated with the reset action.
  39443. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39444. */
  39445. keysReset: number[];
  39446. /**
  39447. * Defines the panning sensibility of the inputs.
  39448. * (How fast is the camera paning)
  39449. */
  39450. panningSensibility: number;
  39451. /**
  39452. * Defines the zooming sensibility of the inputs.
  39453. * (How fast is the camera zooming)
  39454. */
  39455. zoomingSensibility: number;
  39456. /**
  39457. * Defines wether maintaining the alt key down switch the movement mode from
  39458. * orientation to zoom.
  39459. */
  39460. useAltToZoom: boolean;
  39461. /**
  39462. * Rotation speed of the camera
  39463. */
  39464. angularSpeed: number;
  39465. private _keys;
  39466. private _ctrlPressed;
  39467. private _altPressed;
  39468. private _onCanvasBlurObserver;
  39469. private _onKeyboardObserver;
  39470. private _engine;
  39471. private _scene;
  39472. /**
  39473. * Attach the input controls to a specific dom element to get the input from.
  39474. * @param element Defines the element the controls should be listened from
  39475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39476. */
  39477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39478. /**
  39479. * Detach the current controls from the specified dom element.
  39480. * @param element Defines the element to stop listening the inputs from
  39481. */
  39482. detachControl(element: Nullable<HTMLElement>): void;
  39483. /**
  39484. * Update the current camera state depending on the inputs that have been used this frame.
  39485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39486. */
  39487. checkInputs(): void;
  39488. /**
  39489. * Gets the class name of the current intput.
  39490. * @returns the class name
  39491. */
  39492. getClassName(): string;
  39493. /**
  39494. * Get the friendly name associated with the input class.
  39495. * @returns the input friendly name
  39496. */
  39497. getSimpleName(): string;
  39498. }
  39499. }
  39500. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39501. import { Nullable } from "babylonjs/types";
  39502. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39503. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39504. /**
  39505. * Manage the mouse wheel inputs to control an arc rotate camera.
  39506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39507. */
  39508. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39509. /**
  39510. * Defines the camera the input is attached to.
  39511. */
  39512. camera: ArcRotateCamera;
  39513. /**
  39514. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39515. */
  39516. wheelPrecision: number;
  39517. /**
  39518. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39519. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39520. */
  39521. wheelDeltaPercentage: number;
  39522. private _wheel;
  39523. private _observer;
  39524. private computeDeltaFromMouseWheelLegacyEvent;
  39525. /**
  39526. * Attach the input controls to a specific dom element to get the input from.
  39527. * @param element Defines the element the controls should be listened from
  39528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39529. */
  39530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39531. /**
  39532. * Detach the current controls from the specified dom element.
  39533. * @param element Defines the element to stop listening the inputs from
  39534. */
  39535. detachControl(element: Nullable<HTMLElement>): void;
  39536. /**
  39537. * Gets the class name of the current intput.
  39538. * @returns the class name
  39539. */
  39540. getClassName(): string;
  39541. /**
  39542. * Get the friendly name associated with the input class.
  39543. * @returns the input friendly name
  39544. */
  39545. getSimpleName(): string;
  39546. }
  39547. }
  39548. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39549. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39550. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39551. /**
  39552. * Default Inputs manager for the ArcRotateCamera.
  39553. * It groups all the default supported inputs for ease of use.
  39554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39555. */
  39556. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39557. /**
  39558. * Instantiates a new ArcRotateCameraInputsManager.
  39559. * @param camera Defines the camera the inputs belong to
  39560. */
  39561. constructor(camera: ArcRotateCamera);
  39562. /**
  39563. * Add mouse wheel input support to the input manager.
  39564. * @returns the current input manager
  39565. */
  39566. addMouseWheel(): ArcRotateCameraInputsManager;
  39567. /**
  39568. * Add pointers input support to the input manager.
  39569. * @returns the current input manager
  39570. */
  39571. addPointers(): ArcRotateCameraInputsManager;
  39572. /**
  39573. * Add keyboard input support to the input manager.
  39574. * @returns the current input manager
  39575. */
  39576. addKeyboard(): ArcRotateCameraInputsManager;
  39577. }
  39578. }
  39579. declare module "babylonjs/Cameras/arcRotateCamera" {
  39580. import { Observable } from "babylonjs/Misc/observable";
  39581. import { Nullable } from "babylonjs/types";
  39582. import { Scene } from "babylonjs/scene";
  39583. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39585. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39586. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39587. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39588. import { Camera } from "babylonjs/Cameras/camera";
  39589. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39590. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39591. import { Collider } from "babylonjs/Collisions/collider";
  39592. /**
  39593. * This represents an orbital type of camera.
  39594. *
  39595. * 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.
  39596. * 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.
  39597. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39598. */
  39599. export class ArcRotateCamera extends TargetCamera {
  39600. /**
  39601. * Defines the rotation angle of the camera along the longitudinal axis.
  39602. */
  39603. alpha: number;
  39604. /**
  39605. * Defines the rotation angle of the camera along the latitudinal axis.
  39606. */
  39607. beta: number;
  39608. /**
  39609. * Defines the radius of the camera from it s target point.
  39610. */
  39611. radius: number;
  39612. protected _target: Vector3;
  39613. protected _targetHost: Nullable<AbstractMesh>;
  39614. /**
  39615. * Defines the target point of the camera.
  39616. * The camera looks towards it form the radius distance.
  39617. */
  39618. get target(): Vector3;
  39619. set target(value: Vector3);
  39620. /**
  39621. * Define the current local position of the camera in the scene
  39622. */
  39623. get position(): Vector3;
  39624. set position(newPosition: Vector3);
  39625. protected _upVector: Vector3;
  39626. protected _upToYMatrix: Matrix;
  39627. protected _YToUpMatrix: Matrix;
  39628. /**
  39629. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39630. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39631. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39632. */
  39633. set upVector(vec: Vector3);
  39634. get upVector(): Vector3;
  39635. /**
  39636. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39637. */
  39638. setMatUp(): void;
  39639. /**
  39640. * Current inertia value on the longitudinal axis.
  39641. * The bigger this number the longer it will take for the camera to stop.
  39642. */
  39643. inertialAlphaOffset: number;
  39644. /**
  39645. * Current inertia value on the latitudinal axis.
  39646. * The bigger this number the longer it will take for the camera to stop.
  39647. */
  39648. inertialBetaOffset: number;
  39649. /**
  39650. * Current inertia value on the radius axis.
  39651. * The bigger this number the longer it will take for the camera to stop.
  39652. */
  39653. inertialRadiusOffset: number;
  39654. /**
  39655. * Minimum allowed angle on the longitudinal axis.
  39656. * This can help limiting how the Camera is able to move in the scene.
  39657. */
  39658. lowerAlphaLimit: Nullable<number>;
  39659. /**
  39660. * Maximum allowed angle on the longitudinal axis.
  39661. * This can help limiting how the Camera is able to move in the scene.
  39662. */
  39663. upperAlphaLimit: Nullable<number>;
  39664. /**
  39665. * Minimum allowed angle on the latitudinal axis.
  39666. * This can help limiting how the Camera is able to move in the scene.
  39667. */
  39668. lowerBetaLimit: number;
  39669. /**
  39670. * Maximum allowed angle on the latitudinal axis.
  39671. * This can help limiting how the Camera is able to move in the scene.
  39672. */
  39673. upperBetaLimit: number;
  39674. /**
  39675. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39676. * This can help limiting how the Camera is able to move in the scene.
  39677. */
  39678. lowerRadiusLimit: Nullable<number>;
  39679. /**
  39680. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39681. * This can help limiting how the Camera is able to move in the scene.
  39682. */
  39683. upperRadiusLimit: Nullable<number>;
  39684. /**
  39685. * Defines the current inertia value used during panning of the camera along the X axis.
  39686. */
  39687. inertialPanningX: number;
  39688. /**
  39689. * Defines the current inertia value used during panning of the camera along the Y axis.
  39690. */
  39691. inertialPanningY: number;
  39692. /**
  39693. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39694. * Basically if your fingers moves away from more than this distance you will be considered
  39695. * in pinch mode.
  39696. */
  39697. pinchToPanMaxDistance: number;
  39698. /**
  39699. * Defines the maximum distance the camera can pan.
  39700. * This could help keeping the cammera always in your scene.
  39701. */
  39702. panningDistanceLimit: Nullable<number>;
  39703. /**
  39704. * Defines the target of the camera before paning.
  39705. */
  39706. panningOriginTarget: Vector3;
  39707. /**
  39708. * Defines the value of the inertia used during panning.
  39709. * 0 would mean stop inertia and one would mean no decelleration at all.
  39710. */
  39711. panningInertia: number;
  39712. /**
  39713. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39714. */
  39715. get angularSensibilityX(): number;
  39716. set angularSensibilityX(value: number);
  39717. /**
  39718. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39719. */
  39720. get angularSensibilityY(): number;
  39721. set angularSensibilityY(value: number);
  39722. /**
  39723. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39724. */
  39725. get pinchPrecision(): number;
  39726. set pinchPrecision(value: number);
  39727. /**
  39728. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39729. * It will be used instead of pinchDeltaPrecision if different from 0.
  39730. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39731. */
  39732. get pinchDeltaPercentage(): number;
  39733. set pinchDeltaPercentage(value: number);
  39734. /**
  39735. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39736. */
  39737. get panningSensibility(): number;
  39738. set panningSensibility(value: number);
  39739. /**
  39740. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39741. */
  39742. get keysUp(): number[];
  39743. set keysUp(value: number[]);
  39744. /**
  39745. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39746. */
  39747. get keysDown(): number[];
  39748. set keysDown(value: number[]);
  39749. /**
  39750. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39751. */
  39752. get keysLeft(): number[];
  39753. set keysLeft(value: number[]);
  39754. /**
  39755. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39756. */
  39757. get keysRight(): number[];
  39758. set keysRight(value: number[]);
  39759. /**
  39760. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39761. */
  39762. get wheelPrecision(): number;
  39763. set wheelPrecision(value: number);
  39764. /**
  39765. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39766. * It will be used instead of pinchDeltaPrecision if different from 0.
  39767. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39768. */
  39769. get wheelDeltaPercentage(): number;
  39770. set wheelDeltaPercentage(value: number);
  39771. /**
  39772. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39773. */
  39774. zoomOnFactor: number;
  39775. /**
  39776. * Defines a screen offset for the camera position.
  39777. */
  39778. targetScreenOffset: Vector2;
  39779. /**
  39780. * Allows the camera to be completely reversed.
  39781. * If false the camera can not arrive upside down.
  39782. */
  39783. allowUpsideDown: boolean;
  39784. /**
  39785. * Define if double tap/click is used to restore the previously saved state of the camera.
  39786. */
  39787. useInputToRestoreState: boolean;
  39788. /** @hidden */
  39789. _viewMatrix: Matrix;
  39790. /** @hidden */
  39791. _useCtrlForPanning: boolean;
  39792. /** @hidden */
  39793. _panningMouseButton: number;
  39794. /**
  39795. * Defines the input associated to the camera.
  39796. */
  39797. inputs: ArcRotateCameraInputsManager;
  39798. /** @hidden */
  39799. _reset: () => void;
  39800. /**
  39801. * Defines the allowed panning axis.
  39802. */
  39803. panningAxis: Vector3;
  39804. protected _localDirection: Vector3;
  39805. protected _transformedDirection: Vector3;
  39806. private _bouncingBehavior;
  39807. /**
  39808. * Gets the bouncing behavior of the camera if it has been enabled.
  39809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39810. */
  39811. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39812. /**
  39813. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39814. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39815. */
  39816. get useBouncingBehavior(): boolean;
  39817. set useBouncingBehavior(value: boolean);
  39818. private _framingBehavior;
  39819. /**
  39820. * Gets the framing behavior of the camera if it has been enabled.
  39821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39822. */
  39823. get framingBehavior(): Nullable<FramingBehavior>;
  39824. /**
  39825. * Defines if the framing behavior of the camera is enabled on the camera.
  39826. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39827. */
  39828. get useFramingBehavior(): boolean;
  39829. set useFramingBehavior(value: boolean);
  39830. private _autoRotationBehavior;
  39831. /**
  39832. * Gets the auto rotation behavior of the camera if it has been enabled.
  39833. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39834. */
  39835. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39836. /**
  39837. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39838. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39839. */
  39840. get useAutoRotationBehavior(): boolean;
  39841. set useAutoRotationBehavior(value: boolean);
  39842. /**
  39843. * Observable triggered when the mesh target has been changed on the camera.
  39844. */
  39845. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39846. /**
  39847. * Event raised when the camera is colliding with a mesh.
  39848. */
  39849. onCollide: (collidedMesh: AbstractMesh) => void;
  39850. /**
  39851. * Defines whether the camera should check collision with the objects oh the scene.
  39852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39853. */
  39854. checkCollisions: boolean;
  39855. /**
  39856. * Defines the collision radius of the camera.
  39857. * This simulates a sphere around the camera.
  39858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39859. */
  39860. collisionRadius: Vector3;
  39861. protected _collider: Collider;
  39862. protected _previousPosition: Vector3;
  39863. protected _collisionVelocity: Vector3;
  39864. protected _newPosition: Vector3;
  39865. protected _previousAlpha: number;
  39866. protected _previousBeta: number;
  39867. protected _previousRadius: number;
  39868. protected _collisionTriggered: boolean;
  39869. protected _targetBoundingCenter: Nullable<Vector3>;
  39870. private _computationVector;
  39871. /**
  39872. * Instantiates a new ArcRotateCamera in a given scene
  39873. * @param name Defines the name of the camera
  39874. * @param alpha Defines the camera rotation along the logitudinal axis
  39875. * @param beta Defines the camera rotation along the latitudinal axis
  39876. * @param radius Defines the camera distance from its target
  39877. * @param target Defines the camera target
  39878. * @param scene Defines the scene the camera belongs to
  39879. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39880. */
  39881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39882. /** @hidden */
  39883. _initCache(): void;
  39884. /** @hidden */
  39885. _updateCache(ignoreParentClass?: boolean): void;
  39886. protected _getTargetPosition(): Vector3;
  39887. private _storedAlpha;
  39888. private _storedBeta;
  39889. private _storedRadius;
  39890. private _storedTarget;
  39891. private _storedTargetScreenOffset;
  39892. /**
  39893. * Stores the current state of the camera (alpha, beta, radius and target)
  39894. * @returns the camera itself
  39895. */
  39896. storeState(): Camera;
  39897. /**
  39898. * @hidden
  39899. * Restored camera state. You must call storeState() first
  39900. */
  39901. _restoreStateValues(): boolean;
  39902. /** @hidden */
  39903. _isSynchronizedViewMatrix(): boolean;
  39904. /**
  39905. * Attached controls to the current camera.
  39906. * @param element Defines the element the controls should be listened from
  39907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39908. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39909. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39910. */
  39911. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39912. /**
  39913. * Detach the current controls from the camera.
  39914. * The camera will stop reacting to inputs.
  39915. * @param element Defines the element to stop listening the inputs from
  39916. */
  39917. detachControl(element: HTMLElement): void;
  39918. /** @hidden */
  39919. _checkInputs(): void;
  39920. protected _checkLimits(): void;
  39921. /**
  39922. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39923. */
  39924. rebuildAnglesAndRadius(): void;
  39925. /**
  39926. * Use a position to define the current camera related information like alpha, beta and radius
  39927. * @param position Defines the position to set the camera at
  39928. */
  39929. setPosition(position: Vector3): void;
  39930. /**
  39931. * Defines the target the camera should look at.
  39932. * This will automatically adapt alpha beta and radius to fit within the new target.
  39933. * @param target Defines the new target as a Vector or a mesh
  39934. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39935. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39936. */
  39937. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39938. /** @hidden */
  39939. _getViewMatrix(): Matrix;
  39940. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39941. /**
  39942. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39943. * @param meshes Defines the mesh to zoom on
  39944. * @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)
  39945. */
  39946. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39947. /**
  39948. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39949. * The target will be changed but the radius
  39950. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39951. * @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)
  39952. */
  39953. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39954. min: Vector3;
  39955. max: Vector3;
  39956. distance: number;
  39957. }, doNotUpdateMaxZ?: boolean): void;
  39958. /**
  39959. * @override
  39960. * Override Camera.createRigCamera
  39961. */
  39962. createRigCamera(name: string, cameraIndex: number): Camera;
  39963. /**
  39964. * @hidden
  39965. * @override
  39966. * Override Camera._updateRigCameras
  39967. */
  39968. _updateRigCameras(): void;
  39969. /**
  39970. * Destroy the camera and release the current resources hold by it.
  39971. */
  39972. dispose(): void;
  39973. /**
  39974. * Gets the current object class name.
  39975. * @return the class name
  39976. */
  39977. getClassName(): string;
  39978. }
  39979. }
  39980. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39981. import { Behavior } from "babylonjs/Behaviors/behavior";
  39982. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39983. /**
  39984. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39985. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39986. */
  39987. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39988. /**
  39989. * Gets the name of the behavior.
  39990. */
  39991. get name(): string;
  39992. private _zoomStopsAnimation;
  39993. private _idleRotationSpeed;
  39994. private _idleRotationWaitTime;
  39995. private _idleRotationSpinupTime;
  39996. /**
  39997. * Sets the flag that indicates if user zooming should stop animation.
  39998. */
  39999. set zoomStopsAnimation(flag: boolean);
  40000. /**
  40001. * Gets the flag that indicates if user zooming should stop animation.
  40002. */
  40003. get zoomStopsAnimation(): boolean;
  40004. /**
  40005. * Sets the default speed at which the camera rotates around the model.
  40006. */
  40007. set idleRotationSpeed(speed: number);
  40008. /**
  40009. * Gets the default speed at which the camera rotates around the model.
  40010. */
  40011. get idleRotationSpeed(): number;
  40012. /**
  40013. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40014. */
  40015. set idleRotationWaitTime(time: number);
  40016. /**
  40017. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40018. */
  40019. get idleRotationWaitTime(): number;
  40020. /**
  40021. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40022. */
  40023. set idleRotationSpinupTime(time: number);
  40024. /**
  40025. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40026. */
  40027. get idleRotationSpinupTime(): number;
  40028. /**
  40029. * Gets a value indicating if the camera is currently rotating because of this behavior
  40030. */
  40031. get rotationInProgress(): boolean;
  40032. private _onPrePointerObservableObserver;
  40033. private _onAfterCheckInputsObserver;
  40034. private _attachedCamera;
  40035. private _isPointerDown;
  40036. private _lastFrameTime;
  40037. private _lastInteractionTime;
  40038. private _cameraRotationSpeed;
  40039. /**
  40040. * Initializes the behavior.
  40041. */
  40042. init(): void;
  40043. /**
  40044. * Attaches the behavior to its arc rotate camera.
  40045. * @param camera Defines the camera to attach the behavior to
  40046. */
  40047. attach(camera: ArcRotateCamera): void;
  40048. /**
  40049. * Detaches the behavior from its current arc rotate camera.
  40050. */
  40051. detach(): void;
  40052. /**
  40053. * Returns true if user is scrolling.
  40054. * @return true if user is scrolling.
  40055. */
  40056. private _userIsZooming;
  40057. private _lastFrameRadius;
  40058. private _shouldAnimationStopForInteraction;
  40059. /**
  40060. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40061. */
  40062. private _applyUserInteraction;
  40063. private _userIsMoving;
  40064. }
  40065. }
  40066. declare module "babylonjs/Behaviors/Cameras/index" {
  40067. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40068. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40069. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40070. }
  40071. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40072. import { Mesh } from "babylonjs/Meshes/mesh";
  40073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40074. import { Behavior } from "babylonjs/Behaviors/behavior";
  40075. /**
  40076. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40077. */
  40078. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40079. private ui;
  40080. /**
  40081. * The name of the behavior
  40082. */
  40083. name: string;
  40084. /**
  40085. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40086. */
  40087. distanceAwayFromFace: number;
  40088. /**
  40089. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40090. */
  40091. distanceAwayFromBottomOfFace: number;
  40092. private _faceVectors;
  40093. private _target;
  40094. private _scene;
  40095. private _onRenderObserver;
  40096. private _tmpMatrix;
  40097. private _tmpVector;
  40098. /**
  40099. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40100. * @param ui The transform node that should be attched to the mesh
  40101. */
  40102. constructor(ui: TransformNode);
  40103. /**
  40104. * Initializes the behavior
  40105. */
  40106. init(): void;
  40107. private _closestFace;
  40108. private _zeroVector;
  40109. private _lookAtTmpMatrix;
  40110. private _lookAtToRef;
  40111. /**
  40112. * Attaches the AttachToBoxBehavior to the passed in mesh
  40113. * @param target The mesh that the specified node will be attached to
  40114. */
  40115. attach(target: Mesh): void;
  40116. /**
  40117. * Detaches the behavior from the mesh
  40118. */
  40119. detach(): void;
  40120. }
  40121. }
  40122. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40123. import { Behavior } from "babylonjs/Behaviors/behavior";
  40124. import { Mesh } from "babylonjs/Meshes/mesh";
  40125. /**
  40126. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40127. */
  40128. export class FadeInOutBehavior implements Behavior<Mesh> {
  40129. /**
  40130. * Time in milliseconds to delay before fading in (Default: 0)
  40131. */
  40132. delay: number;
  40133. /**
  40134. * Time in milliseconds for the mesh to fade in (Default: 300)
  40135. */
  40136. fadeInTime: number;
  40137. private _millisecondsPerFrame;
  40138. private _hovered;
  40139. private _hoverValue;
  40140. private _ownerNode;
  40141. /**
  40142. * Instatiates the FadeInOutBehavior
  40143. */
  40144. constructor();
  40145. /**
  40146. * The name of the behavior
  40147. */
  40148. get name(): string;
  40149. /**
  40150. * Initializes the behavior
  40151. */
  40152. init(): void;
  40153. /**
  40154. * Attaches the fade behavior on the passed in mesh
  40155. * @param ownerNode The mesh that will be faded in/out once attached
  40156. */
  40157. attach(ownerNode: Mesh): void;
  40158. /**
  40159. * Detaches the behavior from the mesh
  40160. */
  40161. detach(): void;
  40162. /**
  40163. * Triggers the mesh to begin fading in or out
  40164. * @param value if the object should fade in or out (true to fade in)
  40165. */
  40166. fadeIn(value: boolean): void;
  40167. private _update;
  40168. private _setAllVisibility;
  40169. }
  40170. }
  40171. declare module "babylonjs/Misc/pivotTools" {
  40172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40173. /**
  40174. * Class containing a set of static utilities functions for managing Pivots
  40175. * @hidden
  40176. */
  40177. export class PivotTools {
  40178. private static _PivotCached;
  40179. private static _OldPivotPoint;
  40180. private static _PivotTranslation;
  40181. private static _PivotTmpVector;
  40182. /** @hidden */
  40183. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40184. /** @hidden */
  40185. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40186. }
  40187. }
  40188. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40189. import { Scene } from "babylonjs/scene";
  40190. import { Vector4 } from "babylonjs/Maths/math.vector";
  40191. import { Mesh } from "babylonjs/Meshes/mesh";
  40192. import { Nullable } from "babylonjs/types";
  40193. import { Plane } from "babylonjs/Maths/math.plane";
  40194. /**
  40195. * Class containing static functions to help procedurally build meshes
  40196. */
  40197. export class PlaneBuilder {
  40198. /**
  40199. * Creates a plane mesh
  40200. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40201. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40202. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40206. * @param name defines the name of the mesh
  40207. * @param options defines the options used to create the mesh
  40208. * @param scene defines the hosting scene
  40209. * @returns the plane mesh
  40210. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40211. */
  40212. static CreatePlane(name: string, options: {
  40213. size?: number;
  40214. width?: number;
  40215. height?: number;
  40216. sideOrientation?: number;
  40217. frontUVs?: Vector4;
  40218. backUVs?: Vector4;
  40219. updatable?: boolean;
  40220. sourcePlane?: Plane;
  40221. }, scene?: Nullable<Scene>): Mesh;
  40222. }
  40223. }
  40224. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40225. import { Behavior } from "babylonjs/Behaviors/behavior";
  40226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40227. import { Observable } from "babylonjs/Misc/observable";
  40228. import { Vector3 } from "babylonjs/Maths/math.vector";
  40229. import { Ray } from "babylonjs/Culling/ray";
  40230. import "babylonjs/Meshes/Builders/planeBuilder";
  40231. /**
  40232. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40233. */
  40234. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40235. private static _AnyMouseID;
  40236. /**
  40237. * Abstract mesh the behavior is set on
  40238. */
  40239. attachedNode: AbstractMesh;
  40240. private _dragPlane;
  40241. private _scene;
  40242. private _pointerObserver;
  40243. private _beforeRenderObserver;
  40244. private static _planeScene;
  40245. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40246. /**
  40247. * 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)
  40248. */
  40249. maxDragAngle: number;
  40250. /**
  40251. * @hidden
  40252. */
  40253. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40254. /**
  40255. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40256. */
  40257. currentDraggingPointerID: number;
  40258. /**
  40259. * The last position where the pointer hit the drag plane in world space
  40260. */
  40261. lastDragPosition: Vector3;
  40262. /**
  40263. * If the behavior is currently in a dragging state
  40264. */
  40265. dragging: boolean;
  40266. /**
  40267. * 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)
  40268. */
  40269. dragDeltaRatio: number;
  40270. /**
  40271. * If the drag plane orientation should be updated during the dragging (Default: true)
  40272. */
  40273. updateDragPlane: boolean;
  40274. private _debugMode;
  40275. private _moving;
  40276. /**
  40277. * Fires each time the attached mesh is dragged with the pointer
  40278. * * delta between last drag position and current drag position in world space
  40279. * * dragDistance along the drag axis
  40280. * * dragPlaneNormal normal of the current drag plane used during the drag
  40281. * * dragPlanePoint in world space where the drag intersects the drag plane
  40282. */
  40283. onDragObservable: Observable<{
  40284. delta: Vector3;
  40285. dragPlanePoint: Vector3;
  40286. dragPlaneNormal: Vector3;
  40287. dragDistance: number;
  40288. pointerId: number;
  40289. }>;
  40290. /**
  40291. * Fires each time a drag begins (eg. mouse down on mesh)
  40292. */
  40293. onDragStartObservable: Observable<{
  40294. dragPlanePoint: Vector3;
  40295. pointerId: number;
  40296. }>;
  40297. /**
  40298. * Fires each time a drag ends (eg. mouse release after drag)
  40299. */
  40300. onDragEndObservable: Observable<{
  40301. dragPlanePoint: Vector3;
  40302. pointerId: number;
  40303. }>;
  40304. /**
  40305. * If the attached mesh should be moved when dragged
  40306. */
  40307. moveAttached: boolean;
  40308. /**
  40309. * If the drag behavior will react to drag events (Default: true)
  40310. */
  40311. enabled: boolean;
  40312. /**
  40313. * If pointer events should start and release the drag (Default: true)
  40314. */
  40315. startAndReleaseDragOnPointerEvents: boolean;
  40316. /**
  40317. * If camera controls should be detached during the drag
  40318. */
  40319. detachCameraControls: boolean;
  40320. /**
  40321. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40322. */
  40323. useObjectOrientationForDragging: boolean;
  40324. private _options;
  40325. /**
  40326. * Gets the options used by the behavior
  40327. */
  40328. get options(): {
  40329. dragAxis?: Vector3;
  40330. dragPlaneNormal?: Vector3;
  40331. };
  40332. /**
  40333. * Sets the options used by the behavior
  40334. */
  40335. set options(options: {
  40336. dragAxis?: Vector3;
  40337. dragPlaneNormal?: Vector3;
  40338. });
  40339. /**
  40340. * Creates a pointer drag behavior that can be attached to a mesh
  40341. * @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)
  40342. */
  40343. constructor(options?: {
  40344. dragAxis?: Vector3;
  40345. dragPlaneNormal?: Vector3;
  40346. });
  40347. /**
  40348. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40349. */
  40350. validateDrag: (targetPosition: Vector3) => boolean;
  40351. /**
  40352. * The name of the behavior
  40353. */
  40354. get name(): string;
  40355. /**
  40356. * Initializes the behavior
  40357. */
  40358. init(): void;
  40359. private _tmpVector;
  40360. private _alternatePickedPoint;
  40361. private _worldDragAxis;
  40362. private _targetPosition;
  40363. private _attachedElement;
  40364. /**
  40365. * Attaches the drag behavior the passed in mesh
  40366. * @param ownerNode The mesh that will be dragged around once attached
  40367. * @param predicate Predicate to use for pick filtering
  40368. */
  40369. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40370. /**
  40371. * Force relase the drag action by code.
  40372. */
  40373. releaseDrag(): void;
  40374. private _startDragRay;
  40375. private _lastPointerRay;
  40376. /**
  40377. * Simulates the start of a pointer drag event on the behavior
  40378. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40379. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40380. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40381. */
  40382. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40383. private _startDrag;
  40384. private _dragDelta;
  40385. private _moveDrag;
  40386. private _pickWithRayOnDragPlane;
  40387. private _pointA;
  40388. private _pointB;
  40389. private _pointC;
  40390. private _lineA;
  40391. private _lineB;
  40392. private _localAxis;
  40393. private _lookAt;
  40394. private _updateDragPlanePosition;
  40395. /**
  40396. * Detaches the behavior from the mesh
  40397. */
  40398. detach(): void;
  40399. }
  40400. }
  40401. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40402. import { Mesh } from "babylonjs/Meshes/mesh";
  40403. import { Behavior } from "babylonjs/Behaviors/behavior";
  40404. /**
  40405. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40406. */
  40407. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40408. private _dragBehaviorA;
  40409. private _dragBehaviorB;
  40410. private _startDistance;
  40411. private _initialScale;
  40412. private _targetScale;
  40413. private _ownerNode;
  40414. private _sceneRenderObserver;
  40415. /**
  40416. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40417. */
  40418. constructor();
  40419. /**
  40420. * The name of the behavior
  40421. */
  40422. get name(): string;
  40423. /**
  40424. * Initializes the behavior
  40425. */
  40426. init(): void;
  40427. private _getCurrentDistance;
  40428. /**
  40429. * Attaches the scale behavior the passed in mesh
  40430. * @param ownerNode The mesh that will be scaled around once attached
  40431. */
  40432. attach(ownerNode: Mesh): void;
  40433. /**
  40434. * Detaches the behavior from the mesh
  40435. */
  40436. detach(): void;
  40437. }
  40438. }
  40439. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40440. import { Behavior } from "babylonjs/Behaviors/behavior";
  40441. import { Mesh } from "babylonjs/Meshes/mesh";
  40442. import { Observable } from "babylonjs/Misc/observable";
  40443. /**
  40444. * 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
  40445. */
  40446. export class SixDofDragBehavior implements Behavior<Mesh> {
  40447. private static _virtualScene;
  40448. private _ownerNode;
  40449. private _sceneRenderObserver;
  40450. private _scene;
  40451. private _targetPosition;
  40452. private _virtualOriginMesh;
  40453. private _virtualDragMesh;
  40454. private _pointerObserver;
  40455. private _moving;
  40456. private _startingOrientation;
  40457. /**
  40458. * 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)
  40459. */
  40460. private zDragFactor;
  40461. /**
  40462. * If the object should rotate to face the drag origin
  40463. */
  40464. rotateDraggedObject: boolean;
  40465. /**
  40466. * If the behavior is currently in a dragging state
  40467. */
  40468. dragging: boolean;
  40469. /**
  40470. * 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)
  40471. */
  40472. dragDeltaRatio: number;
  40473. /**
  40474. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40475. */
  40476. currentDraggingPointerID: number;
  40477. /**
  40478. * If camera controls should be detached during the drag
  40479. */
  40480. detachCameraControls: boolean;
  40481. /**
  40482. * Fires each time a drag starts
  40483. */
  40484. onDragStartObservable: Observable<{}>;
  40485. /**
  40486. * Fires each time a drag ends (eg. mouse release after drag)
  40487. */
  40488. onDragEndObservable: Observable<{}>;
  40489. /**
  40490. * 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
  40491. */
  40492. constructor();
  40493. /**
  40494. * The name of the behavior
  40495. */
  40496. get name(): string;
  40497. /**
  40498. * Initializes the behavior
  40499. */
  40500. init(): void;
  40501. /**
  40502. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40503. */
  40504. private get _pointerCamera();
  40505. /**
  40506. * Attaches the scale behavior the passed in mesh
  40507. * @param ownerNode The mesh that will be scaled around once attached
  40508. */
  40509. attach(ownerNode: Mesh): void;
  40510. /**
  40511. * Detaches the behavior from the mesh
  40512. */
  40513. detach(): void;
  40514. }
  40515. }
  40516. declare module "babylonjs/Behaviors/Meshes/index" {
  40517. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40518. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40519. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40520. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40521. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40522. }
  40523. declare module "babylonjs/Behaviors/index" {
  40524. export * from "babylonjs/Behaviors/behavior";
  40525. export * from "babylonjs/Behaviors/Cameras/index";
  40526. export * from "babylonjs/Behaviors/Meshes/index";
  40527. }
  40528. declare module "babylonjs/Bones/boneIKController" {
  40529. import { Bone } from "babylonjs/Bones/bone";
  40530. import { Vector3 } from "babylonjs/Maths/math.vector";
  40531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40532. import { Nullable } from "babylonjs/types";
  40533. /**
  40534. * Class used to apply inverse kinematics to bones
  40535. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40536. */
  40537. export class BoneIKController {
  40538. private static _tmpVecs;
  40539. private static _tmpQuat;
  40540. private static _tmpMats;
  40541. /**
  40542. * Gets or sets the target mesh
  40543. */
  40544. targetMesh: AbstractMesh;
  40545. /** Gets or sets the mesh used as pole */
  40546. poleTargetMesh: AbstractMesh;
  40547. /**
  40548. * Gets or sets the bone used as pole
  40549. */
  40550. poleTargetBone: Nullable<Bone>;
  40551. /**
  40552. * Gets or sets the target position
  40553. */
  40554. targetPosition: Vector3;
  40555. /**
  40556. * Gets or sets the pole target position
  40557. */
  40558. poleTargetPosition: Vector3;
  40559. /**
  40560. * Gets or sets the pole target local offset
  40561. */
  40562. poleTargetLocalOffset: Vector3;
  40563. /**
  40564. * Gets or sets the pole angle
  40565. */
  40566. poleAngle: number;
  40567. /**
  40568. * Gets or sets the mesh associated with the controller
  40569. */
  40570. mesh: AbstractMesh;
  40571. /**
  40572. * 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)
  40573. */
  40574. slerpAmount: number;
  40575. private _bone1Quat;
  40576. private _bone1Mat;
  40577. private _bone2Ang;
  40578. private _bone1;
  40579. private _bone2;
  40580. private _bone1Length;
  40581. private _bone2Length;
  40582. private _maxAngle;
  40583. private _maxReach;
  40584. private _rightHandedSystem;
  40585. private _bendAxis;
  40586. private _slerping;
  40587. private _adjustRoll;
  40588. /**
  40589. * Gets or sets maximum allowed angle
  40590. */
  40591. get maxAngle(): number;
  40592. set maxAngle(value: number);
  40593. /**
  40594. * Creates a new BoneIKController
  40595. * @param mesh defines the mesh to control
  40596. * @param bone defines the bone to control
  40597. * @param options defines options to set up the controller
  40598. */
  40599. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40600. targetMesh?: AbstractMesh;
  40601. poleTargetMesh?: AbstractMesh;
  40602. poleTargetBone?: Bone;
  40603. poleTargetLocalOffset?: Vector3;
  40604. poleAngle?: number;
  40605. bendAxis?: Vector3;
  40606. maxAngle?: number;
  40607. slerpAmount?: number;
  40608. });
  40609. private _setMaxAngle;
  40610. /**
  40611. * Force the controller to update the bones
  40612. */
  40613. update(): void;
  40614. }
  40615. }
  40616. declare module "babylonjs/Bones/boneLookController" {
  40617. import { Vector3 } from "babylonjs/Maths/math.vector";
  40618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40619. import { Bone } from "babylonjs/Bones/bone";
  40620. import { Space } from "babylonjs/Maths/math.axis";
  40621. /**
  40622. * Class used to make a bone look toward a point in space
  40623. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40624. */
  40625. export class BoneLookController {
  40626. private static _tmpVecs;
  40627. private static _tmpQuat;
  40628. private static _tmpMats;
  40629. /**
  40630. * The target Vector3 that the bone will look at
  40631. */
  40632. target: Vector3;
  40633. /**
  40634. * The mesh that the bone is attached to
  40635. */
  40636. mesh: AbstractMesh;
  40637. /**
  40638. * The bone that will be looking to the target
  40639. */
  40640. bone: Bone;
  40641. /**
  40642. * The up axis of the coordinate system that is used when the bone is rotated
  40643. */
  40644. upAxis: Vector3;
  40645. /**
  40646. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40647. */
  40648. upAxisSpace: Space;
  40649. /**
  40650. * Used to make an adjustment to the yaw of the bone
  40651. */
  40652. adjustYaw: number;
  40653. /**
  40654. * Used to make an adjustment to the pitch of the bone
  40655. */
  40656. adjustPitch: number;
  40657. /**
  40658. * Used to make an adjustment to the roll of the bone
  40659. */
  40660. adjustRoll: number;
  40661. /**
  40662. * 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)
  40663. */
  40664. slerpAmount: number;
  40665. private _minYaw;
  40666. private _maxYaw;
  40667. private _minPitch;
  40668. private _maxPitch;
  40669. private _minYawSin;
  40670. private _minYawCos;
  40671. private _maxYawSin;
  40672. private _maxYawCos;
  40673. private _midYawConstraint;
  40674. private _minPitchTan;
  40675. private _maxPitchTan;
  40676. private _boneQuat;
  40677. private _slerping;
  40678. private _transformYawPitch;
  40679. private _transformYawPitchInv;
  40680. private _firstFrameSkipped;
  40681. private _yawRange;
  40682. private _fowardAxis;
  40683. /**
  40684. * Gets or sets the minimum yaw angle that the bone can look to
  40685. */
  40686. get minYaw(): number;
  40687. set minYaw(value: number);
  40688. /**
  40689. * Gets or sets the maximum yaw angle that the bone can look to
  40690. */
  40691. get maxYaw(): number;
  40692. set maxYaw(value: number);
  40693. /**
  40694. * Gets or sets the minimum pitch angle that the bone can look to
  40695. */
  40696. get minPitch(): number;
  40697. set minPitch(value: number);
  40698. /**
  40699. * Gets or sets the maximum pitch angle that the bone can look to
  40700. */
  40701. get maxPitch(): number;
  40702. set maxPitch(value: number);
  40703. /**
  40704. * Create a BoneLookController
  40705. * @param mesh the mesh that the bone belongs to
  40706. * @param bone the bone that will be looking to the target
  40707. * @param target the target Vector3 to look at
  40708. * @param options optional settings:
  40709. * * maxYaw: the maximum angle the bone will yaw to
  40710. * * minYaw: the minimum angle the bone will yaw to
  40711. * * maxPitch: the maximum angle the bone will pitch to
  40712. * * minPitch: the minimum angle the bone will yaw to
  40713. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40714. * * upAxis: the up axis of the coordinate system
  40715. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40716. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40717. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40718. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40719. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40720. * * adjustRoll: used to make an adjustment to the roll of the bone
  40721. **/
  40722. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40723. maxYaw?: number;
  40724. minYaw?: number;
  40725. maxPitch?: number;
  40726. minPitch?: number;
  40727. slerpAmount?: number;
  40728. upAxis?: Vector3;
  40729. upAxisSpace?: Space;
  40730. yawAxis?: Vector3;
  40731. pitchAxis?: Vector3;
  40732. adjustYaw?: number;
  40733. adjustPitch?: number;
  40734. adjustRoll?: number;
  40735. });
  40736. /**
  40737. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40738. */
  40739. update(): void;
  40740. private _getAngleDiff;
  40741. private _getAngleBetween;
  40742. private _isAngleBetween;
  40743. }
  40744. }
  40745. declare module "babylonjs/Bones/index" {
  40746. export * from "babylonjs/Bones/bone";
  40747. export * from "babylonjs/Bones/boneIKController";
  40748. export * from "babylonjs/Bones/boneLookController";
  40749. export * from "babylonjs/Bones/skeleton";
  40750. }
  40751. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40752. import { Nullable } from "babylonjs/types";
  40753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40754. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40755. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40756. /**
  40757. * Manage the gamepad inputs to control an arc rotate camera.
  40758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40759. */
  40760. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40761. /**
  40762. * Defines the camera the input is attached to.
  40763. */
  40764. camera: ArcRotateCamera;
  40765. /**
  40766. * Defines the gamepad the input is gathering event from.
  40767. */
  40768. gamepad: Nullable<Gamepad>;
  40769. /**
  40770. * Defines the gamepad rotation sensiblity.
  40771. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40772. */
  40773. gamepadRotationSensibility: number;
  40774. /**
  40775. * Defines the gamepad move sensiblity.
  40776. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40777. */
  40778. gamepadMoveSensibility: number;
  40779. private _yAxisScale;
  40780. /**
  40781. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40782. */
  40783. get invertYAxis(): boolean;
  40784. set invertYAxis(value: boolean);
  40785. private _onGamepadConnectedObserver;
  40786. private _onGamepadDisconnectedObserver;
  40787. /**
  40788. * Attach the input controls to a specific dom element to get the input from.
  40789. * @param element Defines the element the controls should be listened from
  40790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40791. */
  40792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40793. /**
  40794. * Detach the current controls from the specified dom element.
  40795. * @param element Defines the element to stop listening the inputs from
  40796. */
  40797. detachControl(element: Nullable<HTMLElement>): void;
  40798. /**
  40799. * Update the current camera state depending on the inputs that have been used this frame.
  40800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40801. */
  40802. checkInputs(): void;
  40803. /**
  40804. * Gets the class name of the current intput.
  40805. * @returns the class name
  40806. */
  40807. getClassName(): string;
  40808. /**
  40809. * Get the friendly name associated with the input class.
  40810. * @returns the input friendly name
  40811. */
  40812. getSimpleName(): string;
  40813. }
  40814. }
  40815. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40816. import { Nullable } from "babylonjs/types";
  40817. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40818. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40819. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40820. interface ArcRotateCameraInputsManager {
  40821. /**
  40822. * Add orientation input support to the input manager.
  40823. * @returns the current input manager
  40824. */
  40825. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40826. }
  40827. }
  40828. /**
  40829. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40831. */
  40832. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40833. /**
  40834. * Defines the camera the input is attached to.
  40835. */
  40836. camera: ArcRotateCamera;
  40837. /**
  40838. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40839. */
  40840. alphaCorrection: number;
  40841. /**
  40842. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40843. */
  40844. gammaCorrection: number;
  40845. private _alpha;
  40846. private _gamma;
  40847. private _dirty;
  40848. private _deviceOrientationHandler;
  40849. /**
  40850. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40851. */
  40852. constructor();
  40853. /**
  40854. * Attach the input controls to a specific dom element to get the input from.
  40855. * @param element Defines the element the controls should be listened from
  40856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40857. */
  40858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40859. /** @hidden */
  40860. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40861. /**
  40862. * Update the current camera state depending on the inputs that have been used this frame.
  40863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40864. */
  40865. checkInputs(): void;
  40866. /**
  40867. * Detach the current controls from the specified dom element.
  40868. * @param element Defines the element to stop listening the inputs from
  40869. */
  40870. detachControl(element: Nullable<HTMLElement>): void;
  40871. /**
  40872. * Gets the class name of the current intput.
  40873. * @returns the class name
  40874. */
  40875. getClassName(): string;
  40876. /**
  40877. * Get the friendly name associated with the input class.
  40878. * @returns the input friendly name
  40879. */
  40880. getSimpleName(): string;
  40881. }
  40882. }
  40883. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40884. import { Nullable } from "babylonjs/types";
  40885. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40886. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40887. /**
  40888. * Listen to mouse events to control the camera.
  40889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40890. */
  40891. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40892. /**
  40893. * Defines the camera the input is attached to.
  40894. */
  40895. camera: FlyCamera;
  40896. /**
  40897. * Defines if touch is enabled. (Default is true.)
  40898. */
  40899. touchEnabled: boolean;
  40900. /**
  40901. * Defines the buttons associated with the input to handle camera rotation.
  40902. */
  40903. buttons: number[];
  40904. /**
  40905. * Assign buttons for Yaw control.
  40906. */
  40907. buttonsYaw: number[];
  40908. /**
  40909. * Assign buttons for Pitch control.
  40910. */
  40911. buttonsPitch: number[];
  40912. /**
  40913. * Assign buttons for Roll control.
  40914. */
  40915. buttonsRoll: number[];
  40916. /**
  40917. * Detect if any button is being pressed while mouse is moved.
  40918. * -1 = Mouse locked.
  40919. * 0 = Left button.
  40920. * 1 = Middle Button.
  40921. * 2 = Right Button.
  40922. */
  40923. activeButton: number;
  40924. /**
  40925. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40926. * Higher values reduce its sensitivity.
  40927. */
  40928. angularSensibility: number;
  40929. private _mousemoveCallback;
  40930. private _observer;
  40931. private _rollObserver;
  40932. private previousPosition;
  40933. private noPreventDefault;
  40934. private element;
  40935. /**
  40936. * Listen to mouse events to control the camera.
  40937. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40939. */
  40940. constructor(touchEnabled?: boolean);
  40941. /**
  40942. * Attach the mouse control to the HTML DOM element.
  40943. * @param element Defines the element that listens to the input events.
  40944. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40945. */
  40946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40947. /**
  40948. * Detach the current controls from the specified dom element.
  40949. * @param element Defines the element to stop listening the inputs from
  40950. */
  40951. detachControl(element: Nullable<HTMLElement>): void;
  40952. /**
  40953. * Gets the class name of the current input.
  40954. * @returns the class name.
  40955. */
  40956. getClassName(): string;
  40957. /**
  40958. * Get the friendly name associated with the input class.
  40959. * @returns the input's friendly name.
  40960. */
  40961. getSimpleName(): string;
  40962. private _pointerInput;
  40963. private _onMouseMove;
  40964. /**
  40965. * Rotate camera by mouse offset.
  40966. */
  40967. private rotateCamera;
  40968. }
  40969. }
  40970. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40971. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40972. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40973. /**
  40974. * Default Inputs manager for the FlyCamera.
  40975. * It groups all the default supported inputs for ease of use.
  40976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40977. */
  40978. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40979. /**
  40980. * Instantiates a new FlyCameraInputsManager.
  40981. * @param camera Defines the camera the inputs belong to.
  40982. */
  40983. constructor(camera: FlyCamera);
  40984. /**
  40985. * Add keyboard input support to the input manager.
  40986. * @returns the new FlyCameraKeyboardMoveInput().
  40987. */
  40988. addKeyboard(): FlyCameraInputsManager;
  40989. /**
  40990. * Add mouse input support to the input manager.
  40991. * @param touchEnabled Enable touch screen support.
  40992. * @returns the new FlyCameraMouseInput().
  40993. */
  40994. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40995. }
  40996. }
  40997. declare module "babylonjs/Cameras/flyCamera" {
  40998. import { Scene } from "babylonjs/scene";
  40999. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41001. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41002. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41003. /**
  41004. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41005. * such as in a 3D Space Shooter or a Flight Simulator.
  41006. */
  41007. export class FlyCamera extends TargetCamera {
  41008. /**
  41009. * Define the collision ellipsoid of the camera.
  41010. * This is helpful for simulating a camera body, like a player's body.
  41011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41012. */
  41013. ellipsoid: Vector3;
  41014. /**
  41015. * Define an offset for the position of the ellipsoid around the camera.
  41016. * This can be helpful if the camera is attached away from the player's body center,
  41017. * such as at its head.
  41018. */
  41019. ellipsoidOffset: Vector3;
  41020. /**
  41021. * Enable or disable collisions of the camera with the rest of the scene objects.
  41022. */
  41023. checkCollisions: boolean;
  41024. /**
  41025. * Enable or disable gravity on the camera.
  41026. */
  41027. applyGravity: boolean;
  41028. /**
  41029. * Define the current direction the camera is moving to.
  41030. */
  41031. cameraDirection: Vector3;
  41032. /**
  41033. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41034. * This overrides and empties cameraRotation.
  41035. */
  41036. rotationQuaternion: Quaternion;
  41037. /**
  41038. * Track Roll to maintain the wanted Rolling when looking around.
  41039. */
  41040. _trackRoll: number;
  41041. /**
  41042. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41043. */
  41044. rollCorrect: number;
  41045. /**
  41046. * Mimic a banked turn, Rolling the camera when Yawing.
  41047. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41048. */
  41049. bankedTurn: boolean;
  41050. /**
  41051. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41052. */
  41053. bankedTurnLimit: number;
  41054. /**
  41055. * Value of 0 disables the banked Roll.
  41056. * Value of 1 is equal to the Yaw angle in radians.
  41057. */
  41058. bankedTurnMultiplier: number;
  41059. /**
  41060. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41061. */
  41062. inputs: FlyCameraInputsManager;
  41063. /**
  41064. * Gets the input sensibility for mouse input.
  41065. * Higher values reduce sensitivity.
  41066. */
  41067. get angularSensibility(): number;
  41068. /**
  41069. * Sets the input sensibility for a mouse input.
  41070. * Higher values reduce sensitivity.
  41071. */
  41072. set angularSensibility(value: number);
  41073. /**
  41074. * Get the keys for camera movement forward.
  41075. */
  41076. get keysForward(): number[];
  41077. /**
  41078. * Set the keys for camera movement forward.
  41079. */
  41080. set keysForward(value: number[]);
  41081. /**
  41082. * Get the keys for camera movement backward.
  41083. */
  41084. get keysBackward(): number[];
  41085. set keysBackward(value: number[]);
  41086. /**
  41087. * Get the keys for camera movement up.
  41088. */
  41089. get keysUp(): number[];
  41090. /**
  41091. * Set the keys for camera movement up.
  41092. */
  41093. set keysUp(value: number[]);
  41094. /**
  41095. * Get the keys for camera movement down.
  41096. */
  41097. get keysDown(): number[];
  41098. /**
  41099. * Set the keys for camera movement down.
  41100. */
  41101. set keysDown(value: number[]);
  41102. /**
  41103. * Get the keys for camera movement left.
  41104. */
  41105. get keysLeft(): number[];
  41106. /**
  41107. * Set the keys for camera movement left.
  41108. */
  41109. set keysLeft(value: number[]);
  41110. /**
  41111. * Set the keys for camera movement right.
  41112. */
  41113. get keysRight(): number[];
  41114. /**
  41115. * Set the keys for camera movement right.
  41116. */
  41117. set keysRight(value: number[]);
  41118. /**
  41119. * Event raised when the camera collides with a mesh in the scene.
  41120. */
  41121. onCollide: (collidedMesh: AbstractMesh) => void;
  41122. private _collider;
  41123. private _needMoveForGravity;
  41124. private _oldPosition;
  41125. private _diffPosition;
  41126. private _newPosition;
  41127. /** @hidden */
  41128. _localDirection: Vector3;
  41129. /** @hidden */
  41130. _transformedDirection: Vector3;
  41131. /**
  41132. * Instantiates a FlyCamera.
  41133. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41134. * such as in a 3D Space Shooter or a Flight Simulator.
  41135. * @param name Define the name of the camera in the scene.
  41136. * @param position Define the starting position of the camera in the scene.
  41137. * @param scene Define the scene the camera belongs to.
  41138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41139. */
  41140. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41141. /**
  41142. * Attach a control to the HTML DOM element.
  41143. * @param element Defines the element that listens to the input events.
  41144. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41145. */
  41146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41147. /**
  41148. * Detach a control from the HTML DOM element.
  41149. * The camera will stop reacting to that input.
  41150. * @param element Defines the element that listens to the input events.
  41151. */
  41152. detachControl(element: HTMLElement): void;
  41153. private _collisionMask;
  41154. /**
  41155. * Get the mask that the camera ignores in collision events.
  41156. */
  41157. get collisionMask(): number;
  41158. /**
  41159. * Set the mask that the camera ignores in collision events.
  41160. */
  41161. set collisionMask(mask: number);
  41162. /** @hidden */
  41163. _collideWithWorld(displacement: Vector3): void;
  41164. /** @hidden */
  41165. private _onCollisionPositionChange;
  41166. /** @hidden */
  41167. _checkInputs(): void;
  41168. /** @hidden */
  41169. _decideIfNeedsToMove(): boolean;
  41170. /** @hidden */
  41171. _updatePosition(): void;
  41172. /**
  41173. * Restore the Roll to its target value at the rate specified.
  41174. * @param rate - Higher means slower restoring.
  41175. * @hidden
  41176. */
  41177. restoreRoll(rate: number): void;
  41178. /**
  41179. * Destroy the camera and release the current resources held by it.
  41180. */
  41181. dispose(): void;
  41182. /**
  41183. * Get the current object class name.
  41184. * @returns the class name.
  41185. */
  41186. getClassName(): string;
  41187. }
  41188. }
  41189. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41190. import { Nullable } from "babylonjs/types";
  41191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41192. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41193. /**
  41194. * Listen to keyboard events to control the camera.
  41195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41196. */
  41197. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41198. /**
  41199. * Defines the camera the input is attached to.
  41200. */
  41201. camera: FlyCamera;
  41202. /**
  41203. * The list of keyboard keys used to control the forward move of the camera.
  41204. */
  41205. keysForward: number[];
  41206. /**
  41207. * The list of keyboard keys used to control the backward move of the camera.
  41208. */
  41209. keysBackward: number[];
  41210. /**
  41211. * The list of keyboard keys used to control the forward move of the camera.
  41212. */
  41213. keysUp: number[];
  41214. /**
  41215. * The list of keyboard keys used to control the backward move of the camera.
  41216. */
  41217. keysDown: number[];
  41218. /**
  41219. * The list of keyboard keys used to control the right strafe move of the camera.
  41220. */
  41221. keysRight: number[];
  41222. /**
  41223. * The list of keyboard keys used to control the left strafe move of the camera.
  41224. */
  41225. keysLeft: number[];
  41226. private _keys;
  41227. private _onCanvasBlurObserver;
  41228. private _onKeyboardObserver;
  41229. private _engine;
  41230. private _scene;
  41231. /**
  41232. * Attach the input controls to a specific dom element to get the input from.
  41233. * @param element Defines the element the controls should be listened from
  41234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41235. */
  41236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41237. /**
  41238. * Detach the current controls from the specified dom element.
  41239. * @param element Defines the element to stop listening the inputs from
  41240. */
  41241. detachControl(element: Nullable<HTMLElement>): void;
  41242. /**
  41243. * Gets the class name of the current intput.
  41244. * @returns the class name
  41245. */
  41246. getClassName(): string;
  41247. /** @hidden */
  41248. _onLostFocus(e: FocusEvent): void;
  41249. /**
  41250. * Get the friendly name associated with the input class.
  41251. * @returns the input friendly name
  41252. */
  41253. getSimpleName(): string;
  41254. /**
  41255. * Update the current camera state depending on the inputs that have been used this frame.
  41256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41257. */
  41258. checkInputs(): void;
  41259. }
  41260. }
  41261. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41262. import { Nullable } from "babylonjs/types";
  41263. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41264. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41265. /**
  41266. * Manage the mouse wheel inputs to control a follow camera.
  41267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41268. */
  41269. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41270. /**
  41271. * Defines the camera the input is attached to.
  41272. */
  41273. camera: FollowCamera;
  41274. /**
  41275. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41276. */
  41277. axisControlRadius: boolean;
  41278. /**
  41279. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41280. */
  41281. axisControlHeight: boolean;
  41282. /**
  41283. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41284. */
  41285. axisControlRotation: boolean;
  41286. /**
  41287. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41288. * relation to mouseWheel events.
  41289. */
  41290. wheelPrecision: number;
  41291. /**
  41292. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41293. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41294. */
  41295. wheelDeltaPercentage: number;
  41296. private _wheel;
  41297. private _observer;
  41298. /**
  41299. * Attach the input controls to a specific dom element to get the input from.
  41300. * @param element Defines the element the controls should be listened from
  41301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41302. */
  41303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41304. /**
  41305. * Detach the current controls from the specified dom element.
  41306. * @param element Defines the element to stop listening the inputs from
  41307. */
  41308. detachControl(element: Nullable<HTMLElement>): void;
  41309. /**
  41310. * Gets the class name of the current intput.
  41311. * @returns the class name
  41312. */
  41313. getClassName(): string;
  41314. /**
  41315. * Get the friendly name associated with the input class.
  41316. * @returns the input friendly name
  41317. */
  41318. getSimpleName(): string;
  41319. }
  41320. }
  41321. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41322. import { Nullable } from "babylonjs/types";
  41323. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41324. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41325. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41326. /**
  41327. * Manage the pointers inputs to control an follow camera.
  41328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41329. */
  41330. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41331. /**
  41332. * Defines the camera the input is attached to.
  41333. */
  41334. camera: FollowCamera;
  41335. /**
  41336. * Gets the class name of the current input.
  41337. * @returns the class name
  41338. */
  41339. getClassName(): string;
  41340. /**
  41341. * Defines the pointer angular sensibility along the X axis or how fast is
  41342. * the camera rotating.
  41343. * A negative number will reverse the axis direction.
  41344. */
  41345. angularSensibilityX: number;
  41346. /**
  41347. * Defines the pointer angular sensibility along the Y axis or how fast is
  41348. * the camera rotating.
  41349. * A negative number will reverse the axis direction.
  41350. */
  41351. angularSensibilityY: number;
  41352. /**
  41353. * Defines the pointer pinch precision or how fast is the camera zooming.
  41354. * A negative number will reverse the axis direction.
  41355. */
  41356. pinchPrecision: number;
  41357. /**
  41358. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41359. * from 0.
  41360. * It defines the percentage of current camera.radius to use as delta when
  41361. * pinch zoom is used.
  41362. */
  41363. pinchDeltaPercentage: number;
  41364. /**
  41365. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41366. */
  41367. axisXControlRadius: boolean;
  41368. /**
  41369. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41370. */
  41371. axisXControlHeight: boolean;
  41372. /**
  41373. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41374. */
  41375. axisXControlRotation: boolean;
  41376. /**
  41377. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41378. */
  41379. axisYControlRadius: boolean;
  41380. /**
  41381. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41382. */
  41383. axisYControlHeight: boolean;
  41384. /**
  41385. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41386. */
  41387. axisYControlRotation: boolean;
  41388. /**
  41389. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41390. */
  41391. axisPinchControlRadius: boolean;
  41392. /**
  41393. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41394. */
  41395. axisPinchControlHeight: boolean;
  41396. /**
  41397. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41398. */
  41399. axisPinchControlRotation: boolean;
  41400. /**
  41401. * Log error messages if basic misconfiguration has occurred.
  41402. */
  41403. warningEnable: boolean;
  41404. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41405. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41406. private _warningCounter;
  41407. private _warning;
  41408. }
  41409. }
  41410. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41411. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41412. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41413. /**
  41414. * Default Inputs manager for the FollowCamera.
  41415. * It groups all the default supported inputs for ease of use.
  41416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41417. */
  41418. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41419. /**
  41420. * Instantiates a new FollowCameraInputsManager.
  41421. * @param camera Defines the camera the inputs belong to
  41422. */
  41423. constructor(camera: FollowCamera);
  41424. /**
  41425. * Add keyboard input support to the input manager.
  41426. * @returns the current input manager
  41427. */
  41428. addKeyboard(): FollowCameraInputsManager;
  41429. /**
  41430. * Add mouse wheel input support to the input manager.
  41431. * @returns the current input manager
  41432. */
  41433. addMouseWheel(): FollowCameraInputsManager;
  41434. /**
  41435. * Add pointers input support to the input manager.
  41436. * @returns the current input manager
  41437. */
  41438. addPointers(): FollowCameraInputsManager;
  41439. /**
  41440. * Add orientation input support to the input manager.
  41441. * @returns the current input manager
  41442. */
  41443. addVRDeviceOrientation(): FollowCameraInputsManager;
  41444. }
  41445. }
  41446. declare module "babylonjs/Cameras/followCamera" {
  41447. import { Nullable } from "babylonjs/types";
  41448. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41449. import { Scene } from "babylonjs/scene";
  41450. import { Vector3 } from "babylonjs/Maths/math.vector";
  41451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41452. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41453. /**
  41454. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41455. * an arc rotate version arcFollowCamera are available.
  41456. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41457. */
  41458. export class FollowCamera extends TargetCamera {
  41459. /**
  41460. * Distance the follow camera should follow an object at
  41461. */
  41462. radius: number;
  41463. /**
  41464. * Minimum allowed distance of the camera to the axis of rotation
  41465. * (The camera can not get closer).
  41466. * This can help limiting how the Camera is able to move in the scene.
  41467. */
  41468. lowerRadiusLimit: Nullable<number>;
  41469. /**
  41470. * Maximum allowed distance of the camera to the axis of rotation
  41471. * (The camera can not get further).
  41472. * This can help limiting how the Camera is able to move in the scene.
  41473. */
  41474. upperRadiusLimit: Nullable<number>;
  41475. /**
  41476. * Define a rotation offset between the camera and the object it follows
  41477. */
  41478. rotationOffset: number;
  41479. /**
  41480. * Minimum allowed angle to camera position relative to target object.
  41481. * This can help limiting how the Camera is able to move in the scene.
  41482. */
  41483. lowerRotationOffsetLimit: Nullable<number>;
  41484. /**
  41485. * Maximum allowed angle to camera position relative to target object.
  41486. * This can help limiting how the Camera is able to move in the scene.
  41487. */
  41488. upperRotationOffsetLimit: Nullable<number>;
  41489. /**
  41490. * Define a height offset between the camera and the object it follows.
  41491. * It can help following an object from the top (like a car chaing a plane)
  41492. */
  41493. heightOffset: number;
  41494. /**
  41495. * Minimum allowed height of camera position relative to target object.
  41496. * This can help limiting how the Camera is able to move in the scene.
  41497. */
  41498. lowerHeightOffsetLimit: Nullable<number>;
  41499. /**
  41500. * Maximum allowed height of camera position relative to target object.
  41501. * This can help limiting how the Camera is able to move in the scene.
  41502. */
  41503. upperHeightOffsetLimit: Nullable<number>;
  41504. /**
  41505. * Define how fast the camera can accelerate to follow it s target.
  41506. */
  41507. cameraAcceleration: number;
  41508. /**
  41509. * Define the speed limit of the camera following an object.
  41510. */
  41511. maxCameraSpeed: number;
  41512. /**
  41513. * Define the target of the camera.
  41514. */
  41515. lockedTarget: Nullable<AbstractMesh>;
  41516. /**
  41517. * Defines the input associated with the camera.
  41518. */
  41519. inputs: FollowCameraInputsManager;
  41520. /**
  41521. * Instantiates the follow camera.
  41522. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41523. * @param name Define the name of the camera in the scene
  41524. * @param position Define the position of the camera
  41525. * @param scene Define the scene the camera belong to
  41526. * @param lockedTarget Define the target of the camera
  41527. */
  41528. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41529. private _follow;
  41530. /**
  41531. * Attached controls to the current camera.
  41532. * @param element Defines the element the controls should be listened from
  41533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41534. */
  41535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41536. /**
  41537. * Detach the current controls from the camera.
  41538. * The camera will stop reacting to inputs.
  41539. * @param element Defines the element to stop listening the inputs from
  41540. */
  41541. detachControl(element: HTMLElement): void;
  41542. /** @hidden */
  41543. _checkInputs(): void;
  41544. private _checkLimits;
  41545. /**
  41546. * Gets the camera class name.
  41547. * @returns the class name
  41548. */
  41549. getClassName(): string;
  41550. }
  41551. /**
  41552. * Arc Rotate version of the follow camera.
  41553. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41554. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41555. */
  41556. export class ArcFollowCamera extends TargetCamera {
  41557. /** The longitudinal angle of the camera */
  41558. alpha: number;
  41559. /** The latitudinal angle of the camera */
  41560. beta: number;
  41561. /** The radius of the camera from its target */
  41562. radius: number;
  41563. /** Define the camera target (the messh it should follow) */
  41564. target: Nullable<AbstractMesh>;
  41565. private _cartesianCoordinates;
  41566. /**
  41567. * Instantiates a new ArcFollowCamera
  41568. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41569. * @param name Define the name of the camera
  41570. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41571. * @param beta Define the rotation angle of the camera around the elevation axis
  41572. * @param radius Define the radius of the camera from its target point
  41573. * @param target Define the target of the camera
  41574. * @param scene Define the scene the camera belongs to
  41575. */
  41576. constructor(name: string,
  41577. /** The longitudinal angle of the camera */
  41578. alpha: number,
  41579. /** The latitudinal angle of the camera */
  41580. beta: number,
  41581. /** The radius of the camera from its target */
  41582. radius: number,
  41583. /** Define the camera target (the messh it should follow) */
  41584. target: Nullable<AbstractMesh>, scene: Scene);
  41585. private _follow;
  41586. /** @hidden */
  41587. _checkInputs(): void;
  41588. /**
  41589. * Returns the class name of the object.
  41590. * It is mostly used internally for serialization purposes.
  41591. */
  41592. getClassName(): string;
  41593. }
  41594. }
  41595. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41596. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41597. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41598. import { Nullable } from "babylonjs/types";
  41599. /**
  41600. * Manage the keyboard inputs to control the movement of a follow camera.
  41601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41602. */
  41603. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41604. /**
  41605. * Defines the camera the input is attached to.
  41606. */
  41607. camera: FollowCamera;
  41608. /**
  41609. * Defines the list of key codes associated with the up action (increase heightOffset)
  41610. */
  41611. keysHeightOffsetIncr: number[];
  41612. /**
  41613. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41614. */
  41615. keysHeightOffsetDecr: number[];
  41616. /**
  41617. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41618. */
  41619. keysHeightOffsetModifierAlt: boolean;
  41620. /**
  41621. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41622. */
  41623. keysHeightOffsetModifierCtrl: boolean;
  41624. /**
  41625. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41626. */
  41627. keysHeightOffsetModifierShift: boolean;
  41628. /**
  41629. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41630. */
  41631. keysRotationOffsetIncr: number[];
  41632. /**
  41633. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41634. */
  41635. keysRotationOffsetDecr: number[];
  41636. /**
  41637. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41638. */
  41639. keysRotationOffsetModifierAlt: boolean;
  41640. /**
  41641. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41642. */
  41643. keysRotationOffsetModifierCtrl: boolean;
  41644. /**
  41645. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41646. */
  41647. keysRotationOffsetModifierShift: boolean;
  41648. /**
  41649. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41650. */
  41651. keysRadiusIncr: number[];
  41652. /**
  41653. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41654. */
  41655. keysRadiusDecr: number[];
  41656. /**
  41657. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41658. */
  41659. keysRadiusModifierAlt: boolean;
  41660. /**
  41661. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41662. */
  41663. keysRadiusModifierCtrl: boolean;
  41664. /**
  41665. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41666. */
  41667. keysRadiusModifierShift: boolean;
  41668. /**
  41669. * Defines the rate of change of heightOffset.
  41670. */
  41671. heightSensibility: number;
  41672. /**
  41673. * Defines the rate of change of rotationOffset.
  41674. */
  41675. rotationSensibility: number;
  41676. /**
  41677. * Defines the rate of change of radius.
  41678. */
  41679. radiusSensibility: number;
  41680. private _keys;
  41681. private _ctrlPressed;
  41682. private _altPressed;
  41683. private _shiftPressed;
  41684. private _onCanvasBlurObserver;
  41685. private _onKeyboardObserver;
  41686. private _engine;
  41687. private _scene;
  41688. /**
  41689. * Attach the input controls to a specific dom element to get the input from.
  41690. * @param element Defines the element the controls should be listened from
  41691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41692. */
  41693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41694. /**
  41695. * Detach the current controls from the specified dom element.
  41696. * @param element Defines the element to stop listening the inputs from
  41697. */
  41698. detachControl(element: Nullable<HTMLElement>): void;
  41699. /**
  41700. * Update the current camera state depending on the inputs that have been used this frame.
  41701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41702. */
  41703. checkInputs(): void;
  41704. /**
  41705. * Gets the class name of the current input.
  41706. * @returns the class name
  41707. */
  41708. getClassName(): string;
  41709. /**
  41710. * Get the friendly name associated with the input class.
  41711. * @returns the input friendly name
  41712. */
  41713. getSimpleName(): string;
  41714. /**
  41715. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41716. * allow modification of the heightOffset value.
  41717. */
  41718. private _modifierHeightOffset;
  41719. /**
  41720. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41721. * allow modification of the rotationOffset value.
  41722. */
  41723. private _modifierRotationOffset;
  41724. /**
  41725. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41726. * allow modification of the radius value.
  41727. */
  41728. private _modifierRadius;
  41729. }
  41730. }
  41731. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41732. import { Nullable } from "babylonjs/types";
  41733. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41734. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41735. import { Observable } from "babylonjs/Misc/observable";
  41736. module "babylonjs/Cameras/freeCameraInputsManager" {
  41737. interface FreeCameraInputsManager {
  41738. /**
  41739. * @hidden
  41740. */
  41741. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41742. /**
  41743. * Add orientation input support to the input manager.
  41744. * @returns the current input manager
  41745. */
  41746. addDeviceOrientation(): FreeCameraInputsManager;
  41747. }
  41748. }
  41749. /**
  41750. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41751. * Screen rotation is taken into account.
  41752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41753. */
  41754. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41755. private _camera;
  41756. private _screenOrientationAngle;
  41757. private _constantTranform;
  41758. private _screenQuaternion;
  41759. private _alpha;
  41760. private _beta;
  41761. private _gamma;
  41762. /**
  41763. * Can be used to detect if a device orientation sensor is available on a device
  41764. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41765. * @returns a promise that will resolve on orientation change
  41766. */
  41767. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41768. /**
  41769. * @hidden
  41770. */
  41771. _onDeviceOrientationChangedObservable: Observable<void>;
  41772. /**
  41773. * Instantiates a new input
  41774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41775. */
  41776. constructor();
  41777. /**
  41778. * Define the camera controlled by the input.
  41779. */
  41780. get camera(): FreeCamera;
  41781. set camera(camera: FreeCamera);
  41782. /**
  41783. * Attach the input controls to a specific dom element to get the input from.
  41784. * @param element Defines the element the controls should be listened from
  41785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41786. */
  41787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41788. private _orientationChanged;
  41789. private _deviceOrientation;
  41790. /**
  41791. * Detach the current controls from the specified dom element.
  41792. * @param element Defines the element to stop listening the inputs from
  41793. */
  41794. detachControl(element: Nullable<HTMLElement>): void;
  41795. /**
  41796. * Update the current camera state depending on the inputs that have been used this frame.
  41797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41798. */
  41799. checkInputs(): void;
  41800. /**
  41801. * Gets the class name of the current intput.
  41802. * @returns the class name
  41803. */
  41804. getClassName(): string;
  41805. /**
  41806. * Get the friendly name associated with the input class.
  41807. * @returns the input friendly name
  41808. */
  41809. getSimpleName(): string;
  41810. }
  41811. }
  41812. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41813. import { Nullable } from "babylonjs/types";
  41814. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41815. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41816. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41817. /**
  41818. * Manage the gamepad inputs to control a free camera.
  41819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41820. */
  41821. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41822. /**
  41823. * Define the camera the input is attached to.
  41824. */
  41825. camera: FreeCamera;
  41826. /**
  41827. * Define the Gamepad controlling the input
  41828. */
  41829. gamepad: Nullable<Gamepad>;
  41830. /**
  41831. * Defines the gamepad rotation sensiblity.
  41832. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41833. */
  41834. gamepadAngularSensibility: number;
  41835. /**
  41836. * Defines the gamepad move sensiblity.
  41837. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41838. */
  41839. gamepadMoveSensibility: number;
  41840. private _yAxisScale;
  41841. /**
  41842. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41843. */
  41844. get invertYAxis(): boolean;
  41845. set invertYAxis(value: boolean);
  41846. private _onGamepadConnectedObserver;
  41847. private _onGamepadDisconnectedObserver;
  41848. private _cameraTransform;
  41849. private _deltaTransform;
  41850. private _vector3;
  41851. private _vector2;
  41852. /**
  41853. * Attach the input controls to a specific dom element to get the input from.
  41854. * @param element Defines the element the controls should be listened from
  41855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41856. */
  41857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41858. /**
  41859. * Detach the current controls from the specified dom element.
  41860. * @param element Defines the element to stop listening the inputs from
  41861. */
  41862. detachControl(element: Nullable<HTMLElement>): void;
  41863. /**
  41864. * Update the current camera state depending on the inputs that have been used this frame.
  41865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41866. */
  41867. checkInputs(): void;
  41868. /**
  41869. * Gets the class name of the current intput.
  41870. * @returns the class name
  41871. */
  41872. getClassName(): string;
  41873. /**
  41874. * Get the friendly name associated with the input class.
  41875. * @returns the input friendly name
  41876. */
  41877. getSimpleName(): string;
  41878. }
  41879. }
  41880. declare module "babylonjs/Misc/virtualJoystick" {
  41881. import { Nullable } from "babylonjs/types";
  41882. import { Vector3 } from "babylonjs/Maths/math.vector";
  41883. /**
  41884. * Defines the potential axis of a Joystick
  41885. */
  41886. export enum JoystickAxis {
  41887. /** X axis */
  41888. X = 0,
  41889. /** Y axis */
  41890. Y = 1,
  41891. /** Z axis */
  41892. Z = 2
  41893. }
  41894. /**
  41895. * Class used to define virtual joystick (used in touch mode)
  41896. */
  41897. export class VirtualJoystick {
  41898. /**
  41899. * Gets or sets a boolean indicating that left and right values must be inverted
  41900. */
  41901. reverseLeftRight: boolean;
  41902. /**
  41903. * Gets or sets a boolean indicating that up and down values must be inverted
  41904. */
  41905. reverseUpDown: boolean;
  41906. /**
  41907. * Gets the offset value for the position (ie. the change of the position value)
  41908. */
  41909. deltaPosition: Vector3;
  41910. /**
  41911. * Gets a boolean indicating if the virtual joystick was pressed
  41912. */
  41913. pressed: boolean;
  41914. /**
  41915. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41916. */
  41917. static Canvas: Nullable<HTMLCanvasElement>;
  41918. private static _globalJoystickIndex;
  41919. private static vjCanvasContext;
  41920. private static vjCanvasWidth;
  41921. private static vjCanvasHeight;
  41922. private static halfWidth;
  41923. private _action;
  41924. private _axisTargetedByLeftAndRight;
  41925. private _axisTargetedByUpAndDown;
  41926. private _joystickSensibility;
  41927. private _inversedSensibility;
  41928. private _joystickPointerID;
  41929. private _joystickColor;
  41930. private _joystickPointerPos;
  41931. private _joystickPreviousPointerPos;
  41932. private _joystickPointerStartPos;
  41933. private _deltaJoystickVector;
  41934. private _leftJoystick;
  41935. private _touches;
  41936. private _onPointerDownHandlerRef;
  41937. private _onPointerMoveHandlerRef;
  41938. private _onPointerUpHandlerRef;
  41939. private _onResize;
  41940. /**
  41941. * Creates a new virtual joystick
  41942. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41943. */
  41944. constructor(leftJoystick?: boolean);
  41945. /**
  41946. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41947. * @param newJoystickSensibility defines the new sensibility
  41948. */
  41949. setJoystickSensibility(newJoystickSensibility: number): void;
  41950. private _onPointerDown;
  41951. private _onPointerMove;
  41952. private _onPointerUp;
  41953. /**
  41954. * Change the color of the virtual joystick
  41955. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41956. */
  41957. setJoystickColor(newColor: string): void;
  41958. /**
  41959. * Defines a callback to call when the joystick is touched
  41960. * @param action defines the callback
  41961. */
  41962. setActionOnTouch(action: () => any): void;
  41963. /**
  41964. * Defines which axis you'd like to control for left & right
  41965. * @param axis defines the axis to use
  41966. */
  41967. setAxisForLeftRight(axis: JoystickAxis): void;
  41968. /**
  41969. * Defines which axis you'd like to control for up & down
  41970. * @param axis defines the axis to use
  41971. */
  41972. setAxisForUpDown(axis: JoystickAxis): void;
  41973. private _drawVirtualJoystick;
  41974. /**
  41975. * Release internal HTML canvas
  41976. */
  41977. releaseCanvas(): void;
  41978. }
  41979. }
  41980. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41981. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41982. import { Nullable } from "babylonjs/types";
  41983. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41984. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41985. module "babylonjs/Cameras/freeCameraInputsManager" {
  41986. interface FreeCameraInputsManager {
  41987. /**
  41988. * Add virtual joystick input support to the input manager.
  41989. * @returns the current input manager
  41990. */
  41991. addVirtualJoystick(): FreeCameraInputsManager;
  41992. }
  41993. }
  41994. /**
  41995. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41997. */
  41998. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41999. /**
  42000. * Defines the camera the input is attached to.
  42001. */
  42002. camera: FreeCamera;
  42003. private _leftjoystick;
  42004. private _rightjoystick;
  42005. /**
  42006. * Gets the left stick of the virtual joystick.
  42007. * @returns The virtual Joystick
  42008. */
  42009. getLeftJoystick(): VirtualJoystick;
  42010. /**
  42011. * Gets the right stick of the virtual joystick.
  42012. * @returns The virtual Joystick
  42013. */
  42014. getRightJoystick(): VirtualJoystick;
  42015. /**
  42016. * Update the current camera state depending on the inputs that have been used this frame.
  42017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42018. */
  42019. checkInputs(): void;
  42020. /**
  42021. * Attach the input controls to a specific dom element to get the input from.
  42022. * @param element Defines the element the controls should be listened from
  42023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42024. */
  42025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42026. /**
  42027. * Detach the current controls from the specified dom element.
  42028. * @param element Defines the element to stop listening the inputs from
  42029. */
  42030. detachControl(element: Nullable<HTMLElement>): void;
  42031. /**
  42032. * Gets the class name of the current intput.
  42033. * @returns the class name
  42034. */
  42035. getClassName(): string;
  42036. /**
  42037. * Get the friendly name associated with the input class.
  42038. * @returns the input friendly name
  42039. */
  42040. getSimpleName(): string;
  42041. }
  42042. }
  42043. declare module "babylonjs/Cameras/Inputs/index" {
  42044. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42045. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42046. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42047. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42048. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42049. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42050. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42051. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42052. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42053. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42054. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42055. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42056. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42057. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42058. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42059. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42060. }
  42061. declare module "babylonjs/Cameras/touchCamera" {
  42062. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42063. import { Scene } from "babylonjs/scene";
  42064. import { Vector3 } from "babylonjs/Maths/math.vector";
  42065. /**
  42066. * This represents a FPS type of camera controlled by touch.
  42067. * This is like a universal camera minus the Gamepad controls.
  42068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42069. */
  42070. export class TouchCamera extends FreeCamera {
  42071. /**
  42072. * Defines the touch sensibility for rotation.
  42073. * The higher the faster.
  42074. */
  42075. get touchAngularSensibility(): number;
  42076. set touchAngularSensibility(value: number);
  42077. /**
  42078. * Defines the touch sensibility for move.
  42079. * The higher the faster.
  42080. */
  42081. get touchMoveSensibility(): number;
  42082. set touchMoveSensibility(value: number);
  42083. /**
  42084. * Instantiates a new touch camera.
  42085. * This represents a FPS type of camera controlled by touch.
  42086. * This is like a universal camera minus the Gamepad controls.
  42087. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42088. * @param name Define the name of the camera in the scene
  42089. * @param position Define the start position of the camera in the scene
  42090. * @param scene Define the scene the camera belongs to
  42091. */
  42092. constructor(name: string, position: Vector3, scene: Scene);
  42093. /**
  42094. * Gets the current object class name.
  42095. * @return the class name
  42096. */
  42097. getClassName(): string;
  42098. /** @hidden */
  42099. _setupInputs(): void;
  42100. }
  42101. }
  42102. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42103. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42104. import { Scene } from "babylonjs/scene";
  42105. import { Vector3 } from "babylonjs/Maths/math.vector";
  42106. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42107. import { Axis } from "babylonjs/Maths/math.axis";
  42108. /**
  42109. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42110. * being tilted forward or back and left or right.
  42111. */
  42112. export class DeviceOrientationCamera extends FreeCamera {
  42113. private _initialQuaternion;
  42114. private _quaternionCache;
  42115. private _tmpDragQuaternion;
  42116. private _disablePointerInputWhenUsingDeviceOrientation;
  42117. /**
  42118. * Creates a new device orientation camera
  42119. * @param name The name of the camera
  42120. * @param position The start position camera
  42121. * @param scene The scene the camera belongs to
  42122. */
  42123. constructor(name: string, position: Vector3, scene: Scene);
  42124. /**
  42125. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42126. */
  42127. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42128. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42129. private _dragFactor;
  42130. /**
  42131. * Enabled turning on the y axis when the orientation sensor is active
  42132. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42133. */
  42134. enableHorizontalDragging(dragFactor?: number): void;
  42135. /**
  42136. * Gets the current instance class name ("DeviceOrientationCamera").
  42137. * This helps avoiding instanceof at run time.
  42138. * @returns the class name
  42139. */
  42140. getClassName(): string;
  42141. /**
  42142. * @hidden
  42143. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42144. */
  42145. _checkInputs(): void;
  42146. /**
  42147. * Reset the camera to its default orientation on the specified axis only.
  42148. * @param axis The axis to reset
  42149. */
  42150. resetToCurrentRotation(axis?: Axis): void;
  42151. }
  42152. }
  42153. declare module "babylonjs/Gamepads/xboxGamepad" {
  42154. import { Observable } from "babylonjs/Misc/observable";
  42155. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42156. /**
  42157. * Defines supported buttons for XBox360 compatible gamepads
  42158. */
  42159. export enum Xbox360Button {
  42160. /** A */
  42161. A = 0,
  42162. /** B */
  42163. B = 1,
  42164. /** X */
  42165. X = 2,
  42166. /** Y */
  42167. Y = 3,
  42168. /** Start */
  42169. Start = 4,
  42170. /** Back */
  42171. Back = 5,
  42172. /** Left button */
  42173. LB = 6,
  42174. /** Right button */
  42175. RB = 7,
  42176. /** Left stick */
  42177. LeftStick = 8,
  42178. /** Right stick */
  42179. RightStick = 9
  42180. }
  42181. /** Defines values for XBox360 DPad */
  42182. export enum Xbox360Dpad {
  42183. /** Up */
  42184. Up = 0,
  42185. /** Down */
  42186. Down = 1,
  42187. /** Left */
  42188. Left = 2,
  42189. /** Right */
  42190. Right = 3
  42191. }
  42192. /**
  42193. * Defines a XBox360 gamepad
  42194. */
  42195. export class Xbox360Pad extends Gamepad {
  42196. private _leftTrigger;
  42197. private _rightTrigger;
  42198. private _onlefttriggerchanged;
  42199. private _onrighttriggerchanged;
  42200. private _onbuttondown;
  42201. private _onbuttonup;
  42202. private _ondpaddown;
  42203. private _ondpadup;
  42204. /** Observable raised when a button is pressed */
  42205. onButtonDownObservable: Observable<Xbox360Button>;
  42206. /** Observable raised when a button is released */
  42207. onButtonUpObservable: Observable<Xbox360Button>;
  42208. /** Observable raised when a pad is pressed */
  42209. onPadDownObservable: Observable<Xbox360Dpad>;
  42210. /** Observable raised when a pad is released */
  42211. onPadUpObservable: Observable<Xbox360Dpad>;
  42212. private _buttonA;
  42213. private _buttonB;
  42214. private _buttonX;
  42215. private _buttonY;
  42216. private _buttonBack;
  42217. private _buttonStart;
  42218. private _buttonLB;
  42219. private _buttonRB;
  42220. private _buttonLeftStick;
  42221. private _buttonRightStick;
  42222. private _dPadUp;
  42223. private _dPadDown;
  42224. private _dPadLeft;
  42225. private _dPadRight;
  42226. private _isXboxOnePad;
  42227. /**
  42228. * Creates a new XBox360 gamepad object
  42229. * @param id defines the id of this gamepad
  42230. * @param index defines its index
  42231. * @param gamepad defines the internal HTML gamepad object
  42232. * @param xboxOne defines if it is a XBox One gamepad
  42233. */
  42234. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42235. /**
  42236. * Defines the callback to call when left trigger is pressed
  42237. * @param callback defines the callback to use
  42238. */
  42239. onlefttriggerchanged(callback: (value: number) => void): void;
  42240. /**
  42241. * Defines the callback to call when right trigger is pressed
  42242. * @param callback defines the callback to use
  42243. */
  42244. onrighttriggerchanged(callback: (value: number) => void): void;
  42245. /**
  42246. * Gets the left trigger value
  42247. */
  42248. get leftTrigger(): number;
  42249. /**
  42250. * Sets the left trigger value
  42251. */
  42252. set leftTrigger(newValue: number);
  42253. /**
  42254. * Gets the right trigger value
  42255. */
  42256. get rightTrigger(): number;
  42257. /**
  42258. * Sets the right trigger value
  42259. */
  42260. set rightTrigger(newValue: number);
  42261. /**
  42262. * Defines the callback to call when a button is pressed
  42263. * @param callback defines the callback to use
  42264. */
  42265. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42266. /**
  42267. * Defines the callback to call when a button is released
  42268. * @param callback defines the callback to use
  42269. */
  42270. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42271. /**
  42272. * Defines the callback to call when a pad is pressed
  42273. * @param callback defines the callback to use
  42274. */
  42275. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42276. /**
  42277. * Defines the callback to call when a pad is released
  42278. * @param callback defines the callback to use
  42279. */
  42280. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42281. private _setButtonValue;
  42282. private _setDPadValue;
  42283. /**
  42284. * Gets the value of the `A` button
  42285. */
  42286. get buttonA(): number;
  42287. /**
  42288. * Sets the value of the `A` button
  42289. */
  42290. set buttonA(value: number);
  42291. /**
  42292. * Gets the value of the `B` button
  42293. */
  42294. get buttonB(): number;
  42295. /**
  42296. * Sets the value of the `B` button
  42297. */
  42298. set buttonB(value: number);
  42299. /**
  42300. * Gets the value of the `X` button
  42301. */
  42302. get buttonX(): number;
  42303. /**
  42304. * Sets the value of the `X` button
  42305. */
  42306. set buttonX(value: number);
  42307. /**
  42308. * Gets the value of the `Y` button
  42309. */
  42310. get buttonY(): number;
  42311. /**
  42312. * Sets the value of the `Y` button
  42313. */
  42314. set buttonY(value: number);
  42315. /**
  42316. * Gets the value of the `Start` button
  42317. */
  42318. get buttonStart(): number;
  42319. /**
  42320. * Sets the value of the `Start` button
  42321. */
  42322. set buttonStart(value: number);
  42323. /**
  42324. * Gets the value of the `Back` button
  42325. */
  42326. get buttonBack(): number;
  42327. /**
  42328. * Sets the value of the `Back` button
  42329. */
  42330. set buttonBack(value: number);
  42331. /**
  42332. * Gets the value of the `Left` button
  42333. */
  42334. get buttonLB(): number;
  42335. /**
  42336. * Sets the value of the `Left` button
  42337. */
  42338. set buttonLB(value: number);
  42339. /**
  42340. * Gets the value of the `Right` button
  42341. */
  42342. get buttonRB(): number;
  42343. /**
  42344. * Sets the value of the `Right` button
  42345. */
  42346. set buttonRB(value: number);
  42347. /**
  42348. * Gets the value of the Left joystick
  42349. */
  42350. get buttonLeftStick(): number;
  42351. /**
  42352. * Sets the value of the Left joystick
  42353. */
  42354. set buttonLeftStick(value: number);
  42355. /**
  42356. * Gets the value of the Right joystick
  42357. */
  42358. get buttonRightStick(): number;
  42359. /**
  42360. * Sets the value of the Right joystick
  42361. */
  42362. set buttonRightStick(value: number);
  42363. /**
  42364. * Gets the value of D-pad up
  42365. */
  42366. get dPadUp(): number;
  42367. /**
  42368. * Sets the value of D-pad up
  42369. */
  42370. set dPadUp(value: number);
  42371. /**
  42372. * Gets the value of D-pad down
  42373. */
  42374. get dPadDown(): number;
  42375. /**
  42376. * Sets the value of D-pad down
  42377. */
  42378. set dPadDown(value: number);
  42379. /**
  42380. * Gets the value of D-pad left
  42381. */
  42382. get dPadLeft(): number;
  42383. /**
  42384. * Sets the value of D-pad left
  42385. */
  42386. set dPadLeft(value: number);
  42387. /**
  42388. * Gets the value of D-pad right
  42389. */
  42390. get dPadRight(): number;
  42391. /**
  42392. * Sets the value of D-pad right
  42393. */
  42394. set dPadRight(value: number);
  42395. /**
  42396. * Force the gamepad to synchronize with device values
  42397. */
  42398. update(): void;
  42399. /**
  42400. * Disposes the gamepad
  42401. */
  42402. dispose(): void;
  42403. }
  42404. }
  42405. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42406. import { Observable } from "babylonjs/Misc/observable";
  42407. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42408. /**
  42409. * Defines supported buttons for DualShock compatible gamepads
  42410. */
  42411. export enum DualShockButton {
  42412. /** Cross */
  42413. Cross = 0,
  42414. /** Circle */
  42415. Circle = 1,
  42416. /** Square */
  42417. Square = 2,
  42418. /** Triangle */
  42419. Triangle = 3,
  42420. /** Options */
  42421. Options = 4,
  42422. /** Share */
  42423. Share = 5,
  42424. /** L1 */
  42425. L1 = 6,
  42426. /** R1 */
  42427. R1 = 7,
  42428. /** Left stick */
  42429. LeftStick = 8,
  42430. /** Right stick */
  42431. RightStick = 9
  42432. }
  42433. /** Defines values for DualShock DPad */
  42434. export enum DualShockDpad {
  42435. /** Up */
  42436. Up = 0,
  42437. /** Down */
  42438. Down = 1,
  42439. /** Left */
  42440. Left = 2,
  42441. /** Right */
  42442. Right = 3
  42443. }
  42444. /**
  42445. * Defines a DualShock gamepad
  42446. */
  42447. export class DualShockPad extends Gamepad {
  42448. private _leftTrigger;
  42449. private _rightTrigger;
  42450. private _onlefttriggerchanged;
  42451. private _onrighttriggerchanged;
  42452. private _onbuttondown;
  42453. private _onbuttonup;
  42454. private _ondpaddown;
  42455. private _ondpadup;
  42456. /** Observable raised when a button is pressed */
  42457. onButtonDownObservable: Observable<DualShockButton>;
  42458. /** Observable raised when a button is released */
  42459. onButtonUpObservable: Observable<DualShockButton>;
  42460. /** Observable raised when a pad is pressed */
  42461. onPadDownObservable: Observable<DualShockDpad>;
  42462. /** Observable raised when a pad is released */
  42463. onPadUpObservable: Observable<DualShockDpad>;
  42464. private _buttonCross;
  42465. private _buttonCircle;
  42466. private _buttonSquare;
  42467. private _buttonTriangle;
  42468. private _buttonShare;
  42469. private _buttonOptions;
  42470. private _buttonL1;
  42471. private _buttonR1;
  42472. private _buttonLeftStick;
  42473. private _buttonRightStick;
  42474. private _dPadUp;
  42475. private _dPadDown;
  42476. private _dPadLeft;
  42477. private _dPadRight;
  42478. /**
  42479. * Creates a new DualShock gamepad object
  42480. * @param id defines the id of this gamepad
  42481. * @param index defines its index
  42482. * @param gamepad defines the internal HTML gamepad object
  42483. */
  42484. constructor(id: string, index: number, gamepad: any);
  42485. /**
  42486. * Defines the callback to call when left trigger is pressed
  42487. * @param callback defines the callback to use
  42488. */
  42489. onlefttriggerchanged(callback: (value: number) => void): void;
  42490. /**
  42491. * Defines the callback to call when right trigger is pressed
  42492. * @param callback defines the callback to use
  42493. */
  42494. onrighttriggerchanged(callback: (value: number) => void): void;
  42495. /**
  42496. * Gets the left trigger value
  42497. */
  42498. get leftTrigger(): number;
  42499. /**
  42500. * Sets the left trigger value
  42501. */
  42502. set leftTrigger(newValue: number);
  42503. /**
  42504. * Gets the right trigger value
  42505. */
  42506. get rightTrigger(): number;
  42507. /**
  42508. * Sets the right trigger value
  42509. */
  42510. set rightTrigger(newValue: number);
  42511. /**
  42512. * Defines the callback to call when a button is pressed
  42513. * @param callback defines the callback to use
  42514. */
  42515. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42516. /**
  42517. * Defines the callback to call when a button is released
  42518. * @param callback defines the callback to use
  42519. */
  42520. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42521. /**
  42522. * Defines the callback to call when a pad is pressed
  42523. * @param callback defines the callback to use
  42524. */
  42525. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42526. /**
  42527. * Defines the callback to call when a pad is released
  42528. * @param callback defines the callback to use
  42529. */
  42530. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42531. private _setButtonValue;
  42532. private _setDPadValue;
  42533. /**
  42534. * Gets the value of the `Cross` button
  42535. */
  42536. get buttonCross(): number;
  42537. /**
  42538. * Sets the value of the `Cross` button
  42539. */
  42540. set buttonCross(value: number);
  42541. /**
  42542. * Gets the value of the `Circle` button
  42543. */
  42544. get buttonCircle(): number;
  42545. /**
  42546. * Sets the value of the `Circle` button
  42547. */
  42548. set buttonCircle(value: number);
  42549. /**
  42550. * Gets the value of the `Square` button
  42551. */
  42552. get buttonSquare(): number;
  42553. /**
  42554. * Sets the value of the `Square` button
  42555. */
  42556. set buttonSquare(value: number);
  42557. /**
  42558. * Gets the value of the `Triangle` button
  42559. */
  42560. get buttonTriangle(): number;
  42561. /**
  42562. * Sets the value of the `Triangle` button
  42563. */
  42564. set buttonTriangle(value: number);
  42565. /**
  42566. * Gets the value of the `Options` button
  42567. */
  42568. get buttonOptions(): number;
  42569. /**
  42570. * Sets the value of the `Options` button
  42571. */
  42572. set buttonOptions(value: number);
  42573. /**
  42574. * Gets the value of the `Share` button
  42575. */
  42576. get buttonShare(): number;
  42577. /**
  42578. * Sets the value of the `Share` button
  42579. */
  42580. set buttonShare(value: number);
  42581. /**
  42582. * Gets the value of the `L1` button
  42583. */
  42584. get buttonL1(): number;
  42585. /**
  42586. * Sets the value of the `L1` button
  42587. */
  42588. set buttonL1(value: number);
  42589. /**
  42590. * Gets the value of the `R1` button
  42591. */
  42592. get buttonR1(): number;
  42593. /**
  42594. * Sets the value of the `R1` button
  42595. */
  42596. set buttonR1(value: number);
  42597. /**
  42598. * Gets the value of the Left joystick
  42599. */
  42600. get buttonLeftStick(): number;
  42601. /**
  42602. * Sets the value of the Left joystick
  42603. */
  42604. set buttonLeftStick(value: number);
  42605. /**
  42606. * Gets the value of the Right joystick
  42607. */
  42608. get buttonRightStick(): number;
  42609. /**
  42610. * Sets the value of the Right joystick
  42611. */
  42612. set buttonRightStick(value: number);
  42613. /**
  42614. * Gets the value of D-pad up
  42615. */
  42616. get dPadUp(): number;
  42617. /**
  42618. * Sets the value of D-pad up
  42619. */
  42620. set dPadUp(value: number);
  42621. /**
  42622. * Gets the value of D-pad down
  42623. */
  42624. get dPadDown(): number;
  42625. /**
  42626. * Sets the value of D-pad down
  42627. */
  42628. set dPadDown(value: number);
  42629. /**
  42630. * Gets the value of D-pad left
  42631. */
  42632. get dPadLeft(): number;
  42633. /**
  42634. * Sets the value of D-pad left
  42635. */
  42636. set dPadLeft(value: number);
  42637. /**
  42638. * Gets the value of D-pad right
  42639. */
  42640. get dPadRight(): number;
  42641. /**
  42642. * Sets the value of D-pad right
  42643. */
  42644. set dPadRight(value: number);
  42645. /**
  42646. * Force the gamepad to synchronize with device values
  42647. */
  42648. update(): void;
  42649. /**
  42650. * Disposes the gamepad
  42651. */
  42652. dispose(): void;
  42653. }
  42654. }
  42655. declare module "babylonjs/Gamepads/gamepadManager" {
  42656. import { Observable } from "babylonjs/Misc/observable";
  42657. import { Nullable } from "babylonjs/types";
  42658. import { Scene } from "babylonjs/scene";
  42659. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42660. /**
  42661. * Manager for handling gamepads
  42662. */
  42663. export class GamepadManager {
  42664. private _scene?;
  42665. private _babylonGamepads;
  42666. private _oneGamepadConnected;
  42667. /** @hidden */
  42668. _isMonitoring: boolean;
  42669. private _gamepadEventSupported;
  42670. private _gamepadSupport?;
  42671. /**
  42672. * observable to be triggered when the gamepad controller has been connected
  42673. */
  42674. onGamepadConnectedObservable: Observable<Gamepad>;
  42675. /**
  42676. * observable to be triggered when the gamepad controller has been disconnected
  42677. */
  42678. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42679. private _onGamepadConnectedEvent;
  42680. private _onGamepadDisconnectedEvent;
  42681. /**
  42682. * Initializes the gamepad manager
  42683. * @param _scene BabylonJS scene
  42684. */
  42685. constructor(_scene?: Scene | undefined);
  42686. /**
  42687. * The gamepads in the game pad manager
  42688. */
  42689. get gamepads(): Gamepad[];
  42690. /**
  42691. * Get the gamepad controllers based on type
  42692. * @param type The type of gamepad controller
  42693. * @returns Nullable gamepad
  42694. */
  42695. getGamepadByType(type?: number): Nullable<Gamepad>;
  42696. /**
  42697. * Disposes the gamepad manager
  42698. */
  42699. dispose(): void;
  42700. private _addNewGamepad;
  42701. private _startMonitoringGamepads;
  42702. private _stopMonitoringGamepads;
  42703. /** @hidden */
  42704. _checkGamepadsStatus(): void;
  42705. private _updateGamepadObjects;
  42706. }
  42707. }
  42708. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42709. import { Nullable } from "babylonjs/types";
  42710. import { Scene } from "babylonjs/scene";
  42711. import { ISceneComponent } from "babylonjs/sceneComponent";
  42712. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42713. module "babylonjs/scene" {
  42714. interface Scene {
  42715. /** @hidden */
  42716. _gamepadManager: Nullable<GamepadManager>;
  42717. /**
  42718. * Gets the gamepad manager associated with the scene
  42719. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42720. */
  42721. gamepadManager: GamepadManager;
  42722. }
  42723. }
  42724. module "babylonjs/Cameras/freeCameraInputsManager" {
  42725. /**
  42726. * Interface representing a free camera inputs manager
  42727. */
  42728. interface FreeCameraInputsManager {
  42729. /**
  42730. * Adds gamepad input support to the FreeCameraInputsManager.
  42731. * @returns the FreeCameraInputsManager
  42732. */
  42733. addGamepad(): FreeCameraInputsManager;
  42734. }
  42735. }
  42736. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42737. /**
  42738. * Interface representing an arc rotate camera inputs manager
  42739. */
  42740. interface ArcRotateCameraInputsManager {
  42741. /**
  42742. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42743. * @returns the camera inputs manager
  42744. */
  42745. addGamepad(): ArcRotateCameraInputsManager;
  42746. }
  42747. }
  42748. /**
  42749. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42750. */
  42751. export class GamepadSystemSceneComponent implements ISceneComponent {
  42752. /**
  42753. * The component name helpfull to identify the component in the list of scene components.
  42754. */
  42755. readonly name: string;
  42756. /**
  42757. * The scene the component belongs to.
  42758. */
  42759. scene: Scene;
  42760. /**
  42761. * Creates a new instance of the component for the given scene
  42762. * @param scene Defines the scene to register the component in
  42763. */
  42764. constructor(scene: Scene);
  42765. /**
  42766. * Registers the component in a given scene
  42767. */
  42768. register(): void;
  42769. /**
  42770. * Rebuilds the elements related to this component in case of
  42771. * context lost for instance.
  42772. */
  42773. rebuild(): void;
  42774. /**
  42775. * Disposes the component and the associated ressources
  42776. */
  42777. dispose(): void;
  42778. private _beforeCameraUpdate;
  42779. }
  42780. }
  42781. declare module "babylonjs/Cameras/universalCamera" {
  42782. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42783. import { Scene } from "babylonjs/scene";
  42784. import { Vector3 } from "babylonjs/Maths/math.vector";
  42785. import "babylonjs/Gamepads/gamepadSceneComponent";
  42786. /**
  42787. * 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,
  42788. * which still works and will still be found in many Playgrounds.
  42789. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42790. */
  42791. export class UniversalCamera extends TouchCamera {
  42792. /**
  42793. * Defines the gamepad rotation sensiblity.
  42794. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42795. */
  42796. get gamepadAngularSensibility(): number;
  42797. set gamepadAngularSensibility(value: number);
  42798. /**
  42799. * Defines the gamepad move sensiblity.
  42800. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42801. */
  42802. get gamepadMoveSensibility(): number;
  42803. set gamepadMoveSensibility(value: number);
  42804. /**
  42805. * 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,
  42806. * which still works and will still be found in many Playgrounds.
  42807. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42808. * @param name Define the name of the camera in the scene
  42809. * @param position Define the start position of the camera in the scene
  42810. * @param scene Define the scene the camera belongs to
  42811. */
  42812. constructor(name: string, position: Vector3, scene: Scene);
  42813. /**
  42814. * Gets the current object class name.
  42815. * @return the class name
  42816. */
  42817. getClassName(): string;
  42818. }
  42819. }
  42820. declare module "babylonjs/Cameras/gamepadCamera" {
  42821. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42822. import { Scene } from "babylonjs/scene";
  42823. import { Vector3 } from "babylonjs/Maths/math.vector";
  42824. /**
  42825. * This represents a FPS type of camera. This is only here for back compat purpose.
  42826. * Please use the UniversalCamera instead as both are identical.
  42827. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42828. */
  42829. export class GamepadCamera extends UniversalCamera {
  42830. /**
  42831. * Instantiates a new Gamepad Camera
  42832. * This represents a FPS type of camera. This is only here for back compat purpose.
  42833. * Please use the UniversalCamera instead as both are identical.
  42834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42835. * @param name Define the name of the camera in the scene
  42836. * @param position Define the start position of the camera in the scene
  42837. * @param scene Define the scene the camera belongs to
  42838. */
  42839. constructor(name: string, position: Vector3, scene: Scene);
  42840. /**
  42841. * Gets the current object class name.
  42842. * @return the class name
  42843. */
  42844. getClassName(): string;
  42845. }
  42846. }
  42847. declare module "babylonjs/Shaders/pass.fragment" {
  42848. /** @hidden */
  42849. export var passPixelShader: {
  42850. name: string;
  42851. shader: string;
  42852. };
  42853. }
  42854. declare module "babylonjs/Shaders/passCube.fragment" {
  42855. /** @hidden */
  42856. export var passCubePixelShader: {
  42857. name: string;
  42858. shader: string;
  42859. };
  42860. }
  42861. declare module "babylonjs/PostProcesses/passPostProcess" {
  42862. import { Nullable } from "babylonjs/types";
  42863. import { Camera } from "babylonjs/Cameras/camera";
  42864. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42865. import { Engine } from "babylonjs/Engines/engine";
  42866. import "babylonjs/Shaders/pass.fragment";
  42867. import "babylonjs/Shaders/passCube.fragment";
  42868. /**
  42869. * PassPostProcess which produces an output the same as it's input
  42870. */
  42871. export class PassPostProcess extends PostProcess {
  42872. /**
  42873. * Creates the PassPostProcess
  42874. * @param name The name of the effect.
  42875. * @param options The required width/height ratio to downsize to before computing the render pass.
  42876. * @param camera The camera to apply the render pass to.
  42877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42878. * @param engine The engine which the post process will be applied. (default: current engine)
  42879. * @param reusable If the post process can be reused on the same frame. (default: false)
  42880. * @param textureType The type of texture to be used when performing the post processing.
  42881. * @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)
  42882. */
  42883. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42884. }
  42885. /**
  42886. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42887. */
  42888. export class PassCubePostProcess extends PostProcess {
  42889. private _face;
  42890. /**
  42891. * Gets or sets the cube face to display.
  42892. * * 0 is +X
  42893. * * 1 is -X
  42894. * * 2 is +Y
  42895. * * 3 is -Y
  42896. * * 4 is +Z
  42897. * * 5 is -Z
  42898. */
  42899. get face(): number;
  42900. set face(value: number);
  42901. /**
  42902. * Creates the PassCubePostProcess
  42903. * @param name The name of the effect.
  42904. * @param options The required width/height ratio to downsize to before computing the render pass.
  42905. * @param camera The camera to apply the render pass to.
  42906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42907. * @param engine The engine which the post process will be applied. (default: current engine)
  42908. * @param reusable If the post process can be reused on the same frame. (default: false)
  42909. * @param textureType The type of texture to be used when performing the post processing.
  42910. * @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)
  42911. */
  42912. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42913. }
  42914. }
  42915. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42916. /** @hidden */
  42917. export var anaglyphPixelShader: {
  42918. name: string;
  42919. shader: string;
  42920. };
  42921. }
  42922. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42923. import { Engine } from "babylonjs/Engines/engine";
  42924. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42925. import { Camera } from "babylonjs/Cameras/camera";
  42926. import "babylonjs/Shaders/anaglyph.fragment";
  42927. /**
  42928. * Postprocess used to generate anaglyphic rendering
  42929. */
  42930. export class AnaglyphPostProcess extends PostProcess {
  42931. private _passedProcess;
  42932. /**
  42933. * Creates a new AnaglyphPostProcess
  42934. * @param name defines postprocess name
  42935. * @param options defines creation options or target ratio scale
  42936. * @param rigCameras defines cameras using this postprocess
  42937. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42938. * @param engine defines hosting engine
  42939. * @param reusable defines if the postprocess will be reused multiple times per frame
  42940. */
  42941. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42942. }
  42943. }
  42944. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42945. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42946. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42947. import { Scene } from "babylonjs/scene";
  42948. import { Vector3 } from "babylonjs/Maths/math.vector";
  42949. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42950. /**
  42951. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42952. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42953. */
  42954. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42955. /**
  42956. * Creates a new AnaglyphArcRotateCamera
  42957. * @param name defines camera name
  42958. * @param alpha defines alpha angle (in radians)
  42959. * @param beta defines beta angle (in radians)
  42960. * @param radius defines radius
  42961. * @param target defines camera target
  42962. * @param interaxialDistance defines distance between each color axis
  42963. * @param scene defines the hosting scene
  42964. */
  42965. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42966. /**
  42967. * Gets camera class name
  42968. * @returns AnaglyphArcRotateCamera
  42969. */
  42970. getClassName(): string;
  42971. }
  42972. }
  42973. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42974. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42975. import { Scene } from "babylonjs/scene";
  42976. import { Vector3 } from "babylonjs/Maths/math.vector";
  42977. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42978. /**
  42979. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42980. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42981. */
  42982. export class AnaglyphFreeCamera extends FreeCamera {
  42983. /**
  42984. * Creates a new AnaglyphFreeCamera
  42985. * @param name defines camera name
  42986. * @param position defines initial position
  42987. * @param interaxialDistance defines distance between each color axis
  42988. * @param scene defines the hosting scene
  42989. */
  42990. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42991. /**
  42992. * Gets camera class name
  42993. * @returns AnaglyphFreeCamera
  42994. */
  42995. getClassName(): string;
  42996. }
  42997. }
  42998. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42999. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43000. import { Scene } from "babylonjs/scene";
  43001. import { Vector3 } from "babylonjs/Maths/math.vector";
  43002. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43003. /**
  43004. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43005. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43006. */
  43007. export class AnaglyphGamepadCamera extends GamepadCamera {
  43008. /**
  43009. * Creates a new AnaglyphGamepadCamera
  43010. * @param name defines camera name
  43011. * @param position defines initial position
  43012. * @param interaxialDistance defines distance between each color axis
  43013. * @param scene defines the hosting scene
  43014. */
  43015. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43016. /**
  43017. * Gets camera class name
  43018. * @returns AnaglyphGamepadCamera
  43019. */
  43020. getClassName(): string;
  43021. }
  43022. }
  43023. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43024. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43025. import { Scene } from "babylonjs/scene";
  43026. import { Vector3 } from "babylonjs/Maths/math.vector";
  43027. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43028. /**
  43029. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43030. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43031. */
  43032. export class AnaglyphUniversalCamera extends UniversalCamera {
  43033. /**
  43034. * Creates a new AnaglyphUniversalCamera
  43035. * @param name defines camera name
  43036. * @param position defines initial position
  43037. * @param interaxialDistance defines distance between each color axis
  43038. * @param scene defines the hosting scene
  43039. */
  43040. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43041. /**
  43042. * Gets camera class name
  43043. * @returns AnaglyphUniversalCamera
  43044. */
  43045. getClassName(): string;
  43046. }
  43047. }
  43048. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43049. /** @hidden */
  43050. export var stereoscopicInterlacePixelShader: {
  43051. name: string;
  43052. shader: string;
  43053. };
  43054. }
  43055. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43056. import { Camera } from "babylonjs/Cameras/camera";
  43057. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43058. import { Engine } from "babylonjs/Engines/engine";
  43059. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43060. /**
  43061. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43062. */
  43063. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43064. private _stepSize;
  43065. private _passedProcess;
  43066. /**
  43067. * Initializes a StereoscopicInterlacePostProcessI
  43068. * @param name The name of the effect.
  43069. * @param rigCameras The rig cameras to be appled to the post process
  43070. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43071. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43073. * @param engine The engine which the post process will be applied. (default: current engine)
  43074. * @param reusable If the post process can be reused on the same frame. (default: false)
  43075. */
  43076. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43077. }
  43078. /**
  43079. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43080. */
  43081. export class StereoscopicInterlacePostProcess extends PostProcess {
  43082. private _stepSize;
  43083. private _passedProcess;
  43084. /**
  43085. * Initializes a StereoscopicInterlacePostProcess
  43086. * @param name The name of the effect.
  43087. * @param rigCameras The rig cameras to be appled to the post process
  43088. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43090. * @param engine The engine which the post process will be applied. (default: current engine)
  43091. * @param reusable If the post process can be reused on the same frame. (default: false)
  43092. */
  43093. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43094. }
  43095. }
  43096. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43097. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43098. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43099. import { Scene } from "babylonjs/scene";
  43100. import { Vector3 } from "babylonjs/Maths/math.vector";
  43101. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43102. /**
  43103. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43104. * @see http://doc.babylonjs.com/features/cameras
  43105. */
  43106. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43107. /**
  43108. * Creates a new StereoscopicArcRotateCamera
  43109. * @param name defines camera name
  43110. * @param alpha defines alpha angle (in radians)
  43111. * @param beta defines beta angle (in radians)
  43112. * @param radius defines radius
  43113. * @param target defines camera target
  43114. * @param interaxialDistance defines distance between each color axis
  43115. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43116. * @param scene defines the hosting scene
  43117. */
  43118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43119. /**
  43120. * Gets camera class name
  43121. * @returns StereoscopicArcRotateCamera
  43122. */
  43123. getClassName(): string;
  43124. }
  43125. }
  43126. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43127. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43128. import { Scene } from "babylonjs/scene";
  43129. import { Vector3 } from "babylonjs/Maths/math.vector";
  43130. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43131. /**
  43132. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43133. * @see http://doc.babylonjs.com/features/cameras
  43134. */
  43135. export class StereoscopicFreeCamera extends FreeCamera {
  43136. /**
  43137. * Creates a new StereoscopicFreeCamera
  43138. * @param name defines camera name
  43139. * @param position defines initial position
  43140. * @param interaxialDistance defines distance between each color axis
  43141. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43142. * @param scene defines the hosting scene
  43143. */
  43144. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43145. /**
  43146. * Gets camera class name
  43147. * @returns StereoscopicFreeCamera
  43148. */
  43149. getClassName(): string;
  43150. }
  43151. }
  43152. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43153. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43154. import { Scene } from "babylonjs/scene";
  43155. import { Vector3 } from "babylonjs/Maths/math.vector";
  43156. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43157. /**
  43158. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43159. * @see http://doc.babylonjs.com/features/cameras
  43160. */
  43161. export class StereoscopicGamepadCamera extends GamepadCamera {
  43162. /**
  43163. * Creates a new StereoscopicGamepadCamera
  43164. * @param name defines camera name
  43165. * @param position defines initial position
  43166. * @param interaxialDistance defines distance between each color axis
  43167. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43168. * @param scene defines the hosting scene
  43169. */
  43170. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43171. /**
  43172. * Gets camera class name
  43173. * @returns StereoscopicGamepadCamera
  43174. */
  43175. getClassName(): string;
  43176. }
  43177. }
  43178. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43179. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43180. import { Scene } from "babylonjs/scene";
  43181. import { Vector3 } from "babylonjs/Maths/math.vector";
  43182. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43183. /**
  43184. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43185. * @see http://doc.babylonjs.com/features/cameras
  43186. */
  43187. export class StereoscopicUniversalCamera extends UniversalCamera {
  43188. /**
  43189. * Creates a new StereoscopicUniversalCamera
  43190. * @param name defines camera name
  43191. * @param position defines initial position
  43192. * @param interaxialDistance defines distance between each color axis
  43193. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43194. * @param scene defines the hosting scene
  43195. */
  43196. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43197. /**
  43198. * Gets camera class name
  43199. * @returns StereoscopicUniversalCamera
  43200. */
  43201. getClassName(): string;
  43202. }
  43203. }
  43204. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43205. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43206. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43207. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43208. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43209. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43210. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43211. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43212. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43213. }
  43214. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43216. import { Scene } from "babylonjs/scene";
  43217. import { Vector3 } from "babylonjs/Maths/math.vector";
  43218. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43219. /**
  43220. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43221. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43222. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43223. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43224. */
  43225. export class VirtualJoysticksCamera extends FreeCamera {
  43226. /**
  43227. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43228. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43229. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43230. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43231. * @param name Define the name of the camera in the scene
  43232. * @param position Define the start position of the camera in the scene
  43233. * @param scene Define the scene the camera belongs to
  43234. */
  43235. constructor(name: string, position: Vector3, scene: Scene);
  43236. /**
  43237. * Gets the current object class name.
  43238. * @return the class name
  43239. */
  43240. getClassName(): string;
  43241. }
  43242. }
  43243. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43244. import { Matrix } from "babylonjs/Maths/math.vector";
  43245. /**
  43246. * This represents all the required metrics to create a VR camera.
  43247. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43248. */
  43249. export class VRCameraMetrics {
  43250. /**
  43251. * Define the horizontal resolution off the screen.
  43252. */
  43253. hResolution: number;
  43254. /**
  43255. * Define the vertical resolution off the screen.
  43256. */
  43257. vResolution: number;
  43258. /**
  43259. * Define the horizontal screen size.
  43260. */
  43261. hScreenSize: number;
  43262. /**
  43263. * Define the vertical screen size.
  43264. */
  43265. vScreenSize: number;
  43266. /**
  43267. * Define the vertical screen center position.
  43268. */
  43269. vScreenCenter: number;
  43270. /**
  43271. * Define the distance of the eyes to the screen.
  43272. */
  43273. eyeToScreenDistance: number;
  43274. /**
  43275. * Define the distance between both lenses
  43276. */
  43277. lensSeparationDistance: number;
  43278. /**
  43279. * Define the distance between both viewer's eyes.
  43280. */
  43281. interpupillaryDistance: number;
  43282. /**
  43283. * Define the distortion factor of the VR postprocess.
  43284. * Please, touch with care.
  43285. */
  43286. distortionK: number[];
  43287. /**
  43288. * Define the chromatic aberration correction factors for the VR post process.
  43289. */
  43290. chromaAbCorrection: number[];
  43291. /**
  43292. * Define the scale factor of the post process.
  43293. * The smaller the better but the slower.
  43294. */
  43295. postProcessScaleFactor: number;
  43296. /**
  43297. * Define an offset for the lens center.
  43298. */
  43299. lensCenterOffset: number;
  43300. /**
  43301. * Define if the current vr camera should compensate the distortion of the lense or not.
  43302. */
  43303. compensateDistortion: boolean;
  43304. /**
  43305. * Defines if multiview should be enabled when rendering (Default: false)
  43306. */
  43307. multiviewEnabled: boolean;
  43308. /**
  43309. * Gets the rendering aspect ratio based on the provided resolutions.
  43310. */
  43311. get aspectRatio(): number;
  43312. /**
  43313. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43314. */
  43315. get aspectRatioFov(): number;
  43316. /**
  43317. * @hidden
  43318. */
  43319. get leftHMatrix(): Matrix;
  43320. /**
  43321. * @hidden
  43322. */
  43323. get rightHMatrix(): Matrix;
  43324. /**
  43325. * @hidden
  43326. */
  43327. get leftPreViewMatrix(): Matrix;
  43328. /**
  43329. * @hidden
  43330. */
  43331. get rightPreViewMatrix(): Matrix;
  43332. /**
  43333. * Get the default VRMetrics based on the most generic setup.
  43334. * @returns the default vr metrics
  43335. */
  43336. static GetDefault(): VRCameraMetrics;
  43337. }
  43338. }
  43339. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43340. /** @hidden */
  43341. export var vrDistortionCorrectionPixelShader: {
  43342. name: string;
  43343. shader: string;
  43344. };
  43345. }
  43346. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43347. import { Camera } from "babylonjs/Cameras/camera";
  43348. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43350. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43351. /**
  43352. * VRDistortionCorrectionPostProcess used for mobile VR
  43353. */
  43354. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43355. private _isRightEye;
  43356. private _distortionFactors;
  43357. private _postProcessScaleFactor;
  43358. private _lensCenterOffset;
  43359. private _scaleIn;
  43360. private _scaleFactor;
  43361. private _lensCenter;
  43362. /**
  43363. * Initializes the VRDistortionCorrectionPostProcess
  43364. * @param name The name of the effect.
  43365. * @param camera The camera to apply the render pass to.
  43366. * @param isRightEye If this is for the right eye distortion
  43367. * @param vrMetrics All the required metrics for the VR camera
  43368. */
  43369. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43370. }
  43371. }
  43372. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43373. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43374. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43375. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43376. import { Scene } from "babylonjs/scene";
  43377. import { Vector3 } from "babylonjs/Maths/math.vector";
  43378. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43379. import "babylonjs/Cameras/RigModes/vrRigMode";
  43380. /**
  43381. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43382. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43383. */
  43384. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43385. /**
  43386. * Creates a new VRDeviceOrientationArcRotateCamera
  43387. * @param name defines camera name
  43388. * @param alpha defines the camera rotation along the logitudinal axis
  43389. * @param beta defines the camera rotation along the latitudinal axis
  43390. * @param radius defines the camera distance from its target
  43391. * @param target defines the camera target
  43392. * @param scene defines the scene the camera belongs to
  43393. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43394. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43395. */
  43396. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43397. /**
  43398. * Gets camera class name
  43399. * @returns VRDeviceOrientationArcRotateCamera
  43400. */
  43401. getClassName(): string;
  43402. }
  43403. }
  43404. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43405. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43406. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43407. import { Scene } from "babylonjs/scene";
  43408. import { Vector3 } from "babylonjs/Maths/math.vector";
  43409. import "babylonjs/Cameras/RigModes/vrRigMode";
  43410. /**
  43411. * Camera used to simulate VR rendering (based on FreeCamera)
  43412. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43413. */
  43414. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43415. /**
  43416. * Creates a new VRDeviceOrientationFreeCamera
  43417. * @param name defines camera name
  43418. * @param position defines the start position of the camera
  43419. * @param scene defines the scene the camera belongs to
  43420. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43421. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43422. */
  43423. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43424. /**
  43425. * Gets camera class name
  43426. * @returns VRDeviceOrientationFreeCamera
  43427. */
  43428. getClassName(): string;
  43429. }
  43430. }
  43431. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43432. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43433. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43434. import { Scene } from "babylonjs/scene";
  43435. import { Vector3 } from "babylonjs/Maths/math.vector";
  43436. import "babylonjs/Gamepads/gamepadSceneComponent";
  43437. /**
  43438. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43439. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43440. */
  43441. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43442. /**
  43443. * Creates a new VRDeviceOrientationGamepadCamera
  43444. * @param name defines camera name
  43445. * @param position defines the start position of the camera
  43446. * @param scene defines the scene the camera belongs to
  43447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43449. */
  43450. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43451. /**
  43452. * Gets camera class name
  43453. * @returns VRDeviceOrientationGamepadCamera
  43454. */
  43455. getClassName(): string;
  43456. }
  43457. }
  43458. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43459. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43460. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43461. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43462. /** @hidden */
  43463. export var imageProcessingPixelShader: {
  43464. name: string;
  43465. shader: string;
  43466. };
  43467. }
  43468. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43469. import { Nullable } from "babylonjs/types";
  43470. import { Color4 } from "babylonjs/Maths/math.color";
  43471. import { Camera } from "babylonjs/Cameras/camera";
  43472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43473. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43474. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43475. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43476. import { Engine } from "babylonjs/Engines/engine";
  43477. import "babylonjs/Shaders/imageProcessing.fragment";
  43478. import "babylonjs/Shaders/postprocess.vertex";
  43479. /**
  43480. * ImageProcessingPostProcess
  43481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43482. */
  43483. export class ImageProcessingPostProcess extends PostProcess {
  43484. /**
  43485. * Default configuration related to image processing available in the PBR Material.
  43486. */
  43487. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43488. /**
  43489. * Gets the image processing configuration used either in this material.
  43490. */
  43491. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43492. /**
  43493. * Sets the Default image processing configuration used either in the this material.
  43494. *
  43495. * If sets to null, the scene one is in use.
  43496. */
  43497. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43498. /**
  43499. * Keep track of the image processing observer to allow dispose and replace.
  43500. */
  43501. private _imageProcessingObserver;
  43502. /**
  43503. * Attaches a new image processing configuration to the PBR Material.
  43504. * @param configuration
  43505. */
  43506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43507. /**
  43508. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43509. */
  43510. get colorCurves(): Nullable<ColorCurves>;
  43511. /**
  43512. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43513. */
  43514. set colorCurves(value: Nullable<ColorCurves>);
  43515. /**
  43516. * Gets wether the color curves effect is enabled.
  43517. */
  43518. get colorCurvesEnabled(): boolean;
  43519. /**
  43520. * Sets wether the color curves effect is enabled.
  43521. */
  43522. set colorCurvesEnabled(value: boolean);
  43523. /**
  43524. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43525. */
  43526. get colorGradingTexture(): Nullable<BaseTexture>;
  43527. /**
  43528. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43529. */
  43530. set colorGradingTexture(value: Nullable<BaseTexture>);
  43531. /**
  43532. * Gets wether the color grading effect is enabled.
  43533. */
  43534. get colorGradingEnabled(): boolean;
  43535. /**
  43536. * Gets wether the color grading effect is enabled.
  43537. */
  43538. set colorGradingEnabled(value: boolean);
  43539. /**
  43540. * Gets exposure used in the effect.
  43541. */
  43542. get exposure(): number;
  43543. /**
  43544. * Sets exposure used in the effect.
  43545. */
  43546. set exposure(value: number);
  43547. /**
  43548. * Gets wether tonemapping is enabled or not.
  43549. */
  43550. get toneMappingEnabled(): boolean;
  43551. /**
  43552. * Sets wether tonemapping is enabled or not
  43553. */
  43554. set toneMappingEnabled(value: boolean);
  43555. /**
  43556. * Gets the type of tone mapping effect.
  43557. */
  43558. get toneMappingType(): number;
  43559. /**
  43560. * Sets the type of tone mapping effect.
  43561. */
  43562. set toneMappingType(value: number);
  43563. /**
  43564. * Gets contrast used in the effect.
  43565. */
  43566. get contrast(): number;
  43567. /**
  43568. * Sets contrast used in the effect.
  43569. */
  43570. set contrast(value: number);
  43571. /**
  43572. * Gets Vignette stretch size.
  43573. */
  43574. get vignetteStretch(): number;
  43575. /**
  43576. * Sets Vignette stretch size.
  43577. */
  43578. set vignetteStretch(value: number);
  43579. /**
  43580. * Gets Vignette centre X Offset.
  43581. */
  43582. get vignetteCentreX(): number;
  43583. /**
  43584. * Sets Vignette centre X Offset.
  43585. */
  43586. set vignetteCentreX(value: number);
  43587. /**
  43588. * Gets Vignette centre Y Offset.
  43589. */
  43590. get vignetteCentreY(): number;
  43591. /**
  43592. * Sets Vignette centre Y Offset.
  43593. */
  43594. set vignetteCentreY(value: number);
  43595. /**
  43596. * Gets Vignette weight or intensity of the vignette effect.
  43597. */
  43598. get vignetteWeight(): number;
  43599. /**
  43600. * Sets Vignette weight or intensity of the vignette effect.
  43601. */
  43602. set vignetteWeight(value: number);
  43603. /**
  43604. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43605. * if vignetteEnabled is set to true.
  43606. */
  43607. get vignetteColor(): Color4;
  43608. /**
  43609. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43610. * if vignetteEnabled is set to true.
  43611. */
  43612. set vignetteColor(value: Color4);
  43613. /**
  43614. * Gets Camera field of view used by the Vignette effect.
  43615. */
  43616. get vignetteCameraFov(): number;
  43617. /**
  43618. * Sets Camera field of view used by the Vignette effect.
  43619. */
  43620. set vignetteCameraFov(value: number);
  43621. /**
  43622. * Gets the vignette blend mode allowing different kind of effect.
  43623. */
  43624. get vignetteBlendMode(): number;
  43625. /**
  43626. * Sets the vignette blend mode allowing different kind of effect.
  43627. */
  43628. set vignetteBlendMode(value: number);
  43629. /**
  43630. * Gets wether the vignette effect is enabled.
  43631. */
  43632. get vignetteEnabled(): boolean;
  43633. /**
  43634. * Sets wether the vignette effect is enabled.
  43635. */
  43636. set vignetteEnabled(value: boolean);
  43637. private _fromLinearSpace;
  43638. /**
  43639. * Gets wether the input of the processing is in Gamma or Linear Space.
  43640. */
  43641. get fromLinearSpace(): boolean;
  43642. /**
  43643. * Sets wether the input of the processing is in Gamma or Linear Space.
  43644. */
  43645. set fromLinearSpace(value: boolean);
  43646. /**
  43647. * Defines cache preventing GC.
  43648. */
  43649. private _defines;
  43650. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43651. /**
  43652. * "ImageProcessingPostProcess"
  43653. * @returns "ImageProcessingPostProcess"
  43654. */
  43655. getClassName(): string;
  43656. protected _updateParameters(): void;
  43657. dispose(camera?: Camera): void;
  43658. }
  43659. }
  43660. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43661. import { Scene } from "babylonjs/scene";
  43662. import { Color3 } from "babylonjs/Maths/math.color";
  43663. import { Mesh } from "babylonjs/Meshes/mesh";
  43664. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43665. import { Nullable } from "babylonjs/types";
  43666. /**
  43667. * Class containing static functions to help procedurally build meshes
  43668. */
  43669. export class GroundBuilder {
  43670. /**
  43671. * Creates a ground mesh
  43672. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43673. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43675. * @param name defines the name of the mesh
  43676. * @param options defines the options used to create the mesh
  43677. * @param scene defines the hosting scene
  43678. * @returns the ground mesh
  43679. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43680. */
  43681. static CreateGround(name: string, options: {
  43682. width?: number;
  43683. height?: number;
  43684. subdivisions?: number;
  43685. subdivisionsX?: number;
  43686. subdivisionsY?: number;
  43687. updatable?: boolean;
  43688. }, scene: any): Mesh;
  43689. /**
  43690. * Creates a tiled ground mesh
  43691. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43692. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43693. * * 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
  43694. * * 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
  43695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43696. * @param name defines the name of the mesh
  43697. * @param options defines the options used to create the mesh
  43698. * @param scene defines the hosting scene
  43699. * @returns the tiled ground mesh
  43700. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43701. */
  43702. static CreateTiledGround(name: string, options: {
  43703. xmin: number;
  43704. zmin: number;
  43705. xmax: number;
  43706. zmax: number;
  43707. subdivisions?: {
  43708. w: number;
  43709. h: number;
  43710. };
  43711. precision?: {
  43712. w: number;
  43713. h: number;
  43714. };
  43715. updatable?: boolean;
  43716. }, scene?: Nullable<Scene>): Mesh;
  43717. /**
  43718. * Creates a ground mesh from a height map
  43719. * * The parameter `url` sets the URL of the height map image resource.
  43720. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43721. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43722. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43723. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43724. * * 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.
  43725. * * 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).
  43726. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43728. * @param name defines the name of the mesh
  43729. * @param url defines the url to the height map
  43730. * @param options defines the options used to create the mesh
  43731. * @param scene defines the hosting scene
  43732. * @returns the ground mesh
  43733. * @see https://doc.babylonjs.com/babylon101/height_map
  43734. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43735. */
  43736. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43737. width?: number;
  43738. height?: number;
  43739. subdivisions?: number;
  43740. minHeight?: number;
  43741. maxHeight?: number;
  43742. colorFilter?: Color3;
  43743. alphaFilter?: number;
  43744. updatable?: boolean;
  43745. onReady?: (mesh: GroundMesh) => void;
  43746. }, scene?: Nullable<Scene>): GroundMesh;
  43747. }
  43748. }
  43749. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43750. import { Vector4 } from "babylonjs/Maths/math.vector";
  43751. import { Mesh } from "babylonjs/Meshes/mesh";
  43752. /**
  43753. * Class containing static functions to help procedurally build meshes
  43754. */
  43755. export class TorusBuilder {
  43756. /**
  43757. * Creates a torus mesh
  43758. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43759. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43760. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43764. * @param name defines the name of the mesh
  43765. * @param options defines the options used to create the mesh
  43766. * @param scene defines the hosting scene
  43767. * @returns the torus mesh
  43768. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43769. */
  43770. static CreateTorus(name: string, options: {
  43771. diameter?: number;
  43772. thickness?: number;
  43773. tessellation?: number;
  43774. updatable?: boolean;
  43775. sideOrientation?: number;
  43776. frontUVs?: Vector4;
  43777. backUVs?: Vector4;
  43778. }, scene: any): Mesh;
  43779. }
  43780. }
  43781. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43782. import { Vector4 } from "babylonjs/Maths/math.vector";
  43783. import { Color4 } from "babylonjs/Maths/math.color";
  43784. import { Mesh } from "babylonjs/Meshes/mesh";
  43785. /**
  43786. * Class containing static functions to help procedurally build meshes
  43787. */
  43788. export class CylinderBuilder {
  43789. /**
  43790. * Creates a cylinder or a cone mesh
  43791. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43792. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43793. * * 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.
  43794. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43795. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43796. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43797. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43798. * * 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).
  43799. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43800. * * 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).
  43801. * * 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
  43802. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43803. * * 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
  43804. * * 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.
  43805. * * If `enclose` is false, a ring surface is one element.
  43806. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43807. * * 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
  43808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43811. * @param name defines the name of the mesh
  43812. * @param options defines the options used to create the mesh
  43813. * @param scene defines the hosting scene
  43814. * @returns the cylinder mesh
  43815. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43816. */
  43817. static CreateCylinder(name: string, options: {
  43818. height?: number;
  43819. diameterTop?: number;
  43820. diameterBottom?: number;
  43821. diameter?: number;
  43822. tessellation?: number;
  43823. subdivisions?: number;
  43824. arc?: number;
  43825. faceColors?: Color4[];
  43826. faceUV?: Vector4[];
  43827. updatable?: boolean;
  43828. hasRings?: boolean;
  43829. enclose?: boolean;
  43830. cap?: number;
  43831. sideOrientation?: number;
  43832. frontUVs?: Vector4;
  43833. backUVs?: Vector4;
  43834. }, scene: any): Mesh;
  43835. }
  43836. }
  43837. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43838. import { Nullable } from "babylonjs/types";
  43839. import { IDisposable } from "babylonjs/scene";
  43840. /**
  43841. * States of the webXR experience
  43842. */
  43843. export enum WebXRState {
  43844. /**
  43845. * Transitioning to being in XR mode
  43846. */
  43847. ENTERING_XR = 0,
  43848. /**
  43849. * Transitioning to non XR mode
  43850. */
  43851. EXITING_XR = 1,
  43852. /**
  43853. * In XR mode and presenting
  43854. */
  43855. IN_XR = 2,
  43856. /**
  43857. * Not entered XR mode
  43858. */
  43859. NOT_IN_XR = 3
  43860. }
  43861. /**
  43862. * Abstraction of the XR render target
  43863. */
  43864. export interface WebXRRenderTarget extends IDisposable {
  43865. /**
  43866. * xrpresent context of the canvas which can be used to display/mirror xr content
  43867. */
  43868. canvasContext: WebGLRenderingContext;
  43869. /**
  43870. * xr layer for the canvas
  43871. */
  43872. xrLayer: Nullable<XRWebGLLayer>;
  43873. /**
  43874. * Initializes the xr layer for the session
  43875. * @param xrSession xr session
  43876. * @returns a promise that will resolve once the XR Layer has been created
  43877. */
  43878. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43879. }
  43880. }
  43881. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43882. import { Nullable } from "babylonjs/types";
  43883. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43884. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43885. /**
  43886. * COnfiguration object for WebXR output canvas
  43887. */
  43888. export class WebXRManagedOutputCanvasOptions {
  43889. /**
  43890. * Options for this XR Layer output
  43891. */
  43892. canvasOptions?: XRWebGLLayerOptions;
  43893. /**
  43894. * CSS styling for a newly created canvas (if not provided)
  43895. */
  43896. newCanvasCssStyle?: string;
  43897. /**
  43898. * An optional canvas in case you wish to create it yourself and provide it here.
  43899. * If not provided, a new canvas will be created
  43900. */
  43901. canvasElement?: HTMLCanvasElement;
  43902. /**
  43903. * Get the default values of the configuration object
  43904. * @returns default values of this configuration object
  43905. */
  43906. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43907. }
  43908. /**
  43909. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43910. */
  43911. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43912. private _options;
  43913. private _engine;
  43914. private _canvas;
  43915. /**
  43916. * Rendering context of the canvas which can be used to display/mirror xr content
  43917. */
  43918. canvasContext: WebGLRenderingContext;
  43919. /**
  43920. * xr layer for the canvas
  43921. */
  43922. xrLayer: Nullable<XRWebGLLayer>;
  43923. /**
  43924. * Initializes the xr layer for the session
  43925. * @param xrSession xr session
  43926. * @returns a promise that will resolve once the XR Layer has been created
  43927. */
  43928. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43929. /**
  43930. * Initializes the canvas to be added/removed upon entering/exiting xr
  43931. * @param _xrSessionManager The XR Session manager
  43932. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43933. */
  43934. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43935. /**
  43936. * Disposes of the object
  43937. */
  43938. dispose(): void;
  43939. private _setManagedOutputCanvas;
  43940. private _addCanvas;
  43941. private _removeCanvas;
  43942. }
  43943. }
  43944. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43945. import { Observable } from "babylonjs/Misc/observable";
  43946. import { Nullable } from "babylonjs/types";
  43947. import { IDisposable, Scene } from "babylonjs/scene";
  43948. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43949. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43950. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43951. /**
  43952. * Manages an XRSession to work with Babylon's engine
  43953. * @see https://doc.babylonjs.com/how_to/webxr
  43954. */
  43955. export class WebXRSessionManager implements IDisposable {
  43956. /** The scene which the session should be created for */
  43957. scene: Scene;
  43958. /**
  43959. * Fires every time a new xrFrame arrives which can be used to update the camera
  43960. */
  43961. onXRFrameObservable: Observable<XRFrame>;
  43962. /**
  43963. * Fires when the xr session is ended either by the device or manually done
  43964. */
  43965. onXRSessionEnded: Observable<any>;
  43966. /**
  43967. * Fires when the xr session is ended either by the device or manually done
  43968. */
  43969. onXRSessionInit: Observable<XRSession>;
  43970. /**
  43971. * Fires when the reference space changed
  43972. */
  43973. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43974. /**
  43975. * Underlying xr session
  43976. */
  43977. session: XRSession;
  43978. /**
  43979. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43980. * or get the offset the player is currently at.
  43981. */
  43982. viewerReferenceSpace: XRReferenceSpace;
  43983. private _referenceSpace;
  43984. /**
  43985. * The current reference space used in this session. This reference space can constantly change!
  43986. * It is mainly used to offset the camera's position.
  43987. */
  43988. get referenceSpace(): XRReferenceSpace;
  43989. /**
  43990. * Set a new reference space and triggers the observable
  43991. */
  43992. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43993. /**
  43994. * The base reference space from which the session started. good if you want to reset your
  43995. * reference space
  43996. */
  43997. baseReferenceSpace: XRReferenceSpace;
  43998. /**
  43999. * Used just in case of a failure to initialize an immersive session.
  44000. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44001. */
  44002. defaultHeightCompensation: number;
  44003. /**
  44004. * Current XR frame
  44005. */
  44006. currentFrame: Nullable<XRFrame>;
  44007. /** WebXR timestamp updated every frame */
  44008. currentTimestamp: number;
  44009. private _xrNavigator;
  44010. private baseLayer;
  44011. private _rttProvider;
  44012. private _sessionEnded;
  44013. /**
  44014. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44015. * @param scene The scene which the session should be created for
  44016. */
  44017. constructor(
  44018. /** The scene which the session should be created for */
  44019. scene: Scene);
  44020. /**
  44021. * Initializes the manager
  44022. * After initialization enterXR can be called to start an XR session
  44023. * @returns Promise which resolves after it is initialized
  44024. */
  44025. initializeAsync(): Promise<void>;
  44026. /**
  44027. * Initializes an xr session
  44028. * @param xrSessionMode mode to initialize
  44029. * @param xrSessionInit defines optional and required values to pass to the session builder
  44030. * @returns a promise which will resolve once the session has been initialized
  44031. */
  44032. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44033. /**
  44034. * Sets the reference space on the xr session
  44035. * @param referenceSpaceType space to set
  44036. * @returns a promise that will resolve once the reference space has been set
  44037. */
  44038. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44039. /**
  44040. * Resets the reference space to the one started the session
  44041. */
  44042. resetReferenceSpace(): void;
  44043. /**
  44044. * Updates the render state of the session
  44045. * @param state state to set
  44046. * @returns a promise that resolves once the render state has been updated
  44047. */
  44048. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44049. /**
  44050. * Starts rendering to the xr layer
  44051. */
  44052. runXRRenderLoop(): void;
  44053. /**
  44054. * Gets the correct render target texture to be rendered this frame for this eye
  44055. * @param eye the eye for which to get the render target
  44056. * @returns the render target for the specified eye
  44057. */
  44058. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44059. /**
  44060. * Stops the xrSession and restores the renderloop
  44061. * @returns Promise which resolves after it exits XR
  44062. */
  44063. exitXRAsync(): Promise<void>;
  44064. /**
  44065. * Checks if a session would be supported for the creation options specified
  44066. * @param sessionMode session mode to check if supported eg. immersive-vr
  44067. * @returns true if supported
  44068. */
  44069. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44070. /**
  44071. * Creates a WebXRRenderTarget object for the XR session
  44072. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44073. * @param options optional options to provide when creating a new render target
  44074. * @returns a WebXR render target to which the session can render
  44075. */
  44076. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44077. /**
  44078. * @hidden
  44079. * Converts the render layer of xrSession to a render target
  44080. * @param session session to create render target for
  44081. * @param scene scene the new render target should be created for
  44082. * @param baseLayer the webgl layer to create the render target for
  44083. */
  44084. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44085. /**
  44086. * Disposes of the session manager
  44087. */
  44088. dispose(): void;
  44089. /**
  44090. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44091. * @param sessionMode defines the session to test
  44092. * @returns a promise with boolean as final value
  44093. */
  44094. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44095. }
  44096. }
  44097. declare module "babylonjs/Cameras/XR/webXRCamera" {
  44098. import { Scene } from "babylonjs/scene";
  44099. import { Camera } from "babylonjs/Cameras/camera";
  44100. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44101. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44102. /**
  44103. * WebXR Camera which holds the views for the xrSession
  44104. * @see https://doc.babylonjs.com/how_to/webxr
  44105. */
  44106. export class WebXRCamera extends FreeCamera {
  44107. private _xrSessionManager;
  44108. private _firstFrame;
  44109. private _referencedPosition;
  44110. private _referenceQuaternion;
  44111. private _xrInvPositionCache;
  44112. private _xrInvQuaternionCache;
  44113. /**
  44114. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44115. * @param name the name of the camera
  44116. * @param scene the scene to add the camera to
  44117. */
  44118. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44119. private _updateNumberOfRigCameras;
  44120. /**
  44121. * Sets this camera's transformation based on a non-vr camera
  44122. * @param otherCamera the non-vr camera to copy the transformation from
  44123. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44124. */
  44125. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44126. /** @hidden */
  44127. _updateForDualEyeDebugging(): void;
  44128. private _updateReferenceSpace;
  44129. private _updateReferenceSpaceOffset;
  44130. private _updateFromXRSession;
  44131. }
  44132. }
  44133. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  44134. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44135. import { IDisposable } from "babylonjs/scene";
  44136. /**
  44137. * Defining the interface required for a (webxr) feature
  44138. */
  44139. export interface IWebXRFeature extends IDisposable {
  44140. /**
  44141. * Is this feature attached
  44142. */
  44143. attached: boolean;
  44144. /**
  44145. * Should auto-attach be disabled?
  44146. */
  44147. disableAutoAttach: boolean;
  44148. /**
  44149. * Attach the feature to the session
  44150. * Will usually be called by the features manager
  44151. *
  44152. * @param force should attachment be forced (even when already attached)
  44153. * @returns true if successful.
  44154. */
  44155. attach(force?: boolean): boolean;
  44156. /**
  44157. * Detach the feature from the session
  44158. * Will usually be called by the features manager
  44159. *
  44160. * @returns true if successful.
  44161. */
  44162. detach(): boolean;
  44163. }
  44164. /**
  44165. * A list of the currently available features without referencing them
  44166. */
  44167. export class WebXRFeatureName {
  44168. /**
  44169. * The name of the hit test feature
  44170. */
  44171. static HIT_TEST: string;
  44172. /**
  44173. * The name of the anchor system feature
  44174. */
  44175. static ANCHOR_SYSTEM: string;
  44176. /**
  44177. * The name of the background remover feature
  44178. */
  44179. static BACKGROUND_REMOVER: string;
  44180. /**
  44181. * The name of the pointer selection feature
  44182. */
  44183. static POINTER_SELECTION: string;
  44184. /**
  44185. * The name of the teleportation feature
  44186. */
  44187. static TELEPORTATION: string;
  44188. /**
  44189. * The name of the plane detection feature
  44190. */
  44191. static PLANE_DETECTION: string;
  44192. }
  44193. /**
  44194. * Defining the constructor of a feature. Used to register the modules.
  44195. */
  44196. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44197. /**
  44198. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44199. * It is mainly used in AR sessions.
  44200. *
  44201. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44202. */
  44203. export class WebXRFeaturesManager implements IDisposable {
  44204. private _xrSessionManager;
  44205. private static readonly _AvailableFeatures;
  44206. /**
  44207. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44208. * Mainly used internally.
  44209. *
  44210. * @param featureName the name of the feature to register
  44211. * @param constructorFunction the function used to construct the module
  44212. * @param version the (babylon) version of the module
  44213. * @param stable is that a stable version of this module
  44214. */
  44215. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44216. /**
  44217. * Returns a constructor of a specific feature.
  44218. *
  44219. * @param featureName the name of the feature to construct
  44220. * @param version the version of the feature to load
  44221. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44222. * @param options optional options provided to the module.
  44223. * @returns a function that, when called, will return a new instance of this feature
  44224. */
  44225. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44226. /**
  44227. * Return the latest unstable version of this feature
  44228. * @param featureName the name of the feature to search
  44229. * @returns the version number. if not found will return -1
  44230. */
  44231. static GetLatestVersionOfFeature(featureName: string): number;
  44232. /**
  44233. * Return the latest stable version of this feature
  44234. * @param featureName the name of the feature to search
  44235. * @returns the version number. if not found will return -1
  44236. */
  44237. static GetStableVersionOfFeature(featureName: string): number;
  44238. /**
  44239. * Can be used to return the list of features currently registered
  44240. *
  44241. * @returns an Array of available features
  44242. */
  44243. static GetAvailableFeatures(): string[];
  44244. /**
  44245. * Gets the versions available for a specific feature
  44246. * @param featureName the name of the feature
  44247. * @returns an array with the available versions
  44248. */
  44249. static GetAvailableVersions(featureName: string): string[];
  44250. private _features;
  44251. /**
  44252. * constructs a new features manages.
  44253. *
  44254. * @param _xrSessionManager an instance of WebXRSessionManager
  44255. */
  44256. constructor(_xrSessionManager: WebXRSessionManager);
  44257. /**
  44258. * 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.
  44259. * 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.
  44260. *
  44261. * @param featureName the name of the feature to load or the class of the feature
  44262. * @param version optional version to load. if not provided the latest version will be enabled
  44263. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44264. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44265. * @returns a new constructed feature or throws an error if feature not found.
  44266. */
  44267. enableFeature(featureName: string | {
  44268. Name: string;
  44269. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44270. /**
  44271. * Used to disable an already-enabled feature
  44272. * The feature will be disposed and will be recreated once enabled.
  44273. * @param featureName the feature to disable
  44274. * @returns true if disable was successful
  44275. */
  44276. disableFeature(featureName: string | {
  44277. Name: string;
  44278. }): boolean;
  44279. /**
  44280. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44281. * Can be used during a session to start a feature
  44282. * @param featureName the name of feature to attach
  44283. */
  44284. attachFeature(featureName: string): void;
  44285. /**
  44286. * Can be used inside a session or when the session ends to detach a specific feature
  44287. * @param featureName the name of the feature to detach
  44288. */
  44289. detachFeature(featureName: string): void;
  44290. /**
  44291. * Get the list of enabled features
  44292. * @returns an array of enabled features
  44293. */
  44294. getEnabledFeatures(): string[];
  44295. /**
  44296. * get the implementation of an enabled feature.
  44297. * @param featureName the name of the feature to load
  44298. * @returns the feature class, if found
  44299. */
  44300. getEnabledFeature(featureName: string): IWebXRFeature;
  44301. /**
  44302. * dispose this features manager
  44303. */
  44304. dispose(): void;
  44305. }
  44306. }
  44307. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44308. import { Observable } from "babylonjs/Misc/observable";
  44309. import { IDisposable, Scene } from "babylonjs/scene";
  44310. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44311. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44312. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44313. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44314. /**
  44315. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44316. * @see https://doc.babylonjs.com/how_to/webxr
  44317. */
  44318. export class WebXRExperienceHelper implements IDisposable {
  44319. private scene;
  44320. /**
  44321. * Camera used to render xr content
  44322. */
  44323. camera: WebXRCamera;
  44324. /**
  44325. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44326. */
  44327. state: WebXRState;
  44328. private _setState;
  44329. /**
  44330. * Fires when the state of the experience helper has changed
  44331. */
  44332. onStateChangedObservable: Observable<WebXRState>;
  44333. /**
  44334. * Observers registered here will be triggered after the camera's initial transformation is set
  44335. * This can be used to set a different ground level or an extra rotation.
  44336. *
  44337. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44338. * to the position set after this observable is done executing.
  44339. */
  44340. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44341. /** Session manager used to keep track of xr session */
  44342. sessionManager: WebXRSessionManager;
  44343. /** A features manager for this xr session */
  44344. featuresManager: WebXRFeaturesManager;
  44345. private _nonVRCamera;
  44346. private _originalSceneAutoClear;
  44347. private _supported;
  44348. /**
  44349. * Creates the experience helper
  44350. * @param scene the scene to attach the experience helper to
  44351. * @returns a promise for the experience helper
  44352. */
  44353. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44354. /**
  44355. * Creates a WebXRExperienceHelper
  44356. * @param scene The scene the helper should be created in
  44357. */
  44358. private constructor();
  44359. /**
  44360. * Exits XR mode and returns the scene to its original state
  44361. * @returns promise that resolves after xr mode has exited
  44362. */
  44363. exitXRAsync(): Promise<void>;
  44364. /**
  44365. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44366. * @param sessionMode options for the XR session
  44367. * @param referenceSpaceType frame of reference of the XR session
  44368. * @param renderTarget the output canvas that will be used to enter XR mode
  44369. * @returns promise that resolves after xr mode has entered
  44370. */
  44371. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44372. /**
  44373. * Disposes of the experience helper
  44374. */
  44375. dispose(): void;
  44376. private _nonXRToXRCamera;
  44377. }
  44378. }
  44379. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44380. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44381. import { Observable } from "babylonjs/Misc/observable";
  44382. import { IDisposable } from "babylonjs/scene";
  44383. /**
  44384. * X-Y values for axes in WebXR
  44385. */
  44386. export interface IWebXRMotionControllerAxesValue {
  44387. /**
  44388. * The value of the x axis
  44389. */
  44390. x: number;
  44391. /**
  44392. * The value of the y-axis
  44393. */
  44394. y: number;
  44395. }
  44396. /**
  44397. * changed / previous values for the values of this component
  44398. */
  44399. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44400. /**
  44401. * current (this frame) value
  44402. */
  44403. current: T;
  44404. /**
  44405. * previous (last change) value
  44406. */
  44407. previous: T;
  44408. }
  44409. /**
  44410. * Represents changes in the component between current frame and last values recorded
  44411. */
  44412. export interface IWebXRMotionControllerComponentChanges {
  44413. /**
  44414. * will be populated with previous and current values if touched changed
  44415. */
  44416. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44417. /**
  44418. * will be populated with previous and current values if pressed changed
  44419. */
  44420. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44421. /**
  44422. * will be populated with previous and current values if value changed
  44423. */
  44424. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44425. /**
  44426. * will be populated with previous and current values if axes changed
  44427. */
  44428. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44429. }
  44430. /**
  44431. * This class represents a single component (for example button or thumbstick) of a motion controller
  44432. */
  44433. export class WebXRControllerComponent implements IDisposable {
  44434. /**
  44435. * the id of this component
  44436. */
  44437. id: string;
  44438. /**
  44439. * the type of the component
  44440. */
  44441. type: MotionControllerComponentType;
  44442. private _buttonIndex;
  44443. private _axesIndices;
  44444. /**
  44445. * Thumbstick component type
  44446. */
  44447. static THUMBSTICK: string;
  44448. /**
  44449. * Touchpad component type
  44450. */
  44451. static TOUCHPAD: string;
  44452. /**
  44453. * trigger component type
  44454. */
  44455. static TRIGGER: string;
  44456. /**
  44457. * squeeze component type
  44458. */
  44459. static SQUEEZE: string;
  44460. /**
  44461. * Observers registered here will be triggered when the state of a button changes
  44462. * State change is either pressed / touched / value
  44463. */
  44464. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44465. /**
  44466. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44467. * the axes data changes
  44468. */
  44469. onAxisValueChanged: Observable<{
  44470. x: number;
  44471. y: number;
  44472. }>;
  44473. private _currentValue;
  44474. private _touched;
  44475. private _pressed;
  44476. private _axes;
  44477. private _changes;
  44478. /**
  44479. * Creates a new component for a motion controller.
  44480. * It is created by the motion controller itself
  44481. *
  44482. * @param id the id of this component
  44483. * @param type the type of the component
  44484. * @param _buttonIndex index in the buttons array of the gamepad
  44485. * @param _axesIndices indices of the values in the axes array of the gamepad
  44486. */
  44487. constructor(
  44488. /**
  44489. * the id of this component
  44490. */
  44491. id: string,
  44492. /**
  44493. * the type of the component
  44494. */
  44495. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44496. /**
  44497. * Get the current value of this component
  44498. */
  44499. get value(): number;
  44500. /**
  44501. * is the button currently pressed
  44502. */
  44503. get pressed(): boolean;
  44504. /**
  44505. * is the button currently touched
  44506. */
  44507. get touched(): boolean;
  44508. /**
  44509. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44510. */
  44511. get axes(): IWebXRMotionControllerAxesValue;
  44512. /**
  44513. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44514. */
  44515. get changes(): IWebXRMotionControllerComponentChanges;
  44516. /**
  44517. * Is this component a button (hence - pressable)
  44518. * @returns true if can be pressed
  44519. */
  44520. isButton(): boolean;
  44521. /**
  44522. * Are there axes correlating to this component
  44523. * @return true is axes data is available
  44524. */
  44525. isAxes(): boolean;
  44526. /**
  44527. * update this component using the gamepad object it is in. Called on every frame
  44528. * @param nativeController the native gamepad controller object
  44529. */
  44530. update(nativeController: IMinimalMotionControllerObject): void;
  44531. /**
  44532. * Dispose this component
  44533. */
  44534. dispose(): void;
  44535. }
  44536. }
  44537. declare module "babylonjs/Loading/sceneLoader" {
  44538. import { Observable } from "babylonjs/Misc/observable";
  44539. import { Nullable } from "babylonjs/types";
  44540. import { Scene } from "babylonjs/scene";
  44541. import { Engine } from "babylonjs/Engines/engine";
  44542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44543. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44544. import { AssetContainer } from "babylonjs/assetContainer";
  44545. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44546. import { Skeleton } from "babylonjs/Bones/skeleton";
  44547. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44548. import { WebRequest } from "babylonjs/Misc/webRequest";
  44549. /**
  44550. * Class used to represent data loading progression
  44551. */
  44552. export class SceneLoaderProgressEvent {
  44553. /** defines if data length to load can be evaluated */
  44554. readonly lengthComputable: boolean;
  44555. /** defines the loaded data length */
  44556. readonly loaded: number;
  44557. /** defines the data length to load */
  44558. readonly total: number;
  44559. /**
  44560. * Create a new progress event
  44561. * @param lengthComputable defines if data length to load can be evaluated
  44562. * @param loaded defines the loaded data length
  44563. * @param total defines the data length to load
  44564. */
  44565. constructor(
  44566. /** defines if data length to load can be evaluated */
  44567. lengthComputable: boolean,
  44568. /** defines the loaded data length */
  44569. loaded: number,
  44570. /** defines the data length to load */
  44571. total: number);
  44572. /**
  44573. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44574. * @param event defines the source event
  44575. * @returns a new SceneLoaderProgressEvent
  44576. */
  44577. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44578. }
  44579. /**
  44580. * Interface used by SceneLoader plugins to define supported file extensions
  44581. */
  44582. export interface ISceneLoaderPluginExtensions {
  44583. /**
  44584. * Defines the list of supported extensions
  44585. */
  44586. [extension: string]: {
  44587. isBinary: boolean;
  44588. };
  44589. }
  44590. /**
  44591. * Interface used by SceneLoader plugin factory
  44592. */
  44593. export interface ISceneLoaderPluginFactory {
  44594. /**
  44595. * Defines the name of the factory
  44596. */
  44597. name: string;
  44598. /**
  44599. * Function called to create a new plugin
  44600. * @return the new plugin
  44601. */
  44602. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44603. /**
  44604. * The callback that returns true if the data can be directly loaded.
  44605. * @param data string containing the file data
  44606. * @returns if the data can be loaded directly
  44607. */
  44608. canDirectLoad?(data: string): boolean;
  44609. }
  44610. /**
  44611. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44612. */
  44613. export interface ISceneLoaderPluginBase {
  44614. /**
  44615. * The friendly name of this plugin.
  44616. */
  44617. name: string;
  44618. /**
  44619. * The file extensions supported by this plugin.
  44620. */
  44621. extensions: string | ISceneLoaderPluginExtensions;
  44622. /**
  44623. * The callback called when loading from a url.
  44624. * @param scene scene loading this url
  44625. * @param url url to load
  44626. * @param onSuccess callback called when the file successfully loads
  44627. * @param onProgress callback called while file is loading (if the server supports this mode)
  44628. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44629. * @param onError callback called when the file fails to load
  44630. * @returns a file request object
  44631. */
  44632. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44633. /**
  44634. * The callback called when loading from a file object.
  44635. * @param scene scene loading this file
  44636. * @param file defines the file to load
  44637. * @param onSuccess defines the callback to call when data is loaded
  44638. * @param onProgress defines the callback to call during loading process
  44639. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44640. * @param onError defines the callback to call when an error occurs
  44641. * @returns a file request object
  44642. */
  44643. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44644. /**
  44645. * The callback that returns true if the data can be directly loaded.
  44646. * @param data string containing the file data
  44647. * @returns if the data can be loaded directly
  44648. */
  44649. canDirectLoad?(data: string): boolean;
  44650. /**
  44651. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44652. * @param scene scene loading this data
  44653. * @param data string containing the data
  44654. * @returns data to pass to the plugin
  44655. */
  44656. directLoad?(scene: Scene, data: string): any;
  44657. /**
  44658. * The callback that allows custom handling of the root url based on the response url.
  44659. * @param rootUrl the original root url
  44660. * @param responseURL the response url if available
  44661. * @returns the new root url
  44662. */
  44663. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44664. }
  44665. /**
  44666. * Interface used to define a SceneLoader plugin
  44667. */
  44668. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44669. /**
  44670. * Import meshes into a scene.
  44671. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44672. * @param scene The scene to import into
  44673. * @param data The data to import
  44674. * @param rootUrl The root url for scene and resources
  44675. * @param meshes The meshes array to import into
  44676. * @param particleSystems The particle systems array to import into
  44677. * @param skeletons The skeletons array to import into
  44678. * @param onError The callback when import fails
  44679. * @returns True if successful or false otherwise
  44680. */
  44681. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44682. /**
  44683. * Load into a scene.
  44684. * @param scene The scene to load into
  44685. * @param data The data to import
  44686. * @param rootUrl The root url for scene and resources
  44687. * @param onError The callback when import fails
  44688. * @returns True if successful or false otherwise
  44689. */
  44690. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44691. /**
  44692. * Load into an asset container.
  44693. * @param scene The scene to load into
  44694. * @param data The data to import
  44695. * @param rootUrl The root url for scene and resources
  44696. * @param onError The callback when import fails
  44697. * @returns The loaded asset container
  44698. */
  44699. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44700. }
  44701. /**
  44702. * Interface used to define an async SceneLoader plugin
  44703. */
  44704. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44705. /**
  44706. * Import meshes into a scene.
  44707. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44708. * @param scene The scene to import into
  44709. * @param data The data to import
  44710. * @param rootUrl The root url for scene and resources
  44711. * @param onProgress The callback when the load progresses
  44712. * @param fileName Defines the name of the file to load
  44713. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44714. */
  44715. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44716. meshes: AbstractMesh[];
  44717. particleSystems: IParticleSystem[];
  44718. skeletons: Skeleton[];
  44719. animationGroups: AnimationGroup[];
  44720. }>;
  44721. /**
  44722. * Load into a scene.
  44723. * @param scene The scene to load into
  44724. * @param data The data to import
  44725. * @param rootUrl The root url for scene and resources
  44726. * @param onProgress The callback when the load progresses
  44727. * @param fileName Defines the name of the file to load
  44728. * @returns Nothing
  44729. */
  44730. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44731. /**
  44732. * Load into an asset container.
  44733. * @param scene The scene to load into
  44734. * @param data The data to import
  44735. * @param rootUrl The root url for scene and resources
  44736. * @param onProgress The callback when the load progresses
  44737. * @param fileName Defines the name of the file to load
  44738. * @returns The loaded asset container
  44739. */
  44740. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44741. }
  44742. /**
  44743. * Mode that determines how to handle old animation groups before loading new ones.
  44744. */
  44745. export enum SceneLoaderAnimationGroupLoadingMode {
  44746. /**
  44747. * Reset all old animations to initial state then dispose them.
  44748. */
  44749. Clean = 0,
  44750. /**
  44751. * Stop all old animations.
  44752. */
  44753. Stop = 1,
  44754. /**
  44755. * Restart old animations from first frame.
  44756. */
  44757. Sync = 2,
  44758. /**
  44759. * Old animations remains untouched.
  44760. */
  44761. NoSync = 3
  44762. }
  44763. /**
  44764. * Class used to load scene from various file formats using registered plugins
  44765. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44766. */
  44767. export class SceneLoader {
  44768. /**
  44769. * No logging while loading
  44770. */
  44771. static readonly NO_LOGGING: number;
  44772. /**
  44773. * Minimal logging while loading
  44774. */
  44775. static readonly MINIMAL_LOGGING: number;
  44776. /**
  44777. * Summary logging while loading
  44778. */
  44779. static readonly SUMMARY_LOGGING: number;
  44780. /**
  44781. * Detailled logging while loading
  44782. */
  44783. static readonly DETAILED_LOGGING: number;
  44784. /**
  44785. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44786. */
  44787. static get ForceFullSceneLoadingForIncremental(): boolean;
  44788. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44789. /**
  44790. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44791. */
  44792. static get ShowLoadingScreen(): boolean;
  44793. static set ShowLoadingScreen(value: boolean);
  44794. /**
  44795. * Defines the current logging level (while loading the scene)
  44796. * @ignorenaming
  44797. */
  44798. static get loggingLevel(): number;
  44799. static set loggingLevel(value: number);
  44800. /**
  44801. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44802. */
  44803. static get CleanBoneMatrixWeights(): boolean;
  44804. static set CleanBoneMatrixWeights(value: boolean);
  44805. /**
  44806. * Event raised when a plugin is used to load a scene
  44807. */
  44808. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44809. private static _registeredPlugins;
  44810. private static _getDefaultPlugin;
  44811. private static _getPluginForExtension;
  44812. private static _getPluginForDirectLoad;
  44813. private static _getPluginForFilename;
  44814. private static _getDirectLoad;
  44815. private static _loadData;
  44816. private static _getFileInfo;
  44817. /**
  44818. * Gets a plugin that can load the given extension
  44819. * @param extension defines the extension to load
  44820. * @returns a plugin or null if none works
  44821. */
  44822. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44823. /**
  44824. * Gets a boolean indicating that the given extension can be loaded
  44825. * @param extension defines the extension to load
  44826. * @returns true if the extension is supported
  44827. */
  44828. static IsPluginForExtensionAvailable(extension: string): boolean;
  44829. /**
  44830. * Adds a new plugin to the list of registered plugins
  44831. * @param plugin defines the plugin to add
  44832. */
  44833. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44834. /**
  44835. * Import meshes into a scene
  44836. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44837. * @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)
  44838. * @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)
  44839. * @param scene the instance of BABYLON.Scene to append to
  44840. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44841. * @param onProgress a callback with a progress event for each file being loaded
  44842. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44843. * @param pluginExtension the extension used to determine the plugin
  44844. * @returns The loaded plugin
  44845. */
  44846. 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>;
  44847. /**
  44848. * Import meshes into a scene
  44849. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44850. * @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)
  44851. * @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)
  44852. * @param scene the instance of BABYLON.Scene to append to
  44853. * @param onProgress a callback with a progress event for each file being loaded
  44854. * @param pluginExtension the extension used to determine the plugin
  44855. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44856. */
  44857. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44858. meshes: AbstractMesh[];
  44859. particleSystems: IParticleSystem[];
  44860. skeletons: Skeleton[];
  44861. animationGroups: AnimationGroup[];
  44862. }>;
  44863. /**
  44864. * Load a scene
  44865. * @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)
  44866. * @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)
  44867. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44868. * @param onSuccess a callback with the scene when import succeeds
  44869. * @param onProgress a callback with a progress event for each file being loaded
  44870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44871. * @param pluginExtension the extension used to determine the plugin
  44872. * @returns The loaded plugin
  44873. */
  44874. 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>;
  44875. /**
  44876. * Load a scene
  44877. * @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)
  44878. * @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)
  44879. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44880. * @param onProgress a callback with a progress event for each file being loaded
  44881. * @param pluginExtension the extension used to determine the plugin
  44882. * @returns The loaded scene
  44883. */
  44884. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44885. /**
  44886. * Append a scene
  44887. * @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)
  44888. * @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)
  44889. * @param scene is the instance of BABYLON.Scene to append to
  44890. * @param onSuccess a callback with the scene when import succeeds
  44891. * @param onProgress a callback with a progress event for each file being loaded
  44892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44893. * @param pluginExtension the extension used to determine the plugin
  44894. * @returns The loaded plugin
  44895. */
  44896. 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>;
  44897. /**
  44898. * Append a scene
  44899. * @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)
  44900. * @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)
  44901. * @param scene is the instance of BABYLON.Scene to append to
  44902. * @param onProgress a callback with a progress event for each file being loaded
  44903. * @param pluginExtension the extension used to determine the plugin
  44904. * @returns The given scene
  44905. */
  44906. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44907. /**
  44908. * Load a scene into an asset container
  44909. * @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)
  44910. * @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)
  44911. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44912. * @param onSuccess a callback with the scene when import succeeds
  44913. * @param onProgress a callback with a progress event for each file being loaded
  44914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44915. * @param pluginExtension the extension used to determine the plugin
  44916. * @returns The loaded plugin
  44917. */
  44918. 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>;
  44919. /**
  44920. * Load a scene into an asset container
  44921. * @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)
  44922. * @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)
  44923. * @param scene is the instance of Scene to append to
  44924. * @param onProgress a callback with a progress event for each file being loaded
  44925. * @param pluginExtension the extension used to determine the plugin
  44926. * @returns The loaded asset container
  44927. */
  44928. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44929. /**
  44930. * Import animations from a file into 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 scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44934. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44935. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44936. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44937. * @param onSuccess a callback with the scene when import succeeds
  44938. * @param onProgress a callback with a progress event for each file being loaded
  44939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44940. */
  44941. 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;
  44942. /**
  44943. * Import animations from a file into a scene
  44944. * @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)
  44945. * @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)
  44946. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44947. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44948. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44949. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44950. * @param onSuccess a callback with the scene when import succeeds
  44951. * @param onProgress a callback with a progress event for each file being loaded
  44952. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44953. * @returns the updated scene with imported animations
  44954. */
  44955. 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>;
  44956. }
  44957. }
  44958. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44959. import { IDisposable, Scene } from "babylonjs/scene";
  44960. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44961. import { Observable } from "babylonjs/Misc/observable";
  44962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44963. import { Nullable } from "babylonjs/types";
  44964. /**
  44965. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44966. */
  44967. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44968. /**
  44969. * The type of components available in motion controllers.
  44970. * This is not the name of the component.
  44971. */
  44972. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44973. /**
  44974. * The schema of motion controller layout.
  44975. * No object will be initialized using this interface
  44976. * This is used just to define the profile.
  44977. */
  44978. export interface IMotionControllerLayout {
  44979. /**
  44980. * Defines the main button component id
  44981. */
  44982. selectComponentId: string;
  44983. /**
  44984. * Available components (unsorted)
  44985. */
  44986. components: {
  44987. /**
  44988. * A map of component Ids
  44989. */
  44990. [componentId: string]: {
  44991. /**
  44992. * The type of input the component outputs
  44993. */
  44994. type: MotionControllerComponentType;
  44995. };
  44996. };
  44997. /**
  44998. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44999. */
  45000. gamepad?: {
  45001. /**
  45002. * Is the mapping based on the xr-standard defined here:
  45003. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  45004. */
  45005. mapping: "" | "xr-standard";
  45006. /**
  45007. * The buttons available in this input in the right order
  45008. * index of this button will be the index in the gamepadObject.buttons array
  45009. * correlates to the componentId in components
  45010. */
  45011. buttons: Array<string | null>;
  45012. /**
  45013. * Definition of the axes of the gamepad input, sorted
  45014. * Correlates to componentIds in the components map
  45015. */
  45016. axes: Array<{
  45017. /**
  45018. * The component id that the axis correlates to
  45019. */
  45020. componentId: string;
  45021. /**
  45022. * X or Y Axis
  45023. */
  45024. axis: "x-axis" | "y-axis";
  45025. } | null>;
  45026. };
  45027. }
  45028. /**
  45029. * A definition for the layout map in the input profile
  45030. */
  45031. export interface IMotionControllerLayoutMap {
  45032. /**
  45033. * Layouts with handness type as a key
  45034. */
  45035. [handness: string]: IMotionControllerLayout;
  45036. }
  45037. /**
  45038. * The XR Input profile schema
  45039. * Profiles can be found here:
  45040. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45041. */
  45042. export interface IMotionControllerProfile {
  45043. /**
  45044. * The id of this profile
  45045. * correlates to the profile(s) in the xrInput.profiles array
  45046. */
  45047. profileId: string;
  45048. /**
  45049. * fallback profiles for this profileId
  45050. */
  45051. fallbackProfileIds: string[];
  45052. /**
  45053. * The layout map, with handness as key
  45054. */
  45055. layouts: IMotionControllerLayoutMap;
  45056. }
  45057. /**
  45058. * A helper-interface for the 3 meshes needed for controller button animation
  45059. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45060. */
  45061. export interface IMotionControllerButtonMeshMap {
  45062. /**
  45063. * The mesh that will be changed when value changes
  45064. */
  45065. valueMesh: AbstractMesh;
  45066. /**
  45067. * the mesh that defines the pressed value mesh position.
  45068. * This is used to find the max-position of this button
  45069. */
  45070. pressedMesh: AbstractMesh;
  45071. /**
  45072. * the mesh that defines the unpressed value mesh position.
  45073. * This is used to find the min (or initial) position of this button
  45074. */
  45075. unpressedMesh: AbstractMesh;
  45076. }
  45077. /**
  45078. * A helper-interface for the 3 meshes needed for controller axis animation.
  45079. * This will be expanded when touchpad animations are fully supported
  45080. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45081. */
  45082. export interface IMotionControllerAxisMeshMap {
  45083. /**
  45084. * The mesh that will be changed when axis value changes
  45085. */
  45086. valueMesh: AbstractMesh;
  45087. /**
  45088. * the mesh that defines the minimum value mesh position.
  45089. */
  45090. minMesh: AbstractMesh;
  45091. /**
  45092. * the mesh that defines the maximum value mesh position.
  45093. */
  45094. maxMesh: AbstractMesh;
  45095. }
  45096. /**
  45097. * The elements needed for change-detection of the gamepad objects in motion controllers
  45098. */
  45099. export interface IMinimalMotionControllerObject {
  45100. /**
  45101. * An array of available buttons
  45102. */
  45103. buttons: Array<{
  45104. /**
  45105. * Value of the button/trigger
  45106. */
  45107. value: number;
  45108. /**
  45109. * If the button/trigger is currently touched
  45110. */
  45111. touched: boolean;
  45112. /**
  45113. * If the button/trigger is currently pressed
  45114. */
  45115. pressed: boolean;
  45116. }>;
  45117. /**
  45118. * Available axes of this controller
  45119. */
  45120. axes: number[];
  45121. }
  45122. /**
  45123. * An Abstract Motion controller
  45124. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45125. * Each component has an observable to check for changes in value and state
  45126. */
  45127. export abstract class WebXRAbstractMotionController implements IDisposable {
  45128. protected scene: Scene;
  45129. protected layout: IMotionControllerLayout;
  45130. /**
  45131. * The gamepad object correlating to this controller
  45132. */
  45133. gamepadObject: IMinimalMotionControllerObject;
  45134. /**
  45135. * handness (left/right/none) of this controller
  45136. */
  45137. handness: MotionControllerHandness;
  45138. /**
  45139. * Component type map
  45140. */
  45141. static ComponentType: {
  45142. TRIGGER: string;
  45143. SQUEEZE: string;
  45144. TOUCHPAD: string;
  45145. THUMBSTICK: string;
  45146. BUTTON: string;
  45147. };
  45148. /**
  45149. * The profile id of this motion controller
  45150. */
  45151. abstract profileId: string;
  45152. /**
  45153. * A map of components (WebXRControllerComponent) in this motion controller
  45154. * Components have a ComponentType and can also have both button and axis definitions
  45155. */
  45156. readonly components: {
  45157. [id: string]: WebXRControllerComponent;
  45158. };
  45159. /**
  45160. * Observers registered here will be triggered when the model of this controller is done loading
  45161. */
  45162. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45163. /**
  45164. * The root mesh of the model. It is null if the model was not yet initialized
  45165. */
  45166. rootMesh: Nullable<AbstractMesh>;
  45167. private _modelReady;
  45168. /**
  45169. * constructs a new abstract motion controller
  45170. * @param scene the scene to which the model of the controller will be added
  45171. * @param layout The profile layout to load
  45172. * @param gamepadObject The gamepad object correlating to this controller
  45173. * @param handness handness (left/right/none) of this controller
  45174. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45175. */
  45176. constructor(scene: Scene, layout: IMotionControllerLayout,
  45177. /**
  45178. * The gamepad object correlating to this controller
  45179. */
  45180. gamepadObject: IMinimalMotionControllerObject,
  45181. /**
  45182. * handness (left/right/none) of this controller
  45183. */
  45184. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45185. private _initComponent;
  45186. /**
  45187. * Update this model using the current XRFrame
  45188. * @param xrFrame the current xr frame to use and update the model
  45189. */
  45190. updateFromXRFrame(xrFrame: XRFrame): void;
  45191. /**
  45192. * Get the list of components available in this motion controller
  45193. * @returns an array of strings correlating to available components
  45194. */
  45195. getComponentTypes(): string[];
  45196. /**
  45197. * Get the main (Select) component of this controller as defined in the layout
  45198. * @returns the main component of this controller
  45199. */
  45200. getMainComponent(): WebXRControllerComponent;
  45201. /**
  45202. * get a component based an its component id as defined in layout.components
  45203. * @param id the id of the component
  45204. * @returns the component correlates to the id or undefined if not found
  45205. */
  45206. getComponent(id: string): WebXRControllerComponent;
  45207. /**
  45208. * Loads the model correlating to this controller
  45209. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45210. * @returns A promise fulfilled with the result of the model loading
  45211. */
  45212. loadModel(): Promise<boolean>;
  45213. /**
  45214. * Update the model itself with the current frame data
  45215. * @param xrFrame the frame to use for updating the model mesh
  45216. */
  45217. protected updateModel(xrFrame: XRFrame): void;
  45218. /**
  45219. * Moves the axis on the controller mesh based on its current state
  45220. * @param axis the index of the axis
  45221. * @param axisValue the value of the axis which determines the meshes new position
  45222. * @hidden
  45223. */
  45224. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45225. /**
  45226. * Moves the buttons on the controller mesh based on their current state
  45227. * @param buttonName the name of the button to move
  45228. * @param buttonValue the value of the button which determines the buttons new position
  45229. */
  45230. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45231. private _getGenericFilenameAndPath;
  45232. private _getGenericParentMesh;
  45233. /**
  45234. * Get the filename and path for this controller's model
  45235. * @returns a map of filename and path
  45236. */
  45237. protected abstract _getFilenameAndPath(): {
  45238. filename: string;
  45239. path: string;
  45240. };
  45241. /**
  45242. * This function will be called after the model was successfully loaded and can be used
  45243. * for mesh transformations before it is available for the user
  45244. * @param meshes the loaded meshes
  45245. */
  45246. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45247. /**
  45248. * Set the root mesh for this controller. Important for the WebXR controller class
  45249. * @param meshes the loaded meshes
  45250. */
  45251. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45252. /**
  45253. * A function executed each frame that updates the mesh (if needed)
  45254. * @param xrFrame the current xrFrame
  45255. */
  45256. protected abstract _updateModel(xrFrame: XRFrame): void;
  45257. /**
  45258. * This function is called before the mesh is loaded. It checks for loading constraints.
  45259. * For example, this function can check if the GLB loader is available
  45260. * If this function returns false, the generic controller will be loaded instead
  45261. * @returns Is the client ready to load the mesh
  45262. */
  45263. protected abstract _getModelLoadingConstraints(): boolean;
  45264. /**
  45265. * Dispose this controller, the model mesh and all its components
  45266. */
  45267. dispose(): void;
  45268. }
  45269. }
  45270. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45271. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45273. import { Scene } from "babylonjs/scene";
  45274. /**
  45275. * A generic trigger-only motion controller for WebXR
  45276. */
  45277. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45278. /**
  45279. * Static version of the profile id of this controller
  45280. */
  45281. static ProfileId: string;
  45282. profileId: string;
  45283. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45284. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45285. protected _updateModel(): void;
  45286. protected _getFilenameAndPath(): {
  45287. filename: string;
  45288. path: string;
  45289. };
  45290. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45291. protected _getModelLoadingConstraints(): boolean;
  45292. }
  45293. }
  45294. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45295. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45296. import { Scene } from "babylonjs/scene";
  45297. /**
  45298. * A construction function type to create a new controller based on an xrInput object
  45299. */
  45300. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45301. /**
  45302. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45303. *
  45304. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45305. * it should be replaced with auto-loaded controllers.
  45306. *
  45307. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45308. */
  45309. export class WebXRMotionControllerManager {
  45310. private static _AvailableControllers;
  45311. private static _Fallbacks;
  45312. /**
  45313. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45314. *
  45315. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45316. *
  45317. * @param type the profile type to register
  45318. * @param constructFunction the function to be called when loading this profile
  45319. */
  45320. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45321. /**
  45322. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45323. * The order of search:
  45324. *
  45325. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45326. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45327. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45328. * 4) return the generic trigger controller if none were found
  45329. *
  45330. * @param xrInput the xrInput to which a new controller is initialized
  45331. * @param scene the scene to which the model will be added
  45332. * @param forceProfile force a certain profile for this controller
  45333. * @return the motion controller class for this profile id or the generic standard class if none was found
  45334. */
  45335. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  45336. /**
  45337. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45338. * @param profileId the profile to which a fallback needs to be found
  45339. * @return an array with corresponding fallback profiles
  45340. */
  45341. static FindFallbackWithProfileId(profileId: string): string[];
  45342. /**
  45343. * Register a fallback to a specific profile.
  45344. * @param profileId the profileId that will receive the fallbacks
  45345. * @param fallbacks A list of fallback profiles
  45346. */
  45347. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45348. /**
  45349. * Register the default fallbacks.
  45350. * This function is called automatically when this file is imported.
  45351. */
  45352. static DefaultFallbacks(): void;
  45353. }
  45354. }
  45355. declare module "babylonjs/Cameras/XR/webXRController" {
  45356. import { Observable } from "babylonjs/Misc/observable";
  45357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45358. import { Ray } from "babylonjs/Culling/ray";
  45359. import { Scene } from "babylonjs/scene";
  45360. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45361. /**
  45362. * Configuration options for the WebXR controller creation
  45363. */
  45364. export interface IWebXRControllerOptions {
  45365. /**
  45366. * Force a specific controller type for this controller.
  45367. * This can be used when creating your own profile or when testing different controllers
  45368. */
  45369. forceControllerProfile?: string;
  45370. }
  45371. /**
  45372. * Represents an XR controller
  45373. */
  45374. export class WebXRController {
  45375. private _scene;
  45376. /** The underlying input source for the controller */
  45377. inputSource: XRInputSource;
  45378. private _options;
  45379. /**
  45380. * 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
  45381. */
  45382. grip?: AbstractMesh;
  45383. /**
  45384. * Pointer which can be used to select objects or attach a visible laser to
  45385. */
  45386. pointer: AbstractMesh;
  45387. /**
  45388. * If available, this is the gamepad object related to this controller.
  45389. * Using this object it is possible to get click events and trackpad changes of the
  45390. * webxr controller that is currently being used.
  45391. */
  45392. motionController?: WebXRAbstractMotionController;
  45393. /**
  45394. * Event that fires when the controller is removed/disposed
  45395. */
  45396. onDisposeObservable: Observable<{}>;
  45397. private _tmpQuaternion;
  45398. private _tmpVector;
  45399. private _uniqueId;
  45400. /**
  45401. * Creates the controller
  45402. * @see https://doc.babylonjs.com/how_to/webxr
  45403. * @param _scene the scene which the controller should be associated to
  45404. * @param inputSource the underlying input source for the controller
  45405. * @param _options options for this controller creation
  45406. */
  45407. constructor(_scene: Scene,
  45408. /** The underlying input source for the controller */
  45409. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45410. /**
  45411. * Get this controllers unique id
  45412. */
  45413. get uniqueId(): string;
  45414. /**
  45415. * Updates the controller pose based on the given XRFrame
  45416. * @param xrFrame xr frame to update the pose with
  45417. * @param referenceSpace reference space to use
  45418. */
  45419. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45420. /**
  45421. * Gets a world space ray coming from the controller
  45422. * @param result the resulting ray
  45423. */
  45424. getWorldPointerRayToRef(result: Ray): void;
  45425. /**
  45426. * Disposes of the object
  45427. */
  45428. dispose(): void;
  45429. }
  45430. }
  45431. declare module "babylonjs/Cameras/XR/webXRInput" {
  45432. import { Observable } from "babylonjs/Misc/observable";
  45433. import { IDisposable } from "babylonjs/scene";
  45434. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45435. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45436. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45437. /**
  45438. * The schema for initialization options of the XR Input class
  45439. */
  45440. export interface IWebXRInputOptions {
  45441. /**
  45442. * If set to true no model will be automatically loaded
  45443. */
  45444. doNotLoadControllerMeshes?: boolean;
  45445. /**
  45446. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45447. * If not found, the xr input profile data will be used.
  45448. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45449. */
  45450. forceInputProfile?: string;
  45451. }
  45452. /**
  45453. * XR input used to track XR inputs such as controllers/rays
  45454. */
  45455. export class WebXRInput implements IDisposable {
  45456. /**
  45457. * the xr session manager for this session
  45458. */
  45459. xrSessionManager: WebXRSessionManager;
  45460. /**
  45461. * the WebXR camera for this session. Mainly used for teleportation
  45462. */
  45463. xrCamera: WebXRCamera;
  45464. private readonly options;
  45465. /**
  45466. * XR controllers being tracked
  45467. */
  45468. controllers: Array<WebXRController>;
  45469. private _frameObserver;
  45470. private _sessionEndedObserver;
  45471. private _sessionInitObserver;
  45472. /**
  45473. * Event when a controller has been connected/added
  45474. */
  45475. onControllerAddedObservable: Observable<WebXRController>;
  45476. /**
  45477. * Event when a controller has been removed/disconnected
  45478. */
  45479. onControllerRemovedObservable: Observable<WebXRController>;
  45480. /**
  45481. * Initializes the WebXRInput
  45482. * @param xrSessionManager the xr session manager for this session
  45483. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45484. * @param options = initialization options for this xr input
  45485. */
  45486. constructor(
  45487. /**
  45488. * the xr session manager for this session
  45489. */
  45490. xrSessionManager: WebXRSessionManager,
  45491. /**
  45492. * the WebXR camera for this session. Mainly used for teleportation
  45493. */
  45494. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45495. private _onInputSourcesChange;
  45496. private _addAndRemoveControllers;
  45497. /**
  45498. * Disposes of the object
  45499. */
  45500. dispose(): void;
  45501. }
  45502. }
  45503. declare module "babylonjs/Cameras/XR/features/WebXRAbstractFeature" {
  45504. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45505. import { Observable, EventState } from "babylonjs/Misc/observable";
  45506. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45507. /**
  45508. * This is the base class for all WebXR features.
  45509. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45510. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45511. */
  45512. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45513. protected _xrSessionManager: WebXRSessionManager;
  45514. /**
  45515. * Construct a new (abstract) webxr feature
  45516. * @param _xrSessionManager the xr session manager for this feature
  45517. */
  45518. constructor(_xrSessionManager: WebXRSessionManager);
  45519. private _attached;
  45520. private _removeOnDetach;
  45521. /**
  45522. * Is this feature attached
  45523. */
  45524. get attached(): boolean;
  45525. /**
  45526. * Should auto-attach be disabled?
  45527. */
  45528. disableAutoAttach: boolean;
  45529. /**
  45530. * attach this feature
  45531. *
  45532. * @param force should attachment be forced (even when already attached)
  45533. * @returns true if successful, false is failed or already attached
  45534. */
  45535. attach(force?: boolean): boolean;
  45536. /**
  45537. * detach this feature.
  45538. *
  45539. * @returns true if successful, false if failed or already detached
  45540. */
  45541. detach(): boolean;
  45542. /**
  45543. * Dispose this feature and all of the resources attached
  45544. */
  45545. dispose(): void;
  45546. /**
  45547. * Code in this function will be executed on each xrFrame received from the browser.
  45548. * This function will not execute after the feature is detached.
  45549. * @param _xrFrame the current frame
  45550. */
  45551. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45552. /**
  45553. * This is used to register callbacks that will automatically be removed when detach is called.
  45554. * @param observable the observable to which the observer will be attached
  45555. * @param callback the callback to register
  45556. */
  45557. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45558. }
  45559. }
  45560. declare module "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection" {
  45561. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45562. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45563. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45564. import { Nullable } from "babylonjs/types";
  45565. import { Color3 } from "babylonjs/Maths/math.color";
  45566. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  45567. /**
  45568. * Options interface for the pointer selection module
  45569. */
  45570. export interface IWebXRControllerPointerSelectionOptions {
  45571. /**
  45572. * the xr input to use with this pointer selection
  45573. */
  45574. xrInput: WebXRInput;
  45575. /**
  45576. * Different button type to use instead of the main component
  45577. */
  45578. overrideButtonId?: string;
  45579. /**
  45580. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  45581. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45582. * 3000 means 3 seconds between pointing at something and selecting it
  45583. */
  45584. timeToSelect?: number;
  45585. /**
  45586. * 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)
  45587. * If not disabled, the last picked point will be used to execute a pointer up event
  45588. * If disabled, pointer up event will be triggered right after the pointer down event.
  45589. * Used in screen and gaze target ray mode only
  45590. */
  45591. disablePointerUpOnTouchOut: boolean;
  45592. /**
  45593. * For gaze mode (time to select instead of press)
  45594. */
  45595. forceGazeMode: boolean;
  45596. /**
  45597. * 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
  45598. * to start a new countdown to the pointer down event.
  45599. * Defaults to 1.
  45600. */
  45601. gazeModePointerMovedFactor?: number;
  45602. }
  45603. /**
  45604. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45605. */
  45606. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45607. private readonly _options;
  45608. /**
  45609. * The module's name
  45610. */
  45611. static readonly Name: string;
  45612. /**
  45613. * The (Babylon) version of this module.
  45614. * This is an integer representing the implementation version.
  45615. * This number does not correspond to the webxr specs version
  45616. */
  45617. static readonly Version: number;
  45618. /**
  45619. * This color will be set to the laser pointer when selection is triggered
  45620. */
  45621. laserPointerPickedColor: Color3;
  45622. /**
  45623. * This color will be applied to the selection ring when selection is triggered
  45624. */
  45625. selectionMeshPickedColor: Color3;
  45626. /**
  45627. * default color of the selection ring
  45628. */
  45629. selectionMeshDefaultColor: Color3;
  45630. /**
  45631. * Default color of the laser pointer
  45632. */
  45633. lasterPointerDefaultColor: Color3;
  45634. /**
  45635. * Should the laser pointer be displayed
  45636. */
  45637. displayLaserPointer: boolean;
  45638. /**
  45639. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45640. */
  45641. displaySelectionMesh: boolean;
  45642. /**
  45643. * Disable lighting on the laser pointer (so it will always be visible)
  45644. */
  45645. disablePointerLighting: boolean;
  45646. /**
  45647. * Disable lighting on the selection mesh (so it will always be visible)
  45648. */
  45649. disableSelectionMeshLighting: boolean;
  45650. private static _idCounter;
  45651. private _tmpRay;
  45652. private _controllers;
  45653. private _scene;
  45654. /**
  45655. * constructs a new background remover module
  45656. * @param _xrSessionManager the session manager for this module
  45657. * @param _options read-only options to be used in this module
  45658. */
  45659. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45660. /**
  45661. * attach this feature
  45662. * Will usually be called by the features manager
  45663. *
  45664. * @returns true if successful.
  45665. */
  45666. attach(): boolean;
  45667. /**
  45668. * detach this feature.
  45669. * Will usually be called by the features manager
  45670. *
  45671. * @returns true if successful.
  45672. */
  45673. detach(): boolean;
  45674. /**
  45675. * Get the xr controller that correlates to the pointer id in the pointer event
  45676. *
  45677. * @param id the pointer id to search for
  45678. * @returns the controller that correlates to this id or null if not found
  45679. */
  45680. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  45681. protected _onXRFrame(_xrFrame: XRFrame): void;
  45682. private _attachController;
  45683. private _attachScreenRayMode;
  45684. private _attachGazeMode;
  45685. private _tmpVectorForPickCompare;
  45686. private _pickingMoved;
  45687. private _attachTrackedPointerRayMode;
  45688. private _detachController;
  45689. private _generateNewMeshPair;
  45690. private _convertNormalToDirectionOfRay;
  45691. private _updatePointerDistance;
  45692. }
  45693. }
  45694. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45695. import { Nullable } from "babylonjs/types";
  45696. import { Observable } from "babylonjs/Misc/observable";
  45697. import { IDisposable, Scene } from "babylonjs/scene";
  45698. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45699. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45700. /**
  45701. * Button which can be used to enter a different mode of XR
  45702. */
  45703. export class WebXREnterExitUIButton {
  45704. /** button element */
  45705. element: HTMLElement;
  45706. /** XR initialization options for the button */
  45707. sessionMode: XRSessionMode;
  45708. /** Reference space type */
  45709. referenceSpaceType: XRReferenceSpaceType;
  45710. /**
  45711. * Creates a WebXREnterExitUIButton
  45712. * @param element button element
  45713. * @param sessionMode XR initialization session mode
  45714. * @param referenceSpaceType the type of reference space to be used
  45715. */
  45716. constructor(
  45717. /** button element */
  45718. element: HTMLElement,
  45719. /** XR initialization options for the button */
  45720. sessionMode: XRSessionMode,
  45721. /** Reference space type */
  45722. referenceSpaceType: XRReferenceSpaceType);
  45723. /**
  45724. * Overwritable function which can be used to update the button's visuals when the state changes
  45725. * @param activeButton the current active button in the UI
  45726. */
  45727. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45728. }
  45729. /**
  45730. * Options to create the webXR UI
  45731. */
  45732. export class WebXREnterExitUIOptions {
  45733. /**
  45734. * Context to enter xr with
  45735. */
  45736. renderTarget?: Nullable<WebXRRenderTarget>;
  45737. /**
  45738. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45739. */
  45740. customButtons?: Array<WebXREnterExitUIButton>;
  45741. /**
  45742. * A session mode to use when creating the default button.
  45743. * Default is immersive-vr
  45744. */
  45745. sessionMode?: XRSessionMode;
  45746. /**
  45747. * A reference space type to use when creating the default button.
  45748. * Default is local-floor
  45749. */
  45750. referenceSpaceType?: XRReferenceSpaceType;
  45751. }
  45752. /**
  45753. * UI to allow the user to enter/exit XR mode
  45754. */
  45755. export class WebXREnterExitUI implements IDisposable {
  45756. private scene;
  45757. /** version of the options passed to this UI */
  45758. options: WebXREnterExitUIOptions;
  45759. private _overlay;
  45760. private _buttons;
  45761. private _activeButton;
  45762. /**
  45763. * Fired every time the active button is changed.
  45764. *
  45765. * When xr is entered via a button that launches xr that button will be the callback parameter
  45766. *
  45767. * When exiting xr the callback parameter will be null)
  45768. */
  45769. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45770. /**
  45771. * Creates UI to allow the user to enter/exit XR mode
  45772. * @param scene the scene to add the ui to
  45773. * @param helper the xr experience helper to enter/exit xr with
  45774. * @param options options to configure the UI
  45775. * @returns the created ui
  45776. */
  45777. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45778. /**
  45779. *
  45780. * @param scene babylon scene object to use
  45781. * @param options (read-only) version of the options passed to this UI
  45782. */
  45783. private constructor();
  45784. private _updateButtons;
  45785. /**
  45786. * Disposes of the object
  45787. */
  45788. dispose(): void;
  45789. }
  45790. }
  45791. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45792. import { Vector3 } from "babylonjs/Maths/math.vector";
  45793. import { Color4 } from "babylonjs/Maths/math.color";
  45794. import { Nullable } from "babylonjs/types";
  45795. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45796. import { Scene } from "babylonjs/scene";
  45797. /**
  45798. * Class containing static functions to help procedurally build meshes
  45799. */
  45800. export class LinesBuilder {
  45801. /**
  45802. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45803. * * 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
  45804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45805. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45806. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45807. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45808. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45809. * * 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
  45810. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45813. * @param name defines the name of the new line system
  45814. * @param options defines the options used to create the line system
  45815. * @param scene defines the hosting scene
  45816. * @returns a new line system mesh
  45817. */
  45818. static CreateLineSystem(name: string, options: {
  45819. lines: Vector3[][];
  45820. updatable?: boolean;
  45821. instance?: Nullable<LinesMesh>;
  45822. colors?: Nullable<Color4[][]>;
  45823. useVertexAlpha?: boolean;
  45824. }, scene: Nullable<Scene>): LinesMesh;
  45825. /**
  45826. * Creates a line mesh
  45827. * 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
  45828. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45829. * * The parameter `points` is an array successive Vector3
  45830. * * 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
  45831. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45832. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45833. * * When updating an instance, remember that only point positions can change, not the number of points
  45834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45836. * @param name defines the name of the new line system
  45837. * @param options defines the options used to create the line system
  45838. * @param scene defines the hosting scene
  45839. * @returns a new line mesh
  45840. */
  45841. static CreateLines(name: string, options: {
  45842. points: Vector3[];
  45843. updatable?: boolean;
  45844. instance?: Nullable<LinesMesh>;
  45845. colors?: Color4[];
  45846. useVertexAlpha?: boolean;
  45847. }, scene?: Nullable<Scene>): LinesMesh;
  45848. /**
  45849. * Creates a dashed line mesh
  45850. * * 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
  45851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45852. * * The parameter `points` is an array successive Vector3
  45853. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45854. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45855. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45856. * * 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
  45857. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45858. * * When updating an instance, remember that only point positions can change, not the number of points
  45859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45860. * @param name defines the name of the mesh
  45861. * @param options defines the options used to create the mesh
  45862. * @param scene defines the hosting scene
  45863. * @returns the dashed line mesh
  45864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45865. */
  45866. static CreateDashedLines(name: string, options: {
  45867. points: Vector3[];
  45868. dashSize?: number;
  45869. gapSize?: number;
  45870. dashNb?: number;
  45871. updatable?: boolean;
  45872. instance?: LinesMesh;
  45873. useVertexAlpha?: boolean;
  45874. }, scene?: Nullable<Scene>): LinesMesh;
  45875. }
  45876. }
  45877. declare module "babylonjs/Cameras/XR/features/WebXRControllerTeleportation" {
  45878. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45879. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45880. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45882. import { Material } from "babylonjs/Materials/material";
  45883. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  45884. /**
  45885. * The options container for the teleportation module
  45886. */
  45887. export interface IWebXRTeleportationOptions {
  45888. /**
  45889. * Babylon XR Input class for controller
  45890. */
  45891. xrInput: WebXRInput;
  45892. /**
  45893. * A list of meshes to use as floor meshes.
  45894. * Meshes can be added and removed after initializing the feature using the
  45895. * addFloorMesh and removeFloorMesh functions
  45896. * If empty, rotation will still work
  45897. */
  45898. floorMeshes?: AbstractMesh[];
  45899. /**
  45900. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45901. * If you want to support rotation, make sure your mesh has a direction indicator.
  45902. *
  45903. * When left untouched, the default mesh will be initialized.
  45904. */
  45905. teleportationTargetMesh?: AbstractMesh;
  45906. /**
  45907. * Values to configure the default target mesh
  45908. */
  45909. defaultTargetMeshOptions?: {
  45910. /**
  45911. * Fill color of the teleportation area
  45912. */
  45913. teleportationFillColor?: string;
  45914. /**
  45915. * Border color for the teleportation area
  45916. */
  45917. teleportationBorderColor?: string;
  45918. /**
  45919. * Override the default material of the torus and arrow
  45920. */
  45921. torusArrowMaterial?: Material;
  45922. /**
  45923. * Disable the mesh's animation sequence
  45924. */
  45925. disableAnimation?: boolean;
  45926. };
  45927. /**
  45928. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  45929. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  45930. */
  45931. useMainComponentOnly?: boolean;
  45932. /**
  45933. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  45934. */
  45935. timeToTeleport?: number;
  45936. }
  45937. /**
  45938. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  45939. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  45940. * the input of the attached controllers.
  45941. */
  45942. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45943. private _options;
  45944. /**
  45945. * The module's name
  45946. */
  45947. static readonly Name: string;
  45948. /**
  45949. * The (Babylon) version of this module.
  45950. * This is an integer representing the implementation version.
  45951. * This number does not correspond to the webxr specs version
  45952. */
  45953. static readonly Version: number;
  45954. /**
  45955. * Is rotation enabled when moving forward?
  45956. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45957. */
  45958. rotationEnabled: boolean;
  45959. /**
  45960. * Should the module support parabolic ray on top of direct ray
  45961. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45962. * Very helpful when moving between floors / different heights
  45963. */
  45964. parabolicRayEnabled: boolean;
  45965. /**
  45966. * The distance from the user to the inspection point in the direction of the controller
  45967. * A higher number will allow the user to move further
  45968. * defaults to 5 (meters, in xr units)
  45969. */
  45970. parabolicCheckRadius: number;
  45971. /**
  45972. * How much rotation should be applied when rotating right and left
  45973. */
  45974. rotationAngle: number;
  45975. /**
  45976. * Distance to travel when moving backwards
  45977. */
  45978. backwardsTeleportationDistance: number;
  45979. /**
  45980. * Add a new mesh to the floor meshes array
  45981. * @param mesh the mesh to use as floor mesh
  45982. */
  45983. addFloorMesh(mesh: AbstractMesh): void;
  45984. /**
  45985. * Remove a mesh from the floor meshes array
  45986. * @param mesh the mesh to remove
  45987. */
  45988. removeFloorMesh(mesh: AbstractMesh): void;
  45989. /**
  45990. * Remove a mesh from the floor meshes array using its name
  45991. * @param name the mesh name to remove
  45992. */
  45993. removeFloorMeshByName(name: string): void;
  45994. private _tmpRay;
  45995. private _tmpVector;
  45996. private _floorMeshes;
  45997. private _controllers;
  45998. /**
  45999. * constructs a new anchor system
  46000. * @param _xrSessionManager an instance of WebXRSessionManager
  46001. * @param _options configuration object for this feature
  46002. */
  46003. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46004. private _selectionFeature;
  46005. /**
  46006. * This function sets a selection feature that will be disabled when
  46007. * the forward ray is shown and will be reattached when hidden.
  46008. * This is used to remove the selection rays when moving.
  46009. * @param selectionFeature the feature to disable when forward movement is enabled
  46010. */
  46011. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46012. attach(): boolean;
  46013. detach(): boolean;
  46014. dispose(): void;
  46015. protected _onXRFrame(_xrFrame: XRFrame): void;
  46016. private _currentTeleportationControllerId;
  46017. private _attachController;
  46018. private _teleportForward;
  46019. private _detachController;
  46020. private createDefaultTargetMesh;
  46021. private setTargetMeshVisibility;
  46022. private setTargetMeshPosition;
  46023. private _quadraticBezierCurve;
  46024. private showParabolicPath;
  46025. }
  46026. }
  46027. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  46028. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46029. import { Scene } from "babylonjs/scene";
  46030. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  46031. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  46032. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  46033. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  46034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46035. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46036. import { WebXRMotionControllerTeleportation } from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  46037. /**
  46038. * Options for the default xr helper
  46039. */
  46040. export class WebXRDefaultExperienceOptions {
  46041. /**
  46042. * Floor meshes that will be used for teleporting
  46043. */
  46044. floorMeshes?: Array<AbstractMesh>;
  46045. /**
  46046. * Enable or disable default UI to enter XR
  46047. */
  46048. disableDefaultUI?: boolean;
  46049. /**
  46050. * optional configuration for the output canvas
  46051. */
  46052. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46053. /**
  46054. * optional UI options. This can be used among other to change session mode and reference space type
  46055. */
  46056. uiOptions?: WebXREnterExitUIOptions;
  46057. /**
  46058. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46059. */
  46060. inputOptions?: IWebXRInputOptions;
  46061. /**
  46062. * Should teleportation not initialize. defaults to false.
  46063. */
  46064. disableTeleportation?: boolean;
  46065. }
  46066. /**
  46067. * Default experience which provides a similar setup to the previous webVRExperience
  46068. */
  46069. export class WebXRDefaultExperience {
  46070. /**
  46071. * Base experience
  46072. */
  46073. baseExperience: WebXRExperienceHelper;
  46074. /**
  46075. * Input experience extension
  46076. */
  46077. input: WebXRInput;
  46078. /**
  46079. * Enables laser pointer and selection
  46080. */
  46081. pointerSelection: WebXRControllerPointerSelection;
  46082. /**
  46083. * Enables teleportation
  46084. */
  46085. teleportation: WebXRMotionControllerTeleportation;
  46086. /**
  46087. * Enables ui for entering/exiting xr
  46088. */
  46089. enterExitUI: WebXREnterExitUI;
  46090. /**
  46091. * Default target xr should render to
  46092. */
  46093. renderTarget: WebXRRenderTarget;
  46094. /**
  46095. * Creates the default xr experience
  46096. * @param scene scene
  46097. * @param options options for basic configuration
  46098. * @returns resulting WebXRDefaultExperience
  46099. */
  46100. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46101. private constructor();
  46102. /**
  46103. * DIsposes of the experience helper
  46104. */
  46105. dispose(): void;
  46106. }
  46107. }
  46108. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46109. import { Observable } from "babylonjs/Misc/observable";
  46110. import { Nullable } from "babylonjs/types";
  46111. import { Camera } from "babylonjs/Cameras/camera";
  46112. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46113. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46114. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46115. import { Scene } from "babylonjs/scene";
  46116. import { Vector3 } from "babylonjs/Maths/math.vector";
  46117. import { Color3 } from "babylonjs/Maths/math.color";
  46118. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46120. import { Mesh } from "babylonjs/Meshes/mesh";
  46121. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46122. import { EasingFunction } from "babylonjs/Animations/easing";
  46123. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46124. import "babylonjs/Meshes/Builders/groundBuilder";
  46125. import "babylonjs/Meshes/Builders/torusBuilder";
  46126. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46127. import "babylonjs/Gamepads/gamepadSceneComponent";
  46128. import "babylonjs/Animations/animatable";
  46129. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46130. /**
  46131. * Options to modify the vr teleportation behavior.
  46132. */
  46133. export interface VRTeleportationOptions {
  46134. /**
  46135. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46136. */
  46137. floorMeshName?: string;
  46138. /**
  46139. * A list of meshes to be used as the teleportation floor. (default: empty)
  46140. */
  46141. floorMeshes?: Mesh[];
  46142. /**
  46143. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46144. */
  46145. teleportationMode?: number;
  46146. /**
  46147. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46148. */
  46149. teleportationTime?: number;
  46150. /**
  46151. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46152. */
  46153. teleportationSpeed?: number;
  46154. /**
  46155. * The easing function used in the animation or null for Linear. (default CircleEase)
  46156. */
  46157. easingFunction?: EasingFunction;
  46158. }
  46159. /**
  46160. * Options to modify the vr experience helper's behavior.
  46161. */
  46162. export interface VRExperienceHelperOptions extends WebVROptions {
  46163. /**
  46164. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46165. */
  46166. createDeviceOrientationCamera?: boolean;
  46167. /**
  46168. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46169. */
  46170. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46171. /**
  46172. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46173. */
  46174. laserToggle?: boolean;
  46175. /**
  46176. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46177. */
  46178. floorMeshes?: Mesh[];
  46179. /**
  46180. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46181. */
  46182. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46183. /**
  46184. * Defines if WebXR should be used instead of WebVR (if available)
  46185. */
  46186. useXR?: boolean;
  46187. }
  46188. /**
  46189. * Event containing information after VR has been entered
  46190. */
  46191. export class OnAfterEnteringVRObservableEvent {
  46192. /**
  46193. * If entering vr was successful
  46194. */
  46195. success: boolean;
  46196. }
  46197. /**
  46198. * Helps to quickly add VR support to an existing scene.
  46199. * See http://doc.babylonjs.com/how_to/webvr_helper
  46200. */
  46201. export class VRExperienceHelper {
  46202. /** Options to modify the vr experience helper's behavior. */
  46203. webVROptions: VRExperienceHelperOptions;
  46204. private _scene;
  46205. private _position;
  46206. private _btnVR;
  46207. private _btnVRDisplayed;
  46208. private _webVRsupported;
  46209. private _webVRready;
  46210. private _webVRrequesting;
  46211. private _webVRpresenting;
  46212. private _hasEnteredVR;
  46213. private _fullscreenVRpresenting;
  46214. private _inputElement;
  46215. private _webVRCamera;
  46216. private _vrDeviceOrientationCamera;
  46217. private _deviceOrientationCamera;
  46218. private _existingCamera;
  46219. private _onKeyDown;
  46220. private _onVrDisplayPresentChange;
  46221. private _onVRDisplayChanged;
  46222. private _onVRRequestPresentStart;
  46223. private _onVRRequestPresentComplete;
  46224. /**
  46225. * 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)
  46226. */
  46227. enableGazeEvenWhenNoPointerLock: boolean;
  46228. /**
  46229. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46230. */
  46231. exitVROnDoubleTap: boolean;
  46232. /**
  46233. * Observable raised right before entering VR.
  46234. */
  46235. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46236. /**
  46237. * Observable raised when entering VR has completed.
  46238. */
  46239. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46240. /**
  46241. * Observable raised when exiting VR.
  46242. */
  46243. onExitingVRObservable: Observable<VRExperienceHelper>;
  46244. /**
  46245. * Observable raised when controller mesh is loaded.
  46246. */
  46247. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46248. /** Return this.onEnteringVRObservable
  46249. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46250. */
  46251. get onEnteringVR(): Observable<VRExperienceHelper>;
  46252. /** Return this.onExitingVRObservable
  46253. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46254. */
  46255. get onExitingVR(): Observable<VRExperienceHelper>;
  46256. /** Return this.onControllerMeshLoadedObservable
  46257. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46258. */
  46259. get onControllerMeshLoaded(): Observable<WebVRController>;
  46260. private _rayLength;
  46261. private _useCustomVRButton;
  46262. private _teleportationRequested;
  46263. private _teleportActive;
  46264. private _floorMeshName;
  46265. private _floorMeshesCollection;
  46266. private _teleportationMode;
  46267. private _teleportationTime;
  46268. private _teleportationSpeed;
  46269. private _teleportationEasing;
  46270. private _rotationAllowed;
  46271. private _teleportBackwardsVector;
  46272. private _teleportationTarget;
  46273. private _isDefaultTeleportationTarget;
  46274. private _postProcessMove;
  46275. private _teleportationFillColor;
  46276. private _teleportationBorderColor;
  46277. private _rotationAngle;
  46278. private _haloCenter;
  46279. private _cameraGazer;
  46280. private _padSensibilityUp;
  46281. private _padSensibilityDown;
  46282. private _leftController;
  46283. private _rightController;
  46284. private _gazeColor;
  46285. private _laserColor;
  46286. private _pickedLaserColor;
  46287. private _pickedGazeColor;
  46288. /**
  46289. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46290. */
  46291. onNewMeshSelected: Observable<AbstractMesh>;
  46292. /**
  46293. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46294. * This observable will provide the mesh and the controller used to select the mesh
  46295. */
  46296. onMeshSelectedWithController: Observable<{
  46297. mesh: AbstractMesh;
  46298. controller: WebVRController;
  46299. }>;
  46300. /**
  46301. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46302. */
  46303. onNewMeshPicked: Observable<PickingInfo>;
  46304. private _circleEase;
  46305. /**
  46306. * Observable raised before camera teleportation
  46307. */
  46308. onBeforeCameraTeleport: Observable<Vector3>;
  46309. /**
  46310. * Observable raised after camera teleportation
  46311. */
  46312. onAfterCameraTeleport: Observable<Vector3>;
  46313. /**
  46314. * Observable raised when current selected mesh gets unselected
  46315. */
  46316. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46317. private _raySelectionPredicate;
  46318. /**
  46319. * To be optionaly changed by user to define custom ray selection
  46320. */
  46321. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46322. /**
  46323. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46324. */
  46325. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46326. /**
  46327. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46328. */
  46329. teleportationEnabled: boolean;
  46330. private _defaultHeight;
  46331. private _teleportationInitialized;
  46332. private _interactionsEnabled;
  46333. private _interactionsRequested;
  46334. private _displayGaze;
  46335. private _displayLaserPointer;
  46336. /**
  46337. * The mesh used to display where the user is going to teleport.
  46338. */
  46339. get teleportationTarget(): Mesh;
  46340. /**
  46341. * Sets the mesh to be used to display where the user is going to teleport.
  46342. */
  46343. set teleportationTarget(value: Mesh);
  46344. /**
  46345. * 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
  46346. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46347. * See http://doc.babylonjs.com/resources/baking_transformations
  46348. */
  46349. get gazeTrackerMesh(): Mesh;
  46350. set gazeTrackerMesh(value: Mesh);
  46351. /**
  46352. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46353. */
  46354. updateGazeTrackerScale: boolean;
  46355. /**
  46356. * If the gaze trackers color should be updated when selecting meshes
  46357. */
  46358. updateGazeTrackerColor: boolean;
  46359. /**
  46360. * If the controller laser color should be updated when selecting meshes
  46361. */
  46362. updateControllerLaserColor: boolean;
  46363. /**
  46364. * The gaze tracking mesh corresponding to the left controller
  46365. */
  46366. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46367. /**
  46368. * The gaze tracking mesh corresponding to the right controller
  46369. */
  46370. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46371. /**
  46372. * If the ray of the gaze should be displayed.
  46373. */
  46374. get displayGaze(): boolean;
  46375. /**
  46376. * Sets if the ray of the gaze should be displayed.
  46377. */
  46378. set displayGaze(value: boolean);
  46379. /**
  46380. * If the ray of the LaserPointer should be displayed.
  46381. */
  46382. get displayLaserPointer(): boolean;
  46383. /**
  46384. * Sets if the ray of the LaserPointer should be displayed.
  46385. */
  46386. set displayLaserPointer(value: boolean);
  46387. /**
  46388. * The deviceOrientationCamera used as the camera when not in VR.
  46389. */
  46390. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46391. /**
  46392. * Based on the current WebVR support, returns the current VR camera used.
  46393. */
  46394. get currentVRCamera(): Nullable<Camera>;
  46395. /**
  46396. * The webVRCamera which is used when in VR.
  46397. */
  46398. get webVRCamera(): WebVRFreeCamera;
  46399. /**
  46400. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46401. */
  46402. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46403. /**
  46404. * The html button that is used to trigger entering into VR.
  46405. */
  46406. get vrButton(): Nullable<HTMLButtonElement>;
  46407. private get _teleportationRequestInitiated();
  46408. /**
  46409. * Defines wether or not Pointer lock should be requested when switching to
  46410. * full screen.
  46411. */
  46412. requestPointerLockOnFullScreen: boolean;
  46413. /**
  46414. * If asking to force XR, this will be populated with the default xr experience
  46415. */
  46416. xr: WebXRDefaultExperience;
  46417. /**
  46418. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46419. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46420. */
  46421. xrTestDone: boolean;
  46422. /**
  46423. * Instantiates a VRExperienceHelper.
  46424. * Helps to quickly add VR support to an existing scene.
  46425. * @param scene The scene the VRExperienceHelper belongs to.
  46426. * @param webVROptions Options to modify the vr experience helper's behavior.
  46427. */
  46428. constructor(scene: Scene,
  46429. /** Options to modify the vr experience helper's behavior. */
  46430. webVROptions?: VRExperienceHelperOptions);
  46431. private completeVRInit;
  46432. private _onDefaultMeshLoaded;
  46433. private _onResize;
  46434. private _onFullscreenChange;
  46435. /**
  46436. * Gets a value indicating if we are currently in VR mode.
  46437. */
  46438. get isInVRMode(): boolean;
  46439. private onVrDisplayPresentChange;
  46440. private onVRDisplayChanged;
  46441. private moveButtonToBottomRight;
  46442. private displayVRButton;
  46443. private updateButtonVisibility;
  46444. private _cachedAngularSensibility;
  46445. /**
  46446. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46447. * Otherwise, will use the fullscreen API.
  46448. */
  46449. enterVR(): void;
  46450. /**
  46451. * Attempt to exit VR, or fullscreen.
  46452. */
  46453. exitVR(): void;
  46454. /**
  46455. * The position of the vr experience helper.
  46456. */
  46457. get position(): Vector3;
  46458. /**
  46459. * Sets the position of the vr experience helper.
  46460. */
  46461. set position(value: Vector3);
  46462. /**
  46463. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46464. */
  46465. enableInteractions(): void;
  46466. private get _noControllerIsActive();
  46467. private beforeRender;
  46468. private _isTeleportationFloor;
  46469. /**
  46470. * Adds a floor mesh to be used for teleportation.
  46471. * @param floorMesh the mesh to be used for teleportation.
  46472. */
  46473. addFloorMesh(floorMesh: Mesh): void;
  46474. /**
  46475. * Removes a floor mesh from being used for teleportation.
  46476. * @param floorMesh the mesh to be removed.
  46477. */
  46478. removeFloorMesh(floorMesh: Mesh): void;
  46479. /**
  46480. * Enables interactions and teleportation using the VR controllers and gaze.
  46481. * @param vrTeleportationOptions options to modify teleportation behavior.
  46482. */
  46483. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46484. private _onNewGamepadConnected;
  46485. private _tryEnableInteractionOnController;
  46486. private _onNewGamepadDisconnected;
  46487. private _enableInteractionOnController;
  46488. private _checkTeleportWithRay;
  46489. private _checkRotate;
  46490. private _checkTeleportBackwards;
  46491. private _enableTeleportationOnController;
  46492. private _createTeleportationCircles;
  46493. private _displayTeleportationTarget;
  46494. private _hideTeleportationTarget;
  46495. private _rotateCamera;
  46496. private _moveTeleportationSelectorTo;
  46497. private _workingVector;
  46498. private _workingQuaternion;
  46499. private _workingMatrix;
  46500. /**
  46501. * Time Constant Teleportation Mode
  46502. */
  46503. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46504. /**
  46505. * Speed Constant Teleportation Mode
  46506. */
  46507. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46508. /**
  46509. * Teleports the users feet to the desired location
  46510. * @param location The location where the user's feet should be placed
  46511. */
  46512. teleportCamera(location: Vector3): void;
  46513. private _convertNormalToDirectionOfRay;
  46514. private _castRayAndSelectObject;
  46515. private _notifySelectedMeshUnselected;
  46516. /**
  46517. * Permanently set new colors for the laser pointer
  46518. * @param color the new laser color
  46519. * @param pickedColor the new laser color when picked mesh detected
  46520. */
  46521. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46522. /**
  46523. * Set lighting enabled / disabled on the laser pointer of both controllers
  46524. * @param enabled should the lighting be enabled on the laser pointer
  46525. */
  46526. setLaserLightingState(enabled?: boolean): void;
  46527. /**
  46528. * Permanently set new colors for the gaze pointer
  46529. * @param color the new gaze color
  46530. * @param pickedColor the new gaze color when picked mesh detected
  46531. */
  46532. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46533. /**
  46534. * Sets the color of the laser ray from the vr controllers.
  46535. * @param color new color for the ray.
  46536. */
  46537. changeLaserColor(color: Color3): void;
  46538. /**
  46539. * Sets the color of the ray from the vr headsets gaze.
  46540. * @param color new color for the ray.
  46541. */
  46542. changeGazeColor(color: Color3): void;
  46543. /**
  46544. * Exits VR and disposes of the vr experience helper
  46545. */
  46546. dispose(): void;
  46547. /**
  46548. * Gets the name of the VRExperienceHelper class
  46549. * @returns "VRExperienceHelper"
  46550. */
  46551. getClassName(): string;
  46552. }
  46553. }
  46554. declare module "babylonjs/Cameras/VR/index" {
  46555. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  46556. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  46557. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46558. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  46559. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  46560. export * from "babylonjs/Cameras/VR/webVRCamera";
  46561. }
  46562. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  46563. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46564. import { Observable } from "babylonjs/Misc/observable";
  46565. import { Matrix } from "babylonjs/Maths/math.vector";
  46566. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46567. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46568. /**
  46569. * Options used for hit testing
  46570. */
  46571. export interface IWebXRHitTestOptions {
  46572. /**
  46573. * Only test when user interacted with the scene. Default - hit test every frame
  46574. */
  46575. testOnPointerDownOnly?: boolean;
  46576. /**
  46577. * The node to use to transform the local results to world coordinates
  46578. */
  46579. worldParentNode?: TransformNode;
  46580. }
  46581. /**
  46582. * Interface defining the babylon result of raycasting/hit-test
  46583. */
  46584. export interface IWebXRHitResult {
  46585. /**
  46586. * The native hit test result
  46587. */
  46588. xrHitResult: XRHitResult;
  46589. /**
  46590. * Transformation matrix that can be applied to a node that will put it in the hit point location
  46591. */
  46592. transformationMatrix: Matrix;
  46593. }
  46594. /**
  46595. * The currently-working hit-test module.
  46596. * Hit test (or raycasting) is used to interact with the real world.
  46597. * For further information read here - https://github.com/immersive-web/hit-test
  46598. */
  46599. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  46600. /**
  46601. * options to use when constructing this feature
  46602. */
  46603. readonly options: IWebXRHitTestOptions;
  46604. /**
  46605. * The module's name
  46606. */
  46607. static readonly Name: string;
  46608. /**
  46609. * The (Babylon) version of this module.
  46610. * This is an integer representing the implementation version.
  46611. * This number does not correspond to the webxr specs version
  46612. */
  46613. static readonly Version: number;
  46614. /**
  46615. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  46616. * @param event the (select) event to use to select with
  46617. * @param referenceSpace the reference space to use for this hit test
  46618. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46619. */
  46620. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  46621. /**
  46622. * execute a hit test with an XR Ray
  46623. *
  46624. * @param xrSession a native xrSession that will execute this hit test
  46625. * @param xrRay the ray (position and direction) to use for raycasting
  46626. * @param referenceSpace native XR reference space to use for the hit-test
  46627. * @param filter filter function that will filter the results
  46628. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46629. */
  46630. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46631. /**
  46632. * Triggered when new babylon (transformed) hit test results are available
  46633. */
  46634. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46635. private _onSelectEnabled;
  46636. /**
  46637. * Creates a new instance of the (legacy version) hit test feature
  46638. * @param _xrSessionManager an instance of WebXRSessionManager
  46639. * @param options options to use when constructing this feature
  46640. */
  46641. constructor(_xrSessionManager: WebXRSessionManager,
  46642. /**
  46643. * options to use when constructing this feature
  46644. */
  46645. options?: IWebXRHitTestOptions);
  46646. /**
  46647. * Populated with the last native XR Hit Results
  46648. */
  46649. lastNativeXRHitResults: XRHitResult[];
  46650. /**
  46651. * attach this feature
  46652. * Will usually be called by the features manager
  46653. *
  46654. * @returns true if successful.
  46655. */
  46656. attach(): boolean;
  46657. /**
  46658. * detach this feature.
  46659. * Will usually be called by the features manager
  46660. *
  46661. * @returns true if successful.
  46662. */
  46663. detach(): boolean;
  46664. private _onHitTestResults;
  46665. private _origin;
  46666. private _direction;
  46667. private _mat;
  46668. protected _onXRFrame(frame: XRFrame): void;
  46669. private _onSelect;
  46670. /**
  46671. * Dispose this feature and all of the resources attached
  46672. */
  46673. dispose(): void;
  46674. }
  46675. }
  46676. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46677. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46678. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46679. import { Observable } from "babylonjs/Misc/observable";
  46680. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46681. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46682. /**
  46683. * Options used in the plane detector module
  46684. */
  46685. export interface IWebXRPlaneDetectorOptions {
  46686. /**
  46687. * The node to use to transform the local results to world coordinates
  46688. */
  46689. worldParentNode?: TransformNode;
  46690. }
  46691. /**
  46692. * A babylon interface for a webxr plane.
  46693. * A Plane is actually a polygon, built from N points in space
  46694. */
  46695. export interface IWebXRPlane {
  46696. /**
  46697. * a babylon-assigned ID for this polygon
  46698. */
  46699. id: number;
  46700. /**
  46701. * the native xr-plane object
  46702. */
  46703. xrPlane: XRPlane;
  46704. /**
  46705. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46706. */
  46707. polygonDefinition: Array<Vector3>;
  46708. /**
  46709. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46710. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46711. */
  46712. transformationMatrix: Matrix;
  46713. }
  46714. /**
  46715. * The plane detector is used to detect planes in the real world when in AR
  46716. * For more information see https://github.com/immersive-web/real-world-geometry/
  46717. */
  46718. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  46719. private _options;
  46720. /**
  46721. * The module's name
  46722. */
  46723. static readonly Name: string;
  46724. /**
  46725. * The (Babylon) version of this module.
  46726. * This is an integer representing the implementation version.
  46727. * This number does not correspond to the webxr specs version
  46728. */
  46729. static readonly Version: number;
  46730. /**
  46731. * Observers registered here will be executed when a new plane was added to the session
  46732. */
  46733. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46734. /**
  46735. * Observers registered here will be executed when a plane is no longer detected in the session
  46736. */
  46737. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46738. /**
  46739. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46740. * This can execute N times every frame
  46741. */
  46742. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46743. private _enabled;
  46744. private _detectedPlanes;
  46745. private _lastFrameDetected;
  46746. /**
  46747. * construct a new Plane Detector
  46748. * @param _xrSessionManager an instance of xr Session manager
  46749. * @param _options configuration to use when constructing this feature
  46750. */
  46751. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46752. protected _onXRFrame(frame: XRFrame): void;
  46753. /**
  46754. * Dispose this feature and all of the resources attached
  46755. */
  46756. dispose(): void;
  46757. private _updatePlaneWithXRPlane;
  46758. /**
  46759. * avoiding using Array.find for global support.
  46760. * @param xrPlane the plane to find in the array
  46761. */
  46762. private findIndexInPlaneArray;
  46763. }
  46764. }
  46765. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46766. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46767. import { Observable } from "babylonjs/Misc/observable";
  46768. import { Matrix } from "babylonjs/Maths/math.vector";
  46769. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46770. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46771. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46772. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46773. /**
  46774. * Configuration options of the anchor system
  46775. */
  46776. export interface IWebXRAnchorSystemOptions {
  46777. /**
  46778. * a node that will be used to convert local to world coordinates
  46779. */
  46780. worldParentNode?: TransformNode;
  46781. /**
  46782. * should the anchor system use plane detection.
  46783. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46784. */
  46785. usePlaneDetection?: boolean;
  46786. /**
  46787. * Should a new anchor be added every time a select event is triggered
  46788. */
  46789. addAnchorOnSelect?: boolean;
  46790. }
  46791. /**
  46792. * A babylon container for an XR Anchor
  46793. */
  46794. export interface IWebXRAnchor {
  46795. /**
  46796. * A babylon-assigned ID for this anchor
  46797. */
  46798. id: number;
  46799. /**
  46800. * The native anchor object
  46801. */
  46802. xrAnchor: XRAnchor;
  46803. /**
  46804. * Transformation matrix to apply to an object attached to this anchor
  46805. */
  46806. transformationMatrix: Matrix;
  46807. }
  46808. /**
  46809. * An implementation of the anchor system of WebXR.
  46810. * Note that the current documented implementation is not available in any browser. Future implementations
  46811. * will use the frame to create an anchor and not the session or a detected plane
  46812. * For further information see https://github.com/immersive-web/anchors/
  46813. */
  46814. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  46815. private _options;
  46816. /**
  46817. * The module's name
  46818. */
  46819. static readonly Name: string;
  46820. /**
  46821. * The (Babylon) version of this module.
  46822. * This is an integer representing the implementation version.
  46823. * This number does not correspond to the webxr specs version
  46824. */
  46825. static readonly Version: number;
  46826. /**
  46827. * Observers registered here will be executed when a new anchor was added to the session
  46828. */
  46829. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46830. /**
  46831. * Observers registered here will be executed when an existing anchor updates
  46832. * This can execute N times every frame
  46833. */
  46834. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46835. /**
  46836. * Observers registered here will be executed when an anchor was removed from the session
  46837. */
  46838. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46839. private _planeDetector;
  46840. private _hitTestModule;
  46841. private _enabled;
  46842. private _trackedAnchors;
  46843. private _lastFrameDetected;
  46844. /**
  46845. * constructs a new anchor system
  46846. * @param _xrSessionManager an instance of WebXRSessionManager
  46847. * @param _options configuration object for this feature
  46848. */
  46849. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46850. /**
  46851. * set the plane detector to use in order to create anchors from frames
  46852. * @param planeDetector the plane-detector module to use
  46853. * @param enable enable plane-anchors. default is true
  46854. */
  46855. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46856. /**
  46857. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46858. * @param hitTestModule the hit-test module to use.
  46859. */
  46860. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46861. /**
  46862. * attach this feature
  46863. * Will usually be called by the features manager
  46864. *
  46865. * @returns true if successful.
  46866. */
  46867. attach(): boolean;
  46868. /**
  46869. * detach this feature.
  46870. * Will usually be called by the features manager
  46871. *
  46872. * @returns true if successful.
  46873. */
  46874. detach(): boolean;
  46875. /**
  46876. * Dispose this feature and all of the resources attached
  46877. */
  46878. dispose(): void;
  46879. protected _onXRFrame(frame: XRFrame): void;
  46880. private _onSelect;
  46881. /**
  46882. * Add anchor at a specific XR point.
  46883. *
  46884. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46885. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46886. * @returns a promise the fulfills when the anchor was created
  46887. */
  46888. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46889. private _updateAnchorWithXRFrame;
  46890. /**
  46891. * avoiding using Array.find for global support.
  46892. * @param xrAnchor the plane to find in the array
  46893. */
  46894. private _findIndexInAnchorArray;
  46895. }
  46896. }
  46897. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46898. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46900. import { Observable } from "babylonjs/Misc/observable";
  46901. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46902. /**
  46903. * Options interface for the background remover plugin
  46904. */
  46905. export interface IWebXRBackgroundRemoverOptions {
  46906. /**
  46907. * don't disable the environment helper
  46908. */
  46909. ignoreEnvironmentHelper?: boolean;
  46910. /**
  46911. * flags to configure the removal of the environment helper.
  46912. * If not set, the entire background will be removed. If set, flags should be set as well.
  46913. */
  46914. environmentHelperRemovalFlags?: {
  46915. /**
  46916. * Should the skybox be removed (default false)
  46917. */
  46918. skyBox?: boolean;
  46919. /**
  46920. * Should the ground be removed (default false)
  46921. */
  46922. ground?: boolean;
  46923. };
  46924. /**
  46925. * Further background meshes to disable when entering AR
  46926. */
  46927. backgroundMeshes?: AbstractMesh[];
  46928. }
  46929. /**
  46930. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46931. */
  46932. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  46933. /**
  46934. * read-only options to be used in this module
  46935. */
  46936. readonly options: IWebXRBackgroundRemoverOptions;
  46937. /**
  46938. * The module's name
  46939. */
  46940. static readonly Name: string;
  46941. /**
  46942. * The (Babylon) version of this module.
  46943. * This is an integer representing the implementation version.
  46944. * This number does not correspond to the webxr specs version
  46945. */
  46946. static readonly Version: number;
  46947. /**
  46948. * registered observers will be triggered when the background state changes
  46949. */
  46950. onBackgroundStateChangedObservable: Observable<boolean>;
  46951. /**
  46952. * constructs a new background remover module
  46953. * @param _xrSessionManager the session manager for this module
  46954. * @param options read-only options to be used in this module
  46955. */
  46956. constructor(_xrSessionManager: WebXRSessionManager,
  46957. /**
  46958. * read-only options to be used in this module
  46959. */
  46960. options?: IWebXRBackgroundRemoverOptions);
  46961. /**
  46962. * attach this feature
  46963. * Will usually be called by the features manager
  46964. *
  46965. * @returns true if successful.
  46966. */
  46967. attach(): boolean;
  46968. /**
  46969. * detach this feature.
  46970. * Will usually be called by the features manager
  46971. *
  46972. * @returns true if successful.
  46973. */
  46974. detach(): boolean;
  46975. private _setBackgroundState;
  46976. /**
  46977. * Dispose this feature and all of the resources attached
  46978. */
  46979. dispose(): void;
  46980. protected _onXRFrame(_xrFrame: XRFrame): void;
  46981. }
  46982. }
  46983. declare module "babylonjs/Cameras/XR/features/index" {
  46984. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46985. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46986. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46987. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46988. export * from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  46989. export * from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  46990. }
  46991. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46992. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46994. import { Scene } from "babylonjs/scene";
  46995. /**
  46996. * The motion controller class for all microsoft mixed reality controllers
  46997. */
  46998. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46999. /**
  47000. * The base url used to load the left and right controller models
  47001. */
  47002. static MODEL_BASE_URL: string;
  47003. /**
  47004. * The name of the left controller model file
  47005. */
  47006. static MODEL_LEFT_FILENAME: string;
  47007. /**
  47008. * The name of the right controller model file
  47009. */
  47010. static MODEL_RIGHT_FILENAME: string;
  47011. profileId: string;
  47012. protected readonly _mapping: {
  47013. defaultButton: {
  47014. "valueNodeName": string;
  47015. "unpressedNodeName": string;
  47016. "pressedNodeName": string;
  47017. };
  47018. defaultAxis: {
  47019. "valueNodeName": string;
  47020. "minNodeName": string;
  47021. "maxNodeName": string;
  47022. };
  47023. buttons: {
  47024. "xr-standard-trigger": {
  47025. "rootNodeName": string;
  47026. "componentProperty": string;
  47027. "states": string[];
  47028. };
  47029. "xr-standard-squeeze": {
  47030. "rootNodeName": string;
  47031. "componentProperty": string;
  47032. "states": string[];
  47033. };
  47034. "xr-standard-touchpad": {
  47035. "rootNodeName": string;
  47036. "labelAnchorNodeName": string;
  47037. "touchPointNodeName": string;
  47038. };
  47039. "xr-standard-thumbstick": {
  47040. "rootNodeName": string;
  47041. "componentProperty": string;
  47042. "states": string[];
  47043. };
  47044. };
  47045. axes: {
  47046. "xr-standard-touchpad": {
  47047. "x-axis": {
  47048. "rootNodeName": string;
  47049. };
  47050. "y-axis": {
  47051. "rootNodeName": string;
  47052. };
  47053. };
  47054. "xr-standard-thumbstick": {
  47055. "x-axis": {
  47056. "rootNodeName": string;
  47057. };
  47058. "y-axis": {
  47059. "rootNodeName": string;
  47060. };
  47061. };
  47062. };
  47063. };
  47064. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  47065. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47066. private _getChildByName;
  47067. private _getImmediateChildByName;
  47068. protected _getFilenameAndPath(): {
  47069. filename: string;
  47070. path: string;
  47071. };
  47072. protected _updateModel(): void;
  47073. protected _getModelLoadingConstraints(): boolean;
  47074. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47075. }
  47076. }
  47077. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  47078. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47080. import { Scene } from "babylonjs/scene";
  47081. /**
  47082. * The motion controller class for oculus touch (quest, rift).
  47083. * This class supports legacy mapping as well the standard xr mapping
  47084. */
  47085. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  47086. private _forceLegacyControllers;
  47087. /**
  47088. * The base url used to load the left and right controller models
  47089. */
  47090. static MODEL_BASE_URL: string;
  47091. /**
  47092. * The name of the left controller model file
  47093. */
  47094. static MODEL_LEFT_FILENAME: string;
  47095. /**
  47096. * The name of the right controller model file
  47097. */
  47098. static MODEL_RIGHT_FILENAME: string;
  47099. /**
  47100. * Base Url for the Quest controller model.
  47101. */
  47102. static QUEST_MODEL_BASE_URL: string;
  47103. profileId: string;
  47104. private _modelRootNode;
  47105. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  47106. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47107. protected _getFilenameAndPath(): {
  47108. filename: string;
  47109. path: string;
  47110. };
  47111. /**
  47112. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  47113. * between the touch and touch 2.
  47114. */
  47115. private _isQuest;
  47116. protected _updateModel(): void;
  47117. protected _getModelLoadingConstraints(): boolean;
  47118. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47119. }
  47120. }
  47121. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  47122. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47123. import { Scene } from "babylonjs/scene";
  47124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47125. /**
  47126. * The motion controller class for the standard HTC-Vive controllers
  47127. */
  47128. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  47129. /**
  47130. * The base url used to load the left and right controller models
  47131. */
  47132. static MODEL_BASE_URL: string;
  47133. /**
  47134. * File name for the controller model.
  47135. */
  47136. static MODEL_FILENAME: string;
  47137. profileId: string;
  47138. private _modelRootNode;
  47139. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  47140. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47141. protected _getFilenameAndPath(): {
  47142. filename: string;
  47143. path: string;
  47144. };
  47145. protected _updateModel(): void;
  47146. protected _getModelLoadingConstraints(): boolean;
  47147. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47148. }
  47149. }
  47150. declare module "babylonjs/Cameras/XR/motionController/index" {
  47151. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47152. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  47153. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  47154. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  47155. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  47156. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  47157. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  47158. }
  47159. declare module "babylonjs/Cameras/XR/index" {
  47160. export * from "babylonjs/Cameras/XR/webXRCamera";
  47161. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  47162. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47163. export * from "babylonjs/Cameras/XR/webXRInput";
  47164. export * from "babylonjs/Cameras/XR/webXRController";
  47165. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  47166. export * from "babylonjs/Cameras/XR/webXRTypes";
  47167. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  47168. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  47169. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  47170. export * from "babylonjs/Cameras/XR/features/index";
  47171. export * from "babylonjs/Cameras/XR/motionController/index";
  47172. }
  47173. declare module "babylonjs/Cameras/RigModes/index" {
  47174. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47175. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47176. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47177. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47178. }
  47179. declare module "babylonjs/Cameras/index" {
  47180. export * from "babylonjs/Cameras/Inputs/index";
  47181. export * from "babylonjs/Cameras/cameraInputsManager";
  47182. export * from "babylonjs/Cameras/camera";
  47183. export * from "babylonjs/Cameras/targetCamera";
  47184. export * from "babylonjs/Cameras/freeCamera";
  47185. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47186. export * from "babylonjs/Cameras/touchCamera";
  47187. export * from "babylonjs/Cameras/arcRotateCamera";
  47188. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47189. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47190. export * from "babylonjs/Cameras/flyCamera";
  47191. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47192. export * from "babylonjs/Cameras/followCamera";
  47193. export * from "babylonjs/Cameras/followCameraInputsManager";
  47194. export * from "babylonjs/Cameras/gamepadCamera";
  47195. export * from "babylonjs/Cameras/Stereoscopic/index";
  47196. export * from "babylonjs/Cameras/universalCamera";
  47197. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47198. export * from "babylonjs/Cameras/VR/index";
  47199. export * from "babylonjs/Cameras/XR/index";
  47200. export * from "babylonjs/Cameras/RigModes/index";
  47201. }
  47202. declare module "babylonjs/Collisions/index" {
  47203. export * from "babylonjs/Collisions/collider";
  47204. export * from "babylonjs/Collisions/collisionCoordinator";
  47205. export * from "babylonjs/Collisions/pickingInfo";
  47206. export * from "babylonjs/Collisions/intersectionInfo";
  47207. export * from "babylonjs/Collisions/meshCollisionData";
  47208. }
  47209. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47210. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47211. import { Vector3 } from "babylonjs/Maths/math.vector";
  47212. import { Ray } from "babylonjs/Culling/ray";
  47213. import { Plane } from "babylonjs/Maths/math.plane";
  47214. /**
  47215. * Contains an array of blocks representing the octree
  47216. */
  47217. export interface IOctreeContainer<T> {
  47218. /**
  47219. * Blocks within the octree
  47220. */
  47221. blocks: Array<OctreeBlock<T>>;
  47222. }
  47223. /**
  47224. * Class used to store a cell in an octree
  47225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47226. */
  47227. export class OctreeBlock<T> {
  47228. /**
  47229. * Gets the content of the current block
  47230. */
  47231. entries: T[];
  47232. /**
  47233. * Gets the list of block children
  47234. */
  47235. blocks: Array<OctreeBlock<T>>;
  47236. private _depth;
  47237. private _maxDepth;
  47238. private _capacity;
  47239. private _minPoint;
  47240. private _maxPoint;
  47241. private _boundingVectors;
  47242. private _creationFunc;
  47243. /**
  47244. * Creates a new block
  47245. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47246. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47247. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47248. * @param depth defines the current depth of this block in the octree
  47249. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47250. * @param creationFunc defines a callback to call when an element is added to the block
  47251. */
  47252. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47253. /**
  47254. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47255. */
  47256. get capacity(): number;
  47257. /**
  47258. * Gets the minimum vector (in world space) of the block's bounding box
  47259. */
  47260. get minPoint(): Vector3;
  47261. /**
  47262. * Gets the maximum vector (in world space) of the block's bounding box
  47263. */
  47264. get maxPoint(): Vector3;
  47265. /**
  47266. * Add a new element to this block
  47267. * @param entry defines the element to add
  47268. */
  47269. addEntry(entry: T): void;
  47270. /**
  47271. * Remove an element from this block
  47272. * @param entry defines the element to remove
  47273. */
  47274. removeEntry(entry: T): void;
  47275. /**
  47276. * Add an array of elements to this block
  47277. * @param entries defines the array of elements to add
  47278. */
  47279. addEntries(entries: T[]): void;
  47280. /**
  47281. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47282. * @param frustumPlanes defines the frustum planes to test
  47283. * @param selection defines the array to store current content if selection is positive
  47284. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47285. */
  47286. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47287. /**
  47288. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47289. * @param sphereCenter defines the bounding sphere center
  47290. * @param sphereRadius defines the bounding sphere radius
  47291. * @param selection defines the array to store current content if selection is positive
  47292. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47293. */
  47294. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47295. /**
  47296. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47297. * @param ray defines the ray to test with
  47298. * @param selection defines the array to store current content if selection is positive
  47299. */
  47300. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47301. /**
  47302. * Subdivide the content into child blocks (this block will then be empty)
  47303. */
  47304. createInnerBlocks(): void;
  47305. /**
  47306. * @hidden
  47307. */
  47308. 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;
  47309. }
  47310. }
  47311. declare module "babylonjs/Culling/Octrees/octree" {
  47312. import { SmartArray } from "babylonjs/Misc/smartArray";
  47313. import { Vector3 } from "babylonjs/Maths/math.vector";
  47314. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47316. import { Ray } from "babylonjs/Culling/ray";
  47317. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47318. import { Plane } from "babylonjs/Maths/math.plane";
  47319. /**
  47320. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47321. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47322. */
  47323. export class Octree<T> {
  47324. /** 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.) */
  47325. maxDepth: number;
  47326. /**
  47327. * Blocks within the octree containing objects
  47328. */
  47329. blocks: Array<OctreeBlock<T>>;
  47330. /**
  47331. * Content stored in the octree
  47332. */
  47333. dynamicContent: T[];
  47334. private _maxBlockCapacity;
  47335. private _selectionContent;
  47336. private _creationFunc;
  47337. /**
  47338. * Creates a octree
  47339. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47340. * @param creationFunc function to be used to instatiate the octree
  47341. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47342. * @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.)
  47343. */
  47344. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47345. /** 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.) */
  47346. maxDepth?: number);
  47347. /**
  47348. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47349. * @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);
  47350. * @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);
  47351. * @param entries meshes to be added to the octree blocks
  47352. */
  47353. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47354. /**
  47355. * Adds a mesh to the octree
  47356. * @param entry Mesh to add to the octree
  47357. */
  47358. addMesh(entry: T): void;
  47359. /**
  47360. * Remove an element from the octree
  47361. * @param entry defines the element to remove
  47362. */
  47363. removeMesh(entry: T): void;
  47364. /**
  47365. * Selects an array of meshes within the frustum
  47366. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47367. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47368. * @returns array of meshes within the frustum
  47369. */
  47370. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47371. /**
  47372. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47373. * @param sphereCenter defines the bounding sphere center
  47374. * @param sphereRadius defines the bounding sphere radius
  47375. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47376. * @returns an array of objects that intersect the sphere
  47377. */
  47378. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47379. /**
  47380. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47381. * @param ray defines the ray to test with
  47382. * @returns array of intersected objects
  47383. */
  47384. intersectsRay(ray: Ray): SmartArray<T>;
  47385. /**
  47386. * Adds a mesh into the octree block if it intersects the block
  47387. */
  47388. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47389. /**
  47390. * Adds a submesh into the octree block if it intersects the block
  47391. */
  47392. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47393. }
  47394. }
  47395. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47396. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47397. import { Scene } from "babylonjs/scene";
  47398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47400. import { Ray } from "babylonjs/Culling/ray";
  47401. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47402. import { Collider } from "babylonjs/Collisions/collider";
  47403. module "babylonjs/scene" {
  47404. interface Scene {
  47405. /**
  47406. * @hidden
  47407. * Backing Filed
  47408. */
  47409. _selectionOctree: Octree<AbstractMesh>;
  47410. /**
  47411. * Gets the octree used to boost mesh selection (picking)
  47412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47413. */
  47414. selectionOctree: Octree<AbstractMesh>;
  47415. /**
  47416. * Creates or updates the octree used to boost selection (picking)
  47417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47418. * @param maxCapacity defines the maximum capacity per leaf
  47419. * @param maxDepth defines the maximum depth of the octree
  47420. * @returns an octree of AbstractMesh
  47421. */
  47422. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47423. }
  47424. }
  47425. module "babylonjs/Meshes/abstractMesh" {
  47426. interface AbstractMesh {
  47427. /**
  47428. * @hidden
  47429. * Backing Field
  47430. */
  47431. _submeshesOctree: Octree<SubMesh>;
  47432. /**
  47433. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47434. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47435. * @param maxCapacity defines the maximum size of each block (64 by default)
  47436. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47437. * @returns the new octree
  47438. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47440. */
  47441. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47442. }
  47443. }
  47444. /**
  47445. * Defines the octree scene component responsible to manage any octrees
  47446. * in a given scene.
  47447. */
  47448. export class OctreeSceneComponent {
  47449. /**
  47450. * The component name help to identify the component in the list of scene components.
  47451. */
  47452. readonly name: string;
  47453. /**
  47454. * The scene the component belongs to.
  47455. */
  47456. scene: Scene;
  47457. /**
  47458. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47459. */
  47460. readonly checksIsEnabled: boolean;
  47461. /**
  47462. * Creates a new instance of the component for the given scene
  47463. * @param scene Defines the scene to register the component in
  47464. */
  47465. constructor(scene: Scene);
  47466. /**
  47467. * Registers the component in a given scene
  47468. */
  47469. register(): void;
  47470. /**
  47471. * Return the list of active meshes
  47472. * @returns the list of active meshes
  47473. */
  47474. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47475. /**
  47476. * Return the list of active sub meshes
  47477. * @param mesh The mesh to get the candidates sub meshes from
  47478. * @returns the list of active sub meshes
  47479. */
  47480. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47481. private _tempRay;
  47482. /**
  47483. * Return the list of sub meshes intersecting with a given local ray
  47484. * @param mesh defines the mesh to find the submesh for
  47485. * @param localRay defines the ray in local space
  47486. * @returns the list of intersecting sub meshes
  47487. */
  47488. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47489. /**
  47490. * Return the list of sub meshes colliding with a collider
  47491. * @param mesh defines the mesh to find the submesh for
  47492. * @param collider defines the collider to evaluate the collision against
  47493. * @returns the list of colliding sub meshes
  47494. */
  47495. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47496. /**
  47497. * Rebuilds the elements related to this component in case of
  47498. * context lost for instance.
  47499. */
  47500. rebuild(): void;
  47501. /**
  47502. * Disposes the component and the associated ressources.
  47503. */
  47504. dispose(): void;
  47505. }
  47506. }
  47507. declare module "babylonjs/Culling/Octrees/index" {
  47508. export * from "babylonjs/Culling/Octrees/octree";
  47509. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47510. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47511. }
  47512. declare module "babylonjs/Culling/index" {
  47513. export * from "babylonjs/Culling/boundingBox";
  47514. export * from "babylonjs/Culling/boundingInfo";
  47515. export * from "babylonjs/Culling/boundingSphere";
  47516. export * from "babylonjs/Culling/Octrees/index";
  47517. export * from "babylonjs/Culling/ray";
  47518. }
  47519. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  47520. import { IDisposable, Scene } from "babylonjs/scene";
  47521. import { Nullable } from "babylonjs/types";
  47522. import { Observable } from "babylonjs/Misc/observable";
  47523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47524. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  47525. import { Camera } from "babylonjs/Cameras/camera";
  47526. /**
  47527. * Renders a layer on top of an existing scene
  47528. */
  47529. export class UtilityLayerRenderer implements IDisposable {
  47530. /** the original scene that will be rendered on top of */
  47531. originalScene: Scene;
  47532. private _pointerCaptures;
  47533. private _lastPointerEvents;
  47534. private static _DefaultUtilityLayer;
  47535. private static _DefaultKeepDepthUtilityLayer;
  47536. private _sharedGizmoLight;
  47537. private _renderCamera;
  47538. /**
  47539. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47540. * @returns the camera that is used when rendering the utility layer
  47541. */
  47542. getRenderCamera(): Nullable<Camera>;
  47543. /**
  47544. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47545. * @param cam the camera that should be used when rendering the utility layer
  47546. */
  47547. setRenderCamera(cam: Nullable<Camera>): void;
  47548. /**
  47549. * @hidden
  47550. * Light which used by gizmos to get light shading
  47551. */
  47552. _getSharedGizmoLight(): HemisphericLight;
  47553. /**
  47554. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47555. */
  47556. pickUtilitySceneFirst: boolean;
  47557. /**
  47558. * 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)
  47559. */
  47560. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47561. /**
  47562. * 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)
  47563. */
  47564. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47565. /**
  47566. * The scene that is rendered on top of the original scene
  47567. */
  47568. utilityLayerScene: Scene;
  47569. /**
  47570. * If the utility layer should automatically be rendered on top of existing scene
  47571. */
  47572. shouldRender: boolean;
  47573. /**
  47574. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47575. */
  47576. onlyCheckPointerDownEvents: boolean;
  47577. /**
  47578. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47579. */
  47580. processAllEvents: boolean;
  47581. /**
  47582. * Observable raised when the pointer move from the utility layer scene to the main scene
  47583. */
  47584. onPointerOutObservable: Observable<number>;
  47585. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47586. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47587. private _afterRenderObserver;
  47588. private _sceneDisposeObserver;
  47589. private _originalPointerObserver;
  47590. /**
  47591. * Instantiates a UtilityLayerRenderer
  47592. * @param originalScene the original scene that will be rendered on top of
  47593. * @param handleEvents boolean indicating if the utility layer should handle events
  47594. */
  47595. constructor(
  47596. /** the original scene that will be rendered on top of */
  47597. originalScene: Scene, handleEvents?: boolean);
  47598. private _notifyObservers;
  47599. /**
  47600. * Renders the utility layers scene on top of the original scene
  47601. */
  47602. render(): void;
  47603. /**
  47604. * Disposes of the renderer
  47605. */
  47606. dispose(): void;
  47607. private _updateCamera;
  47608. }
  47609. }
  47610. declare module "babylonjs/Gizmos/gizmo" {
  47611. import { Nullable } from "babylonjs/types";
  47612. import { IDisposable } from "babylonjs/scene";
  47613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47614. import { Mesh } from "babylonjs/Meshes/mesh";
  47615. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47616. /**
  47617. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47618. */
  47619. export class Gizmo implements IDisposable {
  47620. /** The utility layer the gizmo will be added to */
  47621. gizmoLayer: UtilityLayerRenderer;
  47622. /**
  47623. * The root mesh of the gizmo
  47624. */
  47625. _rootMesh: Mesh;
  47626. private _attachedMesh;
  47627. /**
  47628. * Ratio for the scale of the gizmo (Default: 1)
  47629. */
  47630. scaleRatio: number;
  47631. /**
  47632. * If a custom mesh has been set (Default: false)
  47633. */
  47634. protected _customMeshSet: boolean;
  47635. /**
  47636. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47637. * * When set, interactions will be enabled
  47638. */
  47639. get attachedMesh(): Nullable<AbstractMesh>;
  47640. set attachedMesh(value: Nullable<AbstractMesh>);
  47641. /**
  47642. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47643. * @param mesh The mesh to replace the default mesh of the gizmo
  47644. */
  47645. setCustomMesh(mesh: Mesh): void;
  47646. /**
  47647. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47648. */
  47649. updateGizmoRotationToMatchAttachedMesh: boolean;
  47650. /**
  47651. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47652. */
  47653. updateGizmoPositionToMatchAttachedMesh: boolean;
  47654. /**
  47655. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47656. */
  47657. updateScale: boolean;
  47658. protected _interactionsEnabled: boolean;
  47659. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47660. private _beforeRenderObserver;
  47661. private _tempVector;
  47662. /**
  47663. * Creates a gizmo
  47664. * @param gizmoLayer The utility layer the gizmo will be added to
  47665. */
  47666. constructor(
  47667. /** The utility layer the gizmo will be added to */
  47668. gizmoLayer?: UtilityLayerRenderer);
  47669. /**
  47670. * Updates the gizmo to match the attached mesh's position/rotation
  47671. */
  47672. protected _update(): void;
  47673. /**
  47674. * Disposes of the gizmo
  47675. */
  47676. dispose(): void;
  47677. }
  47678. }
  47679. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47680. import { Observable } from "babylonjs/Misc/observable";
  47681. import { Nullable } from "babylonjs/types";
  47682. import { Vector3 } from "babylonjs/Maths/math.vector";
  47683. import { Color3 } from "babylonjs/Maths/math.color";
  47684. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47686. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47687. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47689. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47690. import { Scene } from "babylonjs/scene";
  47691. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47692. /**
  47693. * Single plane drag gizmo
  47694. */
  47695. export class PlaneDragGizmo extends Gizmo {
  47696. /**
  47697. * Drag behavior responsible for the gizmos dragging interactions
  47698. */
  47699. dragBehavior: PointerDragBehavior;
  47700. private _pointerObserver;
  47701. /**
  47702. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47703. */
  47704. snapDistance: number;
  47705. /**
  47706. * Event that fires each time the gizmo snaps to a new location.
  47707. * * snapDistance is the the change in distance
  47708. */
  47709. onSnapObservable: Observable<{
  47710. snapDistance: number;
  47711. }>;
  47712. private _plane;
  47713. private _coloredMaterial;
  47714. private _hoverMaterial;
  47715. private _isEnabled;
  47716. private _parent;
  47717. /** @hidden */
  47718. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47719. /** @hidden */
  47720. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47721. /**
  47722. * Creates a PlaneDragGizmo
  47723. * @param gizmoLayer The utility layer the gizmo will be added to
  47724. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47725. * @param color The color of the gizmo
  47726. */
  47727. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47728. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47729. /**
  47730. * If the gizmo is enabled
  47731. */
  47732. set isEnabled(value: boolean);
  47733. get isEnabled(): boolean;
  47734. /**
  47735. * Disposes of the gizmo
  47736. */
  47737. dispose(): void;
  47738. }
  47739. }
  47740. declare module "babylonjs/Gizmos/positionGizmo" {
  47741. import { Observable } from "babylonjs/Misc/observable";
  47742. import { Nullable } from "babylonjs/types";
  47743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47744. import { Mesh } from "babylonjs/Meshes/mesh";
  47745. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47746. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47747. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47748. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47749. /**
  47750. * Gizmo that enables dragging a mesh along 3 axis
  47751. */
  47752. export class PositionGizmo extends Gizmo {
  47753. /**
  47754. * Internal gizmo used for interactions on the x axis
  47755. */
  47756. xGizmo: AxisDragGizmo;
  47757. /**
  47758. * Internal gizmo used for interactions on the y axis
  47759. */
  47760. yGizmo: AxisDragGizmo;
  47761. /**
  47762. * Internal gizmo used for interactions on the z axis
  47763. */
  47764. zGizmo: AxisDragGizmo;
  47765. /**
  47766. * Internal gizmo used for interactions on the yz plane
  47767. */
  47768. xPlaneGizmo: PlaneDragGizmo;
  47769. /**
  47770. * Internal gizmo used for interactions on the xz plane
  47771. */
  47772. yPlaneGizmo: PlaneDragGizmo;
  47773. /**
  47774. * Internal gizmo used for interactions on the xy plane
  47775. */
  47776. zPlaneGizmo: PlaneDragGizmo;
  47777. /**
  47778. * private variables
  47779. */
  47780. private _meshAttached;
  47781. private _updateGizmoRotationToMatchAttachedMesh;
  47782. private _snapDistance;
  47783. private _scaleRatio;
  47784. /** Fires an event when any of it's sub gizmos are dragged */
  47785. onDragStartObservable: Observable<unknown>;
  47786. /** Fires an event when any of it's sub gizmos are released from dragging */
  47787. onDragEndObservable: Observable<unknown>;
  47788. /**
  47789. * If set to true, planar drag is enabled
  47790. */
  47791. private _planarGizmoEnabled;
  47792. get attachedMesh(): Nullable<AbstractMesh>;
  47793. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47794. /**
  47795. * Creates a PositionGizmo
  47796. * @param gizmoLayer The utility layer the gizmo will be added to
  47797. */
  47798. constructor(gizmoLayer?: UtilityLayerRenderer);
  47799. /**
  47800. * If the planar drag gizmo is enabled
  47801. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47802. */
  47803. set planarGizmoEnabled(value: boolean);
  47804. get planarGizmoEnabled(): boolean;
  47805. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47806. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47807. /**
  47808. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47809. */
  47810. set snapDistance(value: number);
  47811. get snapDistance(): number;
  47812. /**
  47813. * Ratio for the scale of the gizmo (Default: 1)
  47814. */
  47815. set scaleRatio(value: number);
  47816. get scaleRatio(): number;
  47817. /**
  47818. * Disposes of the gizmo
  47819. */
  47820. dispose(): void;
  47821. /**
  47822. * CustomMeshes are not supported by this gizmo
  47823. * @param mesh The mesh to replace the default mesh of the gizmo
  47824. */
  47825. setCustomMesh(mesh: Mesh): void;
  47826. }
  47827. }
  47828. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47829. import { Observable } from "babylonjs/Misc/observable";
  47830. import { Nullable } from "babylonjs/types";
  47831. import { Vector3 } from "babylonjs/Maths/math.vector";
  47832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47834. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47837. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47838. import { Scene } from "babylonjs/scene";
  47839. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47840. import { Color3 } from "babylonjs/Maths/math.color";
  47841. /**
  47842. * Single axis drag gizmo
  47843. */
  47844. export class AxisDragGizmo extends Gizmo {
  47845. /**
  47846. * Drag behavior responsible for the gizmos dragging interactions
  47847. */
  47848. dragBehavior: PointerDragBehavior;
  47849. private _pointerObserver;
  47850. /**
  47851. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47852. */
  47853. snapDistance: number;
  47854. /**
  47855. * Event that fires each time the gizmo snaps to a new location.
  47856. * * snapDistance is the the change in distance
  47857. */
  47858. onSnapObservable: Observable<{
  47859. snapDistance: number;
  47860. }>;
  47861. private _isEnabled;
  47862. private _parent;
  47863. private _arrow;
  47864. private _coloredMaterial;
  47865. private _hoverMaterial;
  47866. /** @hidden */
  47867. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47868. /** @hidden */
  47869. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47870. /**
  47871. * Creates an AxisDragGizmo
  47872. * @param gizmoLayer The utility layer the gizmo will be added to
  47873. * @param dragAxis The axis which the gizmo will be able to drag on
  47874. * @param color The color of the gizmo
  47875. */
  47876. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47877. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47878. /**
  47879. * If the gizmo is enabled
  47880. */
  47881. set isEnabled(value: boolean);
  47882. get isEnabled(): boolean;
  47883. /**
  47884. * Disposes of the gizmo
  47885. */
  47886. dispose(): void;
  47887. }
  47888. }
  47889. declare module "babylonjs/Debug/axesViewer" {
  47890. import { Vector3 } from "babylonjs/Maths/math.vector";
  47891. import { Nullable } from "babylonjs/types";
  47892. import { Scene } from "babylonjs/scene";
  47893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47894. /**
  47895. * The Axes viewer will show 3 axes in a specific point in space
  47896. */
  47897. export class AxesViewer {
  47898. private _xAxis;
  47899. private _yAxis;
  47900. private _zAxis;
  47901. private _scaleLinesFactor;
  47902. private _instanced;
  47903. /**
  47904. * Gets the hosting scene
  47905. */
  47906. scene: Scene;
  47907. /**
  47908. * Gets or sets a number used to scale line length
  47909. */
  47910. scaleLines: number;
  47911. /** Gets the node hierarchy used to render x-axis */
  47912. get xAxis(): TransformNode;
  47913. /** Gets the node hierarchy used to render y-axis */
  47914. get yAxis(): TransformNode;
  47915. /** Gets the node hierarchy used to render z-axis */
  47916. get zAxis(): TransformNode;
  47917. /**
  47918. * Creates a new AxesViewer
  47919. * @param scene defines the hosting scene
  47920. * @param scaleLines defines a number used to scale line length (1 by default)
  47921. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47922. * @param xAxis defines the node hierarchy used to render the x-axis
  47923. * @param yAxis defines the node hierarchy used to render the y-axis
  47924. * @param zAxis defines the node hierarchy used to render the z-axis
  47925. */
  47926. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47927. /**
  47928. * Force the viewer to update
  47929. * @param position defines the position of the viewer
  47930. * @param xaxis defines the x axis of the viewer
  47931. * @param yaxis defines the y axis of the viewer
  47932. * @param zaxis defines the z axis of the viewer
  47933. */
  47934. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47935. /**
  47936. * Creates an instance of this axes viewer.
  47937. * @returns a new axes viewer with instanced meshes
  47938. */
  47939. createInstance(): AxesViewer;
  47940. /** Releases resources */
  47941. dispose(): void;
  47942. private static _SetRenderingGroupId;
  47943. }
  47944. }
  47945. declare module "babylonjs/Debug/boneAxesViewer" {
  47946. import { Nullable } from "babylonjs/types";
  47947. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47948. import { Vector3 } from "babylonjs/Maths/math.vector";
  47949. import { Mesh } from "babylonjs/Meshes/mesh";
  47950. import { Bone } from "babylonjs/Bones/bone";
  47951. import { Scene } from "babylonjs/scene";
  47952. /**
  47953. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47954. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47955. */
  47956. export class BoneAxesViewer extends AxesViewer {
  47957. /**
  47958. * Gets or sets the target mesh where to display the axes viewer
  47959. */
  47960. mesh: Nullable<Mesh>;
  47961. /**
  47962. * Gets or sets the target bone where to display the axes viewer
  47963. */
  47964. bone: Nullable<Bone>;
  47965. /** Gets current position */
  47966. pos: Vector3;
  47967. /** Gets direction of X axis */
  47968. xaxis: Vector3;
  47969. /** Gets direction of Y axis */
  47970. yaxis: Vector3;
  47971. /** Gets direction of Z axis */
  47972. zaxis: Vector3;
  47973. /**
  47974. * Creates a new BoneAxesViewer
  47975. * @param scene defines the hosting scene
  47976. * @param bone defines the target bone
  47977. * @param mesh defines the target mesh
  47978. * @param scaleLines defines a scaling factor for line length (1 by default)
  47979. */
  47980. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47981. /**
  47982. * Force the viewer to update
  47983. */
  47984. update(): void;
  47985. /** Releases resources */
  47986. dispose(): void;
  47987. }
  47988. }
  47989. declare module "babylonjs/Debug/debugLayer" {
  47990. import { Scene } from "babylonjs/scene";
  47991. /**
  47992. * Interface used to define scene explorer extensibility option
  47993. */
  47994. export interface IExplorerExtensibilityOption {
  47995. /**
  47996. * Define the option label
  47997. */
  47998. label: string;
  47999. /**
  48000. * Defines the action to execute on click
  48001. */
  48002. action: (entity: any) => void;
  48003. }
  48004. /**
  48005. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48006. */
  48007. export interface IExplorerExtensibilityGroup {
  48008. /**
  48009. * Defines a predicate to test if a given type mut be extended
  48010. */
  48011. predicate: (entity: any) => boolean;
  48012. /**
  48013. * Gets the list of options added to a type
  48014. */
  48015. entries: IExplorerExtensibilityOption[];
  48016. }
  48017. /**
  48018. * Interface used to define the options to use to create the Inspector
  48019. */
  48020. export interface IInspectorOptions {
  48021. /**
  48022. * Display in overlay mode (default: false)
  48023. */
  48024. overlay?: boolean;
  48025. /**
  48026. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48027. */
  48028. globalRoot?: HTMLElement;
  48029. /**
  48030. * Display the Scene explorer
  48031. */
  48032. showExplorer?: boolean;
  48033. /**
  48034. * Display the property inspector
  48035. */
  48036. showInspector?: boolean;
  48037. /**
  48038. * Display in embed mode (both panes on the right)
  48039. */
  48040. embedMode?: boolean;
  48041. /**
  48042. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48043. */
  48044. handleResize?: boolean;
  48045. /**
  48046. * Allow the panes to popup (default: true)
  48047. */
  48048. enablePopup?: boolean;
  48049. /**
  48050. * Allow the panes to be closed by users (default: true)
  48051. */
  48052. enableClose?: boolean;
  48053. /**
  48054. * Optional list of extensibility entries
  48055. */
  48056. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48057. /**
  48058. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48059. */
  48060. inspectorURL?: string;
  48061. /**
  48062. * Optional initial tab (default to DebugLayerTab.Properties)
  48063. */
  48064. initialTab?: DebugLayerTab;
  48065. }
  48066. module "babylonjs/scene" {
  48067. interface Scene {
  48068. /**
  48069. * @hidden
  48070. * Backing field
  48071. */
  48072. _debugLayer: DebugLayer;
  48073. /**
  48074. * Gets the debug layer (aka Inspector) associated with the scene
  48075. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48076. */
  48077. debugLayer: DebugLayer;
  48078. }
  48079. }
  48080. /**
  48081. * Enum of inspector action tab
  48082. */
  48083. export enum DebugLayerTab {
  48084. /**
  48085. * Properties tag (default)
  48086. */
  48087. Properties = 0,
  48088. /**
  48089. * Debug tab
  48090. */
  48091. Debug = 1,
  48092. /**
  48093. * Statistics tab
  48094. */
  48095. Statistics = 2,
  48096. /**
  48097. * Tools tab
  48098. */
  48099. Tools = 3,
  48100. /**
  48101. * Settings tab
  48102. */
  48103. Settings = 4
  48104. }
  48105. /**
  48106. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48107. * what is happening in your scene
  48108. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48109. */
  48110. export class DebugLayer {
  48111. /**
  48112. * Define the url to get the inspector script from.
  48113. * By default it uses the babylonjs CDN.
  48114. * @ignoreNaming
  48115. */
  48116. static InspectorURL: string;
  48117. private _scene;
  48118. private BJSINSPECTOR;
  48119. private _onPropertyChangedObservable?;
  48120. /**
  48121. * Observable triggered when a property is changed through the inspector.
  48122. */
  48123. get onPropertyChangedObservable(): any;
  48124. /**
  48125. * Instantiates a new debug layer.
  48126. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48127. * what is happening in your scene
  48128. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48129. * @param scene Defines the scene to inspect
  48130. */
  48131. constructor(scene: Scene);
  48132. /** Creates the inspector window. */
  48133. private _createInspector;
  48134. /**
  48135. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48136. * @param entity defines the entity to select
  48137. * @param lineContainerTitle defines the specific block to highlight
  48138. */
  48139. select(entity: any, lineContainerTitle?: string): void;
  48140. /** Get the inspector from bundle or global */
  48141. private _getGlobalInspector;
  48142. /**
  48143. * Get if the inspector is visible or not.
  48144. * @returns true if visible otherwise, false
  48145. */
  48146. isVisible(): boolean;
  48147. /**
  48148. * Hide the inspector and close its window.
  48149. */
  48150. hide(): void;
  48151. /**
  48152. * Launch the debugLayer.
  48153. * @param config Define the configuration of the inspector
  48154. * @return a promise fulfilled when the debug layer is visible
  48155. */
  48156. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48157. }
  48158. }
  48159. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48160. import { Nullable } from "babylonjs/types";
  48161. import { Scene } from "babylonjs/scene";
  48162. import { Vector4 } from "babylonjs/Maths/math.vector";
  48163. import { Color4 } from "babylonjs/Maths/math.color";
  48164. import { Mesh } from "babylonjs/Meshes/mesh";
  48165. /**
  48166. * Class containing static functions to help procedurally build meshes
  48167. */
  48168. export class BoxBuilder {
  48169. /**
  48170. * Creates a box mesh
  48171. * * The parameter `size` sets the size (float) of each box side (default 1)
  48172. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48173. * * 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)
  48174. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48178. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48179. * @param name defines the name of the mesh
  48180. * @param options defines the options used to create the mesh
  48181. * @param scene defines the hosting scene
  48182. * @returns the box mesh
  48183. */
  48184. static CreateBox(name: string, options: {
  48185. size?: number;
  48186. width?: number;
  48187. height?: number;
  48188. depth?: number;
  48189. faceUV?: Vector4[];
  48190. faceColors?: Color4[];
  48191. sideOrientation?: number;
  48192. frontUVs?: Vector4;
  48193. backUVs?: Vector4;
  48194. wrap?: boolean;
  48195. topBaseAt?: number;
  48196. bottomBaseAt?: number;
  48197. updatable?: boolean;
  48198. }, scene?: Nullable<Scene>): Mesh;
  48199. }
  48200. }
  48201. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48202. import { Vector4 } from "babylonjs/Maths/math.vector";
  48203. import { Mesh } from "babylonjs/Meshes/mesh";
  48204. import { Scene } from "babylonjs/scene";
  48205. import { Nullable } from "babylonjs/types";
  48206. /**
  48207. * Class containing static functions to help procedurally build meshes
  48208. */
  48209. export class SphereBuilder {
  48210. /**
  48211. * Creates a sphere mesh
  48212. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48213. * * 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`)
  48214. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48215. * * 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
  48216. * * 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)
  48217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48220. * @param name defines the name of the mesh
  48221. * @param options defines the options used to create the mesh
  48222. * @param scene defines the hosting scene
  48223. * @returns the sphere mesh
  48224. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48225. */
  48226. static CreateSphere(name: string, options: {
  48227. segments?: number;
  48228. diameter?: number;
  48229. diameterX?: number;
  48230. diameterY?: number;
  48231. diameterZ?: number;
  48232. arc?: number;
  48233. slice?: number;
  48234. sideOrientation?: number;
  48235. frontUVs?: Vector4;
  48236. backUVs?: Vector4;
  48237. updatable?: boolean;
  48238. }, scene?: Nullable<Scene>): Mesh;
  48239. }
  48240. }
  48241. declare module "babylonjs/Debug/physicsViewer" {
  48242. import { Nullable } from "babylonjs/types";
  48243. import { Scene } from "babylonjs/scene";
  48244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48245. import { Mesh } from "babylonjs/Meshes/mesh";
  48246. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48247. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48248. /**
  48249. * Used to show the physics impostor around the specific mesh
  48250. */
  48251. export class PhysicsViewer {
  48252. /** @hidden */
  48253. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48254. /** @hidden */
  48255. protected _meshes: Array<Nullable<AbstractMesh>>;
  48256. /** @hidden */
  48257. protected _scene: Nullable<Scene>;
  48258. /** @hidden */
  48259. protected _numMeshes: number;
  48260. /** @hidden */
  48261. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48262. private _renderFunction;
  48263. private _utilityLayer;
  48264. private _debugBoxMesh;
  48265. private _debugSphereMesh;
  48266. private _debugCylinderMesh;
  48267. private _debugMaterial;
  48268. private _debugMeshMeshes;
  48269. /**
  48270. * Creates a new PhysicsViewer
  48271. * @param scene defines the hosting scene
  48272. */
  48273. constructor(scene: Scene);
  48274. /** @hidden */
  48275. protected _updateDebugMeshes(): void;
  48276. /**
  48277. * Renders a specified physic impostor
  48278. * @param impostor defines the impostor to render
  48279. * @param targetMesh defines the mesh represented by the impostor
  48280. * @returns the new debug mesh used to render the impostor
  48281. */
  48282. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48283. /**
  48284. * Hides a specified physic impostor
  48285. * @param impostor defines the impostor to hide
  48286. */
  48287. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48288. private _getDebugMaterial;
  48289. private _getDebugBoxMesh;
  48290. private _getDebugSphereMesh;
  48291. private _getDebugCylinderMesh;
  48292. private _getDebugMeshMesh;
  48293. private _getDebugMesh;
  48294. /** Releases all resources */
  48295. dispose(): void;
  48296. }
  48297. }
  48298. declare module "babylonjs/Debug/rayHelper" {
  48299. import { Nullable } from "babylonjs/types";
  48300. import { Ray } from "babylonjs/Culling/ray";
  48301. import { Vector3 } from "babylonjs/Maths/math.vector";
  48302. import { Color3 } from "babylonjs/Maths/math.color";
  48303. import { Scene } from "babylonjs/scene";
  48304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48305. import "babylonjs/Meshes/Builders/linesBuilder";
  48306. /**
  48307. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48308. * in order to better appreciate the issue one might have.
  48309. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48310. */
  48311. export class RayHelper {
  48312. /**
  48313. * Defines the ray we are currently tryin to visualize.
  48314. */
  48315. ray: Nullable<Ray>;
  48316. private _renderPoints;
  48317. private _renderLine;
  48318. private _renderFunction;
  48319. private _scene;
  48320. private _updateToMeshFunction;
  48321. private _attachedToMesh;
  48322. private _meshSpaceDirection;
  48323. private _meshSpaceOrigin;
  48324. /**
  48325. * Helper function to create a colored helper in a scene in one line.
  48326. * @param ray Defines the ray we are currently tryin to visualize
  48327. * @param scene Defines the scene the ray is used in
  48328. * @param color Defines the color we want to see the ray in
  48329. * @returns The newly created ray helper.
  48330. */
  48331. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48332. /**
  48333. * Instantiate a new ray helper.
  48334. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48335. * in order to better appreciate the issue one might have.
  48336. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48337. * @param ray Defines the ray we are currently tryin to visualize
  48338. */
  48339. constructor(ray: Ray);
  48340. /**
  48341. * Shows the ray we are willing to debug.
  48342. * @param scene Defines the scene the ray needs to be rendered in
  48343. * @param color Defines the color the ray needs to be rendered in
  48344. */
  48345. show(scene: Scene, color?: Color3): void;
  48346. /**
  48347. * Hides the ray we are debugging.
  48348. */
  48349. hide(): void;
  48350. private _render;
  48351. /**
  48352. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48353. * @param mesh Defines the mesh we want the helper attached to
  48354. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48355. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48356. * @param length Defines the length of the ray
  48357. */
  48358. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48359. /**
  48360. * Detach the ray helper from the mesh it has previously been attached to.
  48361. */
  48362. detachFromMesh(): void;
  48363. private _updateToMesh;
  48364. /**
  48365. * Dispose the helper and release its associated resources.
  48366. */
  48367. dispose(): void;
  48368. }
  48369. }
  48370. declare module "babylonjs/Debug/skeletonViewer" {
  48371. import { Color3 } from "babylonjs/Maths/math.color";
  48372. import { Scene } from "babylonjs/scene";
  48373. import { Nullable } from "babylonjs/types";
  48374. import { Skeleton } from "babylonjs/Bones/skeleton";
  48375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48376. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48377. /**
  48378. * Class used to render a debug view of a given skeleton
  48379. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48380. */
  48381. export class SkeletonViewer {
  48382. /** defines the skeleton to render */
  48383. skeleton: Skeleton;
  48384. /** defines the mesh attached to the skeleton */
  48385. mesh: AbstractMesh;
  48386. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48387. autoUpdateBonesMatrices: boolean;
  48388. /** defines the rendering group id to use with the viewer */
  48389. renderingGroupId: number;
  48390. /** Gets or sets the color used to render the skeleton */
  48391. color: Color3;
  48392. private _scene;
  48393. private _debugLines;
  48394. private _debugMesh;
  48395. private _isEnabled;
  48396. private _renderFunction;
  48397. private _utilityLayer;
  48398. /**
  48399. * Returns the mesh used to render the bones
  48400. */
  48401. get debugMesh(): Nullable<LinesMesh>;
  48402. /**
  48403. * Creates a new SkeletonViewer
  48404. * @param skeleton defines the skeleton to render
  48405. * @param mesh defines the mesh attached to the skeleton
  48406. * @param scene defines the hosting scene
  48407. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48408. * @param renderingGroupId defines the rendering group id to use with the viewer
  48409. */
  48410. constructor(
  48411. /** defines the skeleton to render */
  48412. skeleton: Skeleton,
  48413. /** defines the mesh attached to the skeleton */
  48414. mesh: AbstractMesh, scene: Scene,
  48415. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48416. autoUpdateBonesMatrices?: boolean,
  48417. /** defines the rendering group id to use with the viewer */
  48418. renderingGroupId?: number);
  48419. /** Gets or sets a boolean indicating if the viewer is enabled */
  48420. set isEnabled(value: boolean);
  48421. get isEnabled(): boolean;
  48422. private _getBonePosition;
  48423. private _getLinesForBonesWithLength;
  48424. private _getLinesForBonesNoLength;
  48425. /** Update the viewer to sync with current skeleton state */
  48426. update(): void;
  48427. /** Release associated resources */
  48428. dispose(): void;
  48429. }
  48430. }
  48431. declare module "babylonjs/Debug/index" {
  48432. export * from "babylonjs/Debug/axesViewer";
  48433. export * from "babylonjs/Debug/boneAxesViewer";
  48434. export * from "babylonjs/Debug/debugLayer";
  48435. export * from "babylonjs/Debug/physicsViewer";
  48436. export * from "babylonjs/Debug/rayHelper";
  48437. export * from "babylonjs/Debug/skeletonViewer";
  48438. }
  48439. declare module "babylonjs/Engines/nullEngine" {
  48440. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48441. import { Scene } from "babylonjs/scene";
  48442. import { Engine } from "babylonjs/Engines/engine";
  48443. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48444. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48445. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48446. import { Effect } from "babylonjs/Materials/effect";
  48447. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48448. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48449. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48450. /**
  48451. * Options to create the null engine
  48452. */
  48453. export class NullEngineOptions {
  48454. /**
  48455. * Render width (Default: 512)
  48456. */
  48457. renderWidth: number;
  48458. /**
  48459. * Render height (Default: 256)
  48460. */
  48461. renderHeight: number;
  48462. /**
  48463. * Texture size (Default: 512)
  48464. */
  48465. textureSize: number;
  48466. /**
  48467. * If delta time between frames should be constant
  48468. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48469. */
  48470. deterministicLockstep: boolean;
  48471. /**
  48472. * Maximum about of steps between frames (Default: 4)
  48473. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48474. */
  48475. lockstepMaxSteps: number;
  48476. }
  48477. /**
  48478. * The null engine class provides support for headless version of babylon.js.
  48479. * This can be used in server side scenario or for testing purposes
  48480. */
  48481. export class NullEngine extends Engine {
  48482. private _options;
  48483. /**
  48484. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48485. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48486. * @returns true if engine is in deterministic lock step mode
  48487. */
  48488. isDeterministicLockStep(): boolean;
  48489. /**
  48490. * Gets the max steps when engine is running in deterministic lock step
  48491. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48492. * @returns the max steps
  48493. */
  48494. getLockstepMaxSteps(): number;
  48495. /**
  48496. * Gets the current hardware scaling level.
  48497. * By default the hardware scaling level is computed from the window device ratio.
  48498. * 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.
  48499. * @returns a number indicating the current hardware scaling level
  48500. */
  48501. getHardwareScalingLevel(): number;
  48502. constructor(options?: NullEngineOptions);
  48503. /**
  48504. * Creates a vertex buffer
  48505. * @param vertices the data for the vertex buffer
  48506. * @returns the new WebGL static buffer
  48507. */
  48508. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48509. /**
  48510. * Creates a new index buffer
  48511. * @param indices defines the content of the index buffer
  48512. * @param updatable defines if the index buffer must be updatable
  48513. * @returns a new webGL buffer
  48514. */
  48515. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48516. /**
  48517. * Clear the current render buffer or the current render target (if any is set up)
  48518. * @param color defines the color to use
  48519. * @param backBuffer defines if the back buffer must be cleared
  48520. * @param depth defines if the depth buffer must be cleared
  48521. * @param stencil defines if the stencil buffer must be cleared
  48522. */
  48523. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48524. /**
  48525. * Gets the current render width
  48526. * @param useScreen defines if screen size must be used (or the current render target if any)
  48527. * @returns a number defining the current render width
  48528. */
  48529. getRenderWidth(useScreen?: boolean): number;
  48530. /**
  48531. * Gets the current render height
  48532. * @param useScreen defines if screen size must be used (or the current render target if any)
  48533. * @returns a number defining the current render height
  48534. */
  48535. getRenderHeight(useScreen?: boolean): number;
  48536. /**
  48537. * Set the WebGL's viewport
  48538. * @param viewport defines the viewport element to be used
  48539. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48540. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48541. */
  48542. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48543. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48544. /**
  48545. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48546. * @param pipelineContext defines the pipeline context to use
  48547. * @param uniformsNames defines the list of uniform names
  48548. * @returns an array of webGL uniform locations
  48549. */
  48550. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48551. /**
  48552. * Gets the lsit of active attributes for a given webGL program
  48553. * @param pipelineContext defines the pipeline context to use
  48554. * @param attributesNames defines the list of attribute names to get
  48555. * @returns an array of indices indicating the offset of each attribute
  48556. */
  48557. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48558. /**
  48559. * Binds an effect to the webGL context
  48560. * @param effect defines the effect to bind
  48561. */
  48562. bindSamplers(effect: Effect): void;
  48563. /**
  48564. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48565. * @param effect defines the effect to activate
  48566. */
  48567. enableEffect(effect: Effect): void;
  48568. /**
  48569. * Set various states to the webGL context
  48570. * @param culling defines backface culling state
  48571. * @param zOffset defines the value to apply to zOffset (0 by default)
  48572. * @param force defines if states must be applied even if cache is up to date
  48573. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48574. */
  48575. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48576. /**
  48577. * Set the value of an uniform to an array of int32
  48578. * @param uniform defines the webGL uniform location where to store the value
  48579. * @param array defines the array of int32 to store
  48580. */
  48581. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48582. /**
  48583. * Set the value of an uniform to an array of int32 (stored as vec2)
  48584. * @param uniform defines the webGL uniform location where to store the value
  48585. * @param array defines the array of int32 to store
  48586. */
  48587. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48588. /**
  48589. * Set the value of an uniform to an array of int32 (stored as vec3)
  48590. * @param uniform defines the webGL uniform location where to store the value
  48591. * @param array defines the array of int32 to store
  48592. */
  48593. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48594. /**
  48595. * Set the value of an uniform to an array of int32 (stored as vec4)
  48596. * @param uniform defines the webGL uniform location where to store the value
  48597. * @param array defines the array of int32 to store
  48598. */
  48599. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48600. /**
  48601. * Set the value of an uniform to an array of float32
  48602. * @param uniform defines the webGL uniform location where to store the value
  48603. * @param array defines the array of float32 to store
  48604. */
  48605. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48606. /**
  48607. * Set the value of an uniform to an array of float32 (stored as vec2)
  48608. * @param uniform defines the webGL uniform location where to store the value
  48609. * @param array defines the array of float32 to store
  48610. */
  48611. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48612. /**
  48613. * Set the value of an uniform to an array of float32 (stored as vec3)
  48614. * @param uniform defines the webGL uniform location where to store the value
  48615. * @param array defines the array of float32 to store
  48616. */
  48617. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48618. /**
  48619. * Set the value of an uniform to an array of float32 (stored as vec4)
  48620. * @param uniform defines the webGL uniform location where to store the value
  48621. * @param array defines the array of float32 to store
  48622. */
  48623. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48624. /**
  48625. * Set the value of an uniform to an array of number
  48626. * @param uniform defines the webGL uniform location where to store the value
  48627. * @param array defines the array of number to store
  48628. */
  48629. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48630. /**
  48631. * Set the value of an uniform to an array of number (stored as vec2)
  48632. * @param uniform defines the webGL uniform location where to store the value
  48633. * @param array defines the array of number to store
  48634. */
  48635. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48636. /**
  48637. * Set the value of an uniform to an array of number (stored as vec3)
  48638. * @param uniform defines the webGL uniform location where to store the value
  48639. * @param array defines the array of number to store
  48640. */
  48641. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48642. /**
  48643. * Set the value of an uniform to an array of number (stored as vec4)
  48644. * @param uniform defines the webGL uniform location where to store the value
  48645. * @param array defines the array of number to store
  48646. */
  48647. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48648. /**
  48649. * Set the value of an uniform to an array of float32 (stored as matrices)
  48650. * @param uniform defines the webGL uniform location where to store the value
  48651. * @param matrices defines the array of float32 to store
  48652. */
  48653. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48654. /**
  48655. * Set the value of an uniform to a matrix (3x3)
  48656. * @param uniform defines the webGL uniform location where to store the value
  48657. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48658. */
  48659. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48660. /**
  48661. * Set the value of an uniform to a matrix (2x2)
  48662. * @param uniform defines the webGL uniform location where to store the value
  48663. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48664. */
  48665. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48666. /**
  48667. * Set the value of an uniform to a number (float)
  48668. * @param uniform defines the webGL uniform location where to store the value
  48669. * @param value defines the float number to store
  48670. */
  48671. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48672. /**
  48673. * Set the value of an uniform to a vec2
  48674. * @param uniform defines the webGL uniform location where to store the value
  48675. * @param x defines the 1st component of the value
  48676. * @param y defines the 2nd component of the value
  48677. */
  48678. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48679. /**
  48680. * Set the value of an uniform to a vec3
  48681. * @param uniform defines the webGL uniform location where to store the value
  48682. * @param x defines the 1st component of the value
  48683. * @param y defines the 2nd component of the value
  48684. * @param z defines the 3rd component of the value
  48685. */
  48686. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48687. /**
  48688. * Set the value of an uniform to a boolean
  48689. * @param uniform defines the webGL uniform location where to store the value
  48690. * @param bool defines the boolean to store
  48691. */
  48692. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48693. /**
  48694. * Set the value of an uniform to a vec4
  48695. * @param uniform defines the webGL uniform location where to store the value
  48696. * @param x defines the 1st component of the value
  48697. * @param y defines the 2nd component of the value
  48698. * @param z defines the 3rd component of the value
  48699. * @param w defines the 4th component of the value
  48700. */
  48701. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48702. /**
  48703. * Sets the current alpha mode
  48704. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48705. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48706. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48707. */
  48708. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48709. /**
  48710. * Bind webGl buffers directly to the webGL context
  48711. * @param vertexBuffers defines the vertex buffer to bind
  48712. * @param indexBuffer defines the index buffer to bind
  48713. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48714. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48715. * @param effect defines the effect associated with the vertex buffer
  48716. */
  48717. bindBuffers(vertexBuffers: {
  48718. [key: string]: VertexBuffer;
  48719. }, indexBuffer: DataBuffer, effect: Effect): void;
  48720. /**
  48721. * Force the entire cache to be cleared
  48722. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48723. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48724. */
  48725. wipeCaches(bruteForce?: boolean): void;
  48726. /**
  48727. * Send a draw order
  48728. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48729. * @param indexStart defines the starting index
  48730. * @param indexCount defines the number of index to draw
  48731. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48732. */
  48733. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48734. /**
  48735. * Draw a list of indexed primitives
  48736. * @param fillMode defines the primitive to use
  48737. * @param indexStart defines the starting index
  48738. * @param indexCount defines the number of index to draw
  48739. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48740. */
  48741. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48742. /**
  48743. * Draw a list of unindexed primitives
  48744. * @param fillMode defines the primitive to use
  48745. * @param verticesStart defines the index of first vertex to draw
  48746. * @param verticesCount defines the count of vertices to draw
  48747. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48748. */
  48749. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48750. /** @hidden */
  48751. _createTexture(): WebGLTexture;
  48752. /** @hidden */
  48753. _releaseTexture(texture: InternalTexture): void;
  48754. /**
  48755. * Usually called from Texture.ts.
  48756. * Passed information to create a WebGLTexture
  48757. * @param urlArg defines a value which contains one of the following:
  48758. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48759. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48760. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48761. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48762. * @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)
  48763. * @param scene needed for loading to the correct scene
  48764. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48765. * @param onLoad optional callback to be called upon successful completion
  48766. * @param onError optional callback to be called upon failure
  48767. * @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
  48768. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48769. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48770. * @param forcedExtension defines the extension to use to pick the right loader
  48771. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48772. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48773. */
  48774. 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;
  48775. /**
  48776. * Creates a new render target texture
  48777. * @param size defines the size of the texture
  48778. * @param options defines the options used to create the texture
  48779. * @returns a new render target texture stored in an InternalTexture
  48780. */
  48781. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48782. /**
  48783. * Update the sampling mode of a given texture
  48784. * @param samplingMode defines the required sampling mode
  48785. * @param texture defines the texture to update
  48786. */
  48787. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48788. /**
  48789. * Binds the frame buffer to the specified texture.
  48790. * @param texture The texture to render to or null for the default canvas
  48791. * @param faceIndex The face of the texture to render to in case of cube texture
  48792. * @param requiredWidth The width of the target to render to
  48793. * @param requiredHeight The height of the target to render to
  48794. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48795. * @param lodLevel defines le lod level to bind to the frame buffer
  48796. */
  48797. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48798. /**
  48799. * Unbind the current render target texture from the webGL context
  48800. * @param texture defines the render target texture to unbind
  48801. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48802. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48803. */
  48804. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48805. /**
  48806. * Creates a dynamic vertex buffer
  48807. * @param vertices the data for the dynamic vertex buffer
  48808. * @returns the new WebGL dynamic buffer
  48809. */
  48810. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48811. /**
  48812. * Update the content of a dynamic texture
  48813. * @param texture defines the texture to update
  48814. * @param canvas defines the canvas containing the source
  48815. * @param invertY defines if data must be stored with Y axis inverted
  48816. * @param premulAlpha defines if alpha is stored as premultiplied
  48817. * @param format defines the format of the data
  48818. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48819. */
  48820. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48821. /**
  48822. * Gets a boolean indicating if all created effects are ready
  48823. * @returns true if all effects are ready
  48824. */
  48825. areAllEffectsReady(): boolean;
  48826. /**
  48827. * @hidden
  48828. * Get the current error code of the webGL context
  48829. * @returns the error code
  48830. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48831. */
  48832. getError(): number;
  48833. /** @hidden */
  48834. _getUnpackAlignement(): number;
  48835. /** @hidden */
  48836. _unpackFlipY(value: boolean): void;
  48837. /**
  48838. * Update a dynamic index buffer
  48839. * @param indexBuffer defines the target index buffer
  48840. * @param indices defines the data to update
  48841. * @param offset defines the offset in the target index buffer where update should start
  48842. */
  48843. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48844. /**
  48845. * Updates a dynamic vertex buffer.
  48846. * @param vertexBuffer the vertex buffer to update
  48847. * @param vertices the data used to update the vertex buffer
  48848. * @param byteOffset the byte offset of the data (optional)
  48849. * @param byteLength the byte length of the data (optional)
  48850. */
  48851. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48852. /** @hidden */
  48853. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48854. /** @hidden */
  48855. _bindTexture(channel: number, texture: InternalTexture): void;
  48856. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48857. /**
  48858. * 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
  48859. */
  48860. releaseEffects(): void;
  48861. displayLoadingUI(): void;
  48862. hideLoadingUI(): void;
  48863. /** @hidden */
  48864. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48865. /** @hidden */
  48866. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48867. /** @hidden */
  48868. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48869. /** @hidden */
  48870. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48871. }
  48872. }
  48873. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48874. import { Nullable, int } from "babylonjs/types";
  48875. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48876. /** @hidden */
  48877. export class _OcclusionDataStorage {
  48878. /** @hidden */
  48879. occlusionInternalRetryCounter: number;
  48880. /** @hidden */
  48881. isOcclusionQueryInProgress: boolean;
  48882. /** @hidden */
  48883. isOccluded: boolean;
  48884. /** @hidden */
  48885. occlusionRetryCount: number;
  48886. /** @hidden */
  48887. occlusionType: number;
  48888. /** @hidden */
  48889. occlusionQueryAlgorithmType: number;
  48890. }
  48891. module "babylonjs/Engines/engine" {
  48892. interface Engine {
  48893. /**
  48894. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48895. * @return the new query
  48896. */
  48897. createQuery(): WebGLQuery;
  48898. /**
  48899. * Delete and release a webGL query
  48900. * @param query defines the query to delete
  48901. * @return the current engine
  48902. */
  48903. deleteQuery(query: WebGLQuery): Engine;
  48904. /**
  48905. * Check if a given query has resolved and got its value
  48906. * @param query defines the query to check
  48907. * @returns true if the query got its value
  48908. */
  48909. isQueryResultAvailable(query: WebGLQuery): boolean;
  48910. /**
  48911. * Gets the value of a given query
  48912. * @param query defines the query to check
  48913. * @returns the value of the query
  48914. */
  48915. getQueryResult(query: WebGLQuery): number;
  48916. /**
  48917. * Initiates an occlusion query
  48918. * @param algorithmType defines the algorithm to use
  48919. * @param query defines the query to use
  48920. * @returns the current engine
  48921. * @see http://doc.babylonjs.com/features/occlusionquery
  48922. */
  48923. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48924. /**
  48925. * Ends an occlusion query
  48926. * @see http://doc.babylonjs.com/features/occlusionquery
  48927. * @param algorithmType defines the algorithm to use
  48928. * @returns the current engine
  48929. */
  48930. endOcclusionQuery(algorithmType: number): Engine;
  48931. /**
  48932. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48933. * Please note that only one query can be issued at a time
  48934. * @returns a time token used to track the time span
  48935. */
  48936. startTimeQuery(): Nullable<_TimeToken>;
  48937. /**
  48938. * Ends a time query
  48939. * @param token defines the token used to measure the time span
  48940. * @returns the time spent (in ns)
  48941. */
  48942. endTimeQuery(token: _TimeToken): int;
  48943. /** @hidden */
  48944. _currentNonTimestampToken: Nullable<_TimeToken>;
  48945. /** @hidden */
  48946. _createTimeQuery(): WebGLQuery;
  48947. /** @hidden */
  48948. _deleteTimeQuery(query: WebGLQuery): void;
  48949. /** @hidden */
  48950. _getGlAlgorithmType(algorithmType: number): number;
  48951. /** @hidden */
  48952. _getTimeQueryResult(query: WebGLQuery): any;
  48953. /** @hidden */
  48954. _getTimeQueryAvailability(query: WebGLQuery): any;
  48955. }
  48956. }
  48957. module "babylonjs/Meshes/abstractMesh" {
  48958. interface AbstractMesh {
  48959. /**
  48960. * Backing filed
  48961. * @hidden
  48962. */
  48963. __occlusionDataStorage: _OcclusionDataStorage;
  48964. /**
  48965. * Access property
  48966. * @hidden
  48967. */
  48968. _occlusionDataStorage: _OcclusionDataStorage;
  48969. /**
  48970. * 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.
  48971. * The default value is -1 which means don't break the query and wait till the result
  48972. * @see http://doc.babylonjs.com/features/occlusionquery
  48973. */
  48974. occlusionRetryCount: number;
  48975. /**
  48976. * 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:
  48977. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48978. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48979. * * 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.
  48980. * @see http://doc.babylonjs.com/features/occlusionquery
  48981. */
  48982. occlusionType: number;
  48983. /**
  48984. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48985. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48986. * * 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.
  48987. * @see http://doc.babylonjs.com/features/occlusionquery
  48988. */
  48989. occlusionQueryAlgorithmType: number;
  48990. /**
  48991. * 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
  48992. * @see http://doc.babylonjs.com/features/occlusionquery
  48993. */
  48994. isOccluded: boolean;
  48995. /**
  48996. * Flag to check the progress status of the query
  48997. * @see http://doc.babylonjs.com/features/occlusionquery
  48998. */
  48999. isOcclusionQueryInProgress: boolean;
  49000. }
  49001. }
  49002. }
  49003. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49004. import { Nullable } from "babylonjs/types";
  49005. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49006. /** @hidden */
  49007. export var _forceTransformFeedbackToBundle: boolean;
  49008. module "babylonjs/Engines/engine" {
  49009. interface Engine {
  49010. /**
  49011. * Creates a webGL transform feedback object
  49012. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49013. * @returns the webGL transform feedback object
  49014. */
  49015. createTransformFeedback(): WebGLTransformFeedback;
  49016. /**
  49017. * Delete a webGL transform feedback object
  49018. * @param value defines the webGL transform feedback object to delete
  49019. */
  49020. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49021. /**
  49022. * Bind a webGL transform feedback object to the webgl context
  49023. * @param value defines the webGL transform feedback object to bind
  49024. */
  49025. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49026. /**
  49027. * Begins a transform feedback operation
  49028. * @param usePoints defines if points or triangles must be used
  49029. */
  49030. beginTransformFeedback(usePoints: boolean): void;
  49031. /**
  49032. * Ends a transform feedback operation
  49033. */
  49034. endTransformFeedback(): void;
  49035. /**
  49036. * Specify the varyings to use with transform feedback
  49037. * @param program defines the associated webGL program
  49038. * @param value defines the list of strings representing the varying names
  49039. */
  49040. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49041. /**
  49042. * Bind a webGL buffer for a transform feedback operation
  49043. * @param value defines the webGL buffer to bind
  49044. */
  49045. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49046. }
  49047. }
  49048. }
  49049. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49050. import { Scene } from "babylonjs/scene";
  49051. import { Engine } from "babylonjs/Engines/engine";
  49052. import { Texture } from "babylonjs/Materials/Textures/texture";
  49053. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49054. import "babylonjs/Engines/Extensions/engine.multiRender";
  49055. /**
  49056. * Creation options of the multi render target texture.
  49057. */
  49058. export interface IMultiRenderTargetOptions {
  49059. /**
  49060. * Define if the texture needs to create mip maps after render.
  49061. */
  49062. generateMipMaps?: boolean;
  49063. /**
  49064. * Define the types of all the draw buffers we want to create
  49065. */
  49066. types?: number[];
  49067. /**
  49068. * Define the sampling modes of all the draw buffers we want to create
  49069. */
  49070. samplingModes?: number[];
  49071. /**
  49072. * Define if a depth buffer is required
  49073. */
  49074. generateDepthBuffer?: boolean;
  49075. /**
  49076. * Define if a stencil buffer is required
  49077. */
  49078. generateStencilBuffer?: boolean;
  49079. /**
  49080. * Define if a depth texture is required instead of a depth buffer
  49081. */
  49082. generateDepthTexture?: boolean;
  49083. /**
  49084. * Define the number of desired draw buffers
  49085. */
  49086. textureCount?: number;
  49087. /**
  49088. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49089. */
  49090. doNotChangeAspectRatio?: boolean;
  49091. /**
  49092. * Define the default type of the buffers we are creating
  49093. */
  49094. defaultType?: number;
  49095. }
  49096. /**
  49097. * A multi render target, like a render target provides the ability to render to a texture.
  49098. * Unlike the render target, it can render to several draw buffers in one draw.
  49099. * This is specially interesting in deferred rendering or for any effects requiring more than
  49100. * just one color from a single pass.
  49101. */
  49102. export class MultiRenderTarget extends RenderTargetTexture {
  49103. private _internalTextures;
  49104. private _textures;
  49105. private _multiRenderTargetOptions;
  49106. /**
  49107. * Get if draw buffers are currently supported by the used hardware and browser.
  49108. */
  49109. get isSupported(): boolean;
  49110. /**
  49111. * Get the list of textures generated by the multi render target.
  49112. */
  49113. get textures(): Texture[];
  49114. /**
  49115. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49116. */
  49117. get depthTexture(): Texture;
  49118. /**
  49119. * Set the wrapping mode on U of all the textures we are rendering to.
  49120. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49121. */
  49122. set wrapU(wrap: number);
  49123. /**
  49124. * Set the wrapping mode on V of all the textures we are rendering to.
  49125. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49126. */
  49127. set wrapV(wrap: number);
  49128. /**
  49129. * Instantiate a new multi render target texture.
  49130. * A multi render target, like a render target provides the ability to render to a texture.
  49131. * Unlike the render target, it can render to several draw buffers in one draw.
  49132. * This is specially interesting in deferred rendering or for any effects requiring more than
  49133. * just one color from a single pass.
  49134. * @param name Define the name of the texture
  49135. * @param size Define the size of the buffers to render to
  49136. * @param count Define the number of target we are rendering into
  49137. * @param scene Define the scene the texture belongs to
  49138. * @param options Define the options used to create the multi render target
  49139. */
  49140. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49141. /** @hidden */
  49142. _rebuild(): void;
  49143. private _createInternalTextures;
  49144. private _createTextures;
  49145. /**
  49146. * Define the number of samples used if MSAA is enabled.
  49147. */
  49148. get samples(): number;
  49149. set samples(value: number);
  49150. /**
  49151. * Resize all the textures in the multi render target.
  49152. * Be carrefull as it will recreate all the data in the new texture.
  49153. * @param size Define the new size
  49154. */
  49155. resize(size: any): void;
  49156. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49157. /**
  49158. * Dispose the render targets and their associated resources
  49159. */
  49160. dispose(): void;
  49161. /**
  49162. * Release all the underlying texture used as draw buffers.
  49163. */
  49164. releaseInternalTextures(): void;
  49165. }
  49166. }
  49167. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49168. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49169. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49170. import { Nullable } from "babylonjs/types";
  49171. module "babylonjs/Engines/thinEngine" {
  49172. interface ThinEngine {
  49173. /**
  49174. * Unbind a list of render target textures from the webGL context
  49175. * This is used only when drawBuffer extension or webGL2 are active
  49176. * @param textures defines the render target textures to unbind
  49177. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49178. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49179. */
  49180. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49181. /**
  49182. * Create a multi render target texture
  49183. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49184. * @param size defines the size of the texture
  49185. * @param options defines the creation options
  49186. * @returns the cube texture as an InternalTexture
  49187. */
  49188. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49189. /**
  49190. * Update the sample count for a given multiple render target texture
  49191. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49192. * @param textures defines the textures to update
  49193. * @param samples defines the sample count to set
  49194. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49195. */
  49196. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49197. }
  49198. }
  49199. }
  49200. declare module "babylonjs/Engines/Extensions/engine.views" {
  49201. import { Camera } from "babylonjs/Cameras/camera";
  49202. import { Nullable } from "babylonjs/types";
  49203. /**
  49204. * Class used to define an additional view for the engine
  49205. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49206. */
  49207. export class EngineView {
  49208. /** Defines the canvas where to render the view */
  49209. target: HTMLCanvasElement;
  49210. /** Defines an optional camera used to render the view (will use active camera else) */
  49211. camera?: Camera;
  49212. }
  49213. module "babylonjs/Engines/engine" {
  49214. interface Engine {
  49215. /**
  49216. * Gets or sets the HTML element to use for attaching events
  49217. */
  49218. inputElement: Nullable<HTMLElement>;
  49219. /**
  49220. * Gets the current engine view
  49221. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49222. */
  49223. activeView: Nullable<EngineView>;
  49224. /** Gets or sets the list of views */
  49225. views: EngineView[];
  49226. /**
  49227. * Register a new child canvas
  49228. * @param canvas defines the canvas to register
  49229. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49230. * @returns the associated view
  49231. */
  49232. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49233. /**
  49234. * Remove a registered child canvas
  49235. * @param canvas defines the canvas to remove
  49236. * @returns the current engine
  49237. */
  49238. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49239. }
  49240. }
  49241. }
  49242. declare module "babylonjs/Engines/Extensions/index" {
  49243. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49244. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49245. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49246. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49247. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49248. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49249. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49250. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49251. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49252. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49253. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49254. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49255. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49256. export * from "babylonjs/Engines/Extensions/engine.views";
  49257. }
  49258. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49259. import { Nullable } from "babylonjs/types";
  49260. /**
  49261. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49262. */
  49263. export interface CubeMapInfo {
  49264. /**
  49265. * The pixel array for the front face.
  49266. * This is stored in format, left to right, up to down format.
  49267. */
  49268. front: Nullable<ArrayBufferView>;
  49269. /**
  49270. * The pixel array for the back face.
  49271. * This is stored in format, left to right, up to down format.
  49272. */
  49273. back: Nullable<ArrayBufferView>;
  49274. /**
  49275. * The pixel array for the left face.
  49276. * This is stored in format, left to right, up to down format.
  49277. */
  49278. left: Nullable<ArrayBufferView>;
  49279. /**
  49280. * The pixel array for the right face.
  49281. * This is stored in format, left to right, up to down format.
  49282. */
  49283. right: Nullable<ArrayBufferView>;
  49284. /**
  49285. * The pixel array for the up face.
  49286. * This is stored in format, left to right, up to down format.
  49287. */
  49288. up: Nullable<ArrayBufferView>;
  49289. /**
  49290. * The pixel array for the down face.
  49291. * This is stored in format, left to right, up to down format.
  49292. */
  49293. down: Nullable<ArrayBufferView>;
  49294. /**
  49295. * The size of the cubemap stored.
  49296. *
  49297. * Each faces will be size * size pixels.
  49298. */
  49299. size: number;
  49300. /**
  49301. * The format of the texture.
  49302. *
  49303. * RGBA, RGB.
  49304. */
  49305. format: number;
  49306. /**
  49307. * The type of the texture data.
  49308. *
  49309. * UNSIGNED_INT, FLOAT.
  49310. */
  49311. type: number;
  49312. /**
  49313. * Specifies whether the texture is in gamma space.
  49314. */
  49315. gammaSpace: boolean;
  49316. }
  49317. /**
  49318. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49319. */
  49320. export class PanoramaToCubeMapTools {
  49321. private static FACE_FRONT;
  49322. private static FACE_BACK;
  49323. private static FACE_RIGHT;
  49324. private static FACE_LEFT;
  49325. private static FACE_DOWN;
  49326. private static FACE_UP;
  49327. /**
  49328. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49329. *
  49330. * @param float32Array The source data.
  49331. * @param inputWidth The width of the input panorama.
  49332. * @param inputHeight The height of the input panorama.
  49333. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49334. * @return The cubemap data
  49335. */
  49336. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49337. private static CreateCubemapTexture;
  49338. private static CalcProjectionSpherical;
  49339. }
  49340. }
  49341. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49342. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49344. import { Nullable } from "babylonjs/types";
  49345. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49346. /**
  49347. * Helper class dealing with the extraction of spherical polynomial dataArray
  49348. * from a cube map.
  49349. */
  49350. export class CubeMapToSphericalPolynomialTools {
  49351. private static FileFaces;
  49352. /**
  49353. * Converts a texture to the according Spherical Polynomial data.
  49354. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49355. *
  49356. * @param texture The texture to extract the information from.
  49357. * @return The Spherical Polynomial data.
  49358. */
  49359. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49360. /**
  49361. * Converts a cubemap to the according Spherical Polynomial data.
  49362. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49363. *
  49364. * @param cubeInfo The Cube map to extract the information from.
  49365. * @return The Spherical Polynomial data.
  49366. */
  49367. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49368. }
  49369. }
  49370. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49371. import { Nullable } from "babylonjs/types";
  49372. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49373. module "babylonjs/Materials/Textures/baseTexture" {
  49374. interface BaseTexture {
  49375. /**
  49376. * Get the polynomial representation of the texture data.
  49377. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49378. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49379. */
  49380. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49381. }
  49382. }
  49383. }
  49384. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49385. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49386. /** @hidden */
  49387. export var rgbdEncodePixelShader: {
  49388. name: string;
  49389. shader: string;
  49390. };
  49391. }
  49392. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49393. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49394. /** @hidden */
  49395. export var rgbdDecodePixelShader: {
  49396. name: string;
  49397. shader: string;
  49398. };
  49399. }
  49400. declare module "babylonjs/Misc/environmentTextureTools" {
  49401. import { Nullable } from "babylonjs/types";
  49402. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49404. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49405. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49406. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49407. import "babylonjs/Shaders/rgbdEncode.fragment";
  49408. import "babylonjs/Shaders/rgbdDecode.fragment";
  49409. /**
  49410. * Raw texture data and descriptor sufficient for WebGL texture upload
  49411. */
  49412. export interface EnvironmentTextureInfo {
  49413. /**
  49414. * Version of the environment map
  49415. */
  49416. version: number;
  49417. /**
  49418. * Width of image
  49419. */
  49420. width: number;
  49421. /**
  49422. * Irradiance information stored in the file.
  49423. */
  49424. irradiance: any;
  49425. /**
  49426. * Specular information stored in the file.
  49427. */
  49428. specular: any;
  49429. }
  49430. /**
  49431. * Defines One Image in the file. It requires only the position in the file
  49432. * as well as the length.
  49433. */
  49434. interface BufferImageData {
  49435. /**
  49436. * Length of the image data.
  49437. */
  49438. length: number;
  49439. /**
  49440. * Position of the data from the null terminator delimiting the end of the JSON.
  49441. */
  49442. position: number;
  49443. }
  49444. /**
  49445. * Defines the specular data enclosed in the file.
  49446. * This corresponds to the version 1 of the data.
  49447. */
  49448. export interface EnvironmentTextureSpecularInfoV1 {
  49449. /**
  49450. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49451. */
  49452. specularDataPosition?: number;
  49453. /**
  49454. * This contains all the images data needed to reconstruct the cubemap.
  49455. */
  49456. mipmaps: Array<BufferImageData>;
  49457. /**
  49458. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49459. */
  49460. lodGenerationScale: number;
  49461. }
  49462. /**
  49463. * Sets of helpers addressing the serialization and deserialization of environment texture
  49464. * stored in a BabylonJS env file.
  49465. * Those files are usually stored as .env files.
  49466. */
  49467. export class EnvironmentTextureTools {
  49468. /**
  49469. * Magic number identifying the env file.
  49470. */
  49471. private static _MagicBytes;
  49472. /**
  49473. * Gets the environment info from an env file.
  49474. * @param data The array buffer containing the .env bytes.
  49475. * @returns the environment file info (the json header) if successfully parsed.
  49476. */
  49477. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49478. /**
  49479. * Creates an environment texture from a loaded cube texture.
  49480. * @param texture defines the cube texture to convert in env file
  49481. * @return a promise containing the environment data if succesfull.
  49482. */
  49483. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49484. /**
  49485. * Creates a JSON representation of the spherical data.
  49486. * @param texture defines the texture containing the polynomials
  49487. * @return the JSON representation of the spherical info
  49488. */
  49489. private static _CreateEnvTextureIrradiance;
  49490. /**
  49491. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49492. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  49493. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49494. * @return the views described by info providing access to the underlying buffer
  49495. */
  49496. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49497. /**
  49498. * Uploads the texture info contained in the env file to the GPU.
  49499. * @param texture defines the internal texture to upload to
  49500. * @param arrayBuffer defines the buffer cotaining the data to load
  49501. * @param info defines the texture info retrieved through the GetEnvInfo method
  49502. * @returns a promise
  49503. */
  49504. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49505. private static _OnImageReadyAsync;
  49506. /**
  49507. * Uploads the levels of image data to the GPU.
  49508. * @param texture defines the internal texture to upload to
  49509. * @param imageData defines the array buffer views of image data [mipmap][face]
  49510. * @returns a promise
  49511. */
  49512. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49513. /**
  49514. * Uploads spherical polynomials information to the texture.
  49515. * @param texture defines the texture we are trying to upload the information to
  49516. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49517. */
  49518. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49519. /** @hidden */
  49520. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49521. }
  49522. }
  49523. declare module "babylonjs/Maths/math.vertexFormat" {
  49524. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49525. /**
  49526. * Contains position and normal vectors for a vertex
  49527. */
  49528. export class PositionNormalVertex {
  49529. /** the position of the vertex (defaut: 0,0,0) */
  49530. position: Vector3;
  49531. /** the normal of the vertex (defaut: 0,1,0) */
  49532. normal: Vector3;
  49533. /**
  49534. * Creates a PositionNormalVertex
  49535. * @param position the position of the vertex (defaut: 0,0,0)
  49536. * @param normal the normal of the vertex (defaut: 0,1,0)
  49537. */
  49538. constructor(
  49539. /** the position of the vertex (defaut: 0,0,0) */
  49540. position?: Vector3,
  49541. /** the normal of the vertex (defaut: 0,1,0) */
  49542. normal?: Vector3);
  49543. /**
  49544. * Clones the PositionNormalVertex
  49545. * @returns the cloned PositionNormalVertex
  49546. */
  49547. clone(): PositionNormalVertex;
  49548. }
  49549. /**
  49550. * Contains position, normal and uv vectors for a vertex
  49551. */
  49552. export class PositionNormalTextureVertex {
  49553. /** the position of the vertex (defaut: 0,0,0) */
  49554. position: Vector3;
  49555. /** the normal of the vertex (defaut: 0,1,0) */
  49556. normal: Vector3;
  49557. /** the uv of the vertex (default: 0,0) */
  49558. uv: Vector2;
  49559. /**
  49560. * Creates a PositionNormalTextureVertex
  49561. * @param position the position of the vertex (defaut: 0,0,0)
  49562. * @param normal the normal of the vertex (defaut: 0,1,0)
  49563. * @param uv the uv of the vertex (default: 0,0)
  49564. */
  49565. constructor(
  49566. /** the position of the vertex (defaut: 0,0,0) */
  49567. position?: Vector3,
  49568. /** the normal of the vertex (defaut: 0,1,0) */
  49569. normal?: Vector3,
  49570. /** the uv of the vertex (default: 0,0) */
  49571. uv?: Vector2);
  49572. /**
  49573. * Clones the PositionNormalTextureVertex
  49574. * @returns the cloned PositionNormalTextureVertex
  49575. */
  49576. clone(): PositionNormalTextureVertex;
  49577. }
  49578. }
  49579. declare module "babylonjs/Maths/math" {
  49580. export * from "babylonjs/Maths/math.axis";
  49581. export * from "babylonjs/Maths/math.color";
  49582. export * from "babylonjs/Maths/math.constants";
  49583. export * from "babylonjs/Maths/math.frustum";
  49584. export * from "babylonjs/Maths/math.path";
  49585. export * from "babylonjs/Maths/math.plane";
  49586. export * from "babylonjs/Maths/math.size";
  49587. export * from "babylonjs/Maths/math.vector";
  49588. export * from "babylonjs/Maths/math.vertexFormat";
  49589. export * from "babylonjs/Maths/math.viewport";
  49590. }
  49591. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49592. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49593. /** @hidden */
  49594. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49595. private _genericAttributeLocation;
  49596. private _varyingLocationCount;
  49597. private _varyingLocationMap;
  49598. private _replacements;
  49599. private _textureCount;
  49600. private _uniforms;
  49601. lineProcessor(line: string): string;
  49602. attributeProcessor(attribute: string): string;
  49603. varyingProcessor(varying: string, isFragment: boolean): string;
  49604. uniformProcessor(uniform: string): string;
  49605. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49606. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49607. }
  49608. }
  49609. declare module "babylonjs/Engines/nativeEngine" {
  49610. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49611. import { Engine } from "babylonjs/Engines/engine";
  49612. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49613. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49615. import { Effect } from "babylonjs/Materials/effect";
  49616. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49617. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49618. import { IColor4Like } from "babylonjs/Maths/math.like";
  49619. import { Scene } from "babylonjs/scene";
  49620. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49621. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49622. /**
  49623. * Container for accessors for natively-stored mesh data buffers.
  49624. */
  49625. class NativeDataBuffer extends DataBuffer {
  49626. /**
  49627. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49628. */
  49629. nativeIndexBuffer?: any;
  49630. /**
  49631. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49632. */
  49633. nativeVertexBuffer?: any;
  49634. }
  49635. /** @hidden */
  49636. class NativeTexture extends InternalTexture {
  49637. getInternalTexture(): InternalTexture;
  49638. getViewCount(): number;
  49639. }
  49640. /** @hidden */
  49641. export class NativeEngine extends Engine {
  49642. private readonly _native;
  49643. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49644. private readonly INVALID_HANDLE;
  49645. getHardwareScalingLevel(): number;
  49646. constructor();
  49647. /**
  49648. * Can be used to override the current requestAnimationFrame requester.
  49649. * @hidden
  49650. */
  49651. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49652. /**
  49653. * Override default engine behavior.
  49654. * @param color
  49655. * @param backBuffer
  49656. * @param depth
  49657. * @param stencil
  49658. */
  49659. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49660. /**
  49661. * Gets host document
  49662. * @returns the host document object
  49663. */
  49664. getHostDocument(): Nullable<Document>;
  49665. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49666. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49667. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49668. recordVertexArrayObject(vertexBuffers: {
  49669. [key: string]: VertexBuffer;
  49670. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49671. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49672. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49673. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49674. /**
  49675. * Draw a list of indexed primitives
  49676. * @param fillMode defines the primitive to use
  49677. * @param indexStart defines the starting index
  49678. * @param indexCount defines the number of index to draw
  49679. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49680. */
  49681. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49682. /**
  49683. * Draw a list of unindexed primitives
  49684. * @param fillMode defines the primitive to use
  49685. * @param verticesStart defines the index of first vertex to draw
  49686. * @param verticesCount defines the count of vertices to draw
  49687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49688. */
  49689. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49690. createPipelineContext(): IPipelineContext;
  49691. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49692. /** @hidden */
  49693. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49694. /** @hidden */
  49695. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49696. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49698. protected _setProgram(program: WebGLProgram): void;
  49699. _releaseEffect(effect: Effect): void;
  49700. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49701. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49702. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49703. bindSamplers(effect: Effect): void;
  49704. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49705. getRenderWidth(useScreen?: boolean): number;
  49706. getRenderHeight(useScreen?: boolean): number;
  49707. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49708. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49709. /**
  49710. * Set the z offset to apply to current rendering
  49711. * @param value defines the offset to apply
  49712. */
  49713. setZOffset(value: number): void;
  49714. /**
  49715. * Gets the current value of the zOffset
  49716. * @returns the current zOffset state
  49717. */
  49718. getZOffset(): number;
  49719. /**
  49720. * Enable or disable depth buffering
  49721. * @param enable defines the state to set
  49722. */
  49723. setDepthBuffer(enable: boolean): void;
  49724. /**
  49725. * Gets a boolean indicating if depth writing is enabled
  49726. * @returns the current depth writing state
  49727. */
  49728. getDepthWrite(): boolean;
  49729. /**
  49730. * Enable or disable depth writing
  49731. * @param enable defines the state to set
  49732. */
  49733. setDepthWrite(enable: boolean): void;
  49734. /**
  49735. * Enable or disable color writing
  49736. * @param enable defines the state to set
  49737. */
  49738. setColorWrite(enable: boolean): void;
  49739. /**
  49740. * Gets a boolean indicating if color writing is enabled
  49741. * @returns the current color writing state
  49742. */
  49743. getColorWrite(): boolean;
  49744. /**
  49745. * Sets alpha constants used by some alpha blending modes
  49746. * @param r defines the red component
  49747. * @param g defines the green component
  49748. * @param b defines the blue component
  49749. * @param a defines the alpha component
  49750. */
  49751. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49752. /**
  49753. * Sets the current alpha mode
  49754. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49755. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49756. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49757. */
  49758. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49759. /**
  49760. * Gets the current alpha mode
  49761. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49762. * @returns the current alpha mode
  49763. */
  49764. getAlphaMode(): number;
  49765. setInt(uniform: WebGLUniformLocation, int: number): void;
  49766. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49767. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49768. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49769. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49770. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49771. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49772. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49773. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49774. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49775. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49776. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49777. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49778. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49779. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49780. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49781. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49782. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49783. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49784. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49785. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49786. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49787. wipeCaches(bruteForce?: boolean): void;
  49788. _createTexture(): WebGLTexture;
  49789. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49790. /**
  49791. * Usually called from BABYLON.Texture.ts.
  49792. * Passed information to create a WebGLTexture
  49793. * @param urlArg defines a value which contains one of the following:
  49794. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49795. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49796. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49797. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49798. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49799. * @param scene needed for loading to the correct scene
  49800. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49801. * @param onLoad optional callback to be called upon successful completion
  49802. * @param onError optional callback to be called upon failure
  49803. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49804. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49805. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49806. * @param forcedExtension defines the extension to use to pick the right loader
  49807. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49808. */
  49809. 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;
  49810. /**
  49811. * Creates a cube texture
  49812. * @param rootUrl defines the url where the files to load is located
  49813. * @param scene defines the current scene
  49814. * @param files defines the list of files to load (1 per face)
  49815. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49816. * @param onLoad defines an optional callback raised when the texture is loaded
  49817. * @param onError defines an optional callback raised if there is an issue to load the texture
  49818. * @param format defines the format of the data
  49819. * @param forcedExtension defines the extension to use to pick the right loader
  49820. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49821. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49822. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49823. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49824. * @returns the cube texture as an InternalTexture
  49825. */
  49826. 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;
  49827. private _getSamplingFilter;
  49828. private static _GetNativeTextureFormat;
  49829. createRenderTargetTexture(size: number | {
  49830. width: number;
  49831. height: number;
  49832. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49833. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49834. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49835. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49836. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49837. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49838. /**
  49839. * Updates a dynamic vertex buffer.
  49840. * @param vertexBuffer the vertex buffer to update
  49841. * @param data the data used to update the vertex buffer
  49842. * @param byteOffset the byte offset of the data (optional)
  49843. * @param byteLength the byte length of the data (optional)
  49844. */
  49845. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49846. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49847. private _updateAnisotropicLevel;
  49848. private _getAddressMode;
  49849. /** @hidden */
  49850. _bindTexture(channel: number, texture: InternalTexture): void;
  49851. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49852. releaseEffects(): void;
  49853. /** @hidden */
  49854. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49855. /** @hidden */
  49856. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49857. /** @hidden */
  49858. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49859. /** @hidden */
  49860. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49861. }
  49862. }
  49863. declare module "babylonjs/Engines/index" {
  49864. export * from "babylonjs/Engines/constants";
  49865. export * from "babylonjs/Engines/engineCapabilities";
  49866. export * from "babylonjs/Engines/instancingAttributeInfo";
  49867. export * from "babylonjs/Engines/thinEngine";
  49868. export * from "babylonjs/Engines/engine";
  49869. export * from "babylonjs/Engines/engineStore";
  49870. export * from "babylonjs/Engines/nullEngine";
  49871. export * from "babylonjs/Engines/Extensions/index";
  49872. export * from "babylonjs/Engines/IPipelineContext";
  49873. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49874. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49875. export * from "babylonjs/Engines/nativeEngine";
  49876. }
  49877. declare module "babylonjs/Events/clipboardEvents" {
  49878. /**
  49879. * Gather the list of clipboard event types as constants.
  49880. */
  49881. export class ClipboardEventTypes {
  49882. /**
  49883. * The clipboard event is fired when a copy command is active (pressed).
  49884. */
  49885. static readonly COPY: number;
  49886. /**
  49887. * The clipboard event is fired when a cut command is active (pressed).
  49888. */
  49889. static readonly CUT: number;
  49890. /**
  49891. * The clipboard event is fired when a paste command is active (pressed).
  49892. */
  49893. static readonly PASTE: number;
  49894. }
  49895. /**
  49896. * This class is used to store clipboard related info for the onClipboardObservable event.
  49897. */
  49898. export class ClipboardInfo {
  49899. /**
  49900. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49901. */
  49902. type: number;
  49903. /**
  49904. * Defines the related dom event
  49905. */
  49906. event: ClipboardEvent;
  49907. /**
  49908. *Creates an instance of ClipboardInfo.
  49909. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49910. * @param event Defines the related dom event
  49911. */
  49912. constructor(
  49913. /**
  49914. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49915. */
  49916. type: number,
  49917. /**
  49918. * Defines the related dom event
  49919. */
  49920. event: ClipboardEvent);
  49921. /**
  49922. * Get the clipboard event's type from the keycode.
  49923. * @param keyCode Defines the keyCode for the current keyboard event.
  49924. * @return {number}
  49925. */
  49926. static GetTypeFromCharacter(keyCode: number): number;
  49927. }
  49928. }
  49929. declare module "babylonjs/Events/index" {
  49930. export * from "babylonjs/Events/keyboardEvents";
  49931. export * from "babylonjs/Events/pointerEvents";
  49932. export * from "babylonjs/Events/clipboardEvents";
  49933. }
  49934. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49935. import { Scene } from "babylonjs/scene";
  49936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49937. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49938. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49939. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49940. /**
  49941. * Google Daydream controller
  49942. */
  49943. export class DaydreamController extends WebVRController {
  49944. /**
  49945. * Base Url for the controller model.
  49946. */
  49947. static MODEL_BASE_URL: string;
  49948. /**
  49949. * File name for the controller model.
  49950. */
  49951. static MODEL_FILENAME: string;
  49952. /**
  49953. * Gamepad Id prefix used to identify Daydream Controller.
  49954. */
  49955. static readonly GAMEPAD_ID_PREFIX: string;
  49956. /**
  49957. * Creates a new DaydreamController from a gamepad
  49958. * @param vrGamepad the gamepad that the controller should be created from
  49959. */
  49960. constructor(vrGamepad: any);
  49961. /**
  49962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49963. * @param scene scene in which to add meshes
  49964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49965. */
  49966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49967. /**
  49968. * Called once for each button that changed state since the last frame
  49969. * @param buttonIdx Which button index changed
  49970. * @param state New state of the button
  49971. * @param changes Which properties on the state changed since last frame
  49972. */
  49973. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49974. }
  49975. }
  49976. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49977. import { Scene } from "babylonjs/scene";
  49978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49979. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49980. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49981. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49982. /**
  49983. * Gear VR Controller
  49984. */
  49985. export class GearVRController extends WebVRController {
  49986. /**
  49987. * Base Url for the controller model.
  49988. */
  49989. static MODEL_BASE_URL: string;
  49990. /**
  49991. * File name for the controller model.
  49992. */
  49993. static MODEL_FILENAME: string;
  49994. /**
  49995. * Gamepad Id prefix used to identify this controller.
  49996. */
  49997. static readonly GAMEPAD_ID_PREFIX: string;
  49998. private readonly _buttonIndexToObservableNameMap;
  49999. /**
  50000. * Creates a new GearVRController from a gamepad
  50001. * @param vrGamepad the gamepad that the controller should be created from
  50002. */
  50003. constructor(vrGamepad: any);
  50004. /**
  50005. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50006. * @param scene scene in which to add meshes
  50007. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50008. */
  50009. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50010. /**
  50011. * Called once for each button that changed state since the last frame
  50012. * @param buttonIdx Which button index changed
  50013. * @param state New state of the button
  50014. * @param changes Which properties on the state changed since last frame
  50015. */
  50016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50017. }
  50018. }
  50019. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50020. import { Scene } from "babylonjs/scene";
  50021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50022. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50023. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50024. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50025. /**
  50026. * Generic Controller
  50027. */
  50028. export class GenericController extends WebVRController {
  50029. /**
  50030. * Base Url for the controller model.
  50031. */
  50032. static readonly MODEL_BASE_URL: string;
  50033. /**
  50034. * File name for the controller model.
  50035. */
  50036. static readonly MODEL_FILENAME: string;
  50037. /**
  50038. * Creates a new GenericController from a gamepad
  50039. * @param vrGamepad the gamepad that the controller should be created from
  50040. */
  50041. constructor(vrGamepad: any);
  50042. /**
  50043. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50044. * @param scene scene in which to add meshes
  50045. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50046. */
  50047. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50048. /**
  50049. * Called once for each button that changed state since the last frame
  50050. * @param buttonIdx Which button index changed
  50051. * @param state New state of the button
  50052. * @param changes Which properties on the state changed since last frame
  50053. */
  50054. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50055. }
  50056. }
  50057. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50058. import { Observable } from "babylonjs/Misc/observable";
  50059. import { Scene } from "babylonjs/scene";
  50060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50061. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50062. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50063. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50064. /**
  50065. * Oculus Touch Controller
  50066. */
  50067. export class OculusTouchController extends WebVRController {
  50068. /**
  50069. * Base Url for the controller model.
  50070. */
  50071. static MODEL_BASE_URL: string;
  50072. /**
  50073. * File name for the left controller model.
  50074. */
  50075. static MODEL_LEFT_FILENAME: string;
  50076. /**
  50077. * File name for the right controller model.
  50078. */
  50079. static MODEL_RIGHT_FILENAME: string;
  50080. /**
  50081. * Base Url for the Quest controller model.
  50082. */
  50083. static QUEST_MODEL_BASE_URL: string;
  50084. /**
  50085. * @hidden
  50086. * If the controllers are running on a device that needs the updated Quest controller models
  50087. */
  50088. static _IsQuest: boolean;
  50089. /**
  50090. * Fired when the secondary trigger on this controller is modified
  50091. */
  50092. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50093. /**
  50094. * Fired when the thumb rest on this controller is modified
  50095. */
  50096. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50097. /**
  50098. * Creates a new OculusTouchController from a gamepad
  50099. * @param vrGamepad the gamepad that the controller should be created from
  50100. */
  50101. constructor(vrGamepad: any);
  50102. /**
  50103. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50104. * @param scene scene in which to add meshes
  50105. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50106. */
  50107. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50108. /**
  50109. * Fired when the A button on this controller is modified
  50110. */
  50111. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50112. /**
  50113. * Fired when the B button on this controller is modified
  50114. */
  50115. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50116. /**
  50117. * Fired when the X button on this controller is modified
  50118. */
  50119. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50120. /**
  50121. * Fired when the Y button on this controller is modified
  50122. */
  50123. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50124. /**
  50125. * Called once for each button that changed state since the last frame
  50126. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50127. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50128. * 2) secondary trigger (same)
  50129. * 3) A (right) X (left), touch, pressed = value
  50130. * 4) B / Y
  50131. * 5) thumb rest
  50132. * @param buttonIdx Which button index changed
  50133. * @param state New state of the button
  50134. * @param changes Which properties on the state changed since last frame
  50135. */
  50136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50137. }
  50138. }
  50139. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50140. import { Scene } from "babylonjs/scene";
  50141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50142. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50143. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50144. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50145. import { Observable } from "babylonjs/Misc/observable";
  50146. /**
  50147. * Vive Controller
  50148. */
  50149. export class ViveController extends WebVRController {
  50150. /**
  50151. * Base Url for the controller model.
  50152. */
  50153. static MODEL_BASE_URL: string;
  50154. /**
  50155. * File name for the controller model.
  50156. */
  50157. static MODEL_FILENAME: string;
  50158. /**
  50159. * Creates a new ViveController from a gamepad
  50160. * @param vrGamepad the gamepad that the controller should be created from
  50161. */
  50162. constructor(vrGamepad: any);
  50163. /**
  50164. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50165. * @param scene scene in which to add meshes
  50166. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50167. */
  50168. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50169. /**
  50170. * Fired when the left button on this controller is modified
  50171. */
  50172. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50173. /**
  50174. * Fired when the right button on this controller is modified
  50175. */
  50176. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50177. /**
  50178. * Fired when the menu button on this controller is modified
  50179. */
  50180. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50181. /**
  50182. * Called once for each button that changed state since the last frame
  50183. * Vive mapping:
  50184. * 0: touchpad
  50185. * 1: trigger
  50186. * 2: left AND right buttons
  50187. * 3: menu button
  50188. * @param buttonIdx Which button index changed
  50189. * @param state New state of the button
  50190. * @param changes Which properties on the state changed since last frame
  50191. */
  50192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50193. }
  50194. }
  50195. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50196. import { Observable } from "babylonjs/Misc/observable";
  50197. import { Scene } from "babylonjs/scene";
  50198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50199. import { Ray } from "babylonjs/Culling/ray";
  50200. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50201. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50202. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50203. /**
  50204. * Defines the WindowsMotionController object that the state of the windows motion controller
  50205. */
  50206. export class WindowsMotionController extends WebVRController {
  50207. /**
  50208. * The base url used to load the left and right controller models
  50209. */
  50210. static MODEL_BASE_URL: string;
  50211. /**
  50212. * The name of the left controller model file
  50213. */
  50214. static MODEL_LEFT_FILENAME: string;
  50215. /**
  50216. * The name of the right controller model file
  50217. */
  50218. static MODEL_RIGHT_FILENAME: string;
  50219. /**
  50220. * The controller name prefix for this controller type
  50221. */
  50222. static readonly GAMEPAD_ID_PREFIX: string;
  50223. /**
  50224. * The controller id pattern for this controller type
  50225. */
  50226. private static readonly GAMEPAD_ID_PATTERN;
  50227. private _loadedMeshInfo;
  50228. protected readonly _mapping: {
  50229. buttons: string[];
  50230. buttonMeshNames: {
  50231. 'trigger': string;
  50232. 'menu': string;
  50233. 'grip': string;
  50234. 'thumbstick': string;
  50235. 'trackpad': string;
  50236. };
  50237. buttonObservableNames: {
  50238. 'trigger': string;
  50239. 'menu': string;
  50240. 'grip': string;
  50241. 'thumbstick': string;
  50242. 'trackpad': string;
  50243. };
  50244. axisMeshNames: string[];
  50245. pointingPoseMeshName: string;
  50246. };
  50247. /**
  50248. * Fired when the trackpad on this controller is clicked
  50249. */
  50250. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50251. /**
  50252. * Fired when the trackpad on this controller is modified
  50253. */
  50254. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50255. /**
  50256. * The current x and y values of this controller's trackpad
  50257. */
  50258. trackpad: StickValues;
  50259. /**
  50260. * Creates a new WindowsMotionController from a gamepad
  50261. * @param vrGamepad the gamepad that the controller should be created from
  50262. */
  50263. constructor(vrGamepad: any);
  50264. /**
  50265. * Fired when the trigger on this controller is modified
  50266. */
  50267. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50268. /**
  50269. * Fired when the menu button on this controller is modified
  50270. */
  50271. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50272. /**
  50273. * Fired when the grip button on this controller is modified
  50274. */
  50275. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50276. /**
  50277. * Fired when the thumbstick button on this controller is modified
  50278. */
  50279. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50280. /**
  50281. * Fired when the touchpad button on this controller is modified
  50282. */
  50283. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50284. /**
  50285. * Fired when the touchpad values on this controller are modified
  50286. */
  50287. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50288. protected _updateTrackpad(): void;
  50289. /**
  50290. * Called once per frame by the engine.
  50291. */
  50292. update(): void;
  50293. /**
  50294. * Called once for each button that changed state since the last frame
  50295. * @param buttonIdx Which button index changed
  50296. * @param state New state of the button
  50297. * @param changes Which properties on the state changed since last frame
  50298. */
  50299. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50300. /**
  50301. * Moves the buttons on the controller mesh based on their current state
  50302. * @param buttonName the name of the button to move
  50303. * @param buttonValue the value of the button which determines the buttons new position
  50304. */
  50305. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50306. /**
  50307. * Moves the axis on the controller mesh based on its current state
  50308. * @param axis the index of the axis
  50309. * @param axisValue the value of the axis which determines the meshes new position
  50310. * @hidden
  50311. */
  50312. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50313. /**
  50314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50315. * @param scene scene in which to add meshes
  50316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50317. */
  50318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50319. /**
  50320. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50321. * can be transformed by button presses and axes values, based on this._mapping.
  50322. *
  50323. * @param scene scene in which the meshes exist
  50324. * @param meshes list of meshes that make up the controller model to process
  50325. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50326. */
  50327. private processModel;
  50328. private createMeshInfo;
  50329. /**
  50330. * Gets the ray of the controller in the direction the controller is pointing
  50331. * @param length the length the resulting ray should be
  50332. * @returns a ray in the direction the controller is pointing
  50333. */
  50334. getForwardRay(length?: number): Ray;
  50335. /**
  50336. * Disposes of the controller
  50337. */
  50338. dispose(): void;
  50339. }
  50340. /**
  50341. * This class represents a new windows motion controller in XR.
  50342. */
  50343. export class XRWindowsMotionController extends WindowsMotionController {
  50344. /**
  50345. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50346. */
  50347. protected readonly _mapping: {
  50348. buttons: string[];
  50349. buttonMeshNames: {
  50350. 'trigger': string;
  50351. 'menu': string;
  50352. 'grip': string;
  50353. 'thumbstick': string;
  50354. 'trackpad': string;
  50355. };
  50356. buttonObservableNames: {
  50357. 'trigger': string;
  50358. 'menu': string;
  50359. 'grip': string;
  50360. 'thumbstick': string;
  50361. 'trackpad': string;
  50362. };
  50363. axisMeshNames: string[];
  50364. pointingPoseMeshName: string;
  50365. };
  50366. /**
  50367. * Construct a new XR-Based windows motion controller
  50368. *
  50369. * @param gamepadInfo the gamepad object from the browser
  50370. */
  50371. constructor(gamepadInfo: any);
  50372. /**
  50373. * holds the thumbstick values (X,Y)
  50374. */
  50375. thumbstickValues: StickValues;
  50376. /**
  50377. * Fired when the thumbstick on this controller is clicked
  50378. */
  50379. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50380. /**
  50381. * Fired when the thumbstick on this controller is modified
  50382. */
  50383. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50384. /**
  50385. * Fired when the touchpad button on this controller is modified
  50386. */
  50387. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50388. /**
  50389. * Fired when the touchpad values on this controller are modified
  50390. */
  50391. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50392. /**
  50393. * Fired when the thumbstick button on this controller is modified
  50394. * here to prevent breaking changes
  50395. */
  50396. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50397. /**
  50398. * updating the thumbstick(!) and not the trackpad.
  50399. * This is named this way due to the difference between WebVR and XR and to avoid
  50400. * changing the parent class.
  50401. */
  50402. protected _updateTrackpad(): void;
  50403. /**
  50404. * Disposes the class with joy
  50405. */
  50406. dispose(): void;
  50407. }
  50408. }
  50409. declare module "babylonjs/Gamepads/Controllers/index" {
  50410. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50411. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50412. export * from "babylonjs/Gamepads/Controllers/genericController";
  50413. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50414. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50415. export * from "babylonjs/Gamepads/Controllers/viveController";
  50416. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50417. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50418. }
  50419. declare module "babylonjs/Gamepads/index" {
  50420. export * from "babylonjs/Gamepads/Controllers/index";
  50421. export * from "babylonjs/Gamepads/gamepad";
  50422. export * from "babylonjs/Gamepads/gamepadManager";
  50423. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50424. export * from "babylonjs/Gamepads/xboxGamepad";
  50425. export * from "babylonjs/Gamepads/dualShockGamepad";
  50426. }
  50427. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50428. import { Scene } from "babylonjs/scene";
  50429. import { Vector4 } from "babylonjs/Maths/math.vector";
  50430. import { Color4 } from "babylonjs/Maths/math.color";
  50431. import { Mesh } from "babylonjs/Meshes/mesh";
  50432. import { Nullable } from "babylonjs/types";
  50433. /**
  50434. * Class containing static functions to help procedurally build meshes
  50435. */
  50436. export class PolyhedronBuilder {
  50437. /**
  50438. * Creates a polyhedron mesh
  50439. * * 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
  50440. * * The parameter `size` (positive float, default 1) sets the polygon size
  50441. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50442. * * 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`
  50443. * * 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
  50444. * * 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)`)
  50445. * * 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
  50446. * * 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
  50447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50450. * @param name defines the name of the mesh
  50451. * @param options defines the options used to create the mesh
  50452. * @param scene defines the hosting scene
  50453. * @returns the polyhedron mesh
  50454. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50455. */
  50456. static CreatePolyhedron(name: string, options: {
  50457. type?: number;
  50458. size?: number;
  50459. sizeX?: number;
  50460. sizeY?: number;
  50461. sizeZ?: number;
  50462. custom?: any;
  50463. faceUV?: Vector4[];
  50464. faceColors?: Color4[];
  50465. flat?: boolean;
  50466. updatable?: boolean;
  50467. sideOrientation?: number;
  50468. frontUVs?: Vector4;
  50469. backUVs?: Vector4;
  50470. }, scene?: Nullable<Scene>): Mesh;
  50471. }
  50472. }
  50473. declare module "babylonjs/Gizmos/scaleGizmo" {
  50474. import { Observable } from "babylonjs/Misc/observable";
  50475. import { Nullable } from "babylonjs/types";
  50476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50477. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50478. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50479. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50480. /**
  50481. * Gizmo that enables scaling a mesh along 3 axis
  50482. */
  50483. export class ScaleGizmo extends Gizmo {
  50484. /**
  50485. * Internal gizmo used for interactions on the x axis
  50486. */
  50487. xGizmo: AxisScaleGizmo;
  50488. /**
  50489. * Internal gizmo used for interactions on the y axis
  50490. */
  50491. yGizmo: AxisScaleGizmo;
  50492. /**
  50493. * Internal gizmo used for interactions on the z axis
  50494. */
  50495. zGizmo: AxisScaleGizmo;
  50496. /**
  50497. * Internal gizmo used to scale all axis equally
  50498. */
  50499. uniformScaleGizmo: AxisScaleGizmo;
  50500. private _meshAttached;
  50501. private _updateGizmoRotationToMatchAttachedMesh;
  50502. private _snapDistance;
  50503. private _scaleRatio;
  50504. private _uniformScalingMesh;
  50505. private _octahedron;
  50506. private _sensitivity;
  50507. /** Fires an event when any of it's sub gizmos are dragged */
  50508. onDragStartObservable: Observable<unknown>;
  50509. /** Fires an event when any of it's sub gizmos are released from dragging */
  50510. onDragEndObservable: Observable<unknown>;
  50511. get attachedMesh(): Nullable<AbstractMesh>;
  50512. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50513. /**
  50514. * Creates a ScaleGizmo
  50515. * @param gizmoLayer The utility layer the gizmo will be added to
  50516. */
  50517. constructor(gizmoLayer?: UtilityLayerRenderer);
  50518. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50519. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50520. /**
  50521. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50522. */
  50523. set snapDistance(value: number);
  50524. get snapDistance(): number;
  50525. /**
  50526. * Ratio for the scale of the gizmo (Default: 1)
  50527. */
  50528. set scaleRatio(value: number);
  50529. get scaleRatio(): number;
  50530. /**
  50531. * Sensitivity factor for dragging (Default: 1)
  50532. */
  50533. set sensitivity(value: number);
  50534. get sensitivity(): number;
  50535. /**
  50536. * Disposes of the gizmo
  50537. */
  50538. dispose(): void;
  50539. }
  50540. }
  50541. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50542. import { Observable } from "babylonjs/Misc/observable";
  50543. import { Nullable } from "babylonjs/types";
  50544. import { Vector3 } from "babylonjs/Maths/math.vector";
  50545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50546. import { Mesh } from "babylonjs/Meshes/mesh";
  50547. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50549. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50550. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50551. import { Color3 } from "babylonjs/Maths/math.color";
  50552. /**
  50553. * Single axis scale gizmo
  50554. */
  50555. export class AxisScaleGizmo extends Gizmo {
  50556. /**
  50557. * Drag behavior responsible for the gizmos dragging interactions
  50558. */
  50559. dragBehavior: PointerDragBehavior;
  50560. private _pointerObserver;
  50561. /**
  50562. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50563. */
  50564. snapDistance: number;
  50565. /**
  50566. * Event that fires each time the gizmo snaps to a new location.
  50567. * * snapDistance is the the change in distance
  50568. */
  50569. onSnapObservable: Observable<{
  50570. snapDistance: number;
  50571. }>;
  50572. /**
  50573. * If the scaling operation should be done on all axis (default: false)
  50574. */
  50575. uniformScaling: boolean;
  50576. /**
  50577. * Custom sensitivity value for the drag strength
  50578. */
  50579. sensitivity: number;
  50580. private _isEnabled;
  50581. private _parent;
  50582. private _arrow;
  50583. private _coloredMaterial;
  50584. private _hoverMaterial;
  50585. /**
  50586. * Creates an AxisScaleGizmo
  50587. * @param gizmoLayer The utility layer the gizmo will be added to
  50588. * @param dragAxis The axis which the gizmo will be able to scale on
  50589. * @param color The color of the gizmo
  50590. */
  50591. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50593. /**
  50594. * If the gizmo is enabled
  50595. */
  50596. set isEnabled(value: boolean);
  50597. get isEnabled(): boolean;
  50598. /**
  50599. * Disposes of the gizmo
  50600. */
  50601. dispose(): void;
  50602. /**
  50603. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50604. * @param mesh The mesh to replace the default mesh of the gizmo
  50605. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50606. */
  50607. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50608. }
  50609. }
  50610. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50611. import { Observable } from "babylonjs/Misc/observable";
  50612. import { Nullable } from "babylonjs/types";
  50613. import { Vector3 } from "babylonjs/Maths/math.vector";
  50614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50615. import { Mesh } from "babylonjs/Meshes/mesh";
  50616. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50617. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50618. import { Color3 } from "babylonjs/Maths/math.color";
  50619. import "babylonjs/Meshes/Builders/boxBuilder";
  50620. /**
  50621. * Bounding box gizmo
  50622. */
  50623. export class BoundingBoxGizmo extends Gizmo {
  50624. private _lineBoundingBox;
  50625. private _rotateSpheresParent;
  50626. private _scaleBoxesParent;
  50627. private _boundingDimensions;
  50628. private _renderObserver;
  50629. private _pointerObserver;
  50630. private _scaleDragSpeed;
  50631. private _tmpQuaternion;
  50632. private _tmpVector;
  50633. private _tmpRotationMatrix;
  50634. /**
  50635. * 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)
  50636. */
  50637. ignoreChildren: boolean;
  50638. /**
  50639. * 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)
  50640. */
  50641. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50642. /**
  50643. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50644. */
  50645. rotationSphereSize: number;
  50646. /**
  50647. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50648. */
  50649. scaleBoxSize: number;
  50650. /**
  50651. * 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)
  50652. */
  50653. fixedDragMeshScreenSize: boolean;
  50654. /**
  50655. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50656. */
  50657. fixedDragMeshScreenSizeDistanceFactor: number;
  50658. /**
  50659. * Fired when a rotation sphere or scale box is dragged
  50660. */
  50661. onDragStartObservable: Observable<{}>;
  50662. /**
  50663. * Fired when a scale box is dragged
  50664. */
  50665. onScaleBoxDragObservable: Observable<{}>;
  50666. /**
  50667. * Fired when a scale box drag is ended
  50668. */
  50669. onScaleBoxDragEndObservable: Observable<{}>;
  50670. /**
  50671. * Fired when a rotation sphere is dragged
  50672. */
  50673. onRotationSphereDragObservable: Observable<{}>;
  50674. /**
  50675. * Fired when a rotation sphere drag is ended
  50676. */
  50677. onRotationSphereDragEndObservable: Observable<{}>;
  50678. /**
  50679. * 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)
  50680. */
  50681. scalePivot: Nullable<Vector3>;
  50682. /**
  50683. * Mesh used as a pivot to rotate the attached mesh
  50684. */
  50685. private _anchorMesh;
  50686. private _existingMeshScale;
  50687. private _dragMesh;
  50688. private pointerDragBehavior;
  50689. private coloredMaterial;
  50690. private hoverColoredMaterial;
  50691. /**
  50692. * Sets the color of the bounding box gizmo
  50693. * @param color the color to set
  50694. */
  50695. setColor(color: Color3): void;
  50696. /**
  50697. * Creates an BoundingBoxGizmo
  50698. * @param gizmoLayer The utility layer the gizmo will be added to
  50699. * @param color The color of the gizmo
  50700. */
  50701. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50703. private _selectNode;
  50704. /**
  50705. * Updates the bounding box information for the Gizmo
  50706. */
  50707. updateBoundingBox(): void;
  50708. private _updateRotationSpheres;
  50709. private _updateScaleBoxes;
  50710. /**
  50711. * Enables rotation on the specified axis and disables rotation on the others
  50712. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50713. */
  50714. setEnabledRotationAxis(axis: string): void;
  50715. /**
  50716. * Enables/disables scaling
  50717. * @param enable if scaling should be enabled
  50718. */
  50719. setEnabledScaling(enable: boolean): void;
  50720. private _updateDummy;
  50721. /**
  50722. * Enables a pointer drag behavior on the bounding box of the gizmo
  50723. */
  50724. enableDragBehavior(): void;
  50725. /**
  50726. * Disposes of the gizmo
  50727. */
  50728. dispose(): void;
  50729. /**
  50730. * 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)
  50731. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50732. * @returns the bounding box mesh with the passed in mesh as a child
  50733. */
  50734. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50735. /**
  50736. * CustomMeshes are not supported by this gizmo
  50737. * @param mesh The mesh to replace the default mesh of the gizmo
  50738. */
  50739. setCustomMesh(mesh: Mesh): void;
  50740. }
  50741. }
  50742. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50743. import { Observable } from "babylonjs/Misc/observable";
  50744. import { Nullable } from "babylonjs/types";
  50745. import { Vector3 } from "babylonjs/Maths/math.vector";
  50746. import { Color3 } from "babylonjs/Maths/math.color";
  50747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50748. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50749. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50750. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50751. import "babylonjs/Meshes/Builders/linesBuilder";
  50752. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50753. /**
  50754. * Single plane rotation gizmo
  50755. */
  50756. export class PlaneRotationGizmo extends Gizmo {
  50757. /**
  50758. * Drag behavior responsible for the gizmos dragging interactions
  50759. */
  50760. dragBehavior: PointerDragBehavior;
  50761. private _pointerObserver;
  50762. /**
  50763. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50764. */
  50765. snapDistance: number;
  50766. /**
  50767. * Event that fires each time the gizmo snaps to a new location.
  50768. * * snapDistance is the the change in distance
  50769. */
  50770. onSnapObservable: Observable<{
  50771. snapDistance: number;
  50772. }>;
  50773. private _isEnabled;
  50774. private _parent;
  50775. /**
  50776. * Creates a PlaneRotationGizmo
  50777. * @param gizmoLayer The utility layer the gizmo will be added to
  50778. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50779. * @param color The color of the gizmo
  50780. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50781. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50782. */
  50783. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50784. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50785. /**
  50786. * If the gizmo is enabled
  50787. */
  50788. set isEnabled(value: boolean);
  50789. get isEnabled(): boolean;
  50790. /**
  50791. * Disposes of the gizmo
  50792. */
  50793. dispose(): void;
  50794. }
  50795. }
  50796. declare module "babylonjs/Gizmos/rotationGizmo" {
  50797. import { Observable } from "babylonjs/Misc/observable";
  50798. import { Nullable } from "babylonjs/types";
  50799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50800. import { Mesh } from "babylonjs/Meshes/mesh";
  50801. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50802. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50803. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50804. /**
  50805. * Gizmo that enables rotating a mesh along 3 axis
  50806. */
  50807. export class RotationGizmo extends Gizmo {
  50808. /**
  50809. * Internal gizmo used for interactions on the x axis
  50810. */
  50811. xGizmo: PlaneRotationGizmo;
  50812. /**
  50813. * Internal gizmo used for interactions on the y axis
  50814. */
  50815. yGizmo: PlaneRotationGizmo;
  50816. /**
  50817. * Internal gizmo used for interactions on the z axis
  50818. */
  50819. zGizmo: PlaneRotationGizmo;
  50820. /** Fires an event when any of it's sub gizmos are dragged */
  50821. onDragStartObservable: Observable<unknown>;
  50822. /** Fires an event when any of it's sub gizmos are released from dragging */
  50823. onDragEndObservable: Observable<unknown>;
  50824. private _meshAttached;
  50825. get attachedMesh(): Nullable<AbstractMesh>;
  50826. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50827. /**
  50828. * Creates a RotationGizmo
  50829. * @param gizmoLayer The utility layer the gizmo will be added to
  50830. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50831. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50832. */
  50833. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50834. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50835. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50836. /**
  50837. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50838. */
  50839. set snapDistance(value: number);
  50840. get snapDistance(): number;
  50841. /**
  50842. * Ratio for the scale of the gizmo (Default: 1)
  50843. */
  50844. set scaleRatio(value: number);
  50845. get scaleRatio(): number;
  50846. /**
  50847. * Disposes of the gizmo
  50848. */
  50849. dispose(): void;
  50850. /**
  50851. * CustomMeshes are not supported by this gizmo
  50852. * @param mesh The mesh to replace the default mesh of the gizmo
  50853. */
  50854. setCustomMesh(mesh: Mesh): void;
  50855. }
  50856. }
  50857. declare module "babylonjs/Gizmos/gizmoManager" {
  50858. import { Observable } from "babylonjs/Misc/observable";
  50859. import { Nullable } from "babylonjs/types";
  50860. import { Scene, IDisposable } from "babylonjs/scene";
  50861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50862. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50863. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50864. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50865. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50866. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50867. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50868. /**
  50869. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50870. */
  50871. export class GizmoManager implements IDisposable {
  50872. private scene;
  50873. /**
  50874. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50875. */
  50876. gizmos: {
  50877. positionGizmo: Nullable<PositionGizmo>;
  50878. rotationGizmo: Nullable<RotationGizmo>;
  50879. scaleGizmo: Nullable<ScaleGizmo>;
  50880. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50881. };
  50882. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50883. clearGizmoOnEmptyPointerEvent: boolean;
  50884. /** Fires an event when the manager is attached to a mesh */
  50885. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50886. private _gizmosEnabled;
  50887. private _pointerObserver;
  50888. private _attachedMesh;
  50889. private _boundingBoxColor;
  50890. private _defaultUtilityLayer;
  50891. private _defaultKeepDepthUtilityLayer;
  50892. /**
  50893. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50894. */
  50895. boundingBoxDragBehavior: SixDofDragBehavior;
  50896. /**
  50897. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50898. */
  50899. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50900. /**
  50901. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50902. */
  50903. usePointerToAttachGizmos: boolean;
  50904. /**
  50905. * Utility layer that the bounding box gizmo belongs to
  50906. */
  50907. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50908. /**
  50909. * Utility layer that all gizmos besides bounding box belong to
  50910. */
  50911. get utilityLayer(): UtilityLayerRenderer;
  50912. /**
  50913. * Instatiates a gizmo manager
  50914. * @param scene the scene to overlay the gizmos on top of
  50915. */
  50916. constructor(scene: Scene);
  50917. /**
  50918. * Attaches a set of gizmos to the specified mesh
  50919. * @param mesh The mesh the gizmo's should be attached to
  50920. */
  50921. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50922. /**
  50923. * If the position gizmo is enabled
  50924. */
  50925. set positionGizmoEnabled(value: boolean);
  50926. get positionGizmoEnabled(): boolean;
  50927. /**
  50928. * If the rotation gizmo is enabled
  50929. */
  50930. set rotationGizmoEnabled(value: boolean);
  50931. get rotationGizmoEnabled(): boolean;
  50932. /**
  50933. * If the scale gizmo is enabled
  50934. */
  50935. set scaleGizmoEnabled(value: boolean);
  50936. get scaleGizmoEnabled(): boolean;
  50937. /**
  50938. * If the boundingBox gizmo is enabled
  50939. */
  50940. set boundingBoxGizmoEnabled(value: boolean);
  50941. get boundingBoxGizmoEnabled(): boolean;
  50942. /**
  50943. * Disposes of the gizmo manager
  50944. */
  50945. dispose(): void;
  50946. }
  50947. }
  50948. declare module "babylonjs/Lights/directionalLight" {
  50949. import { Camera } from "babylonjs/Cameras/camera";
  50950. import { Scene } from "babylonjs/scene";
  50951. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50953. import { Light } from "babylonjs/Lights/light";
  50954. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50955. import { Effect } from "babylonjs/Materials/effect";
  50956. /**
  50957. * A directional light is defined by a direction (what a surprise!).
  50958. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50959. * 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.
  50960. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50961. */
  50962. export class DirectionalLight extends ShadowLight {
  50963. private _shadowFrustumSize;
  50964. /**
  50965. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50966. */
  50967. get shadowFrustumSize(): number;
  50968. /**
  50969. * Specifies a fix frustum size for the shadow generation.
  50970. */
  50971. set shadowFrustumSize(value: number);
  50972. private _shadowOrthoScale;
  50973. /**
  50974. * Gets the shadow projection scale against the optimal computed one.
  50975. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50976. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50977. */
  50978. get shadowOrthoScale(): number;
  50979. /**
  50980. * Sets the shadow projection scale against the optimal computed one.
  50981. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50982. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50983. */
  50984. set shadowOrthoScale(value: number);
  50985. /**
  50986. * Automatically compute the projection matrix to best fit (including all the casters)
  50987. * on each frame.
  50988. */
  50989. autoUpdateExtends: boolean;
  50990. /**
  50991. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50992. * on each frame. autoUpdateExtends must be set to true for this to work
  50993. */
  50994. autoCalcShadowZBounds: boolean;
  50995. private _orthoLeft;
  50996. private _orthoRight;
  50997. private _orthoTop;
  50998. private _orthoBottom;
  50999. /**
  51000. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51001. * The directional light is emitted from everywhere in the given direction.
  51002. * It can cast shadows.
  51003. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51004. * @param name The friendly name of the light
  51005. * @param direction The direction of the light
  51006. * @param scene The scene the light belongs to
  51007. */
  51008. constructor(name: string, direction: Vector3, scene: Scene);
  51009. /**
  51010. * Returns the string "DirectionalLight".
  51011. * @return The class name
  51012. */
  51013. getClassName(): string;
  51014. /**
  51015. * Returns the integer 1.
  51016. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51017. */
  51018. getTypeID(): number;
  51019. /**
  51020. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51021. * Returns the DirectionalLight Shadow projection matrix.
  51022. */
  51023. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51024. /**
  51025. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51026. * Returns the DirectionalLight Shadow projection matrix.
  51027. */
  51028. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51029. /**
  51030. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51031. * Returns the DirectionalLight Shadow projection matrix.
  51032. */
  51033. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51034. protected _buildUniformLayout(): void;
  51035. /**
  51036. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51037. * @param effect The effect to update
  51038. * @param lightIndex The index of the light in the effect to update
  51039. * @returns The directional light
  51040. */
  51041. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51042. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51043. /**
  51044. * Gets the minZ used for shadow according to both the scene and the light.
  51045. *
  51046. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51047. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51048. * @param activeCamera The camera we are returning the min for
  51049. * @returns the depth min z
  51050. */
  51051. getDepthMinZ(activeCamera: Camera): number;
  51052. /**
  51053. * Gets the maxZ used for shadow according to both the scene and the light.
  51054. *
  51055. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51056. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51057. * @param activeCamera The camera we are returning the max for
  51058. * @returns the depth max z
  51059. */
  51060. getDepthMaxZ(activeCamera: Camera): number;
  51061. /**
  51062. * Prepares the list of defines specific to the light type.
  51063. * @param defines the list of defines
  51064. * @param lightIndex defines the index of the light for the effect
  51065. */
  51066. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51067. }
  51068. }
  51069. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51070. import { Mesh } from "babylonjs/Meshes/mesh";
  51071. /**
  51072. * Class containing static functions to help procedurally build meshes
  51073. */
  51074. export class HemisphereBuilder {
  51075. /**
  51076. * Creates a hemisphere mesh
  51077. * @param name defines the name of the mesh
  51078. * @param options defines the options used to create the mesh
  51079. * @param scene defines the hosting scene
  51080. * @returns the hemisphere mesh
  51081. */
  51082. static CreateHemisphere(name: string, options: {
  51083. segments?: number;
  51084. diameter?: number;
  51085. sideOrientation?: number;
  51086. }, scene: any): Mesh;
  51087. }
  51088. }
  51089. declare module "babylonjs/Lights/spotLight" {
  51090. import { Nullable } from "babylonjs/types";
  51091. import { Scene } from "babylonjs/scene";
  51092. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51094. import { Effect } from "babylonjs/Materials/effect";
  51095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51096. import { Light } from "babylonjs/Lights/light";
  51097. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51098. /**
  51099. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51100. * These values define a cone of light starting from the position, emitting toward the direction.
  51101. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51102. * and the exponent defines the speed of the decay of the light with distance (reach).
  51103. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51104. */
  51105. export class SpotLight extends ShadowLight {
  51106. private _angle;
  51107. private _innerAngle;
  51108. private _cosHalfAngle;
  51109. private _lightAngleScale;
  51110. private _lightAngleOffset;
  51111. /**
  51112. * Gets the cone angle of the spot light in Radians.
  51113. */
  51114. get angle(): number;
  51115. /**
  51116. * Sets the cone angle of the spot light in Radians.
  51117. */
  51118. set angle(value: number);
  51119. /**
  51120. * Only used in gltf falloff mode, this defines the angle where
  51121. * the directional falloff will start before cutting at angle which could be seen
  51122. * as outer angle.
  51123. */
  51124. get innerAngle(): number;
  51125. /**
  51126. * Only used in gltf falloff mode, this defines the angle where
  51127. * the directional falloff will start before cutting at angle which could be seen
  51128. * as outer angle.
  51129. */
  51130. set innerAngle(value: number);
  51131. private _shadowAngleScale;
  51132. /**
  51133. * Allows scaling the angle of the light for shadow generation only.
  51134. */
  51135. get shadowAngleScale(): number;
  51136. /**
  51137. * Allows scaling the angle of the light for shadow generation only.
  51138. */
  51139. set shadowAngleScale(value: number);
  51140. /**
  51141. * The light decay speed with the distance from the emission spot.
  51142. */
  51143. exponent: number;
  51144. private _projectionTextureMatrix;
  51145. /**
  51146. * Allows reading the projecton texture
  51147. */
  51148. get projectionTextureMatrix(): Matrix;
  51149. protected _projectionTextureLightNear: number;
  51150. /**
  51151. * Gets the near clip of the Spotlight for texture projection.
  51152. */
  51153. get projectionTextureLightNear(): number;
  51154. /**
  51155. * Sets the near clip of the Spotlight for texture projection.
  51156. */
  51157. set projectionTextureLightNear(value: number);
  51158. protected _projectionTextureLightFar: number;
  51159. /**
  51160. * Gets the far clip of the Spotlight for texture projection.
  51161. */
  51162. get projectionTextureLightFar(): number;
  51163. /**
  51164. * Sets the far clip of the Spotlight for texture projection.
  51165. */
  51166. set projectionTextureLightFar(value: number);
  51167. protected _projectionTextureUpDirection: Vector3;
  51168. /**
  51169. * Gets the Up vector of the Spotlight for texture projection.
  51170. */
  51171. get projectionTextureUpDirection(): Vector3;
  51172. /**
  51173. * Sets the Up vector of the Spotlight for texture projection.
  51174. */
  51175. set projectionTextureUpDirection(value: Vector3);
  51176. private _projectionTexture;
  51177. /**
  51178. * Gets the projection texture of the light.
  51179. */
  51180. get projectionTexture(): Nullable<BaseTexture>;
  51181. /**
  51182. * Sets the projection texture of the light.
  51183. */
  51184. set projectionTexture(value: Nullable<BaseTexture>);
  51185. private _projectionTextureViewLightDirty;
  51186. private _projectionTextureProjectionLightDirty;
  51187. private _projectionTextureDirty;
  51188. private _projectionTextureViewTargetVector;
  51189. private _projectionTextureViewLightMatrix;
  51190. private _projectionTextureProjectionLightMatrix;
  51191. private _projectionTextureScalingMatrix;
  51192. /**
  51193. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51194. * It can cast shadows.
  51195. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51196. * @param name The light friendly name
  51197. * @param position The position of the spot light in the scene
  51198. * @param direction The direction of the light in the scene
  51199. * @param angle The cone angle of the light in Radians
  51200. * @param exponent The light decay speed with the distance from the emission spot
  51201. * @param scene The scene the lights belongs to
  51202. */
  51203. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51204. /**
  51205. * Returns the string "SpotLight".
  51206. * @returns the class name
  51207. */
  51208. getClassName(): string;
  51209. /**
  51210. * Returns the integer 2.
  51211. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51212. */
  51213. getTypeID(): number;
  51214. /**
  51215. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51216. */
  51217. protected _setDirection(value: Vector3): void;
  51218. /**
  51219. * Overrides the position setter to recompute the projection texture view light Matrix.
  51220. */
  51221. protected _setPosition(value: Vector3): void;
  51222. /**
  51223. * 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.
  51224. * Returns the SpotLight.
  51225. */
  51226. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51227. protected _computeProjectionTextureViewLightMatrix(): void;
  51228. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51229. /**
  51230. * Main function for light texture projection matrix computing.
  51231. */
  51232. protected _computeProjectionTextureMatrix(): void;
  51233. protected _buildUniformLayout(): void;
  51234. private _computeAngleValues;
  51235. /**
  51236. * Sets the passed Effect "effect" with the Light textures.
  51237. * @param effect The effect to update
  51238. * @param lightIndex The index of the light in the effect to update
  51239. * @returns The light
  51240. */
  51241. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51242. /**
  51243. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51244. * @param effect The effect to update
  51245. * @param lightIndex The index of the light in the effect to update
  51246. * @returns The spot light
  51247. */
  51248. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51249. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51250. /**
  51251. * Disposes the light and the associated resources.
  51252. */
  51253. dispose(): void;
  51254. /**
  51255. * Prepares the list of defines specific to the light type.
  51256. * @param defines the list of defines
  51257. * @param lightIndex defines the index of the light for the effect
  51258. */
  51259. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51260. }
  51261. }
  51262. declare module "babylonjs/Gizmos/lightGizmo" {
  51263. import { Nullable } from "babylonjs/types";
  51264. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51265. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51266. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51267. import { Light } from "babylonjs/Lights/light";
  51268. /**
  51269. * Gizmo that enables viewing a light
  51270. */
  51271. export class LightGizmo extends Gizmo {
  51272. private _lightMesh;
  51273. private _material;
  51274. private _cachedPosition;
  51275. private _cachedForward;
  51276. private _attachedMeshParent;
  51277. /**
  51278. * Creates a LightGizmo
  51279. * @param gizmoLayer The utility layer the gizmo will be added to
  51280. */
  51281. constructor(gizmoLayer?: UtilityLayerRenderer);
  51282. private _light;
  51283. /**
  51284. * The light that the gizmo is attached to
  51285. */
  51286. set light(light: Nullable<Light>);
  51287. get light(): Nullable<Light>;
  51288. /**
  51289. * Gets the material used to render the light gizmo
  51290. */
  51291. get material(): StandardMaterial;
  51292. /**
  51293. * @hidden
  51294. * Updates the gizmo to match the attached mesh's position/rotation
  51295. */
  51296. protected _update(): void;
  51297. private static _Scale;
  51298. /**
  51299. * Creates the lines for a light mesh
  51300. */
  51301. private static _CreateLightLines;
  51302. /**
  51303. * Disposes of the light gizmo
  51304. */
  51305. dispose(): void;
  51306. private static _CreateHemisphericLightMesh;
  51307. private static _CreatePointLightMesh;
  51308. private static _CreateSpotLightMesh;
  51309. private static _CreateDirectionalLightMesh;
  51310. }
  51311. }
  51312. declare module "babylonjs/Gizmos/index" {
  51313. export * from "babylonjs/Gizmos/axisDragGizmo";
  51314. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51315. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51316. export * from "babylonjs/Gizmos/gizmo";
  51317. export * from "babylonjs/Gizmos/gizmoManager";
  51318. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51319. export * from "babylonjs/Gizmos/positionGizmo";
  51320. export * from "babylonjs/Gizmos/rotationGizmo";
  51321. export * from "babylonjs/Gizmos/scaleGizmo";
  51322. export * from "babylonjs/Gizmos/lightGizmo";
  51323. export * from "babylonjs/Gizmos/planeDragGizmo";
  51324. }
  51325. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51326. /** @hidden */
  51327. export var backgroundFragmentDeclaration: {
  51328. name: string;
  51329. shader: string;
  51330. };
  51331. }
  51332. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51333. /** @hidden */
  51334. export var backgroundUboDeclaration: {
  51335. name: string;
  51336. shader: string;
  51337. };
  51338. }
  51339. declare module "babylonjs/Shaders/background.fragment" {
  51340. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51341. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51342. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51343. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51344. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51345. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51346. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51347. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51348. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51349. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51351. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51353. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51354. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51355. /** @hidden */
  51356. export var backgroundPixelShader: {
  51357. name: string;
  51358. shader: string;
  51359. };
  51360. }
  51361. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51362. /** @hidden */
  51363. export var backgroundVertexDeclaration: {
  51364. name: string;
  51365. shader: string;
  51366. };
  51367. }
  51368. declare module "babylonjs/Shaders/background.vertex" {
  51369. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51370. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51371. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51372. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51373. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51375. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51376. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51377. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51378. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51379. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51381. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51382. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51383. /** @hidden */
  51384. export var backgroundVertexShader: {
  51385. name: string;
  51386. shader: string;
  51387. };
  51388. }
  51389. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51390. import { Nullable, int, float } from "babylonjs/types";
  51391. import { Scene } from "babylonjs/scene";
  51392. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51395. import { Mesh } from "babylonjs/Meshes/mesh";
  51396. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51397. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51398. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51399. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51400. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51401. import { Color3 } from "babylonjs/Maths/math.color";
  51402. import "babylonjs/Shaders/background.fragment";
  51403. import "babylonjs/Shaders/background.vertex";
  51404. /**
  51405. * Background material used to create an efficient environement around your scene.
  51406. */
  51407. export class BackgroundMaterial extends PushMaterial {
  51408. /**
  51409. * Standard reflectance value at parallel view angle.
  51410. */
  51411. static StandardReflectance0: number;
  51412. /**
  51413. * Standard reflectance value at grazing angle.
  51414. */
  51415. static StandardReflectance90: number;
  51416. protected _primaryColor: Color3;
  51417. /**
  51418. * Key light Color (multiply against the environement texture)
  51419. */
  51420. primaryColor: Color3;
  51421. protected __perceptualColor: Nullable<Color3>;
  51422. /**
  51423. * Experimental Internal Use Only.
  51424. *
  51425. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51426. * This acts as a helper to set the primary color to a more "human friendly" value.
  51427. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51428. * output color as close as possible from the chosen value.
  51429. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51430. * part of lighting setup.)
  51431. */
  51432. get _perceptualColor(): Nullable<Color3>;
  51433. set _perceptualColor(value: Nullable<Color3>);
  51434. protected _primaryColorShadowLevel: float;
  51435. /**
  51436. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51437. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51438. */
  51439. get primaryColorShadowLevel(): float;
  51440. set primaryColorShadowLevel(value: float);
  51441. protected _primaryColorHighlightLevel: float;
  51442. /**
  51443. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51444. * The primary color is used at the level chosen to define what the white area would look.
  51445. */
  51446. get primaryColorHighlightLevel(): float;
  51447. set primaryColorHighlightLevel(value: float);
  51448. protected _reflectionTexture: Nullable<BaseTexture>;
  51449. /**
  51450. * Reflection Texture used in the material.
  51451. * Should be author in a specific way for the best result (refer to the documentation).
  51452. */
  51453. reflectionTexture: Nullable<BaseTexture>;
  51454. protected _reflectionBlur: float;
  51455. /**
  51456. * Reflection Texture level of blur.
  51457. *
  51458. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51459. * texture twice.
  51460. */
  51461. reflectionBlur: float;
  51462. protected _diffuseTexture: Nullable<BaseTexture>;
  51463. /**
  51464. * Diffuse Texture used in the material.
  51465. * Should be author in a specific way for the best result (refer to the documentation).
  51466. */
  51467. diffuseTexture: Nullable<BaseTexture>;
  51468. protected _shadowLights: Nullable<IShadowLight[]>;
  51469. /**
  51470. * Specify the list of lights casting shadow on the material.
  51471. * All scene shadow lights will be included if null.
  51472. */
  51473. shadowLights: Nullable<IShadowLight[]>;
  51474. protected _shadowLevel: float;
  51475. /**
  51476. * Helps adjusting the shadow to a softer level if required.
  51477. * 0 means black shadows and 1 means no shadows.
  51478. */
  51479. shadowLevel: float;
  51480. protected _sceneCenter: Vector3;
  51481. /**
  51482. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51483. * It is usually zero but might be interesting to modify according to your setup.
  51484. */
  51485. sceneCenter: Vector3;
  51486. protected _opacityFresnel: boolean;
  51487. /**
  51488. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51489. * This helps ensuring a nice transition when the camera goes under the ground.
  51490. */
  51491. opacityFresnel: boolean;
  51492. protected _reflectionFresnel: boolean;
  51493. /**
  51494. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51495. * This helps adding a mirror texture on the ground.
  51496. */
  51497. reflectionFresnel: boolean;
  51498. protected _reflectionFalloffDistance: number;
  51499. /**
  51500. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51501. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51502. */
  51503. reflectionFalloffDistance: number;
  51504. protected _reflectionAmount: number;
  51505. /**
  51506. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51507. */
  51508. reflectionAmount: number;
  51509. protected _reflectionReflectance0: number;
  51510. /**
  51511. * This specifies the weight of the reflection at grazing angle.
  51512. */
  51513. reflectionReflectance0: number;
  51514. protected _reflectionReflectance90: number;
  51515. /**
  51516. * This specifies the weight of the reflection at a perpendicular point of view.
  51517. */
  51518. reflectionReflectance90: number;
  51519. /**
  51520. * Sets the reflection reflectance fresnel values according to the default standard
  51521. * empirically know to work well :-)
  51522. */
  51523. set reflectionStandardFresnelWeight(value: number);
  51524. protected _useRGBColor: boolean;
  51525. /**
  51526. * Helps to directly use the maps channels instead of their level.
  51527. */
  51528. useRGBColor: boolean;
  51529. protected _enableNoise: boolean;
  51530. /**
  51531. * This helps reducing the banding effect that could occur on the background.
  51532. */
  51533. enableNoise: boolean;
  51534. /**
  51535. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51536. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51537. * Recommended to be keep at 1.0 except for special cases.
  51538. */
  51539. get fovMultiplier(): number;
  51540. set fovMultiplier(value: number);
  51541. private _fovMultiplier;
  51542. /**
  51543. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51544. */
  51545. useEquirectangularFOV: boolean;
  51546. private _maxSimultaneousLights;
  51547. /**
  51548. * Number of Simultaneous lights allowed on the material.
  51549. */
  51550. maxSimultaneousLights: int;
  51551. /**
  51552. * Default configuration related to image processing available in the Background Material.
  51553. */
  51554. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51555. /**
  51556. * Keep track of the image processing observer to allow dispose and replace.
  51557. */
  51558. private _imageProcessingObserver;
  51559. /**
  51560. * Attaches a new image processing configuration to the PBR Material.
  51561. * @param configuration (if null the scene configuration will be use)
  51562. */
  51563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51564. /**
  51565. * Gets the image processing configuration used either in this material.
  51566. */
  51567. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51568. /**
  51569. * Sets the Default image processing configuration used either in the this material.
  51570. *
  51571. * If sets to null, the scene one is in use.
  51572. */
  51573. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51574. /**
  51575. * Gets wether the color curves effect is enabled.
  51576. */
  51577. get cameraColorCurvesEnabled(): boolean;
  51578. /**
  51579. * Sets wether the color curves effect is enabled.
  51580. */
  51581. set cameraColorCurvesEnabled(value: boolean);
  51582. /**
  51583. * Gets wether the color grading effect is enabled.
  51584. */
  51585. get cameraColorGradingEnabled(): boolean;
  51586. /**
  51587. * Gets wether the color grading effect is enabled.
  51588. */
  51589. set cameraColorGradingEnabled(value: boolean);
  51590. /**
  51591. * Gets wether tonemapping is enabled or not.
  51592. */
  51593. get cameraToneMappingEnabled(): boolean;
  51594. /**
  51595. * Sets wether tonemapping is enabled or not
  51596. */
  51597. set cameraToneMappingEnabled(value: boolean);
  51598. /**
  51599. * The camera exposure used on this material.
  51600. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51601. * This corresponds to a photographic exposure.
  51602. */
  51603. get cameraExposure(): float;
  51604. /**
  51605. * The camera exposure used on this material.
  51606. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51607. * This corresponds to a photographic exposure.
  51608. */
  51609. set cameraExposure(value: float);
  51610. /**
  51611. * Gets The camera contrast used on this material.
  51612. */
  51613. get cameraContrast(): float;
  51614. /**
  51615. * Sets The camera contrast used on this material.
  51616. */
  51617. set cameraContrast(value: float);
  51618. /**
  51619. * Gets the Color Grading 2D Lookup Texture.
  51620. */
  51621. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51622. /**
  51623. * Sets the Color Grading 2D Lookup Texture.
  51624. */
  51625. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51626. /**
  51627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51629. * 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;
  51630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51631. */
  51632. get cameraColorCurves(): Nullable<ColorCurves>;
  51633. /**
  51634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51636. * 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;
  51637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51638. */
  51639. set cameraColorCurves(value: Nullable<ColorCurves>);
  51640. /**
  51641. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51642. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51643. */
  51644. switchToBGR: boolean;
  51645. private _renderTargets;
  51646. private _reflectionControls;
  51647. private _white;
  51648. private _primaryShadowColor;
  51649. private _primaryHighlightColor;
  51650. /**
  51651. * Instantiates a Background Material in the given scene
  51652. * @param name The friendly name of the material
  51653. * @param scene The scene to add the material to
  51654. */
  51655. constructor(name: string, scene: Scene);
  51656. /**
  51657. * Gets a boolean indicating that current material needs to register RTT
  51658. */
  51659. get hasRenderTargetTextures(): boolean;
  51660. /**
  51661. * The entire material has been created in order to prevent overdraw.
  51662. * @returns false
  51663. */
  51664. needAlphaTesting(): boolean;
  51665. /**
  51666. * The entire material has been created in order to prevent overdraw.
  51667. * @returns true if blending is enable
  51668. */
  51669. needAlphaBlending(): boolean;
  51670. /**
  51671. * Checks wether the material is ready to be rendered for a given mesh.
  51672. * @param mesh The mesh to render
  51673. * @param subMesh The submesh to check against
  51674. * @param useInstances Specify wether or not the material is used with instances
  51675. * @returns true if all the dependencies are ready (Textures, Effects...)
  51676. */
  51677. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51678. /**
  51679. * Compute the primary color according to the chosen perceptual color.
  51680. */
  51681. private _computePrimaryColorFromPerceptualColor;
  51682. /**
  51683. * Compute the highlights and shadow colors according to their chosen levels.
  51684. */
  51685. private _computePrimaryColors;
  51686. /**
  51687. * Build the uniform buffer used in the material.
  51688. */
  51689. buildUniformLayout(): void;
  51690. /**
  51691. * Unbind the material.
  51692. */
  51693. unbind(): void;
  51694. /**
  51695. * Bind only the world matrix to the material.
  51696. * @param world The world matrix to bind.
  51697. */
  51698. bindOnlyWorldMatrix(world: Matrix): void;
  51699. /**
  51700. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51701. * @param world The world matrix to bind.
  51702. * @param subMesh The submesh to bind for.
  51703. */
  51704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51705. /**
  51706. * Checks to see if a texture is used in the material.
  51707. * @param texture - Base texture to use.
  51708. * @returns - Boolean specifying if a texture is used in the material.
  51709. */
  51710. hasTexture(texture: BaseTexture): boolean;
  51711. /**
  51712. * Dispose the material.
  51713. * @param forceDisposeEffect Force disposal of the associated effect.
  51714. * @param forceDisposeTextures Force disposal of the associated textures.
  51715. */
  51716. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51717. /**
  51718. * Clones the material.
  51719. * @param name The cloned name.
  51720. * @returns The cloned material.
  51721. */
  51722. clone(name: string): BackgroundMaterial;
  51723. /**
  51724. * Serializes the current material to its JSON representation.
  51725. * @returns The JSON representation.
  51726. */
  51727. serialize(): any;
  51728. /**
  51729. * Gets the class name of the material
  51730. * @returns "BackgroundMaterial"
  51731. */
  51732. getClassName(): string;
  51733. /**
  51734. * Parse a JSON input to create back a background material.
  51735. * @param source The JSON data to parse
  51736. * @param scene The scene to create the parsed material in
  51737. * @param rootUrl The root url of the assets the material depends upon
  51738. * @returns the instantiated BackgroundMaterial.
  51739. */
  51740. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51741. }
  51742. }
  51743. declare module "babylonjs/Helpers/environmentHelper" {
  51744. import { Observable } from "babylonjs/Misc/observable";
  51745. import { Nullable } from "babylonjs/types";
  51746. import { Scene } from "babylonjs/scene";
  51747. import { Vector3 } from "babylonjs/Maths/math.vector";
  51748. import { Color3 } from "babylonjs/Maths/math.color";
  51749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51750. import { Mesh } from "babylonjs/Meshes/mesh";
  51751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51752. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51753. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51754. import "babylonjs/Meshes/Builders/planeBuilder";
  51755. import "babylonjs/Meshes/Builders/boxBuilder";
  51756. /**
  51757. * Represents the different options available during the creation of
  51758. * a Environment helper.
  51759. *
  51760. * This can control the default ground, skybox and image processing setup of your scene.
  51761. */
  51762. export interface IEnvironmentHelperOptions {
  51763. /**
  51764. * Specifies wether or not to create a ground.
  51765. * True by default.
  51766. */
  51767. createGround: boolean;
  51768. /**
  51769. * Specifies the ground size.
  51770. * 15 by default.
  51771. */
  51772. groundSize: number;
  51773. /**
  51774. * The texture used on the ground for the main color.
  51775. * Comes from the BabylonJS CDN by default.
  51776. *
  51777. * Remarks: Can be either a texture or a url.
  51778. */
  51779. groundTexture: string | BaseTexture;
  51780. /**
  51781. * The color mixed in the ground texture by default.
  51782. * BabylonJS clearColor by default.
  51783. */
  51784. groundColor: Color3;
  51785. /**
  51786. * Specifies the ground opacity.
  51787. * 1 by default.
  51788. */
  51789. groundOpacity: number;
  51790. /**
  51791. * Enables the ground to receive shadows.
  51792. * True by default.
  51793. */
  51794. enableGroundShadow: boolean;
  51795. /**
  51796. * Helps preventing the shadow to be fully black on the ground.
  51797. * 0.5 by default.
  51798. */
  51799. groundShadowLevel: number;
  51800. /**
  51801. * Creates a mirror texture attach to the ground.
  51802. * false by default.
  51803. */
  51804. enableGroundMirror: boolean;
  51805. /**
  51806. * Specifies the ground mirror size ratio.
  51807. * 0.3 by default as the default kernel is 64.
  51808. */
  51809. groundMirrorSizeRatio: number;
  51810. /**
  51811. * Specifies the ground mirror blur kernel size.
  51812. * 64 by default.
  51813. */
  51814. groundMirrorBlurKernel: number;
  51815. /**
  51816. * Specifies the ground mirror visibility amount.
  51817. * 1 by default
  51818. */
  51819. groundMirrorAmount: number;
  51820. /**
  51821. * Specifies the ground mirror reflectance weight.
  51822. * This uses the standard weight of the background material to setup the fresnel effect
  51823. * of the mirror.
  51824. * 1 by default.
  51825. */
  51826. groundMirrorFresnelWeight: number;
  51827. /**
  51828. * Specifies the ground mirror Falloff distance.
  51829. * This can helps reducing the size of the reflection.
  51830. * 0 by Default.
  51831. */
  51832. groundMirrorFallOffDistance: number;
  51833. /**
  51834. * Specifies the ground mirror texture type.
  51835. * Unsigned Int by Default.
  51836. */
  51837. groundMirrorTextureType: number;
  51838. /**
  51839. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51840. * the shown objects.
  51841. */
  51842. groundYBias: number;
  51843. /**
  51844. * Specifies wether or not to create a skybox.
  51845. * True by default.
  51846. */
  51847. createSkybox: boolean;
  51848. /**
  51849. * Specifies the skybox size.
  51850. * 20 by default.
  51851. */
  51852. skyboxSize: number;
  51853. /**
  51854. * The texture used on the skybox for the main color.
  51855. * Comes from the BabylonJS CDN by default.
  51856. *
  51857. * Remarks: Can be either a texture or a url.
  51858. */
  51859. skyboxTexture: string | BaseTexture;
  51860. /**
  51861. * The color mixed in the skybox texture by default.
  51862. * BabylonJS clearColor by default.
  51863. */
  51864. skyboxColor: Color3;
  51865. /**
  51866. * The background rotation around the Y axis of the scene.
  51867. * This helps aligning the key lights of your scene with the background.
  51868. * 0 by default.
  51869. */
  51870. backgroundYRotation: number;
  51871. /**
  51872. * Compute automatically the size of the elements to best fit with the scene.
  51873. */
  51874. sizeAuto: boolean;
  51875. /**
  51876. * Default position of the rootMesh if autoSize is not true.
  51877. */
  51878. rootPosition: Vector3;
  51879. /**
  51880. * Sets up the image processing in the scene.
  51881. * true by default.
  51882. */
  51883. setupImageProcessing: boolean;
  51884. /**
  51885. * The texture used as your environment texture in the scene.
  51886. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51887. *
  51888. * Remarks: Can be either a texture or a url.
  51889. */
  51890. environmentTexture: string | BaseTexture;
  51891. /**
  51892. * The value of the exposure to apply to the scene.
  51893. * 0.6 by default if setupImageProcessing is true.
  51894. */
  51895. cameraExposure: number;
  51896. /**
  51897. * The value of the contrast to apply to the scene.
  51898. * 1.6 by default if setupImageProcessing is true.
  51899. */
  51900. cameraContrast: number;
  51901. /**
  51902. * Specifies wether or not tonemapping should be enabled in the scene.
  51903. * true by default if setupImageProcessing is true.
  51904. */
  51905. toneMappingEnabled: boolean;
  51906. }
  51907. /**
  51908. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51909. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51910. * It also helps with the default setup of your imageProcessing configuration.
  51911. */
  51912. export class EnvironmentHelper {
  51913. /**
  51914. * Default ground texture URL.
  51915. */
  51916. private static _groundTextureCDNUrl;
  51917. /**
  51918. * Default skybox texture URL.
  51919. */
  51920. private static _skyboxTextureCDNUrl;
  51921. /**
  51922. * Default environment texture URL.
  51923. */
  51924. private static _environmentTextureCDNUrl;
  51925. /**
  51926. * Creates the default options for the helper.
  51927. */
  51928. private static _getDefaultOptions;
  51929. private _rootMesh;
  51930. /**
  51931. * Gets the root mesh created by the helper.
  51932. */
  51933. get rootMesh(): Mesh;
  51934. private _skybox;
  51935. /**
  51936. * Gets the skybox created by the helper.
  51937. */
  51938. get skybox(): Nullable<Mesh>;
  51939. private _skyboxTexture;
  51940. /**
  51941. * Gets the skybox texture created by the helper.
  51942. */
  51943. get skyboxTexture(): Nullable<BaseTexture>;
  51944. private _skyboxMaterial;
  51945. /**
  51946. * Gets the skybox material created by the helper.
  51947. */
  51948. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51949. private _ground;
  51950. /**
  51951. * Gets the ground mesh created by the helper.
  51952. */
  51953. get ground(): Nullable<Mesh>;
  51954. private _groundTexture;
  51955. /**
  51956. * Gets the ground texture created by the helper.
  51957. */
  51958. get groundTexture(): Nullable<BaseTexture>;
  51959. private _groundMirror;
  51960. /**
  51961. * Gets the ground mirror created by the helper.
  51962. */
  51963. get groundMirror(): Nullable<MirrorTexture>;
  51964. /**
  51965. * Gets the ground mirror render list to helps pushing the meshes
  51966. * you wish in the ground reflection.
  51967. */
  51968. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51969. private _groundMaterial;
  51970. /**
  51971. * Gets the ground material created by the helper.
  51972. */
  51973. get groundMaterial(): Nullable<BackgroundMaterial>;
  51974. /**
  51975. * Stores the creation options.
  51976. */
  51977. private readonly _scene;
  51978. private _options;
  51979. /**
  51980. * This observable will be notified with any error during the creation of the environment,
  51981. * mainly texture creation errors.
  51982. */
  51983. onErrorObservable: Observable<{
  51984. message?: string;
  51985. exception?: any;
  51986. }>;
  51987. /**
  51988. * constructor
  51989. * @param options Defines the options we want to customize the helper
  51990. * @param scene The scene to add the material to
  51991. */
  51992. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51993. /**
  51994. * Updates the background according to the new options
  51995. * @param options
  51996. */
  51997. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51998. /**
  51999. * Sets the primary color of all the available elements.
  52000. * @param color the main color to affect to the ground and the background
  52001. */
  52002. setMainColor(color: Color3): void;
  52003. /**
  52004. * Setup the image processing according to the specified options.
  52005. */
  52006. private _setupImageProcessing;
  52007. /**
  52008. * Setup the environment texture according to the specified options.
  52009. */
  52010. private _setupEnvironmentTexture;
  52011. /**
  52012. * Setup the background according to the specified options.
  52013. */
  52014. private _setupBackground;
  52015. /**
  52016. * Get the scene sizes according to the setup.
  52017. */
  52018. private _getSceneSize;
  52019. /**
  52020. * Setup the ground according to the specified options.
  52021. */
  52022. private _setupGround;
  52023. /**
  52024. * Setup the ground material according to the specified options.
  52025. */
  52026. private _setupGroundMaterial;
  52027. /**
  52028. * Setup the ground diffuse texture according to the specified options.
  52029. */
  52030. private _setupGroundDiffuseTexture;
  52031. /**
  52032. * Setup the ground mirror texture according to the specified options.
  52033. */
  52034. private _setupGroundMirrorTexture;
  52035. /**
  52036. * Setup the ground to receive the mirror texture.
  52037. */
  52038. private _setupMirrorInGroundMaterial;
  52039. /**
  52040. * Setup the skybox according to the specified options.
  52041. */
  52042. private _setupSkybox;
  52043. /**
  52044. * Setup the skybox material according to the specified options.
  52045. */
  52046. private _setupSkyboxMaterial;
  52047. /**
  52048. * Setup the skybox reflection texture according to the specified options.
  52049. */
  52050. private _setupSkyboxReflectionTexture;
  52051. private _errorHandler;
  52052. /**
  52053. * Dispose all the elements created by the Helper.
  52054. */
  52055. dispose(): void;
  52056. }
  52057. }
  52058. declare module "babylonjs/Helpers/photoDome" {
  52059. import { Observable } from "babylonjs/Misc/observable";
  52060. import { Nullable } from "babylonjs/types";
  52061. import { Scene } from "babylonjs/scene";
  52062. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52063. import { Mesh } from "babylonjs/Meshes/mesh";
  52064. import { Texture } from "babylonjs/Materials/Textures/texture";
  52065. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52066. import "babylonjs/Meshes/Builders/sphereBuilder";
  52067. /**
  52068. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52069. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52070. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52071. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52072. */
  52073. export class PhotoDome extends TransformNode {
  52074. /**
  52075. * Define the image as a Monoscopic panoramic 360 image.
  52076. */
  52077. static readonly MODE_MONOSCOPIC: number;
  52078. /**
  52079. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52080. */
  52081. static readonly MODE_TOPBOTTOM: number;
  52082. /**
  52083. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52084. */
  52085. static readonly MODE_SIDEBYSIDE: number;
  52086. private _useDirectMapping;
  52087. /**
  52088. * The texture being displayed on the sphere
  52089. */
  52090. protected _photoTexture: Texture;
  52091. /**
  52092. * Gets or sets the texture being displayed on the sphere
  52093. */
  52094. get photoTexture(): Texture;
  52095. set photoTexture(value: Texture);
  52096. /**
  52097. * Observable raised when an error occured while loading the 360 image
  52098. */
  52099. onLoadErrorObservable: Observable<string>;
  52100. /**
  52101. * The skybox material
  52102. */
  52103. protected _material: BackgroundMaterial;
  52104. /**
  52105. * The surface used for the skybox
  52106. */
  52107. protected _mesh: Mesh;
  52108. /**
  52109. * Gets the mesh used for the skybox.
  52110. */
  52111. get mesh(): Mesh;
  52112. /**
  52113. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52114. * Also see the options.resolution property.
  52115. */
  52116. get fovMultiplier(): number;
  52117. set fovMultiplier(value: number);
  52118. private _imageMode;
  52119. /**
  52120. * Gets or set the current video mode for the video. It can be:
  52121. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52122. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52123. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52124. */
  52125. get imageMode(): number;
  52126. set imageMode(value: number);
  52127. /**
  52128. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52129. * @param name Element's name, child elements will append suffixes for their own names.
  52130. * @param urlsOfPhoto defines the url of the photo to display
  52131. * @param options defines an object containing optional or exposed sub element properties
  52132. * @param onError defines a callback called when an error occured while loading the texture
  52133. */
  52134. constructor(name: string, urlOfPhoto: string, options: {
  52135. resolution?: number;
  52136. size?: number;
  52137. useDirectMapping?: boolean;
  52138. faceForward?: boolean;
  52139. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52140. private _onBeforeCameraRenderObserver;
  52141. private _changeImageMode;
  52142. /**
  52143. * Releases resources associated with this node.
  52144. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52145. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52146. */
  52147. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52148. }
  52149. }
  52150. declare module "babylonjs/Misc/rgbdTextureTools" {
  52151. import "babylonjs/Shaders/rgbdDecode.fragment";
  52152. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52153. import { Texture } from "babylonjs/Materials/Textures/texture";
  52154. /**
  52155. * Class used to host RGBD texture specific utilities
  52156. */
  52157. export class RGBDTextureTools {
  52158. /**
  52159. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52160. * @param texture the texture to expand.
  52161. */
  52162. static ExpandRGBDTexture(texture: Texture): void;
  52163. }
  52164. }
  52165. declare module "babylonjs/Misc/brdfTextureTools" {
  52166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52167. import { Scene } from "babylonjs/scene";
  52168. /**
  52169. * Class used to host texture specific utilities
  52170. */
  52171. export class BRDFTextureTools {
  52172. /**
  52173. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52174. * @param scene defines the hosting scene
  52175. * @returns the environment BRDF texture
  52176. */
  52177. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52178. private static _environmentBRDFBase64Texture;
  52179. }
  52180. }
  52181. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52182. import { Nullable } from "babylonjs/types";
  52183. import { Color3 } from "babylonjs/Maths/math.color";
  52184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52185. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52186. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52187. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52188. import { Engine } from "babylonjs/Engines/engine";
  52189. import { Scene } from "babylonjs/scene";
  52190. /**
  52191. * @hidden
  52192. */
  52193. export interface IMaterialClearCoatDefines {
  52194. CLEARCOAT: boolean;
  52195. CLEARCOAT_DEFAULTIOR: boolean;
  52196. CLEARCOAT_TEXTURE: boolean;
  52197. CLEARCOAT_TEXTUREDIRECTUV: number;
  52198. CLEARCOAT_BUMP: boolean;
  52199. CLEARCOAT_BUMPDIRECTUV: number;
  52200. CLEARCOAT_TINT: boolean;
  52201. CLEARCOAT_TINT_TEXTURE: boolean;
  52202. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52203. /** @hidden */
  52204. _areTexturesDirty: boolean;
  52205. }
  52206. /**
  52207. * Define the code related to the clear coat parameters of the pbr material.
  52208. */
  52209. export class PBRClearCoatConfiguration {
  52210. /**
  52211. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52212. * The default fits with a polyurethane material.
  52213. */
  52214. private static readonly _DefaultIndexOfRefraction;
  52215. private _isEnabled;
  52216. /**
  52217. * Defines if the clear coat is enabled in the material.
  52218. */
  52219. isEnabled: boolean;
  52220. /**
  52221. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52222. */
  52223. intensity: number;
  52224. /**
  52225. * Defines the clear coat layer roughness.
  52226. */
  52227. roughness: number;
  52228. private _indexOfRefraction;
  52229. /**
  52230. * Defines the index of refraction of the clear coat.
  52231. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52232. * The default fits with a polyurethane material.
  52233. * Changing the default value is more performance intensive.
  52234. */
  52235. indexOfRefraction: number;
  52236. private _texture;
  52237. /**
  52238. * Stores the clear coat values in a texture.
  52239. */
  52240. texture: Nullable<BaseTexture>;
  52241. private _bumpTexture;
  52242. /**
  52243. * Define the clear coat specific bump texture.
  52244. */
  52245. bumpTexture: Nullable<BaseTexture>;
  52246. private _isTintEnabled;
  52247. /**
  52248. * Defines if the clear coat tint is enabled in the material.
  52249. */
  52250. isTintEnabled: boolean;
  52251. /**
  52252. * Defines the clear coat tint of the material.
  52253. * This is only use if tint is enabled
  52254. */
  52255. tintColor: Color3;
  52256. /**
  52257. * Defines the distance at which the tint color should be found in the
  52258. * clear coat media.
  52259. * This is only use if tint is enabled
  52260. */
  52261. tintColorAtDistance: number;
  52262. /**
  52263. * Defines the clear coat layer thickness.
  52264. * This is only use if tint is enabled
  52265. */
  52266. tintThickness: number;
  52267. private _tintTexture;
  52268. /**
  52269. * Stores the clear tint values in a texture.
  52270. * rgb is tint
  52271. * a is a thickness factor
  52272. */
  52273. tintTexture: Nullable<BaseTexture>;
  52274. /** @hidden */
  52275. private _internalMarkAllSubMeshesAsTexturesDirty;
  52276. /** @hidden */
  52277. _markAllSubMeshesAsTexturesDirty(): void;
  52278. /**
  52279. * Instantiate a new istance of clear coat configuration.
  52280. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52281. */
  52282. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52283. /**
  52284. * Gets wehter the submesh is ready to be used or not.
  52285. * @param defines the list of "defines" to update.
  52286. * @param scene defines the scene the material belongs to.
  52287. * @param engine defines the engine the material belongs to.
  52288. * @param disableBumpMap defines wether the material disables bump or not.
  52289. * @returns - boolean indicating that the submesh is ready or not.
  52290. */
  52291. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52292. /**
  52293. * Checks to see if a texture is used in the material.
  52294. * @param defines the list of "defines" to update.
  52295. * @param scene defines the scene to the material belongs to.
  52296. */
  52297. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52298. /**
  52299. * Binds the material data.
  52300. * @param uniformBuffer defines the Uniform buffer to fill in.
  52301. * @param scene defines the scene the material belongs to.
  52302. * @param engine defines the engine the material belongs to.
  52303. * @param disableBumpMap defines wether the material disables bump or not.
  52304. * @param isFrozen defines wether the material is frozen or not.
  52305. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52306. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52307. */
  52308. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52309. /**
  52310. * Checks to see if a texture is used in the material.
  52311. * @param texture - Base texture to use.
  52312. * @returns - Boolean specifying if a texture is used in the material.
  52313. */
  52314. hasTexture(texture: BaseTexture): boolean;
  52315. /**
  52316. * Returns an array of the actively used textures.
  52317. * @param activeTextures Array of BaseTextures
  52318. */
  52319. getActiveTextures(activeTextures: BaseTexture[]): void;
  52320. /**
  52321. * Returns the animatable textures.
  52322. * @param animatables Array of animatable textures.
  52323. */
  52324. getAnimatables(animatables: IAnimatable[]): void;
  52325. /**
  52326. * Disposes the resources of the material.
  52327. * @param forceDisposeTextures - Forces the disposal of all textures.
  52328. */
  52329. dispose(forceDisposeTextures?: boolean): void;
  52330. /**
  52331. * Get the current class name of the texture useful for serialization or dynamic coding.
  52332. * @returns "PBRClearCoatConfiguration"
  52333. */
  52334. getClassName(): string;
  52335. /**
  52336. * Add fallbacks to the effect fallbacks list.
  52337. * @param defines defines the Base texture to use.
  52338. * @param fallbacks defines the current fallback list.
  52339. * @param currentRank defines the current fallback rank.
  52340. * @returns the new fallback rank.
  52341. */
  52342. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52343. /**
  52344. * Add the required uniforms to the current list.
  52345. * @param uniforms defines the current uniform list.
  52346. */
  52347. static AddUniforms(uniforms: string[]): void;
  52348. /**
  52349. * Add the required samplers to the current list.
  52350. * @param samplers defines the current sampler list.
  52351. */
  52352. static AddSamplers(samplers: string[]): void;
  52353. /**
  52354. * Add the required uniforms to the current buffer.
  52355. * @param uniformBuffer defines the current uniform buffer.
  52356. */
  52357. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52358. /**
  52359. * Makes a duplicate of the current configuration into another one.
  52360. * @param clearCoatConfiguration define the config where to copy the info
  52361. */
  52362. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52363. /**
  52364. * Serializes this clear coat configuration.
  52365. * @returns - An object with the serialized config.
  52366. */
  52367. serialize(): any;
  52368. /**
  52369. * Parses a anisotropy Configuration from a serialized object.
  52370. * @param source - Serialized object.
  52371. * @param scene Defines the scene we are parsing for
  52372. * @param rootUrl Defines the rootUrl to load from
  52373. */
  52374. parse(source: any, scene: Scene, rootUrl: string): void;
  52375. }
  52376. }
  52377. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52380. import { Vector2 } from "babylonjs/Maths/math.vector";
  52381. import { Scene } from "babylonjs/scene";
  52382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52383. import { Nullable } from "babylonjs/types";
  52384. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52385. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52386. /**
  52387. * @hidden
  52388. */
  52389. export interface IMaterialAnisotropicDefines {
  52390. ANISOTROPIC: boolean;
  52391. ANISOTROPIC_TEXTURE: boolean;
  52392. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52393. MAINUV1: boolean;
  52394. _areTexturesDirty: boolean;
  52395. _needUVs: boolean;
  52396. }
  52397. /**
  52398. * Define the code related to the anisotropic parameters of the pbr material.
  52399. */
  52400. export class PBRAnisotropicConfiguration {
  52401. private _isEnabled;
  52402. /**
  52403. * Defines if the anisotropy is enabled in the material.
  52404. */
  52405. isEnabled: boolean;
  52406. /**
  52407. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52408. */
  52409. intensity: number;
  52410. /**
  52411. * Defines if the effect is along the tangents, bitangents or in between.
  52412. * By default, the effect is "strectching" the highlights along the tangents.
  52413. */
  52414. direction: Vector2;
  52415. private _texture;
  52416. /**
  52417. * Stores the anisotropy values in a texture.
  52418. * rg is direction (like normal from -1 to 1)
  52419. * b is a intensity
  52420. */
  52421. texture: Nullable<BaseTexture>;
  52422. /** @hidden */
  52423. private _internalMarkAllSubMeshesAsTexturesDirty;
  52424. /** @hidden */
  52425. _markAllSubMeshesAsTexturesDirty(): void;
  52426. /**
  52427. * Instantiate a new istance of anisotropy configuration.
  52428. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52429. */
  52430. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52431. /**
  52432. * Specifies that the submesh is ready to be used.
  52433. * @param defines the list of "defines" to update.
  52434. * @param scene defines the scene the material belongs to.
  52435. * @returns - boolean indicating that the submesh is ready or not.
  52436. */
  52437. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52438. /**
  52439. * Checks to see if a texture is used in the material.
  52440. * @param defines the list of "defines" to update.
  52441. * @param mesh the mesh we are preparing the defines for.
  52442. * @param scene defines the scene the material belongs to.
  52443. */
  52444. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52445. /**
  52446. * Binds the material data.
  52447. * @param uniformBuffer defines the Uniform buffer to fill in.
  52448. * @param scene defines the scene the material belongs to.
  52449. * @param isFrozen defines wether the material is frozen or not.
  52450. */
  52451. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52452. /**
  52453. * Checks to see if a texture is used in the material.
  52454. * @param texture - Base texture to use.
  52455. * @returns - Boolean specifying if a texture is used in the material.
  52456. */
  52457. hasTexture(texture: BaseTexture): boolean;
  52458. /**
  52459. * Returns an array of the actively used textures.
  52460. * @param activeTextures Array of BaseTextures
  52461. */
  52462. getActiveTextures(activeTextures: BaseTexture[]): void;
  52463. /**
  52464. * Returns the animatable textures.
  52465. * @param animatables Array of animatable textures.
  52466. */
  52467. getAnimatables(animatables: IAnimatable[]): void;
  52468. /**
  52469. * Disposes the resources of the material.
  52470. * @param forceDisposeTextures - Forces the disposal of all textures.
  52471. */
  52472. dispose(forceDisposeTextures?: boolean): void;
  52473. /**
  52474. * Get the current class name of the texture useful for serialization or dynamic coding.
  52475. * @returns "PBRAnisotropicConfiguration"
  52476. */
  52477. getClassName(): string;
  52478. /**
  52479. * Add fallbacks to the effect fallbacks list.
  52480. * @param defines defines the Base texture to use.
  52481. * @param fallbacks defines the current fallback list.
  52482. * @param currentRank defines the current fallback rank.
  52483. * @returns the new fallback rank.
  52484. */
  52485. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52486. /**
  52487. * Add the required uniforms to the current list.
  52488. * @param uniforms defines the current uniform list.
  52489. */
  52490. static AddUniforms(uniforms: string[]): void;
  52491. /**
  52492. * Add the required uniforms to the current buffer.
  52493. * @param uniformBuffer defines the current uniform buffer.
  52494. */
  52495. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52496. /**
  52497. * Add the required samplers to the current list.
  52498. * @param samplers defines the current sampler list.
  52499. */
  52500. static AddSamplers(samplers: string[]): void;
  52501. /**
  52502. * Makes a duplicate of the current configuration into another one.
  52503. * @param anisotropicConfiguration define the config where to copy the info
  52504. */
  52505. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52506. /**
  52507. * Serializes this anisotropy configuration.
  52508. * @returns - An object with the serialized config.
  52509. */
  52510. serialize(): any;
  52511. /**
  52512. * Parses a anisotropy Configuration from a serialized object.
  52513. * @param source - Serialized object.
  52514. * @param scene Defines the scene we are parsing for
  52515. * @param rootUrl Defines the rootUrl to load from
  52516. */
  52517. parse(source: any, scene: Scene, rootUrl: string): void;
  52518. }
  52519. }
  52520. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52521. import { Scene } from "babylonjs/scene";
  52522. /**
  52523. * @hidden
  52524. */
  52525. export interface IMaterialBRDFDefines {
  52526. BRDF_V_HEIGHT_CORRELATED: boolean;
  52527. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52528. SPHERICAL_HARMONICS: boolean;
  52529. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52530. /** @hidden */
  52531. _areMiscDirty: boolean;
  52532. }
  52533. /**
  52534. * Define the code related to the BRDF parameters of the pbr material.
  52535. */
  52536. export class PBRBRDFConfiguration {
  52537. /**
  52538. * Default value used for the energy conservation.
  52539. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52540. */
  52541. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52542. /**
  52543. * Default value used for the Smith Visibility Height Correlated mode.
  52544. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52545. */
  52546. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52547. /**
  52548. * Default value used for the IBL diffuse part.
  52549. * This can help switching back to the polynomials mode globally which is a tiny bit
  52550. * less GPU intensive at the drawback of a lower quality.
  52551. */
  52552. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52553. /**
  52554. * Default value used for activating energy conservation for the specular workflow.
  52555. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52556. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52557. */
  52558. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52559. private _useEnergyConservation;
  52560. /**
  52561. * Defines if the material uses energy conservation.
  52562. */
  52563. useEnergyConservation: boolean;
  52564. private _useSmithVisibilityHeightCorrelated;
  52565. /**
  52566. * LEGACY Mode set to false
  52567. * Defines if the material uses height smith correlated visibility term.
  52568. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52569. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52570. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52571. * Not relying on height correlated will also disable energy conservation.
  52572. */
  52573. useSmithVisibilityHeightCorrelated: boolean;
  52574. private _useSphericalHarmonics;
  52575. /**
  52576. * LEGACY Mode set to false
  52577. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52578. * diffuse part of the IBL.
  52579. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52580. * to the ground truth.
  52581. */
  52582. useSphericalHarmonics: boolean;
  52583. private _useSpecularGlossinessInputEnergyConservation;
  52584. /**
  52585. * Defines if the material uses energy conservation, when the specular workflow is active.
  52586. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52587. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52588. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52589. */
  52590. useSpecularGlossinessInputEnergyConservation: boolean;
  52591. /** @hidden */
  52592. private _internalMarkAllSubMeshesAsMiscDirty;
  52593. /** @hidden */
  52594. _markAllSubMeshesAsMiscDirty(): void;
  52595. /**
  52596. * Instantiate a new istance of clear coat configuration.
  52597. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52598. */
  52599. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52600. /**
  52601. * Checks to see if a texture is used in the material.
  52602. * @param defines the list of "defines" to update.
  52603. */
  52604. prepareDefines(defines: IMaterialBRDFDefines): void;
  52605. /**
  52606. * Get the current class name of the texture useful for serialization or dynamic coding.
  52607. * @returns "PBRClearCoatConfiguration"
  52608. */
  52609. getClassName(): string;
  52610. /**
  52611. * Makes a duplicate of the current configuration into another one.
  52612. * @param brdfConfiguration define the config where to copy the info
  52613. */
  52614. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52615. /**
  52616. * Serializes this BRDF configuration.
  52617. * @returns - An object with the serialized config.
  52618. */
  52619. serialize(): any;
  52620. /**
  52621. * Parses a anisotropy Configuration from a serialized object.
  52622. * @param source - Serialized object.
  52623. * @param scene Defines the scene we are parsing for
  52624. * @param rootUrl Defines the rootUrl to load from
  52625. */
  52626. parse(source: any, scene: Scene, rootUrl: string): void;
  52627. }
  52628. }
  52629. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52630. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52631. import { Color3 } from "babylonjs/Maths/math.color";
  52632. import { Scene } from "babylonjs/scene";
  52633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52634. import { Nullable } from "babylonjs/types";
  52635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52636. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52637. /**
  52638. * @hidden
  52639. */
  52640. export interface IMaterialSheenDefines {
  52641. SHEEN: boolean;
  52642. SHEEN_TEXTURE: boolean;
  52643. SHEEN_TEXTUREDIRECTUV: number;
  52644. SHEEN_LINKWITHALBEDO: boolean;
  52645. /** @hidden */
  52646. _areTexturesDirty: boolean;
  52647. }
  52648. /**
  52649. * Define the code related to the Sheen parameters of the pbr material.
  52650. */
  52651. export class PBRSheenConfiguration {
  52652. private _isEnabled;
  52653. /**
  52654. * Defines if the material uses sheen.
  52655. */
  52656. isEnabled: boolean;
  52657. private _linkSheenWithAlbedo;
  52658. /**
  52659. * Defines if the sheen is linked to the sheen color.
  52660. */
  52661. linkSheenWithAlbedo: boolean;
  52662. /**
  52663. * Defines the sheen intensity.
  52664. */
  52665. intensity: number;
  52666. /**
  52667. * Defines the sheen color.
  52668. */
  52669. color: Color3;
  52670. private _texture;
  52671. /**
  52672. * Stores the sheen tint values in a texture.
  52673. * rgb is tint
  52674. * a is a intensity
  52675. */
  52676. texture: Nullable<BaseTexture>;
  52677. /** @hidden */
  52678. private _internalMarkAllSubMeshesAsTexturesDirty;
  52679. /** @hidden */
  52680. _markAllSubMeshesAsTexturesDirty(): void;
  52681. /**
  52682. * Instantiate a new istance of clear coat configuration.
  52683. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52684. */
  52685. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52686. /**
  52687. * Specifies that the submesh is ready to be used.
  52688. * @param defines the list of "defines" to update.
  52689. * @param scene defines the scene the material belongs to.
  52690. * @returns - boolean indicating that the submesh is ready or not.
  52691. */
  52692. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52693. /**
  52694. * Checks to see if a texture is used in the material.
  52695. * @param defines the list of "defines" to update.
  52696. * @param scene defines the scene the material belongs to.
  52697. */
  52698. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52699. /**
  52700. * Binds the material data.
  52701. * @param uniformBuffer defines the Uniform buffer to fill in.
  52702. * @param scene defines the scene the material belongs to.
  52703. * @param isFrozen defines wether the material is frozen or not.
  52704. */
  52705. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52706. /**
  52707. * Checks to see if a texture is used in the material.
  52708. * @param texture - Base texture to use.
  52709. * @returns - Boolean specifying if a texture is used in the material.
  52710. */
  52711. hasTexture(texture: BaseTexture): boolean;
  52712. /**
  52713. * Returns an array of the actively used textures.
  52714. * @param activeTextures Array of BaseTextures
  52715. */
  52716. getActiveTextures(activeTextures: BaseTexture[]): void;
  52717. /**
  52718. * Returns the animatable textures.
  52719. * @param animatables Array of animatable textures.
  52720. */
  52721. getAnimatables(animatables: IAnimatable[]): void;
  52722. /**
  52723. * Disposes the resources of the material.
  52724. * @param forceDisposeTextures - Forces the disposal of all textures.
  52725. */
  52726. dispose(forceDisposeTextures?: boolean): void;
  52727. /**
  52728. * Get the current class name of the texture useful for serialization or dynamic coding.
  52729. * @returns "PBRSheenConfiguration"
  52730. */
  52731. getClassName(): string;
  52732. /**
  52733. * Add fallbacks to the effect fallbacks list.
  52734. * @param defines defines the Base texture to use.
  52735. * @param fallbacks defines the current fallback list.
  52736. * @param currentRank defines the current fallback rank.
  52737. * @returns the new fallback rank.
  52738. */
  52739. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52740. /**
  52741. * Add the required uniforms to the current list.
  52742. * @param uniforms defines the current uniform list.
  52743. */
  52744. static AddUniforms(uniforms: string[]): void;
  52745. /**
  52746. * Add the required uniforms to the current buffer.
  52747. * @param uniformBuffer defines the current uniform buffer.
  52748. */
  52749. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52750. /**
  52751. * Add the required samplers to the current list.
  52752. * @param samplers defines the current sampler list.
  52753. */
  52754. static AddSamplers(samplers: string[]): void;
  52755. /**
  52756. * Makes a duplicate of the current configuration into another one.
  52757. * @param sheenConfiguration define the config where to copy the info
  52758. */
  52759. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52760. /**
  52761. * Serializes this BRDF configuration.
  52762. * @returns - An object with the serialized config.
  52763. */
  52764. serialize(): any;
  52765. /**
  52766. * Parses a anisotropy Configuration from a serialized object.
  52767. * @param source - Serialized object.
  52768. * @param scene Defines the scene we are parsing for
  52769. * @param rootUrl Defines the rootUrl to load from
  52770. */
  52771. parse(source: any, scene: Scene, rootUrl: string): void;
  52772. }
  52773. }
  52774. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52775. import { Nullable } from "babylonjs/types";
  52776. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52777. import { Color3 } from "babylonjs/Maths/math.color";
  52778. import { SmartArray } from "babylonjs/Misc/smartArray";
  52779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52780. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52781. import { Effect } from "babylonjs/Materials/effect";
  52782. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52783. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52784. import { Engine } from "babylonjs/Engines/engine";
  52785. import { Scene } from "babylonjs/scene";
  52786. /**
  52787. * @hidden
  52788. */
  52789. export interface IMaterialSubSurfaceDefines {
  52790. SUBSURFACE: boolean;
  52791. SS_REFRACTION: boolean;
  52792. SS_TRANSLUCENCY: boolean;
  52793. SS_SCATERRING: boolean;
  52794. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52795. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52796. SS_REFRACTIONMAP_3D: boolean;
  52797. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52798. SS_LODINREFRACTIONALPHA: boolean;
  52799. SS_GAMMAREFRACTION: boolean;
  52800. SS_RGBDREFRACTION: boolean;
  52801. SS_LINEARSPECULARREFRACTION: boolean;
  52802. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52803. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52804. /** @hidden */
  52805. _areTexturesDirty: boolean;
  52806. }
  52807. /**
  52808. * Define the code related to the sub surface parameters of the pbr material.
  52809. */
  52810. export class PBRSubSurfaceConfiguration {
  52811. private _isRefractionEnabled;
  52812. /**
  52813. * Defines if the refraction is enabled in the material.
  52814. */
  52815. isRefractionEnabled: boolean;
  52816. private _isTranslucencyEnabled;
  52817. /**
  52818. * Defines if the translucency is enabled in the material.
  52819. */
  52820. isTranslucencyEnabled: boolean;
  52821. private _isScatteringEnabled;
  52822. /**
  52823. * Defines the refraction intensity of the material.
  52824. * The refraction when enabled replaces the Diffuse part of the material.
  52825. * The intensity helps transitionning between diffuse and refraction.
  52826. */
  52827. refractionIntensity: number;
  52828. /**
  52829. * Defines the translucency intensity of the material.
  52830. * When translucency has been enabled, this defines how much of the "translucency"
  52831. * is addded to the diffuse part of the material.
  52832. */
  52833. translucencyIntensity: number;
  52834. /**
  52835. * Defines the scattering intensity of the material.
  52836. * When scattering has been enabled, this defines how much of the "scattered light"
  52837. * is addded to the diffuse part of the material.
  52838. */
  52839. scatteringIntensity: number;
  52840. private _thicknessTexture;
  52841. /**
  52842. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52843. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52844. * 0 would mean minimumThickness
  52845. * 1 would mean maximumThickness
  52846. * The other channels might be use as a mask to vary the different effects intensity.
  52847. */
  52848. thicknessTexture: Nullable<BaseTexture>;
  52849. private _refractionTexture;
  52850. /**
  52851. * Defines the texture to use for refraction.
  52852. */
  52853. refractionTexture: Nullable<BaseTexture>;
  52854. private _indexOfRefraction;
  52855. /**
  52856. * Defines the index of refraction used in the material.
  52857. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52858. */
  52859. indexOfRefraction: number;
  52860. private _invertRefractionY;
  52861. /**
  52862. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52863. */
  52864. invertRefractionY: boolean;
  52865. private _linkRefractionWithTransparency;
  52866. /**
  52867. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52868. * Materials half opaque for instance using refraction could benefit from this control.
  52869. */
  52870. linkRefractionWithTransparency: boolean;
  52871. /**
  52872. * Defines the minimum thickness stored in the thickness map.
  52873. * If no thickness map is defined, this value will be used to simulate thickness.
  52874. */
  52875. minimumThickness: number;
  52876. /**
  52877. * Defines the maximum thickness stored in the thickness map.
  52878. */
  52879. maximumThickness: number;
  52880. /**
  52881. * Defines the volume tint of the material.
  52882. * This is used for both translucency and scattering.
  52883. */
  52884. tintColor: Color3;
  52885. /**
  52886. * Defines the distance at which the tint color should be found in the media.
  52887. * This is used for refraction only.
  52888. */
  52889. tintColorAtDistance: number;
  52890. /**
  52891. * Defines how far each channel transmit through the media.
  52892. * It is defined as a color to simplify it selection.
  52893. */
  52894. diffusionDistance: Color3;
  52895. private _useMaskFromThicknessTexture;
  52896. /**
  52897. * Stores the intensity of the different subsurface effects in the thickness texture.
  52898. * * the green channel is the translucency intensity.
  52899. * * the blue channel is the scattering intensity.
  52900. * * the alpha channel is the refraction intensity.
  52901. */
  52902. useMaskFromThicknessTexture: boolean;
  52903. /** @hidden */
  52904. private _internalMarkAllSubMeshesAsTexturesDirty;
  52905. /** @hidden */
  52906. _markAllSubMeshesAsTexturesDirty(): void;
  52907. /**
  52908. * Instantiate a new istance of sub surface configuration.
  52909. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52910. */
  52911. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52912. /**
  52913. * Gets wehter the submesh is ready to be used or not.
  52914. * @param defines the list of "defines" to update.
  52915. * @param scene defines the scene the material belongs to.
  52916. * @returns - boolean indicating that the submesh is ready or not.
  52917. */
  52918. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52919. /**
  52920. * Checks to see if a texture is used in the material.
  52921. * @param defines the list of "defines" to update.
  52922. * @param scene defines the scene to the material belongs to.
  52923. */
  52924. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52925. /**
  52926. * Binds the material data.
  52927. * @param uniformBuffer defines the Uniform buffer to fill in.
  52928. * @param scene defines the scene the material belongs to.
  52929. * @param engine defines the engine the material belongs to.
  52930. * @param isFrozen defines wether the material is frozen or not.
  52931. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52932. */
  52933. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52934. /**
  52935. * Unbinds the material from the mesh.
  52936. * @param activeEffect defines the effect that should be unbound from.
  52937. * @returns true if unbound, otherwise false
  52938. */
  52939. unbind(activeEffect: Effect): boolean;
  52940. /**
  52941. * Returns the texture used for refraction or null if none is used.
  52942. * @param scene defines the scene the material belongs to.
  52943. * @returns - Refraction texture if present. If no refraction texture and refraction
  52944. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52945. */
  52946. private _getRefractionTexture;
  52947. /**
  52948. * Returns true if alpha blending should be disabled.
  52949. */
  52950. get disableAlphaBlending(): boolean;
  52951. /**
  52952. * Fills the list of render target textures.
  52953. * @param renderTargets the list of render targets to update
  52954. */
  52955. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52956. /**
  52957. * Checks to see if a texture is used in the material.
  52958. * @param texture - Base texture to use.
  52959. * @returns - Boolean specifying if a texture is used in the material.
  52960. */
  52961. hasTexture(texture: BaseTexture): boolean;
  52962. /**
  52963. * Gets a boolean indicating that current material needs to register RTT
  52964. * @returns true if this uses a render target otherwise false.
  52965. */
  52966. hasRenderTargetTextures(): boolean;
  52967. /**
  52968. * Returns an array of the actively used textures.
  52969. * @param activeTextures Array of BaseTextures
  52970. */
  52971. getActiveTextures(activeTextures: BaseTexture[]): void;
  52972. /**
  52973. * Returns the animatable textures.
  52974. * @param animatables Array of animatable textures.
  52975. */
  52976. getAnimatables(animatables: IAnimatable[]): void;
  52977. /**
  52978. * Disposes the resources of the material.
  52979. * @param forceDisposeTextures - Forces the disposal of all textures.
  52980. */
  52981. dispose(forceDisposeTextures?: boolean): void;
  52982. /**
  52983. * Get the current class name of the texture useful for serialization or dynamic coding.
  52984. * @returns "PBRSubSurfaceConfiguration"
  52985. */
  52986. getClassName(): string;
  52987. /**
  52988. * Add fallbacks to the effect fallbacks list.
  52989. * @param defines defines the Base texture to use.
  52990. * @param fallbacks defines the current fallback list.
  52991. * @param currentRank defines the current fallback rank.
  52992. * @returns the new fallback rank.
  52993. */
  52994. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52995. /**
  52996. * Add the required uniforms to the current list.
  52997. * @param uniforms defines the current uniform list.
  52998. */
  52999. static AddUniforms(uniforms: string[]): void;
  53000. /**
  53001. * Add the required samplers to the current list.
  53002. * @param samplers defines the current sampler list.
  53003. */
  53004. static AddSamplers(samplers: string[]): void;
  53005. /**
  53006. * Add the required uniforms to the current buffer.
  53007. * @param uniformBuffer defines the current uniform buffer.
  53008. */
  53009. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53010. /**
  53011. * Makes a duplicate of the current configuration into another one.
  53012. * @param configuration define the config where to copy the info
  53013. */
  53014. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53015. /**
  53016. * Serializes this Sub Surface configuration.
  53017. * @returns - An object with the serialized config.
  53018. */
  53019. serialize(): any;
  53020. /**
  53021. * Parses a anisotropy Configuration from a serialized object.
  53022. * @param source - Serialized object.
  53023. * @param scene Defines the scene we are parsing for
  53024. * @param rootUrl Defines the rootUrl to load from
  53025. */
  53026. parse(source: any, scene: Scene, rootUrl: string): void;
  53027. }
  53028. }
  53029. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53030. /** @hidden */
  53031. export var pbrFragmentDeclaration: {
  53032. name: string;
  53033. shader: string;
  53034. };
  53035. }
  53036. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53037. /** @hidden */
  53038. export var pbrUboDeclaration: {
  53039. name: string;
  53040. shader: string;
  53041. };
  53042. }
  53043. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53044. /** @hidden */
  53045. export var pbrFragmentExtraDeclaration: {
  53046. name: string;
  53047. shader: string;
  53048. };
  53049. }
  53050. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53051. /** @hidden */
  53052. export var pbrFragmentSamplersDeclaration: {
  53053. name: string;
  53054. shader: string;
  53055. };
  53056. }
  53057. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53058. /** @hidden */
  53059. export var pbrHelperFunctions: {
  53060. name: string;
  53061. shader: string;
  53062. };
  53063. }
  53064. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53065. /** @hidden */
  53066. export var harmonicsFunctions: {
  53067. name: string;
  53068. shader: string;
  53069. };
  53070. }
  53071. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53072. /** @hidden */
  53073. export var pbrDirectLightingSetupFunctions: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53079. /** @hidden */
  53080. export var pbrDirectLightingFalloffFunctions: {
  53081. name: string;
  53082. shader: string;
  53083. };
  53084. }
  53085. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53086. /** @hidden */
  53087. export var pbrBRDFFunctions: {
  53088. name: string;
  53089. shader: string;
  53090. };
  53091. }
  53092. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53093. /** @hidden */
  53094. export var pbrDirectLightingFunctions: {
  53095. name: string;
  53096. shader: string;
  53097. };
  53098. }
  53099. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53100. /** @hidden */
  53101. export var pbrIBLFunctions: {
  53102. name: string;
  53103. shader: string;
  53104. };
  53105. }
  53106. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53107. /** @hidden */
  53108. export var pbrDebug: {
  53109. name: string;
  53110. shader: string;
  53111. };
  53112. }
  53113. declare module "babylonjs/Shaders/pbr.fragment" {
  53114. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53115. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53116. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53117. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53118. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53119. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53120. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53122. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53123. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53124. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53125. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53126. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53127. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53128. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53129. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53130. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53131. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53132. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53133. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53134. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53135. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53136. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53137. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53138. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53139. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53140. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53141. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53142. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53143. /** @hidden */
  53144. export var pbrPixelShader: {
  53145. name: string;
  53146. shader: string;
  53147. };
  53148. }
  53149. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53150. /** @hidden */
  53151. export var pbrVertexDeclaration: {
  53152. name: string;
  53153. shader: string;
  53154. };
  53155. }
  53156. declare module "babylonjs/Shaders/pbr.vertex" {
  53157. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53158. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53160. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53161. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53162. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53163. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53164. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53165. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53166. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53167. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53168. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53169. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53170. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53172. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53173. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53174. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53175. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53176. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53177. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53178. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53179. /** @hidden */
  53180. export var pbrVertexShader: {
  53181. name: string;
  53182. shader: string;
  53183. };
  53184. }
  53185. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53186. import { Nullable } from "babylonjs/types";
  53187. import { Scene } from "babylonjs/scene";
  53188. import { Matrix } from "babylonjs/Maths/math.vector";
  53189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53191. import { Mesh } from "babylonjs/Meshes/mesh";
  53192. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53193. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53194. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53195. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53196. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53197. import { Color3 } from "babylonjs/Maths/math.color";
  53198. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53199. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53200. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53201. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53203. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53204. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53205. import "babylonjs/Shaders/pbr.fragment";
  53206. import "babylonjs/Shaders/pbr.vertex";
  53207. /**
  53208. * Manages the defines for the PBR Material.
  53209. * @hidden
  53210. */
  53211. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53212. PBR: boolean;
  53213. MAINUV1: boolean;
  53214. MAINUV2: boolean;
  53215. UV1: boolean;
  53216. UV2: boolean;
  53217. ALBEDO: boolean;
  53218. ALBEDODIRECTUV: number;
  53219. VERTEXCOLOR: boolean;
  53220. AMBIENT: boolean;
  53221. AMBIENTDIRECTUV: number;
  53222. AMBIENTINGRAYSCALE: boolean;
  53223. OPACITY: boolean;
  53224. VERTEXALPHA: boolean;
  53225. OPACITYDIRECTUV: number;
  53226. OPACITYRGB: boolean;
  53227. ALPHATEST: boolean;
  53228. DEPTHPREPASS: boolean;
  53229. ALPHABLEND: boolean;
  53230. ALPHAFROMALBEDO: boolean;
  53231. ALPHATESTVALUE: string;
  53232. SPECULAROVERALPHA: boolean;
  53233. RADIANCEOVERALPHA: boolean;
  53234. ALPHAFRESNEL: boolean;
  53235. LINEARALPHAFRESNEL: boolean;
  53236. PREMULTIPLYALPHA: boolean;
  53237. EMISSIVE: boolean;
  53238. EMISSIVEDIRECTUV: number;
  53239. REFLECTIVITY: boolean;
  53240. REFLECTIVITYDIRECTUV: number;
  53241. SPECULARTERM: boolean;
  53242. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53243. MICROSURFACEAUTOMATIC: boolean;
  53244. LODBASEDMICROSFURACE: boolean;
  53245. MICROSURFACEMAP: boolean;
  53246. MICROSURFACEMAPDIRECTUV: number;
  53247. METALLICWORKFLOW: boolean;
  53248. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53249. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53250. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53251. AOSTOREINMETALMAPRED: boolean;
  53252. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53253. ENVIRONMENTBRDF: boolean;
  53254. ENVIRONMENTBRDF_RGBD: boolean;
  53255. NORMAL: boolean;
  53256. TANGENT: boolean;
  53257. BUMP: boolean;
  53258. BUMPDIRECTUV: number;
  53259. OBJECTSPACE_NORMALMAP: boolean;
  53260. PARALLAX: boolean;
  53261. PARALLAXOCCLUSION: boolean;
  53262. NORMALXYSCALE: boolean;
  53263. LIGHTMAP: boolean;
  53264. LIGHTMAPDIRECTUV: number;
  53265. USELIGHTMAPASSHADOWMAP: boolean;
  53266. GAMMALIGHTMAP: boolean;
  53267. RGBDLIGHTMAP: boolean;
  53268. REFLECTION: boolean;
  53269. REFLECTIONMAP_3D: boolean;
  53270. REFLECTIONMAP_SPHERICAL: boolean;
  53271. REFLECTIONMAP_PLANAR: boolean;
  53272. REFLECTIONMAP_CUBIC: boolean;
  53273. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53274. REFLECTIONMAP_PROJECTION: boolean;
  53275. REFLECTIONMAP_SKYBOX: boolean;
  53276. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53277. REFLECTIONMAP_EXPLICIT: boolean;
  53278. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53279. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53280. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53281. INVERTCUBICMAP: boolean;
  53282. USESPHERICALFROMREFLECTIONMAP: boolean;
  53283. USEIRRADIANCEMAP: boolean;
  53284. SPHERICAL_HARMONICS: boolean;
  53285. USESPHERICALINVERTEX: boolean;
  53286. REFLECTIONMAP_OPPOSITEZ: boolean;
  53287. LODINREFLECTIONALPHA: boolean;
  53288. GAMMAREFLECTION: boolean;
  53289. RGBDREFLECTION: boolean;
  53290. LINEARSPECULARREFLECTION: boolean;
  53291. RADIANCEOCCLUSION: boolean;
  53292. HORIZONOCCLUSION: boolean;
  53293. INSTANCES: boolean;
  53294. NUM_BONE_INFLUENCERS: number;
  53295. BonesPerMesh: number;
  53296. BONETEXTURE: boolean;
  53297. NONUNIFORMSCALING: boolean;
  53298. MORPHTARGETS: boolean;
  53299. MORPHTARGETS_NORMAL: boolean;
  53300. MORPHTARGETS_TANGENT: boolean;
  53301. MORPHTARGETS_UV: boolean;
  53302. NUM_MORPH_INFLUENCERS: number;
  53303. IMAGEPROCESSING: boolean;
  53304. VIGNETTE: boolean;
  53305. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53306. VIGNETTEBLENDMODEOPAQUE: boolean;
  53307. TONEMAPPING: boolean;
  53308. TONEMAPPING_ACES: boolean;
  53309. CONTRAST: boolean;
  53310. COLORCURVES: boolean;
  53311. COLORGRADING: boolean;
  53312. COLORGRADING3D: boolean;
  53313. SAMPLER3DGREENDEPTH: boolean;
  53314. SAMPLER3DBGRMAP: boolean;
  53315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53316. EXPOSURE: boolean;
  53317. MULTIVIEW: boolean;
  53318. USEPHYSICALLIGHTFALLOFF: boolean;
  53319. USEGLTFLIGHTFALLOFF: boolean;
  53320. TWOSIDEDLIGHTING: boolean;
  53321. SHADOWFLOAT: boolean;
  53322. CLIPPLANE: boolean;
  53323. CLIPPLANE2: boolean;
  53324. CLIPPLANE3: boolean;
  53325. CLIPPLANE4: boolean;
  53326. CLIPPLANE5: boolean;
  53327. CLIPPLANE6: boolean;
  53328. POINTSIZE: boolean;
  53329. FOG: boolean;
  53330. LOGARITHMICDEPTH: boolean;
  53331. FORCENORMALFORWARD: boolean;
  53332. SPECULARAA: boolean;
  53333. CLEARCOAT: boolean;
  53334. CLEARCOAT_DEFAULTIOR: boolean;
  53335. CLEARCOAT_TEXTURE: boolean;
  53336. CLEARCOAT_TEXTUREDIRECTUV: number;
  53337. CLEARCOAT_BUMP: boolean;
  53338. CLEARCOAT_BUMPDIRECTUV: number;
  53339. CLEARCOAT_TINT: boolean;
  53340. CLEARCOAT_TINT_TEXTURE: boolean;
  53341. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53342. ANISOTROPIC: boolean;
  53343. ANISOTROPIC_TEXTURE: boolean;
  53344. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53345. BRDF_V_HEIGHT_CORRELATED: boolean;
  53346. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53347. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53348. SHEEN: boolean;
  53349. SHEEN_TEXTURE: boolean;
  53350. SHEEN_TEXTUREDIRECTUV: number;
  53351. SHEEN_LINKWITHALBEDO: boolean;
  53352. SUBSURFACE: boolean;
  53353. SS_REFRACTION: boolean;
  53354. SS_TRANSLUCENCY: boolean;
  53355. SS_SCATERRING: boolean;
  53356. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53357. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53358. SS_REFRACTIONMAP_3D: boolean;
  53359. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53360. SS_LODINREFRACTIONALPHA: boolean;
  53361. SS_GAMMAREFRACTION: boolean;
  53362. SS_RGBDREFRACTION: boolean;
  53363. SS_LINEARSPECULARREFRACTION: boolean;
  53364. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53365. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53366. UNLIT: boolean;
  53367. DEBUGMODE: number;
  53368. /**
  53369. * Initializes the PBR Material defines.
  53370. */
  53371. constructor();
  53372. /**
  53373. * Resets the PBR Material defines.
  53374. */
  53375. reset(): void;
  53376. }
  53377. /**
  53378. * The Physically based material base class of BJS.
  53379. *
  53380. * This offers the main features of a standard PBR material.
  53381. * For more information, please refer to the documentation :
  53382. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53383. */
  53384. export abstract class PBRBaseMaterial extends PushMaterial {
  53385. /**
  53386. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53387. */
  53388. static readonly PBRMATERIAL_OPAQUE: number;
  53389. /**
  53390. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53391. */
  53392. static readonly PBRMATERIAL_ALPHATEST: number;
  53393. /**
  53394. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53395. */
  53396. static readonly PBRMATERIAL_ALPHABLEND: number;
  53397. /**
  53398. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53399. * They are also discarded below the alpha cutoff threshold to improve performances.
  53400. */
  53401. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53402. /**
  53403. * Defines the default value of how much AO map is occluding the analytical lights
  53404. * (point spot...).
  53405. */
  53406. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53407. /**
  53408. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53409. */
  53410. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53411. /**
  53412. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53413. * to enhance interoperability with other engines.
  53414. */
  53415. static readonly LIGHTFALLOFF_GLTF: number;
  53416. /**
  53417. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53418. * to enhance interoperability with other materials.
  53419. */
  53420. static readonly LIGHTFALLOFF_STANDARD: number;
  53421. /**
  53422. * Intensity of the direct lights e.g. the four lights available in your scene.
  53423. * This impacts both the direct diffuse and specular highlights.
  53424. */
  53425. protected _directIntensity: number;
  53426. /**
  53427. * Intensity of the emissive part of the material.
  53428. * This helps controlling the emissive effect without modifying the emissive color.
  53429. */
  53430. protected _emissiveIntensity: number;
  53431. /**
  53432. * Intensity of the environment e.g. how much the environment will light the object
  53433. * either through harmonics for rough material or through the refelction for shiny ones.
  53434. */
  53435. protected _environmentIntensity: number;
  53436. /**
  53437. * This is a special control allowing the reduction of the specular highlights coming from the
  53438. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53439. */
  53440. protected _specularIntensity: number;
  53441. /**
  53442. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53443. */
  53444. private _lightingInfos;
  53445. /**
  53446. * Debug Control allowing disabling the bump map on this material.
  53447. */
  53448. protected _disableBumpMap: boolean;
  53449. /**
  53450. * AKA Diffuse Texture in standard nomenclature.
  53451. */
  53452. protected _albedoTexture: Nullable<BaseTexture>;
  53453. /**
  53454. * AKA Occlusion Texture in other nomenclature.
  53455. */
  53456. protected _ambientTexture: Nullable<BaseTexture>;
  53457. /**
  53458. * AKA Occlusion Texture Intensity in other nomenclature.
  53459. */
  53460. protected _ambientTextureStrength: number;
  53461. /**
  53462. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53463. * 1 means it completely occludes it
  53464. * 0 mean it has no impact
  53465. */
  53466. protected _ambientTextureImpactOnAnalyticalLights: number;
  53467. /**
  53468. * Stores the alpha values in a texture.
  53469. */
  53470. protected _opacityTexture: Nullable<BaseTexture>;
  53471. /**
  53472. * Stores the reflection values in a texture.
  53473. */
  53474. protected _reflectionTexture: Nullable<BaseTexture>;
  53475. /**
  53476. * Stores the emissive values in a texture.
  53477. */
  53478. protected _emissiveTexture: Nullable<BaseTexture>;
  53479. /**
  53480. * AKA Specular texture in other nomenclature.
  53481. */
  53482. protected _reflectivityTexture: Nullable<BaseTexture>;
  53483. /**
  53484. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53485. */
  53486. protected _metallicTexture: Nullable<BaseTexture>;
  53487. /**
  53488. * Specifies the metallic scalar of the metallic/roughness workflow.
  53489. * Can also be used to scale the metalness values of the metallic texture.
  53490. */
  53491. protected _metallic: Nullable<number>;
  53492. /**
  53493. * Specifies the roughness scalar of the metallic/roughness workflow.
  53494. * Can also be used to scale the roughness values of the metallic texture.
  53495. */
  53496. protected _roughness: Nullable<number>;
  53497. /**
  53498. * Specifies the an F0 factor to help configuring the material F0.
  53499. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53500. * to 0.5 the previously hard coded value stays the same.
  53501. * Can also be used to scale the F0 values of the metallic texture.
  53502. */
  53503. protected _metallicF0Factor: number;
  53504. /**
  53505. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53506. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53507. * your expectation as it multiplies with the texture data.
  53508. */
  53509. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53510. /**
  53511. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53512. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53513. */
  53514. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53515. /**
  53516. * Stores surface normal data used to displace a mesh in a texture.
  53517. */
  53518. protected _bumpTexture: Nullable<BaseTexture>;
  53519. /**
  53520. * Stores the pre-calculated light information of a mesh in a texture.
  53521. */
  53522. protected _lightmapTexture: Nullable<BaseTexture>;
  53523. /**
  53524. * The color of a material in ambient lighting.
  53525. */
  53526. protected _ambientColor: Color3;
  53527. /**
  53528. * AKA Diffuse Color in other nomenclature.
  53529. */
  53530. protected _albedoColor: Color3;
  53531. /**
  53532. * AKA Specular Color in other nomenclature.
  53533. */
  53534. protected _reflectivityColor: Color3;
  53535. /**
  53536. * The color applied when light is reflected from a material.
  53537. */
  53538. protected _reflectionColor: Color3;
  53539. /**
  53540. * The color applied when light is emitted from a material.
  53541. */
  53542. protected _emissiveColor: Color3;
  53543. /**
  53544. * AKA Glossiness in other nomenclature.
  53545. */
  53546. protected _microSurface: number;
  53547. /**
  53548. * Specifies that the material will use the light map as a show map.
  53549. */
  53550. protected _useLightmapAsShadowmap: boolean;
  53551. /**
  53552. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53553. * makes the reflect vector face the model (under horizon).
  53554. */
  53555. protected _useHorizonOcclusion: boolean;
  53556. /**
  53557. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53558. * too much the area relying on ambient texture to define their ambient occlusion.
  53559. */
  53560. protected _useRadianceOcclusion: boolean;
  53561. /**
  53562. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53563. */
  53564. protected _useAlphaFromAlbedoTexture: boolean;
  53565. /**
  53566. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53567. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53568. */
  53569. protected _useSpecularOverAlpha: boolean;
  53570. /**
  53571. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53572. */
  53573. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53574. /**
  53575. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53576. */
  53577. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53578. /**
  53579. * Specifies if the metallic texture contains the roughness information in its green channel.
  53580. */
  53581. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53582. /**
  53583. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53584. */
  53585. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53586. /**
  53587. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53588. */
  53589. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53590. /**
  53591. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53592. */
  53593. protected _useAmbientInGrayScale: boolean;
  53594. /**
  53595. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53596. * The material will try to infer what glossiness each pixel should be.
  53597. */
  53598. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53599. /**
  53600. * Defines the falloff type used in this material.
  53601. * It by default is Physical.
  53602. */
  53603. protected _lightFalloff: number;
  53604. /**
  53605. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53606. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53607. */
  53608. protected _useRadianceOverAlpha: boolean;
  53609. /**
  53610. * Allows using an object space normal map (instead of tangent space).
  53611. */
  53612. protected _useObjectSpaceNormalMap: boolean;
  53613. /**
  53614. * Allows using the bump map in parallax mode.
  53615. */
  53616. protected _useParallax: boolean;
  53617. /**
  53618. * Allows using the bump map in parallax occlusion mode.
  53619. */
  53620. protected _useParallaxOcclusion: boolean;
  53621. /**
  53622. * Controls the scale bias of the parallax mode.
  53623. */
  53624. protected _parallaxScaleBias: number;
  53625. /**
  53626. * If sets to true, disables all the lights affecting the material.
  53627. */
  53628. protected _disableLighting: boolean;
  53629. /**
  53630. * Number of Simultaneous lights allowed on the material.
  53631. */
  53632. protected _maxSimultaneousLights: number;
  53633. /**
  53634. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53635. */
  53636. protected _invertNormalMapX: boolean;
  53637. /**
  53638. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53639. */
  53640. protected _invertNormalMapY: boolean;
  53641. /**
  53642. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53643. */
  53644. protected _twoSidedLighting: boolean;
  53645. /**
  53646. * Defines the alpha limits in alpha test mode.
  53647. */
  53648. protected _alphaCutOff: number;
  53649. /**
  53650. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53651. */
  53652. protected _forceAlphaTest: boolean;
  53653. /**
  53654. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53655. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53656. */
  53657. protected _useAlphaFresnel: boolean;
  53658. /**
  53659. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53660. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53661. */
  53662. protected _useLinearAlphaFresnel: boolean;
  53663. /**
  53664. * The transparency mode of the material.
  53665. */
  53666. protected _transparencyMode: Nullable<number>;
  53667. /**
  53668. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53669. * from cos thetav and roughness:
  53670. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53671. */
  53672. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53673. /**
  53674. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53675. */
  53676. protected _forceIrradianceInFragment: boolean;
  53677. /**
  53678. * Force normal to face away from face.
  53679. */
  53680. protected _forceNormalForward: boolean;
  53681. /**
  53682. * Enables specular anti aliasing in the PBR shader.
  53683. * It will both interacts on the Geometry for analytical and IBL lighting.
  53684. * It also prefilter the roughness map based on the bump values.
  53685. */
  53686. protected _enableSpecularAntiAliasing: boolean;
  53687. /**
  53688. * Default configuration related to image processing available in the PBR Material.
  53689. */
  53690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53691. /**
  53692. * Keep track of the image processing observer to allow dispose and replace.
  53693. */
  53694. private _imageProcessingObserver;
  53695. /**
  53696. * Attaches a new image processing configuration to the PBR Material.
  53697. * @param configuration
  53698. */
  53699. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53700. /**
  53701. * Stores the available render targets.
  53702. */
  53703. private _renderTargets;
  53704. /**
  53705. * Sets the global ambient color for the material used in lighting calculations.
  53706. */
  53707. private _globalAmbientColor;
  53708. /**
  53709. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53710. */
  53711. private _useLogarithmicDepth;
  53712. /**
  53713. * If set to true, no lighting calculations will be applied.
  53714. */
  53715. private _unlit;
  53716. private _debugMode;
  53717. /**
  53718. * @hidden
  53719. * This is reserved for the inspector.
  53720. * Defines the material debug mode.
  53721. * It helps seeing only some components of the material while troubleshooting.
  53722. */
  53723. debugMode: number;
  53724. /**
  53725. * @hidden
  53726. * This is reserved for the inspector.
  53727. * Specify from where on screen the debug mode should start.
  53728. * The value goes from -1 (full screen) to 1 (not visible)
  53729. * It helps with side by side comparison against the final render
  53730. * This defaults to -1
  53731. */
  53732. private debugLimit;
  53733. /**
  53734. * @hidden
  53735. * This is reserved for the inspector.
  53736. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53737. * You can use the factor to better multiply the final value.
  53738. */
  53739. private debugFactor;
  53740. /**
  53741. * Defines the clear coat layer parameters for the material.
  53742. */
  53743. readonly clearCoat: PBRClearCoatConfiguration;
  53744. /**
  53745. * Defines the anisotropic parameters for the material.
  53746. */
  53747. readonly anisotropy: PBRAnisotropicConfiguration;
  53748. /**
  53749. * Defines the BRDF parameters for the material.
  53750. */
  53751. readonly brdf: PBRBRDFConfiguration;
  53752. /**
  53753. * Defines the Sheen parameters for the material.
  53754. */
  53755. readonly sheen: PBRSheenConfiguration;
  53756. /**
  53757. * Defines the SubSurface parameters for the material.
  53758. */
  53759. readonly subSurface: PBRSubSurfaceConfiguration;
  53760. /**
  53761. * Custom callback helping to override the default shader used in the material.
  53762. */
  53763. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53764. protected _rebuildInParallel: boolean;
  53765. /**
  53766. * Instantiates a new PBRMaterial instance.
  53767. *
  53768. * @param name The material name
  53769. * @param scene The scene the material will be use in.
  53770. */
  53771. constructor(name: string, scene: Scene);
  53772. /**
  53773. * Gets a boolean indicating that current material needs to register RTT
  53774. */
  53775. get hasRenderTargetTextures(): boolean;
  53776. /**
  53777. * Gets the name of the material class.
  53778. */
  53779. getClassName(): string;
  53780. /**
  53781. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53782. */
  53783. get useLogarithmicDepth(): boolean;
  53784. /**
  53785. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53786. */
  53787. set useLogarithmicDepth(value: boolean);
  53788. /**
  53789. * Gets the current transparency mode.
  53790. */
  53791. get transparencyMode(): Nullable<number>;
  53792. /**
  53793. * Sets the transparency mode of the material.
  53794. *
  53795. * | Value | Type | Description |
  53796. * | ----- | ----------------------------------- | ----------- |
  53797. * | 0 | OPAQUE | |
  53798. * | 1 | ALPHATEST | |
  53799. * | 2 | ALPHABLEND | |
  53800. * | 3 | ALPHATESTANDBLEND | |
  53801. *
  53802. */
  53803. set transparencyMode(value: Nullable<number>);
  53804. /**
  53805. * Returns true if alpha blending should be disabled.
  53806. */
  53807. private get _disableAlphaBlending();
  53808. /**
  53809. * Specifies whether or not this material should be rendered in alpha blend mode.
  53810. */
  53811. needAlphaBlending(): boolean;
  53812. /**
  53813. * Specifies if the mesh will require alpha blending.
  53814. * @param mesh - BJS mesh.
  53815. */
  53816. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53817. /**
  53818. * Specifies whether or not this material should be rendered in alpha test mode.
  53819. */
  53820. needAlphaTesting(): boolean;
  53821. /**
  53822. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53823. */
  53824. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53825. /**
  53826. * Gets the texture used for the alpha test.
  53827. */
  53828. getAlphaTestTexture(): Nullable<BaseTexture>;
  53829. /**
  53830. * Specifies that the submesh is ready to be used.
  53831. * @param mesh - BJS mesh.
  53832. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53833. * @param useInstances - Specifies that instances should be used.
  53834. * @returns - boolean indicating that the submesh is ready or not.
  53835. */
  53836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53837. /**
  53838. * Specifies if the material uses metallic roughness workflow.
  53839. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53840. */
  53841. isMetallicWorkflow(): boolean;
  53842. private _prepareEffect;
  53843. private _prepareDefines;
  53844. /**
  53845. * Force shader compilation
  53846. */
  53847. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53848. /**
  53849. * Initializes the uniform buffer layout for the shader.
  53850. */
  53851. buildUniformLayout(): void;
  53852. /**
  53853. * Unbinds the material from the mesh
  53854. */
  53855. unbind(): void;
  53856. /**
  53857. * Binds the submesh data.
  53858. * @param world - The world matrix.
  53859. * @param mesh - The BJS mesh.
  53860. * @param subMesh - A submesh of the BJS mesh.
  53861. */
  53862. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53863. /**
  53864. * Returns the animatable textures.
  53865. * @returns - Array of animatable textures.
  53866. */
  53867. getAnimatables(): IAnimatable[];
  53868. /**
  53869. * Returns the texture used for reflections.
  53870. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53871. */
  53872. private _getReflectionTexture;
  53873. /**
  53874. * Returns an array of the actively used textures.
  53875. * @returns - Array of BaseTextures
  53876. */
  53877. getActiveTextures(): BaseTexture[];
  53878. /**
  53879. * Checks to see if a texture is used in the material.
  53880. * @param texture - Base texture to use.
  53881. * @returns - Boolean specifying if a texture is used in the material.
  53882. */
  53883. hasTexture(texture: BaseTexture): boolean;
  53884. /**
  53885. * Disposes the resources of the material.
  53886. * @param forceDisposeEffect - Forces the disposal of effects.
  53887. * @param forceDisposeTextures - Forces the disposal of all textures.
  53888. */
  53889. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53890. }
  53891. }
  53892. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53893. import { Nullable } from "babylonjs/types";
  53894. import { Scene } from "babylonjs/scene";
  53895. import { Color3 } from "babylonjs/Maths/math.color";
  53896. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53897. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53899. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53900. /**
  53901. * The Physically based material of BJS.
  53902. *
  53903. * This offers the main features of a standard PBR material.
  53904. * For more information, please refer to the documentation :
  53905. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53906. */
  53907. export class PBRMaterial extends PBRBaseMaterial {
  53908. /**
  53909. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53910. */
  53911. static readonly PBRMATERIAL_OPAQUE: number;
  53912. /**
  53913. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53914. */
  53915. static readonly PBRMATERIAL_ALPHATEST: number;
  53916. /**
  53917. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53918. */
  53919. static readonly PBRMATERIAL_ALPHABLEND: number;
  53920. /**
  53921. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53922. * They are also discarded below the alpha cutoff threshold to improve performances.
  53923. */
  53924. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53925. /**
  53926. * Defines the default value of how much AO map is occluding the analytical lights
  53927. * (point spot...).
  53928. */
  53929. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53930. /**
  53931. * Intensity of the direct lights e.g. the four lights available in your scene.
  53932. * This impacts both the direct diffuse and specular highlights.
  53933. */
  53934. directIntensity: number;
  53935. /**
  53936. * Intensity of the emissive part of the material.
  53937. * This helps controlling the emissive effect without modifying the emissive color.
  53938. */
  53939. emissiveIntensity: number;
  53940. /**
  53941. * Intensity of the environment e.g. how much the environment will light the object
  53942. * either through harmonics for rough material or through the refelction for shiny ones.
  53943. */
  53944. environmentIntensity: number;
  53945. /**
  53946. * This is a special control allowing the reduction of the specular highlights coming from the
  53947. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53948. */
  53949. specularIntensity: number;
  53950. /**
  53951. * Debug Control allowing disabling the bump map on this material.
  53952. */
  53953. disableBumpMap: boolean;
  53954. /**
  53955. * AKA Diffuse Texture in standard nomenclature.
  53956. */
  53957. albedoTexture: BaseTexture;
  53958. /**
  53959. * AKA Occlusion Texture in other nomenclature.
  53960. */
  53961. ambientTexture: BaseTexture;
  53962. /**
  53963. * AKA Occlusion Texture Intensity in other nomenclature.
  53964. */
  53965. ambientTextureStrength: number;
  53966. /**
  53967. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53968. * 1 means it completely occludes it
  53969. * 0 mean it has no impact
  53970. */
  53971. ambientTextureImpactOnAnalyticalLights: number;
  53972. /**
  53973. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53974. */
  53975. opacityTexture: BaseTexture;
  53976. /**
  53977. * Stores the reflection values in a texture.
  53978. */
  53979. reflectionTexture: Nullable<BaseTexture>;
  53980. /**
  53981. * Stores the emissive values in a texture.
  53982. */
  53983. emissiveTexture: BaseTexture;
  53984. /**
  53985. * AKA Specular texture in other nomenclature.
  53986. */
  53987. reflectivityTexture: BaseTexture;
  53988. /**
  53989. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53990. */
  53991. metallicTexture: BaseTexture;
  53992. /**
  53993. * Specifies the metallic scalar of the metallic/roughness workflow.
  53994. * Can also be used to scale the metalness values of the metallic texture.
  53995. */
  53996. metallic: Nullable<number>;
  53997. /**
  53998. * Specifies the roughness scalar of the metallic/roughness workflow.
  53999. * Can also be used to scale the roughness values of the metallic texture.
  54000. */
  54001. roughness: Nullable<number>;
  54002. /**
  54003. * Specifies the an F0 factor to help configuring the material F0.
  54004. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54005. * to 0.5 the previously hard coded value stays the same.
  54006. * Can also be used to scale the F0 values of the metallic texture.
  54007. */
  54008. metallicF0Factor: number;
  54009. /**
  54010. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54011. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54012. * your expectation as it multiplies with the texture data.
  54013. */
  54014. useMetallicF0FactorFromMetallicTexture: boolean;
  54015. /**
  54016. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54017. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54018. */
  54019. microSurfaceTexture: BaseTexture;
  54020. /**
  54021. * Stores surface normal data used to displace a mesh in a texture.
  54022. */
  54023. bumpTexture: BaseTexture;
  54024. /**
  54025. * Stores the pre-calculated light information of a mesh in a texture.
  54026. */
  54027. lightmapTexture: BaseTexture;
  54028. /**
  54029. * Stores the refracted light information in a texture.
  54030. */
  54031. get refractionTexture(): Nullable<BaseTexture>;
  54032. set refractionTexture(value: Nullable<BaseTexture>);
  54033. /**
  54034. * The color of a material in ambient lighting.
  54035. */
  54036. ambientColor: Color3;
  54037. /**
  54038. * AKA Diffuse Color in other nomenclature.
  54039. */
  54040. albedoColor: Color3;
  54041. /**
  54042. * AKA Specular Color in other nomenclature.
  54043. */
  54044. reflectivityColor: Color3;
  54045. /**
  54046. * The color reflected from the material.
  54047. */
  54048. reflectionColor: Color3;
  54049. /**
  54050. * The color emitted from the material.
  54051. */
  54052. emissiveColor: Color3;
  54053. /**
  54054. * AKA Glossiness in other nomenclature.
  54055. */
  54056. microSurface: number;
  54057. /**
  54058. * source material index of refraction (IOR)' / 'destination material IOR.
  54059. */
  54060. get indexOfRefraction(): number;
  54061. set indexOfRefraction(value: number);
  54062. /**
  54063. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54064. */
  54065. get invertRefractionY(): boolean;
  54066. set invertRefractionY(value: boolean);
  54067. /**
  54068. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54069. * Materials half opaque for instance using refraction could benefit from this control.
  54070. */
  54071. get linkRefractionWithTransparency(): boolean;
  54072. set linkRefractionWithTransparency(value: boolean);
  54073. /**
  54074. * If true, the light map contains occlusion information instead of lighting info.
  54075. */
  54076. useLightmapAsShadowmap: boolean;
  54077. /**
  54078. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54079. */
  54080. useAlphaFromAlbedoTexture: boolean;
  54081. /**
  54082. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54083. */
  54084. forceAlphaTest: boolean;
  54085. /**
  54086. * Defines the alpha limits in alpha test mode.
  54087. */
  54088. alphaCutOff: number;
  54089. /**
  54090. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54091. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54092. */
  54093. useSpecularOverAlpha: boolean;
  54094. /**
  54095. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54096. */
  54097. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54098. /**
  54099. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54100. */
  54101. useRoughnessFromMetallicTextureAlpha: boolean;
  54102. /**
  54103. * Specifies if the metallic texture contains the roughness information in its green channel.
  54104. */
  54105. useRoughnessFromMetallicTextureGreen: boolean;
  54106. /**
  54107. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54108. */
  54109. useMetallnessFromMetallicTextureBlue: boolean;
  54110. /**
  54111. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54112. */
  54113. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54114. /**
  54115. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54116. */
  54117. useAmbientInGrayScale: boolean;
  54118. /**
  54119. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54120. * The material will try to infer what glossiness each pixel should be.
  54121. */
  54122. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54123. /**
  54124. * BJS is using an harcoded light falloff based on a manually sets up range.
  54125. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54126. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54127. */
  54128. get usePhysicalLightFalloff(): boolean;
  54129. /**
  54130. * BJS is using an harcoded light falloff based on a manually sets up range.
  54131. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54132. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54133. */
  54134. set usePhysicalLightFalloff(value: boolean);
  54135. /**
  54136. * In order to support the falloff compatibility with gltf, a special mode has been added
  54137. * to reproduce the gltf light falloff.
  54138. */
  54139. get useGLTFLightFalloff(): boolean;
  54140. /**
  54141. * In order to support the falloff compatibility with gltf, a special mode has been added
  54142. * to reproduce the gltf light falloff.
  54143. */
  54144. set useGLTFLightFalloff(value: boolean);
  54145. /**
  54146. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54147. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54148. */
  54149. useRadianceOverAlpha: boolean;
  54150. /**
  54151. * Allows using an object space normal map (instead of tangent space).
  54152. */
  54153. useObjectSpaceNormalMap: boolean;
  54154. /**
  54155. * Allows using the bump map in parallax mode.
  54156. */
  54157. useParallax: boolean;
  54158. /**
  54159. * Allows using the bump map in parallax occlusion mode.
  54160. */
  54161. useParallaxOcclusion: boolean;
  54162. /**
  54163. * Controls the scale bias of the parallax mode.
  54164. */
  54165. parallaxScaleBias: number;
  54166. /**
  54167. * If sets to true, disables all the lights affecting the material.
  54168. */
  54169. disableLighting: boolean;
  54170. /**
  54171. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54172. */
  54173. forceIrradianceInFragment: boolean;
  54174. /**
  54175. * Number of Simultaneous lights allowed on the material.
  54176. */
  54177. maxSimultaneousLights: number;
  54178. /**
  54179. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54180. */
  54181. invertNormalMapX: boolean;
  54182. /**
  54183. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54184. */
  54185. invertNormalMapY: boolean;
  54186. /**
  54187. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54188. */
  54189. twoSidedLighting: boolean;
  54190. /**
  54191. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54192. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54193. */
  54194. useAlphaFresnel: boolean;
  54195. /**
  54196. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54197. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54198. */
  54199. useLinearAlphaFresnel: boolean;
  54200. /**
  54201. * Let user defines the brdf lookup texture used for IBL.
  54202. * A default 8bit version is embedded but you could point at :
  54203. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54204. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54205. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54206. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54207. */
  54208. environmentBRDFTexture: Nullable<BaseTexture>;
  54209. /**
  54210. * Force normal to face away from face.
  54211. */
  54212. forceNormalForward: boolean;
  54213. /**
  54214. * Enables specular anti aliasing in the PBR shader.
  54215. * It will both interacts on the Geometry for analytical and IBL lighting.
  54216. * It also prefilter the roughness map based on the bump values.
  54217. */
  54218. enableSpecularAntiAliasing: boolean;
  54219. /**
  54220. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54221. * makes the reflect vector face the model (under horizon).
  54222. */
  54223. useHorizonOcclusion: boolean;
  54224. /**
  54225. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54226. * too much the area relying on ambient texture to define their ambient occlusion.
  54227. */
  54228. useRadianceOcclusion: boolean;
  54229. /**
  54230. * If set to true, no lighting calculations will be applied.
  54231. */
  54232. unlit: boolean;
  54233. /**
  54234. * Gets the image processing configuration used either in this material.
  54235. */
  54236. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54237. /**
  54238. * Sets the Default image processing configuration used either in the this material.
  54239. *
  54240. * If sets to null, the scene one is in use.
  54241. */
  54242. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54243. /**
  54244. * Gets wether the color curves effect is enabled.
  54245. */
  54246. get cameraColorCurvesEnabled(): boolean;
  54247. /**
  54248. * Sets wether the color curves effect is enabled.
  54249. */
  54250. set cameraColorCurvesEnabled(value: boolean);
  54251. /**
  54252. * Gets wether the color grading effect is enabled.
  54253. */
  54254. get cameraColorGradingEnabled(): boolean;
  54255. /**
  54256. * Gets wether the color grading effect is enabled.
  54257. */
  54258. set cameraColorGradingEnabled(value: boolean);
  54259. /**
  54260. * Gets wether tonemapping is enabled or not.
  54261. */
  54262. get cameraToneMappingEnabled(): boolean;
  54263. /**
  54264. * Sets wether tonemapping is enabled or not
  54265. */
  54266. set cameraToneMappingEnabled(value: boolean);
  54267. /**
  54268. * The camera exposure used on this material.
  54269. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54270. * This corresponds to a photographic exposure.
  54271. */
  54272. get cameraExposure(): number;
  54273. /**
  54274. * The camera exposure used on this material.
  54275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54276. * This corresponds to a photographic exposure.
  54277. */
  54278. set cameraExposure(value: number);
  54279. /**
  54280. * Gets The camera contrast used on this material.
  54281. */
  54282. get cameraContrast(): number;
  54283. /**
  54284. * Sets The camera contrast used on this material.
  54285. */
  54286. set cameraContrast(value: number);
  54287. /**
  54288. * Gets the Color Grading 2D Lookup Texture.
  54289. */
  54290. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54291. /**
  54292. * Sets the Color Grading 2D Lookup Texture.
  54293. */
  54294. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54295. /**
  54296. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54297. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54298. * 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;
  54299. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54300. */
  54301. get cameraColorCurves(): Nullable<ColorCurves>;
  54302. /**
  54303. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54304. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54305. * 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;
  54306. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54307. */
  54308. set cameraColorCurves(value: Nullable<ColorCurves>);
  54309. /**
  54310. * Instantiates a new PBRMaterial instance.
  54311. *
  54312. * @param name The material name
  54313. * @param scene The scene the material will be use in.
  54314. */
  54315. constructor(name: string, scene: Scene);
  54316. /**
  54317. * Returns the name of this material class.
  54318. */
  54319. getClassName(): string;
  54320. /**
  54321. * Makes a duplicate of the current material.
  54322. * @param name - name to use for the new material.
  54323. */
  54324. clone(name: string): PBRMaterial;
  54325. /**
  54326. * Serializes this PBR Material.
  54327. * @returns - An object with the serialized material.
  54328. */
  54329. serialize(): any;
  54330. /**
  54331. * Parses a PBR Material from a serialized object.
  54332. * @param source - Serialized object.
  54333. * @param scene - BJS scene instance.
  54334. * @param rootUrl - url for the scene object
  54335. * @returns - PBRMaterial
  54336. */
  54337. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54338. }
  54339. }
  54340. declare module "babylonjs/Misc/dds" {
  54341. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54343. import { Nullable } from "babylonjs/types";
  54344. import { Scene } from "babylonjs/scene";
  54345. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54346. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54347. /**
  54348. * Direct draw surface info
  54349. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54350. */
  54351. export interface DDSInfo {
  54352. /**
  54353. * Width of the texture
  54354. */
  54355. width: number;
  54356. /**
  54357. * Width of the texture
  54358. */
  54359. height: number;
  54360. /**
  54361. * Number of Mipmaps for the texture
  54362. * @see https://en.wikipedia.org/wiki/Mipmap
  54363. */
  54364. mipmapCount: number;
  54365. /**
  54366. * If the textures format is a known fourCC format
  54367. * @see https://www.fourcc.org/
  54368. */
  54369. isFourCC: boolean;
  54370. /**
  54371. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54372. */
  54373. isRGB: boolean;
  54374. /**
  54375. * If the texture is a lumincance format
  54376. */
  54377. isLuminance: boolean;
  54378. /**
  54379. * If this is a cube texture
  54380. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54381. */
  54382. isCube: boolean;
  54383. /**
  54384. * If the texture is a compressed format eg. FOURCC_DXT1
  54385. */
  54386. isCompressed: boolean;
  54387. /**
  54388. * The dxgiFormat of the texture
  54389. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54390. */
  54391. dxgiFormat: number;
  54392. /**
  54393. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54394. */
  54395. textureType: number;
  54396. /**
  54397. * Sphericle polynomial created for the dds texture
  54398. */
  54399. sphericalPolynomial?: SphericalPolynomial;
  54400. }
  54401. /**
  54402. * Class used to provide DDS decompression tools
  54403. */
  54404. export class DDSTools {
  54405. /**
  54406. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54407. */
  54408. static StoreLODInAlphaChannel: boolean;
  54409. /**
  54410. * Gets DDS information from an array buffer
  54411. * @param arrayBuffer defines the array buffer to read data from
  54412. * @returns the DDS information
  54413. */
  54414. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  54415. private static _FloatView;
  54416. private static _Int32View;
  54417. private static _ToHalfFloat;
  54418. private static _FromHalfFloat;
  54419. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54420. private static _GetHalfFloatRGBAArrayBuffer;
  54421. private static _GetFloatRGBAArrayBuffer;
  54422. private static _GetFloatAsUIntRGBAArrayBuffer;
  54423. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54424. private static _GetRGBAArrayBuffer;
  54425. private static _ExtractLongWordOrder;
  54426. private static _GetRGBArrayBuffer;
  54427. private static _GetLuminanceArrayBuffer;
  54428. /**
  54429. * Uploads DDS Levels to a Babylon Texture
  54430. * @hidden
  54431. */
  54432. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54433. }
  54434. module "babylonjs/Engines/thinEngine" {
  54435. interface ThinEngine {
  54436. /**
  54437. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54438. * @param rootUrl defines the url where the file to load is located
  54439. * @param scene defines the current scene
  54440. * @param lodScale defines scale to apply to the mip map selection
  54441. * @param lodOffset defines offset to apply to the mip map selection
  54442. * @param onLoad defines an optional callback raised when the texture is loaded
  54443. * @param onError defines an optional callback raised if there is an issue to load the texture
  54444. * @param format defines the format of the data
  54445. * @param forcedExtension defines the extension to use to pick the right loader
  54446. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54447. * @returns the cube texture as an InternalTexture
  54448. */
  54449. 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;
  54450. }
  54451. }
  54452. }
  54453. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54454. import { Nullable } from "babylonjs/types";
  54455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54456. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54457. /**
  54458. * Implementation of the DDS Texture Loader.
  54459. * @hidden
  54460. */
  54461. export class _DDSTextureLoader implements IInternalTextureLoader {
  54462. /**
  54463. * Defines wether the loader supports cascade loading the different faces.
  54464. */
  54465. readonly supportCascades: boolean;
  54466. /**
  54467. * This returns if the loader support the current file information.
  54468. * @param extension defines the file extension of the file being loaded
  54469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54470. * @param fallback defines the fallback internal texture if any
  54471. * @param isBase64 defines whether the texture is encoded as a base64
  54472. * @param isBuffer defines whether the texture data are stored as a buffer
  54473. * @returns true if the loader can load the specified file
  54474. */
  54475. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54476. /**
  54477. * Transform the url before loading if required.
  54478. * @param rootUrl the url of the texture
  54479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54480. * @returns the transformed texture
  54481. */
  54482. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54483. /**
  54484. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54485. * @param rootUrl the url of the texture
  54486. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54487. * @returns the fallback texture
  54488. */
  54489. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54490. /**
  54491. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54492. * @param data contains the texture data
  54493. * @param texture defines the BabylonJS internal texture
  54494. * @param createPolynomials will be true if polynomials have been requested
  54495. * @param onLoad defines the callback to trigger once the texture is ready
  54496. * @param onError defines the callback to trigger in case of error
  54497. */
  54498. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54499. /**
  54500. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54501. * @param data contains the texture data
  54502. * @param texture defines the BabylonJS internal texture
  54503. * @param callback defines the method to call once ready to upload
  54504. */
  54505. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54506. }
  54507. }
  54508. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54509. import { Nullable } from "babylonjs/types";
  54510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54511. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54512. /**
  54513. * Implementation of the ENV Texture Loader.
  54514. * @hidden
  54515. */
  54516. export class _ENVTextureLoader implements IInternalTextureLoader {
  54517. /**
  54518. * Defines wether the loader supports cascade loading the different faces.
  54519. */
  54520. readonly supportCascades: boolean;
  54521. /**
  54522. * This returns if the loader support the current file information.
  54523. * @param extension defines the file extension of the file being loaded
  54524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54525. * @param fallback defines the fallback internal texture if any
  54526. * @param isBase64 defines whether the texture is encoded as a base64
  54527. * @param isBuffer defines whether the texture data are stored as a buffer
  54528. * @returns true if the loader can load the specified file
  54529. */
  54530. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54531. /**
  54532. * Transform the url before loading if required.
  54533. * @param rootUrl the url of the texture
  54534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54535. * @returns the transformed texture
  54536. */
  54537. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54538. /**
  54539. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54540. * @param rootUrl the url of the texture
  54541. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54542. * @returns the fallback texture
  54543. */
  54544. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54545. /**
  54546. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54547. * @param data contains the texture data
  54548. * @param texture defines the BabylonJS internal texture
  54549. * @param createPolynomials will be true if polynomials have been requested
  54550. * @param onLoad defines the callback to trigger once the texture is ready
  54551. * @param onError defines the callback to trigger in case of error
  54552. */
  54553. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54554. /**
  54555. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54556. * @param data contains the texture data
  54557. * @param texture defines the BabylonJS internal texture
  54558. * @param callback defines the method to call once ready to upload
  54559. */
  54560. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54561. }
  54562. }
  54563. declare module "babylonjs/Misc/khronosTextureContainer" {
  54564. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54565. /**
  54566. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54567. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54568. */
  54569. export class KhronosTextureContainer {
  54570. /** contents of the KTX container file */
  54571. arrayBuffer: any;
  54572. private static HEADER_LEN;
  54573. private static COMPRESSED_2D;
  54574. private static COMPRESSED_3D;
  54575. private static TEX_2D;
  54576. private static TEX_3D;
  54577. /**
  54578. * Gets the openGL type
  54579. */
  54580. glType: number;
  54581. /**
  54582. * Gets the openGL type size
  54583. */
  54584. glTypeSize: number;
  54585. /**
  54586. * Gets the openGL format
  54587. */
  54588. glFormat: number;
  54589. /**
  54590. * Gets the openGL internal format
  54591. */
  54592. glInternalFormat: number;
  54593. /**
  54594. * Gets the base internal format
  54595. */
  54596. glBaseInternalFormat: number;
  54597. /**
  54598. * Gets image width in pixel
  54599. */
  54600. pixelWidth: number;
  54601. /**
  54602. * Gets image height in pixel
  54603. */
  54604. pixelHeight: number;
  54605. /**
  54606. * Gets image depth in pixels
  54607. */
  54608. pixelDepth: number;
  54609. /**
  54610. * Gets the number of array elements
  54611. */
  54612. numberOfArrayElements: number;
  54613. /**
  54614. * Gets the number of faces
  54615. */
  54616. numberOfFaces: number;
  54617. /**
  54618. * Gets the number of mipmap levels
  54619. */
  54620. numberOfMipmapLevels: number;
  54621. /**
  54622. * Gets the bytes of key value data
  54623. */
  54624. bytesOfKeyValueData: number;
  54625. /**
  54626. * Gets the load type
  54627. */
  54628. loadType: number;
  54629. /**
  54630. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54631. */
  54632. isInvalid: boolean;
  54633. /**
  54634. * Creates a new KhronosTextureContainer
  54635. * @param arrayBuffer contents of the KTX container file
  54636. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54637. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54638. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54639. */
  54640. constructor(
  54641. /** contents of the KTX container file */
  54642. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54643. /**
  54644. * Uploads KTX content to a Babylon Texture.
  54645. * It is assumed that the texture has already been created & is currently bound
  54646. * @hidden
  54647. */
  54648. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54649. private _upload2DCompressedLevels;
  54650. }
  54651. }
  54652. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54653. import { Nullable } from "babylonjs/types";
  54654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54655. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54656. /**
  54657. * Implementation of the KTX Texture Loader.
  54658. * @hidden
  54659. */
  54660. export class _KTXTextureLoader implements IInternalTextureLoader {
  54661. /**
  54662. * Defines wether the loader supports cascade loading the different faces.
  54663. */
  54664. readonly supportCascades: boolean;
  54665. /**
  54666. * This returns if the loader support the current file information.
  54667. * @param extension defines the file extension of the file being loaded
  54668. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54669. * @param fallback defines the fallback internal texture if any
  54670. * @param isBase64 defines whether the texture is encoded as a base64
  54671. * @param isBuffer defines whether the texture data are stored as a buffer
  54672. * @returns true if the loader can load the specified file
  54673. */
  54674. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54675. /**
  54676. * Transform the url before loading if required.
  54677. * @param rootUrl the url of the texture
  54678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54679. * @returns the transformed texture
  54680. */
  54681. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54682. /**
  54683. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54684. * @param rootUrl the url of the texture
  54685. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54686. * @returns the fallback texture
  54687. */
  54688. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54689. /**
  54690. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54691. * @param data contains the texture data
  54692. * @param texture defines the BabylonJS internal texture
  54693. * @param createPolynomials will be true if polynomials have been requested
  54694. * @param onLoad defines the callback to trigger once the texture is ready
  54695. * @param onError defines the callback to trigger in case of error
  54696. */
  54697. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54698. /**
  54699. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54700. * @param data contains the texture data
  54701. * @param texture defines the BabylonJS internal texture
  54702. * @param callback defines the method to call once ready to upload
  54703. */
  54704. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54705. }
  54706. }
  54707. declare module "babylonjs/Helpers/sceneHelpers" {
  54708. import { Nullable } from "babylonjs/types";
  54709. import { Mesh } from "babylonjs/Meshes/mesh";
  54710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54711. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54712. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54713. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54714. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54715. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54716. import "babylonjs/Meshes/Builders/boxBuilder";
  54717. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54718. /** @hidden */
  54719. export var _forceSceneHelpersToBundle: boolean;
  54720. module "babylonjs/scene" {
  54721. interface Scene {
  54722. /**
  54723. * Creates a default light for the scene.
  54724. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54725. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54726. */
  54727. createDefaultLight(replace?: boolean): void;
  54728. /**
  54729. * Creates a default camera for the scene.
  54730. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54731. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54732. * @param replace has default false, when true replaces the active camera in the scene
  54733. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54734. */
  54735. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54736. /**
  54737. * Creates a default camera and a default light.
  54738. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54739. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54740. * @param replace has the default false, when true replaces the active camera/light in the scene
  54741. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54742. */
  54743. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54744. /**
  54745. * Creates a new sky box
  54746. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54747. * @param environmentTexture defines the texture to use as environment texture
  54748. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54749. * @param scale defines the overall scale of the skybox
  54750. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54751. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54752. * @returns a new mesh holding the sky box
  54753. */
  54754. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54755. /**
  54756. * Creates a new environment
  54757. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54758. * @param options defines the options you can use to configure the environment
  54759. * @returns the new EnvironmentHelper
  54760. */
  54761. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54762. /**
  54763. * Creates a new VREXperienceHelper
  54764. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54765. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54766. * @returns a new VREXperienceHelper
  54767. */
  54768. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54769. /**
  54770. * Creates a new WebXRDefaultExperience
  54771. * @see http://doc.babylonjs.com/how_to/webxr
  54772. * @param options experience options
  54773. * @returns a promise for a new WebXRDefaultExperience
  54774. */
  54775. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54776. }
  54777. }
  54778. }
  54779. declare module "babylonjs/Helpers/videoDome" {
  54780. import { Scene } from "babylonjs/scene";
  54781. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54782. import { Mesh } from "babylonjs/Meshes/mesh";
  54783. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54784. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54785. import "babylonjs/Meshes/Builders/sphereBuilder";
  54786. /**
  54787. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54788. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54789. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54790. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54791. */
  54792. export class VideoDome extends TransformNode {
  54793. /**
  54794. * Define the video source as a Monoscopic panoramic 360 video.
  54795. */
  54796. static readonly MODE_MONOSCOPIC: number;
  54797. /**
  54798. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54799. */
  54800. static readonly MODE_TOPBOTTOM: number;
  54801. /**
  54802. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54803. */
  54804. static readonly MODE_SIDEBYSIDE: number;
  54805. private _halfDome;
  54806. private _useDirectMapping;
  54807. /**
  54808. * The video texture being displayed on the sphere
  54809. */
  54810. protected _videoTexture: VideoTexture;
  54811. /**
  54812. * Gets the video texture being displayed on the sphere
  54813. */
  54814. get videoTexture(): VideoTexture;
  54815. /**
  54816. * The skybox material
  54817. */
  54818. protected _material: BackgroundMaterial;
  54819. /**
  54820. * The surface used for the skybox
  54821. */
  54822. protected _mesh: Mesh;
  54823. /**
  54824. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54825. */
  54826. private _halfDomeMask;
  54827. /**
  54828. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54829. * Also see the options.resolution property.
  54830. */
  54831. get fovMultiplier(): number;
  54832. set fovMultiplier(value: number);
  54833. private _videoMode;
  54834. /**
  54835. * Gets or set the current video mode for the video. It can be:
  54836. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54837. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54838. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54839. */
  54840. get videoMode(): number;
  54841. set videoMode(value: number);
  54842. /**
  54843. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54844. *
  54845. */
  54846. get halfDome(): boolean;
  54847. /**
  54848. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54849. */
  54850. set halfDome(enabled: boolean);
  54851. /**
  54852. * Oberserver used in Stereoscopic VR Mode.
  54853. */
  54854. private _onBeforeCameraRenderObserver;
  54855. /**
  54856. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54857. * @param name Element's name, child elements will append suffixes for their own names.
  54858. * @param urlsOrVideo defines the url(s) or the video element to use
  54859. * @param options An object containing optional or exposed sub element properties
  54860. */
  54861. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54862. resolution?: number;
  54863. clickToPlay?: boolean;
  54864. autoPlay?: boolean;
  54865. loop?: boolean;
  54866. size?: number;
  54867. poster?: string;
  54868. faceForward?: boolean;
  54869. useDirectMapping?: boolean;
  54870. halfDomeMode?: boolean;
  54871. }, scene: Scene);
  54872. private _changeVideoMode;
  54873. /**
  54874. * Releases resources associated with this node.
  54875. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54876. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54877. */
  54878. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54879. }
  54880. }
  54881. declare module "babylonjs/Helpers/index" {
  54882. export * from "babylonjs/Helpers/environmentHelper";
  54883. export * from "babylonjs/Helpers/photoDome";
  54884. export * from "babylonjs/Helpers/sceneHelpers";
  54885. export * from "babylonjs/Helpers/videoDome";
  54886. }
  54887. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54888. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54889. import { IDisposable } from "babylonjs/scene";
  54890. import { Engine } from "babylonjs/Engines/engine";
  54891. /**
  54892. * This class can be used to get instrumentation data from a Babylon engine
  54893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54894. */
  54895. export class EngineInstrumentation implements IDisposable {
  54896. /**
  54897. * Define the instrumented engine.
  54898. */
  54899. engine: Engine;
  54900. private _captureGPUFrameTime;
  54901. private _gpuFrameTimeToken;
  54902. private _gpuFrameTime;
  54903. private _captureShaderCompilationTime;
  54904. private _shaderCompilationTime;
  54905. private _onBeginFrameObserver;
  54906. private _onEndFrameObserver;
  54907. private _onBeforeShaderCompilationObserver;
  54908. private _onAfterShaderCompilationObserver;
  54909. /**
  54910. * Gets the perf counter used for GPU frame time
  54911. */
  54912. get gpuFrameTimeCounter(): PerfCounter;
  54913. /**
  54914. * Gets the GPU frame time capture status
  54915. */
  54916. get captureGPUFrameTime(): boolean;
  54917. /**
  54918. * Enable or disable the GPU frame time capture
  54919. */
  54920. set captureGPUFrameTime(value: boolean);
  54921. /**
  54922. * Gets the perf counter used for shader compilation time
  54923. */
  54924. get shaderCompilationTimeCounter(): PerfCounter;
  54925. /**
  54926. * Gets the shader compilation time capture status
  54927. */
  54928. get captureShaderCompilationTime(): boolean;
  54929. /**
  54930. * Enable or disable the shader compilation time capture
  54931. */
  54932. set captureShaderCompilationTime(value: boolean);
  54933. /**
  54934. * Instantiates a new engine instrumentation.
  54935. * This class can be used to get instrumentation data from a Babylon engine
  54936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54937. * @param engine Defines the engine to instrument
  54938. */
  54939. constructor(
  54940. /**
  54941. * Define the instrumented engine.
  54942. */
  54943. engine: Engine);
  54944. /**
  54945. * Dispose and release associated resources.
  54946. */
  54947. dispose(): void;
  54948. }
  54949. }
  54950. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54951. import { Scene, IDisposable } from "babylonjs/scene";
  54952. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54953. /**
  54954. * This class can be used to get instrumentation data from a Babylon engine
  54955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54956. */
  54957. export class SceneInstrumentation implements IDisposable {
  54958. /**
  54959. * Defines the scene to instrument
  54960. */
  54961. scene: Scene;
  54962. private _captureActiveMeshesEvaluationTime;
  54963. private _activeMeshesEvaluationTime;
  54964. private _captureRenderTargetsRenderTime;
  54965. private _renderTargetsRenderTime;
  54966. private _captureFrameTime;
  54967. private _frameTime;
  54968. private _captureRenderTime;
  54969. private _renderTime;
  54970. private _captureInterFrameTime;
  54971. private _interFrameTime;
  54972. private _captureParticlesRenderTime;
  54973. private _particlesRenderTime;
  54974. private _captureSpritesRenderTime;
  54975. private _spritesRenderTime;
  54976. private _capturePhysicsTime;
  54977. private _physicsTime;
  54978. private _captureAnimationsTime;
  54979. private _animationsTime;
  54980. private _captureCameraRenderTime;
  54981. private _cameraRenderTime;
  54982. private _onBeforeActiveMeshesEvaluationObserver;
  54983. private _onAfterActiveMeshesEvaluationObserver;
  54984. private _onBeforeRenderTargetsRenderObserver;
  54985. private _onAfterRenderTargetsRenderObserver;
  54986. private _onAfterRenderObserver;
  54987. private _onBeforeDrawPhaseObserver;
  54988. private _onAfterDrawPhaseObserver;
  54989. private _onBeforeAnimationsObserver;
  54990. private _onBeforeParticlesRenderingObserver;
  54991. private _onAfterParticlesRenderingObserver;
  54992. private _onBeforeSpritesRenderingObserver;
  54993. private _onAfterSpritesRenderingObserver;
  54994. private _onBeforePhysicsObserver;
  54995. private _onAfterPhysicsObserver;
  54996. private _onAfterAnimationsObserver;
  54997. private _onBeforeCameraRenderObserver;
  54998. private _onAfterCameraRenderObserver;
  54999. /**
  55000. * Gets the perf counter used for active meshes evaluation time
  55001. */
  55002. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55003. /**
  55004. * Gets the active meshes evaluation time capture status
  55005. */
  55006. get captureActiveMeshesEvaluationTime(): boolean;
  55007. /**
  55008. * Enable or disable the active meshes evaluation time capture
  55009. */
  55010. set captureActiveMeshesEvaluationTime(value: boolean);
  55011. /**
  55012. * Gets the perf counter used for render targets render time
  55013. */
  55014. get renderTargetsRenderTimeCounter(): PerfCounter;
  55015. /**
  55016. * Gets the render targets render time capture status
  55017. */
  55018. get captureRenderTargetsRenderTime(): boolean;
  55019. /**
  55020. * Enable or disable the render targets render time capture
  55021. */
  55022. set captureRenderTargetsRenderTime(value: boolean);
  55023. /**
  55024. * Gets the perf counter used for particles render time
  55025. */
  55026. get particlesRenderTimeCounter(): PerfCounter;
  55027. /**
  55028. * Gets the particles render time capture status
  55029. */
  55030. get captureParticlesRenderTime(): boolean;
  55031. /**
  55032. * Enable or disable the particles render time capture
  55033. */
  55034. set captureParticlesRenderTime(value: boolean);
  55035. /**
  55036. * Gets the perf counter used for sprites render time
  55037. */
  55038. get spritesRenderTimeCounter(): PerfCounter;
  55039. /**
  55040. * Gets the sprites render time capture status
  55041. */
  55042. get captureSpritesRenderTime(): boolean;
  55043. /**
  55044. * Enable or disable the sprites render time capture
  55045. */
  55046. set captureSpritesRenderTime(value: boolean);
  55047. /**
  55048. * Gets the perf counter used for physics time
  55049. */
  55050. get physicsTimeCounter(): PerfCounter;
  55051. /**
  55052. * Gets the physics time capture status
  55053. */
  55054. get capturePhysicsTime(): boolean;
  55055. /**
  55056. * Enable or disable the physics time capture
  55057. */
  55058. set capturePhysicsTime(value: boolean);
  55059. /**
  55060. * Gets the perf counter used for animations time
  55061. */
  55062. get animationsTimeCounter(): PerfCounter;
  55063. /**
  55064. * Gets the animations time capture status
  55065. */
  55066. get captureAnimationsTime(): boolean;
  55067. /**
  55068. * Enable or disable the animations time capture
  55069. */
  55070. set captureAnimationsTime(value: boolean);
  55071. /**
  55072. * Gets the perf counter used for frame time capture
  55073. */
  55074. get frameTimeCounter(): PerfCounter;
  55075. /**
  55076. * Gets the frame time capture status
  55077. */
  55078. get captureFrameTime(): boolean;
  55079. /**
  55080. * Enable or disable the frame time capture
  55081. */
  55082. set captureFrameTime(value: boolean);
  55083. /**
  55084. * Gets the perf counter used for inter-frames time capture
  55085. */
  55086. get interFrameTimeCounter(): PerfCounter;
  55087. /**
  55088. * Gets the inter-frames time capture status
  55089. */
  55090. get captureInterFrameTime(): boolean;
  55091. /**
  55092. * Enable or disable the inter-frames time capture
  55093. */
  55094. set captureInterFrameTime(value: boolean);
  55095. /**
  55096. * Gets the perf counter used for render time capture
  55097. */
  55098. get renderTimeCounter(): PerfCounter;
  55099. /**
  55100. * Gets the render time capture status
  55101. */
  55102. get captureRenderTime(): boolean;
  55103. /**
  55104. * Enable or disable the render time capture
  55105. */
  55106. set captureRenderTime(value: boolean);
  55107. /**
  55108. * Gets the perf counter used for camera render time capture
  55109. */
  55110. get cameraRenderTimeCounter(): PerfCounter;
  55111. /**
  55112. * Gets the camera render time capture status
  55113. */
  55114. get captureCameraRenderTime(): boolean;
  55115. /**
  55116. * Enable or disable the camera render time capture
  55117. */
  55118. set captureCameraRenderTime(value: boolean);
  55119. /**
  55120. * Gets the perf counter used for draw calls
  55121. */
  55122. get drawCallsCounter(): PerfCounter;
  55123. /**
  55124. * Instantiates a new scene instrumentation.
  55125. * This class can be used to get instrumentation data from a Babylon engine
  55126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55127. * @param scene Defines the scene to instrument
  55128. */
  55129. constructor(
  55130. /**
  55131. * Defines the scene to instrument
  55132. */
  55133. scene: Scene);
  55134. /**
  55135. * Dispose and release associated resources.
  55136. */
  55137. dispose(): void;
  55138. }
  55139. }
  55140. declare module "babylonjs/Instrumentation/index" {
  55141. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55142. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55143. export * from "babylonjs/Instrumentation/timeToken";
  55144. }
  55145. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55146. /** @hidden */
  55147. export var glowMapGenerationPixelShader: {
  55148. name: string;
  55149. shader: string;
  55150. };
  55151. }
  55152. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55153. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55154. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55155. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55156. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55157. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55158. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55159. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55160. /** @hidden */
  55161. export var glowMapGenerationVertexShader: {
  55162. name: string;
  55163. shader: string;
  55164. };
  55165. }
  55166. declare module "babylonjs/Layers/effectLayer" {
  55167. import { Observable } from "babylonjs/Misc/observable";
  55168. import { Nullable } from "babylonjs/types";
  55169. import { Camera } from "babylonjs/Cameras/camera";
  55170. import { Scene } from "babylonjs/scene";
  55171. import { ISize } from "babylonjs/Maths/math.size";
  55172. import { Color4 } from "babylonjs/Maths/math.color";
  55173. import { Engine } from "babylonjs/Engines/engine";
  55174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55176. import { Mesh } from "babylonjs/Meshes/mesh";
  55177. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55180. import { Effect } from "babylonjs/Materials/effect";
  55181. import { Material } from "babylonjs/Materials/material";
  55182. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55183. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55184. /**
  55185. * Effect layer options. This helps customizing the behaviour
  55186. * of the effect layer.
  55187. */
  55188. export interface IEffectLayerOptions {
  55189. /**
  55190. * Multiplication factor apply to the canvas size to compute the render target size
  55191. * used to generated the objects (the smaller the faster).
  55192. */
  55193. mainTextureRatio: number;
  55194. /**
  55195. * Enforces a fixed size texture to ensure effect stability across devices.
  55196. */
  55197. mainTextureFixedSize?: number;
  55198. /**
  55199. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55200. */
  55201. alphaBlendingMode: number;
  55202. /**
  55203. * The camera attached to the layer.
  55204. */
  55205. camera: Nullable<Camera>;
  55206. /**
  55207. * The rendering group to draw the layer in.
  55208. */
  55209. renderingGroupId: number;
  55210. }
  55211. /**
  55212. * The effect layer Helps adding post process effect blended with the main pass.
  55213. *
  55214. * This can be for instance use to generate glow or higlight effects on the scene.
  55215. *
  55216. * The effect layer class can not be used directly and is intented to inherited from to be
  55217. * customized per effects.
  55218. */
  55219. export abstract class EffectLayer {
  55220. private _vertexBuffers;
  55221. private _indexBuffer;
  55222. private _cachedDefines;
  55223. private _effectLayerMapGenerationEffect;
  55224. private _effectLayerOptions;
  55225. private _mergeEffect;
  55226. protected _scene: Scene;
  55227. protected _engine: Engine;
  55228. protected _maxSize: number;
  55229. protected _mainTextureDesiredSize: ISize;
  55230. protected _mainTexture: RenderTargetTexture;
  55231. protected _shouldRender: boolean;
  55232. protected _postProcesses: PostProcess[];
  55233. protected _textures: BaseTexture[];
  55234. protected _emissiveTextureAndColor: {
  55235. texture: Nullable<BaseTexture>;
  55236. color: Color4;
  55237. };
  55238. /**
  55239. * The name of the layer
  55240. */
  55241. name: string;
  55242. /**
  55243. * The clear color of the texture used to generate the glow map.
  55244. */
  55245. neutralColor: Color4;
  55246. /**
  55247. * Specifies wether the highlight layer is enabled or not.
  55248. */
  55249. isEnabled: boolean;
  55250. /**
  55251. * Gets the camera attached to the layer.
  55252. */
  55253. get camera(): Nullable<Camera>;
  55254. /**
  55255. * Gets the rendering group id the layer should render in.
  55256. */
  55257. get renderingGroupId(): number;
  55258. set renderingGroupId(renderingGroupId: number);
  55259. /**
  55260. * An event triggered when the effect layer has been disposed.
  55261. */
  55262. onDisposeObservable: Observable<EffectLayer>;
  55263. /**
  55264. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55265. */
  55266. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55267. /**
  55268. * An event triggered when the generated texture is being merged in the scene.
  55269. */
  55270. onBeforeComposeObservable: Observable<EffectLayer>;
  55271. /**
  55272. * An event triggered when the mesh is rendered into the effect render target.
  55273. */
  55274. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55275. /**
  55276. * An event triggered after the mesh has been rendered into the effect render target.
  55277. */
  55278. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55279. /**
  55280. * An event triggered when the generated texture has been merged in the scene.
  55281. */
  55282. onAfterComposeObservable: Observable<EffectLayer>;
  55283. /**
  55284. * An event triggered when the efffect layer changes its size.
  55285. */
  55286. onSizeChangedObservable: Observable<EffectLayer>;
  55287. /** @hidden */
  55288. static _SceneComponentInitialization: (scene: Scene) => void;
  55289. /**
  55290. * Instantiates a new effect Layer and references it in the scene.
  55291. * @param name The name of the layer
  55292. * @param scene The scene to use the layer in
  55293. */
  55294. constructor(
  55295. /** The Friendly of the effect in the scene */
  55296. name: string, scene: Scene);
  55297. /**
  55298. * Get the effect name of the layer.
  55299. * @return The effect name
  55300. */
  55301. abstract getEffectName(): string;
  55302. /**
  55303. * Checks for the readiness of the element composing the layer.
  55304. * @param subMesh the mesh to check for
  55305. * @param useInstances specify wether or not to use instances to render the mesh
  55306. * @return true if ready otherwise, false
  55307. */
  55308. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55309. /**
  55310. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55311. * @returns true if the effect requires stencil during the main canvas render pass.
  55312. */
  55313. abstract needStencil(): boolean;
  55314. /**
  55315. * Create the merge effect. This is the shader use to blit the information back
  55316. * to the main canvas at the end of the scene rendering.
  55317. * @returns The effect containing the shader used to merge the effect on the main canvas
  55318. */
  55319. protected abstract _createMergeEffect(): Effect;
  55320. /**
  55321. * Creates the render target textures and post processes used in the effect layer.
  55322. */
  55323. protected abstract _createTextureAndPostProcesses(): void;
  55324. /**
  55325. * Implementation specific of rendering the generating effect on the main canvas.
  55326. * @param effect The effect used to render through
  55327. */
  55328. protected abstract _internalRender(effect: Effect): void;
  55329. /**
  55330. * Sets the required values for both the emissive texture and and the main color.
  55331. */
  55332. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55333. /**
  55334. * Free any resources and references associated to a mesh.
  55335. * Internal use
  55336. * @param mesh The mesh to free.
  55337. */
  55338. abstract _disposeMesh(mesh: Mesh): void;
  55339. /**
  55340. * Serializes this layer (Glow or Highlight for example)
  55341. * @returns a serialized layer object
  55342. */
  55343. abstract serialize?(): any;
  55344. /**
  55345. * Initializes the effect layer with the required options.
  55346. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55347. */
  55348. protected _init(options: Partial<IEffectLayerOptions>): void;
  55349. /**
  55350. * Generates the index buffer of the full screen quad blending to the main canvas.
  55351. */
  55352. private _generateIndexBuffer;
  55353. /**
  55354. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55355. */
  55356. private _generateVertexBuffer;
  55357. /**
  55358. * Sets the main texture desired size which is the closest power of two
  55359. * of the engine canvas size.
  55360. */
  55361. private _setMainTextureSize;
  55362. /**
  55363. * Creates the main texture for the effect layer.
  55364. */
  55365. protected _createMainTexture(): void;
  55366. /**
  55367. * Adds specific effects defines.
  55368. * @param defines The defines to add specifics to.
  55369. */
  55370. protected _addCustomEffectDefines(defines: string[]): void;
  55371. /**
  55372. * Checks for the readiness of the element composing the layer.
  55373. * @param subMesh the mesh to check for
  55374. * @param useInstances specify wether or not to use instances to render the mesh
  55375. * @param emissiveTexture the associated emissive texture used to generate the glow
  55376. * @return true if ready otherwise, false
  55377. */
  55378. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55379. /**
  55380. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55381. */
  55382. render(): void;
  55383. /**
  55384. * Determine if a given mesh will be used in the current effect.
  55385. * @param mesh mesh to test
  55386. * @returns true if the mesh will be used
  55387. */
  55388. hasMesh(mesh: AbstractMesh): boolean;
  55389. /**
  55390. * Returns true if the layer contains information to display, otherwise false.
  55391. * @returns true if the glow layer should be rendered
  55392. */
  55393. shouldRender(): boolean;
  55394. /**
  55395. * Returns true if the mesh should render, otherwise false.
  55396. * @param mesh The mesh to render
  55397. * @returns true if it should render otherwise false
  55398. */
  55399. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55400. /**
  55401. * Returns true if the mesh can be rendered, otherwise false.
  55402. * @param mesh The mesh to render
  55403. * @param material The material used on the mesh
  55404. * @returns true if it can be rendered otherwise false
  55405. */
  55406. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55407. /**
  55408. * Returns true if the mesh should render, otherwise false.
  55409. * @param mesh The mesh to render
  55410. * @returns true if it should render otherwise false
  55411. */
  55412. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55413. /**
  55414. * Renders the submesh passed in parameter to the generation map.
  55415. */
  55416. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55417. /**
  55418. * Defines wether the current material of the mesh should be use to render the effect.
  55419. * @param mesh defines the current mesh to render
  55420. */
  55421. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55422. /**
  55423. * Rebuild the required buffers.
  55424. * @hidden Internal use only.
  55425. */
  55426. _rebuild(): void;
  55427. /**
  55428. * Dispose only the render target textures and post process.
  55429. */
  55430. private _disposeTextureAndPostProcesses;
  55431. /**
  55432. * Dispose the highlight layer and free resources.
  55433. */
  55434. dispose(): void;
  55435. /**
  55436. * Gets the class name of the effect layer
  55437. * @returns the string with the class name of the effect layer
  55438. */
  55439. getClassName(): string;
  55440. /**
  55441. * Creates an effect layer from parsed effect layer data
  55442. * @param parsedEffectLayer defines effect layer data
  55443. * @param scene defines the current scene
  55444. * @param rootUrl defines the root URL containing the effect layer information
  55445. * @returns a parsed effect Layer
  55446. */
  55447. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55448. }
  55449. }
  55450. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55451. import { Scene } from "babylonjs/scene";
  55452. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55453. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55454. import { AbstractScene } from "babylonjs/abstractScene";
  55455. module "babylonjs/abstractScene" {
  55456. interface AbstractScene {
  55457. /**
  55458. * The list of effect layers (highlights/glow) added to the scene
  55459. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55460. * @see http://doc.babylonjs.com/how_to/glow_layer
  55461. */
  55462. effectLayers: Array<EffectLayer>;
  55463. /**
  55464. * Removes the given effect layer from this scene.
  55465. * @param toRemove defines the effect layer to remove
  55466. * @returns the index of the removed effect layer
  55467. */
  55468. removeEffectLayer(toRemove: EffectLayer): number;
  55469. /**
  55470. * Adds the given effect layer to this scene
  55471. * @param newEffectLayer defines the effect layer to add
  55472. */
  55473. addEffectLayer(newEffectLayer: EffectLayer): void;
  55474. }
  55475. }
  55476. /**
  55477. * Defines the layer scene component responsible to manage any effect layers
  55478. * in a given scene.
  55479. */
  55480. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55481. /**
  55482. * The component name helpfull to identify the component in the list of scene components.
  55483. */
  55484. readonly name: string;
  55485. /**
  55486. * The scene the component belongs to.
  55487. */
  55488. scene: Scene;
  55489. private _engine;
  55490. private _renderEffects;
  55491. private _needStencil;
  55492. private _previousStencilState;
  55493. /**
  55494. * Creates a new instance of the component for the given scene
  55495. * @param scene Defines the scene to register the component in
  55496. */
  55497. constructor(scene: Scene);
  55498. /**
  55499. * Registers the component in a given scene
  55500. */
  55501. register(): void;
  55502. /**
  55503. * Rebuilds the elements related to this component in case of
  55504. * context lost for instance.
  55505. */
  55506. rebuild(): void;
  55507. /**
  55508. * Serializes the component data to the specified json object
  55509. * @param serializationObject The object to serialize to
  55510. */
  55511. serialize(serializationObject: any): void;
  55512. /**
  55513. * Adds all the elements from the container to the scene
  55514. * @param container the container holding the elements
  55515. */
  55516. addFromContainer(container: AbstractScene): void;
  55517. /**
  55518. * Removes all the elements in the container from the scene
  55519. * @param container contains the elements to remove
  55520. * @param dispose if the removed element should be disposed (default: false)
  55521. */
  55522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55523. /**
  55524. * Disposes the component and the associated ressources.
  55525. */
  55526. dispose(): void;
  55527. private _isReadyForMesh;
  55528. private _renderMainTexture;
  55529. private _setStencil;
  55530. private _setStencilBack;
  55531. private _draw;
  55532. private _drawCamera;
  55533. private _drawRenderingGroup;
  55534. }
  55535. }
  55536. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55537. /** @hidden */
  55538. export var glowMapMergePixelShader: {
  55539. name: string;
  55540. shader: string;
  55541. };
  55542. }
  55543. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55544. /** @hidden */
  55545. export var glowMapMergeVertexShader: {
  55546. name: string;
  55547. shader: string;
  55548. };
  55549. }
  55550. declare module "babylonjs/Layers/glowLayer" {
  55551. import { Nullable } from "babylonjs/types";
  55552. import { Camera } from "babylonjs/Cameras/camera";
  55553. import { Scene } from "babylonjs/scene";
  55554. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55556. import { Mesh } from "babylonjs/Meshes/mesh";
  55557. import { Texture } from "babylonjs/Materials/Textures/texture";
  55558. import { Effect } from "babylonjs/Materials/effect";
  55559. import { Material } from "babylonjs/Materials/material";
  55560. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55561. import { Color4 } from "babylonjs/Maths/math.color";
  55562. import "babylonjs/Shaders/glowMapMerge.fragment";
  55563. import "babylonjs/Shaders/glowMapMerge.vertex";
  55564. import "babylonjs/Layers/effectLayerSceneComponent";
  55565. module "babylonjs/abstractScene" {
  55566. interface AbstractScene {
  55567. /**
  55568. * Return a the first highlight layer of the scene with a given name.
  55569. * @param name The name of the highlight layer to look for.
  55570. * @return The highlight layer if found otherwise null.
  55571. */
  55572. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55573. }
  55574. }
  55575. /**
  55576. * Glow layer options. This helps customizing the behaviour
  55577. * of the glow layer.
  55578. */
  55579. export interface IGlowLayerOptions {
  55580. /**
  55581. * Multiplication factor apply to the canvas size to compute the render target size
  55582. * used to generated the glowing objects (the smaller the faster).
  55583. */
  55584. mainTextureRatio: number;
  55585. /**
  55586. * Enforces a fixed size texture to ensure resize independant blur.
  55587. */
  55588. mainTextureFixedSize?: number;
  55589. /**
  55590. * How big is the kernel of the blur texture.
  55591. */
  55592. blurKernelSize: number;
  55593. /**
  55594. * The camera attached to the layer.
  55595. */
  55596. camera: Nullable<Camera>;
  55597. /**
  55598. * Enable MSAA by chosing the number of samples.
  55599. */
  55600. mainTextureSamples?: number;
  55601. /**
  55602. * The rendering group to draw the layer in.
  55603. */
  55604. renderingGroupId: number;
  55605. }
  55606. /**
  55607. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55608. *
  55609. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55610. *
  55611. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55612. */
  55613. export class GlowLayer extends EffectLayer {
  55614. /**
  55615. * Effect Name of the layer.
  55616. */
  55617. static readonly EffectName: string;
  55618. /**
  55619. * The default blur kernel size used for the glow.
  55620. */
  55621. static DefaultBlurKernelSize: number;
  55622. /**
  55623. * The default texture size ratio used for the glow.
  55624. */
  55625. static DefaultTextureRatio: number;
  55626. /**
  55627. * Sets the kernel size of the blur.
  55628. */
  55629. set blurKernelSize(value: number);
  55630. /**
  55631. * Gets the kernel size of the blur.
  55632. */
  55633. get blurKernelSize(): number;
  55634. /**
  55635. * Sets the glow intensity.
  55636. */
  55637. set intensity(value: number);
  55638. /**
  55639. * Gets the glow intensity.
  55640. */
  55641. get intensity(): number;
  55642. private _options;
  55643. private _intensity;
  55644. private _horizontalBlurPostprocess1;
  55645. private _verticalBlurPostprocess1;
  55646. private _horizontalBlurPostprocess2;
  55647. private _verticalBlurPostprocess2;
  55648. private _blurTexture1;
  55649. private _blurTexture2;
  55650. private _postProcesses1;
  55651. private _postProcesses2;
  55652. private _includedOnlyMeshes;
  55653. private _excludedMeshes;
  55654. private _meshesUsingTheirOwnMaterials;
  55655. /**
  55656. * Callback used to let the user override the color selection on a per mesh basis
  55657. */
  55658. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55659. /**
  55660. * Callback used to let the user override the texture selection on a per mesh basis
  55661. */
  55662. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55663. /**
  55664. * Instantiates a new glow Layer and references it to the scene.
  55665. * @param name The name of the layer
  55666. * @param scene The scene to use the layer in
  55667. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55668. */
  55669. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55670. /**
  55671. * Get the effect name of the layer.
  55672. * @return The effect name
  55673. */
  55674. getEffectName(): string;
  55675. /**
  55676. * Create the merge effect. This is the shader use to blit the information back
  55677. * to the main canvas at the end of the scene rendering.
  55678. */
  55679. protected _createMergeEffect(): Effect;
  55680. /**
  55681. * Creates the render target textures and post processes used in the glow layer.
  55682. */
  55683. protected _createTextureAndPostProcesses(): void;
  55684. /**
  55685. * Checks for the readiness of the element composing the layer.
  55686. * @param subMesh the mesh to check for
  55687. * @param useInstances specify wether or not to use instances to render the mesh
  55688. * @param emissiveTexture the associated emissive texture used to generate the glow
  55689. * @return true if ready otherwise, false
  55690. */
  55691. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55692. /**
  55693. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55694. */
  55695. needStencil(): boolean;
  55696. /**
  55697. * Returns true if the mesh can be rendered, otherwise false.
  55698. * @param mesh The mesh to render
  55699. * @param material The material used on the mesh
  55700. * @returns true if it can be rendered otherwise false
  55701. */
  55702. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55703. /**
  55704. * Implementation specific of rendering the generating effect on the main canvas.
  55705. * @param effect The effect used to render through
  55706. */
  55707. protected _internalRender(effect: Effect): void;
  55708. /**
  55709. * Sets the required values for both the emissive texture and and the main color.
  55710. */
  55711. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55712. /**
  55713. * Returns true if the mesh should render, otherwise false.
  55714. * @param mesh The mesh to render
  55715. * @returns true if it should render otherwise false
  55716. */
  55717. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55718. /**
  55719. * Adds specific effects defines.
  55720. * @param defines The defines to add specifics to.
  55721. */
  55722. protected _addCustomEffectDefines(defines: string[]): void;
  55723. /**
  55724. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55725. * @param mesh The mesh to exclude from the glow layer
  55726. */
  55727. addExcludedMesh(mesh: Mesh): void;
  55728. /**
  55729. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55730. * @param mesh The mesh to remove
  55731. */
  55732. removeExcludedMesh(mesh: Mesh): void;
  55733. /**
  55734. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55735. * @param mesh The mesh to include in the glow layer
  55736. */
  55737. addIncludedOnlyMesh(mesh: Mesh): void;
  55738. /**
  55739. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55740. * @param mesh The mesh to remove
  55741. */
  55742. removeIncludedOnlyMesh(mesh: Mesh): void;
  55743. /**
  55744. * Determine if a given mesh will be used in the glow layer
  55745. * @param mesh The mesh to test
  55746. * @returns true if the mesh will be highlighted by the current glow layer
  55747. */
  55748. hasMesh(mesh: AbstractMesh): boolean;
  55749. /**
  55750. * Defines wether the current material of the mesh should be use to render the effect.
  55751. * @param mesh defines the current mesh to render
  55752. */
  55753. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55754. /**
  55755. * Add a mesh to be rendered through its own material and not with emissive only.
  55756. * @param mesh The mesh for which we need to use its material
  55757. */
  55758. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55759. /**
  55760. * Remove a mesh from being rendered through its own material and not with emissive only.
  55761. * @param mesh The mesh for which we need to not use its material
  55762. */
  55763. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55764. /**
  55765. * Free any resources and references associated to a mesh.
  55766. * Internal use
  55767. * @param mesh The mesh to free.
  55768. * @hidden
  55769. */
  55770. _disposeMesh(mesh: Mesh): void;
  55771. /**
  55772. * Gets the class name of the effect layer
  55773. * @returns the string with the class name of the effect layer
  55774. */
  55775. getClassName(): string;
  55776. /**
  55777. * Serializes this glow layer
  55778. * @returns a serialized glow layer object
  55779. */
  55780. serialize(): any;
  55781. /**
  55782. * Creates a Glow Layer from parsed glow layer data
  55783. * @param parsedGlowLayer defines glow layer data
  55784. * @param scene defines the current scene
  55785. * @param rootUrl defines the root URL containing the glow layer information
  55786. * @returns a parsed Glow Layer
  55787. */
  55788. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55789. }
  55790. }
  55791. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55792. /** @hidden */
  55793. export var glowBlurPostProcessPixelShader: {
  55794. name: string;
  55795. shader: string;
  55796. };
  55797. }
  55798. declare module "babylonjs/Layers/highlightLayer" {
  55799. import { Observable } from "babylonjs/Misc/observable";
  55800. import { Nullable } from "babylonjs/types";
  55801. import { Camera } from "babylonjs/Cameras/camera";
  55802. import { Scene } from "babylonjs/scene";
  55803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55805. import { Mesh } from "babylonjs/Meshes/mesh";
  55806. import { Effect } from "babylonjs/Materials/effect";
  55807. import { Material } from "babylonjs/Materials/material";
  55808. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55809. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55810. import "babylonjs/Shaders/glowMapMerge.fragment";
  55811. import "babylonjs/Shaders/glowMapMerge.vertex";
  55812. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55813. module "babylonjs/abstractScene" {
  55814. interface AbstractScene {
  55815. /**
  55816. * Return a the first highlight layer of the scene with a given name.
  55817. * @param name The name of the highlight layer to look for.
  55818. * @return The highlight layer if found otherwise null.
  55819. */
  55820. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55821. }
  55822. }
  55823. /**
  55824. * Highlight layer options. This helps customizing the behaviour
  55825. * of the highlight layer.
  55826. */
  55827. export interface IHighlightLayerOptions {
  55828. /**
  55829. * Multiplication factor apply to the canvas size to compute the render target size
  55830. * used to generated the glowing objects (the smaller the faster).
  55831. */
  55832. mainTextureRatio: number;
  55833. /**
  55834. * Enforces a fixed size texture to ensure resize independant blur.
  55835. */
  55836. mainTextureFixedSize?: number;
  55837. /**
  55838. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55839. * of the picture to blur (the smaller the faster).
  55840. */
  55841. blurTextureSizeRatio: number;
  55842. /**
  55843. * How big in texel of the blur texture is the vertical blur.
  55844. */
  55845. blurVerticalSize: number;
  55846. /**
  55847. * How big in texel of the blur texture is the horizontal blur.
  55848. */
  55849. blurHorizontalSize: number;
  55850. /**
  55851. * Alpha blending mode used to apply the blur. Default is combine.
  55852. */
  55853. alphaBlendingMode: number;
  55854. /**
  55855. * The camera attached to the layer.
  55856. */
  55857. camera: Nullable<Camera>;
  55858. /**
  55859. * Should we display highlight as a solid stroke?
  55860. */
  55861. isStroke?: boolean;
  55862. /**
  55863. * The rendering group to draw the layer in.
  55864. */
  55865. renderingGroupId: number;
  55866. }
  55867. /**
  55868. * The highlight layer Helps adding a glow effect around a mesh.
  55869. *
  55870. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55871. * glowy meshes to your scene.
  55872. *
  55873. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55874. */
  55875. export class HighlightLayer extends EffectLayer {
  55876. name: string;
  55877. /**
  55878. * Effect Name of the highlight layer.
  55879. */
  55880. static readonly EffectName: string;
  55881. /**
  55882. * The neutral color used during the preparation of the glow effect.
  55883. * This is black by default as the blend operation is a blend operation.
  55884. */
  55885. static NeutralColor: Color4;
  55886. /**
  55887. * Stencil value used for glowing meshes.
  55888. */
  55889. static GlowingMeshStencilReference: number;
  55890. /**
  55891. * Stencil value used for the other meshes in the scene.
  55892. */
  55893. static NormalMeshStencilReference: number;
  55894. /**
  55895. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55896. */
  55897. innerGlow: boolean;
  55898. /**
  55899. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55900. */
  55901. outerGlow: boolean;
  55902. /**
  55903. * Specifies the horizontal size of the blur.
  55904. */
  55905. set blurHorizontalSize(value: number);
  55906. /**
  55907. * Specifies the vertical size of the blur.
  55908. */
  55909. set blurVerticalSize(value: number);
  55910. /**
  55911. * Gets the horizontal size of the blur.
  55912. */
  55913. get blurHorizontalSize(): number;
  55914. /**
  55915. * Gets the vertical size of the blur.
  55916. */
  55917. get blurVerticalSize(): number;
  55918. /**
  55919. * An event triggered when the highlight layer is being blurred.
  55920. */
  55921. onBeforeBlurObservable: Observable<HighlightLayer>;
  55922. /**
  55923. * An event triggered when the highlight layer has been blurred.
  55924. */
  55925. onAfterBlurObservable: Observable<HighlightLayer>;
  55926. private _instanceGlowingMeshStencilReference;
  55927. private _options;
  55928. private _downSamplePostprocess;
  55929. private _horizontalBlurPostprocess;
  55930. private _verticalBlurPostprocess;
  55931. private _blurTexture;
  55932. private _meshes;
  55933. private _excludedMeshes;
  55934. /**
  55935. * Instantiates a new highlight Layer and references it to the scene..
  55936. * @param name The name of the layer
  55937. * @param scene The scene to use the layer in
  55938. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55939. */
  55940. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55941. /**
  55942. * Get the effect name of the layer.
  55943. * @return The effect name
  55944. */
  55945. getEffectName(): string;
  55946. /**
  55947. * Create the merge effect. This is the shader use to blit the information back
  55948. * to the main canvas at the end of the scene rendering.
  55949. */
  55950. protected _createMergeEffect(): Effect;
  55951. /**
  55952. * Creates the render target textures and post processes used in the highlight layer.
  55953. */
  55954. protected _createTextureAndPostProcesses(): void;
  55955. /**
  55956. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55957. */
  55958. needStencil(): boolean;
  55959. /**
  55960. * Checks for the readiness of the element composing the layer.
  55961. * @param subMesh the mesh to check for
  55962. * @param useInstances specify wether or not to use instances to render the mesh
  55963. * @param emissiveTexture the associated emissive texture used to generate the glow
  55964. * @return true if ready otherwise, false
  55965. */
  55966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55967. /**
  55968. * Implementation specific of rendering the generating effect on the main canvas.
  55969. * @param effect The effect used to render through
  55970. */
  55971. protected _internalRender(effect: Effect): void;
  55972. /**
  55973. * Returns true if the layer contains information to display, otherwise false.
  55974. */
  55975. shouldRender(): boolean;
  55976. /**
  55977. * Returns true if the mesh should render, otherwise false.
  55978. * @param mesh The mesh to render
  55979. * @returns true if it should render otherwise false
  55980. */
  55981. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55982. /**
  55983. * Sets the required values for both the emissive texture and and the main color.
  55984. */
  55985. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55986. /**
  55987. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55988. * @param mesh The mesh to exclude from the highlight layer
  55989. */
  55990. addExcludedMesh(mesh: Mesh): void;
  55991. /**
  55992. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55993. * @param mesh The mesh to highlight
  55994. */
  55995. removeExcludedMesh(mesh: Mesh): void;
  55996. /**
  55997. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55998. * @param mesh mesh to test
  55999. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56000. */
  56001. hasMesh(mesh: AbstractMesh): boolean;
  56002. /**
  56003. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56004. * @param mesh The mesh to highlight
  56005. * @param color The color of the highlight
  56006. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56007. */
  56008. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56009. /**
  56010. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56011. * @param mesh The mesh to highlight
  56012. */
  56013. removeMesh(mesh: Mesh): void;
  56014. /**
  56015. * Force the stencil to the normal expected value for none glowing parts
  56016. */
  56017. private _defaultStencilReference;
  56018. /**
  56019. * Free any resources and references associated to a mesh.
  56020. * Internal use
  56021. * @param mesh The mesh to free.
  56022. * @hidden
  56023. */
  56024. _disposeMesh(mesh: Mesh): void;
  56025. /**
  56026. * Dispose the highlight layer and free resources.
  56027. */
  56028. dispose(): void;
  56029. /**
  56030. * Gets the class name of the effect layer
  56031. * @returns the string with the class name of the effect layer
  56032. */
  56033. getClassName(): string;
  56034. /**
  56035. * Serializes this Highlight layer
  56036. * @returns a serialized Highlight layer object
  56037. */
  56038. serialize(): any;
  56039. /**
  56040. * Creates a Highlight layer from parsed Highlight layer data
  56041. * @param parsedHightlightLayer defines the Highlight layer data
  56042. * @param scene defines the current scene
  56043. * @param rootUrl defines the root URL containing the Highlight layer information
  56044. * @returns a parsed Highlight layer
  56045. */
  56046. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56047. }
  56048. }
  56049. declare module "babylonjs/Layers/layerSceneComponent" {
  56050. import { Scene } from "babylonjs/scene";
  56051. import { ISceneComponent } from "babylonjs/sceneComponent";
  56052. import { Layer } from "babylonjs/Layers/layer";
  56053. import { AbstractScene } from "babylonjs/abstractScene";
  56054. module "babylonjs/abstractScene" {
  56055. interface AbstractScene {
  56056. /**
  56057. * The list of layers (background and foreground) of the scene
  56058. */
  56059. layers: Array<Layer>;
  56060. }
  56061. }
  56062. /**
  56063. * Defines the layer scene component responsible to manage any layers
  56064. * in a given scene.
  56065. */
  56066. export class LayerSceneComponent implements ISceneComponent {
  56067. /**
  56068. * The component name helpfull to identify the component in the list of scene components.
  56069. */
  56070. readonly name: string;
  56071. /**
  56072. * The scene the component belongs to.
  56073. */
  56074. scene: Scene;
  56075. private _engine;
  56076. /**
  56077. * Creates a new instance of the component for the given scene
  56078. * @param scene Defines the scene to register the component in
  56079. */
  56080. constructor(scene: Scene);
  56081. /**
  56082. * Registers the component in a given scene
  56083. */
  56084. register(): void;
  56085. /**
  56086. * Rebuilds the elements related to this component in case of
  56087. * context lost for instance.
  56088. */
  56089. rebuild(): void;
  56090. /**
  56091. * Disposes the component and the associated ressources.
  56092. */
  56093. dispose(): void;
  56094. private _draw;
  56095. private _drawCameraPredicate;
  56096. private _drawCameraBackground;
  56097. private _drawCameraForeground;
  56098. private _drawRenderTargetPredicate;
  56099. private _drawRenderTargetBackground;
  56100. private _drawRenderTargetForeground;
  56101. /**
  56102. * Adds all the elements from the container to the scene
  56103. * @param container the container holding the elements
  56104. */
  56105. addFromContainer(container: AbstractScene): void;
  56106. /**
  56107. * Removes all the elements in the container from the scene
  56108. * @param container contains the elements to remove
  56109. * @param dispose if the removed element should be disposed (default: false)
  56110. */
  56111. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56112. }
  56113. }
  56114. declare module "babylonjs/Shaders/layer.fragment" {
  56115. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56116. /** @hidden */
  56117. export var layerPixelShader: {
  56118. name: string;
  56119. shader: string;
  56120. };
  56121. }
  56122. declare module "babylonjs/Shaders/layer.vertex" {
  56123. /** @hidden */
  56124. export var layerVertexShader: {
  56125. name: string;
  56126. shader: string;
  56127. };
  56128. }
  56129. declare module "babylonjs/Layers/layer" {
  56130. import { Observable } from "babylonjs/Misc/observable";
  56131. import { Nullable } from "babylonjs/types";
  56132. import { Scene } from "babylonjs/scene";
  56133. import { Vector2 } from "babylonjs/Maths/math.vector";
  56134. import { Color4 } from "babylonjs/Maths/math.color";
  56135. import { Texture } from "babylonjs/Materials/Textures/texture";
  56136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56137. import "babylonjs/Shaders/layer.fragment";
  56138. import "babylonjs/Shaders/layer.vertex";
  56139. /**
  56140. * This represents a full screen 2d layer.
  56141. * This can be useful to display a picture in the background of your scene for instance.
  56142. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56143. */
  56144. export class Layer {
  56145. /**
  56146. * Define the name of the layer.
  56147. */
  56148. name: string;
  56149. /**
  56150. * Define the texture the layer should display.
  56151. */
  56152. texture: Nullable<Texture>;
  56153. /**
  56154. * Is the layer in background or foreground.
  56155. */
  56156. isBackground: boolean;
  56157. /**
  56158. * Define the color of the layer (instead of texture).
  56159. */
  56160. color: Color4;
  56161. /**
  56162. * Define the scale of the layer in order to zoom in out of the texture.
  56163. */
  56164. scale: Vector2;
  56165. /**
  56166. * Define an offset for the layer in order to shift the texture.
  56167. */
  56168. offset: Vector2;
  56169. /**
  56170. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56171. */
  56172. alphaBlendingMode: number;
  56173. /**
  56174. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56175. * Alpha test will not mix with the background color in case of transparency.
  56176. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56177. */
  56178. alphaTest: boolean;
  56179. /**
  56180. * Define a mask to restrict the layer to only some of the scene cameras.
  56181. */
  56182. layerMask: number;
  56183. /**
  56184. * Define the list of render target the layer is visible into.
  56185. */
  56186. renderTargetTextures: RenderTargetTexture[];
  56187. /**
  56188. * Define if the layer is only used in renderTarget or if it also
  56189. * renders in the main frame buffer of the canvas.
  56190. */
  56191. renderOnlyInRenderTargetTextures: boolean;
  56192. private _scene;
  56193. private _vertexBuffers;
  56194. private _indexBuffer;
  56195. private _effect;
  56196. private _previousDefines;
  56197. /**
  56198. * An event triggered when the layer is disposed.
  56199. */
  56200. onDisposeObservable: Observable<Layer>;
  56201. private _onDisposeObserver;
  56202. /**
  56203. * Back compatibility with callback before the onDisposeObservable existed.
  56204. * The set callback will be triggered when the layer has been disposed.
  56205. */
  56206. set onDispose(callback: () => void);
  56207. /**
  56208. * An event triggered before rendering the scene
  56209. */
  56210. onBeforeRenderObservable: Observable<Layer>;
  56211. private _onBeforeRenderObserver;
  56212. /**
  56213. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56214. * The set callback will be triggered just before rendering the layer.
  56215. */
  56216. set onBeforeRender(callback: () => void);
  56217. /**
  56218. * An event triggered after rendering the scene
  56219. */
  56220. onAfterRenderObservable: Observable<Layer>;
  56221. private _onAfterRenderObserver;
  56222. /**
  56223. * Back compatibility with callback before the onAfterRenderObservable existed.
  56224. * The set callback will be triggered just after rendering the layer.
  56225. */
  56226. set onAfterRender(callback: () => void);
  56227. /**
  56228. * Instantiates a new layer.
  56229. * This represents a full screen 2d layer.
  56230. * This can be useful to display a picture in the background of your scene for instance.
  56231. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56232. * @param name Define the name of the layer in the scene
  56233. * @param imgUrl Define the url of the texture to display in the layer
  56234. * @param scene Define the scene the layer belongs to
  56235. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56236. * @param color Defines a color for the layer
  56237. */
  56238. constructor(
  56239. /**
  56240. * Define the name of the layer.
  56241. */
  56242. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56243. private _createIndexBuffer;
  56244. /** @hidden */
  56245. _rebuild(): void;
  56246. /**
  56247. * Renders the layer in the scene.
  56248. */
  56249. render(): void;
  56250. /**
  56251. * Disposes and releases the associated ressources.
  56252. */
  56253. dispose(): void;
  56254. }
  56255. }
  56256. declare module "babylonjs/Layers/index" {
  56257. export * from "babylonjs/Layers/effectLayer";
  56258. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56259. export * from "babylonjs/Layers/glowLayer";
  56260. export * from "babylonjs/Layers/highlightLayer";
  56261. export * from "babylonjs/Layers/layer";
  56262. export * from "babylonjs/Layers/layerSceneComponent";
  56263. }
  56264. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56265. /** @hidden */
  56266. export var lensFlarePixelShader: {
  56267. name: string;
  56268. shader: string;
  56269. };
  56270. }
  56271. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56272. /** @hidden */
  56273. export var lensFlareVertexShader: {
  56274. name: string;
  56275. shader: string;
  56276. };
  56277. }
  56278. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56279. import { Scene } from "babylonjs/scene";
  56280. import { Vector3 } from "babylonjs/Maths/math.vector";
  56281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56282. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56283. import "babylonjs/Shaders/lensFlare.fragment";
  56284. import "babylonjs/Shaders/lensFlare.vertex";
  56285. import { Viewport } from "babylonjs/Maths/math.viewport";
  56286. /**
  56287. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56288. * It is usually composed of several `lensFlare`.
  56289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56290. */
  56291. export class LensFlareSystem {
  56292. /**
  56293. * Define the name of the lens flare system
  56294. */
  56295. name: string;
  56296. /**
  56297. * List of lens flares used in this system.
  56298. */
  56299. lensFlares: LensFlare[];
  56300. /**
  56301. * Define a limit from the border the lens flare can be visible.
  56302. */
  56303. borderLimit: number;
  56304. /**
  56305. * Define a viewport border we do not want to see the lens flare in.
  56306. */
  56307. viewportBorder: number;
  56308. /**
  56309. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56310. */
  56311. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56312. /**
  56313. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56314. */
  56315. layerMask: number;
  56316. /**
  56317. * Define the id of the lens flare system in the scene.
  56318. * (equal to name by default)
  56319. */
  56320. id: string;
  56321. private _scene;
  56322. private _emitter;
  56323. private _vertexBuffers;
  56324. private _indexBuffer;
  56325. private _effect;
  56326. private _positionX;
  56327. private _positionY;
  56328. private _isEnabled;
  56329. /** @hidden */
  56330. static _SceneComponentInitialization: (scene: Scene) => void;
  56331. /**
  56332. * Instantiates a lens flare system.
  56333. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56334. * It is usually composed of several `lensFlare`.
  56335. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56336. * @param name Define the name of the lens flare system in the scene
  56337. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56338. * @param scene Define the scene the lens flare system belongs to
  56339. */
  56340. constructor(
  56341. /**
  56342. * Define the name of the lens flare system
  56343. */
  56344. name: string, emitter: any, scene: Scene);
  56345. /**
  56346. * Define if the lens flare system is enabled.
  56347. */
  56348. get isEnabled(): boolean;
  56349. set isEnabled(value: boolean);
  56350. /**
  56351. * Get the scene the effects belongs to.
  56352. * @returns the scene holding the lens flare system
  56353. */
  56354. getScene(): Scene;
  56355. /**
  56356. * Get the emitter of the lens flare system.
  56357. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56358. * @returns the emitter of the lens flare system
  56359. */
  56360. getEmitter(): any;
  56361. /**
  56362. * Set the emitter of the lens flare system.
  56363. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56364. * @param newEmitter Define the new emitter of the system
  56365. */
  56366. setEmitter(newEmitter: any): void;
  56367. /**
  56368. * Get the lens flare system emitter position.
  56369. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56370. * @returns the position
  56371. */
  56372. getEmitterPosition(): Vector3;
  56373. /**
  56374. * @hidden
  56375. */
  56376. computeEffectivePosition(globalViewport: Viewport): boolean;
  56377. /** @hidden */
  56378. _isVisible(): boolean;
  56379. /**
  56380. * @hidden
  56381. */
  56382. render(): boolean;
  56383. /**
  56384. * Dispose and release the lens flare with its associated resources.
  56385. */
  56386. dispose(): void;
  56387. /**
  56388. * Parse a lens flare system from a JSON repressentation
  56389. * @param parsedLensFlareSystem Define the JSON to parse
  56390. * @param scene Define the scene the parsed system should be instantiated in
  56391. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56392. * @returns the parsed system
  56393. */
  56394. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56395. /**
  56396. * Serialize the current Lens Flare System into a JSON representation.
  56397. * @returns the serialized JSON
  56398. */
  56399. serialize(): any;
  56400. }
  56401. }
  56402. declare module "babylonjs/LensFlares/lensFlare" {
  56403. import { Nullable } from "babylonjs/types";
  56404. import { Color3 } from "babylonjs/Maths/math.color";
  56405. import { Texture } from "babylonjs/Materials/Textures/texture";
  56406. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56407. /**
  56408. * This represents one of the lens effect in a `lensFlareSystem`.
  56409. * It controls one of the indiviual texture used in the effect.
  56410. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56411. */
  56412. export class LensFlare {
  56413. /**
  56414. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56415. */
  56416. size: number;
  56417. /**
  56418. * 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.
  56419. */
  56420. position: number;
  56421. /**
  56422. * Define the lens color.
  56423. */
  56424. color: Color3;
  56425. /**
  56426. * Define the lens texture.
  56427. */
  56428. texture: Nullable<Texture>;
  56429. /**
  56430. * Define the alpha mode to render this particular lens.
  56431. */
  56432. alphaMode: number;
  56433. private _system;
  56434. /**
  56435. * Creates a new Lens Flare.
  56436. * This represents one of the lens effect in a `lensFlareSystem`.
  56437. * It controls one of the indiviual texture used in the effect.
  56438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56439. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56440. * @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.
  56441. * @param color Define the lens color
  56442. * @param imgUrl Define the lens texture url
  56443. * @param system Define the `lensFlareSystem` this flare is part of
  56444. * @returns The newly created Lens Flare
  56445. */
  56446. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56447. /**
  56448. * Instantiates a new Lens Flare.
  56449. * This represents one of the lens effect in a `lensFlareSystem`.
  56450. * It controls one of the indiviual texture used in the effect.
  56451. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56452. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56453. * @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.
  56454. * @param color Define the lens color
  56455. * @param imgUrl Define the lens texture url
  56456. * @param system Define the `lensFlareSystem` this flare is part of
  56457. */
  56458. constructor(
  56459. /**
  56460. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56461. */
  56462. size: number,
  56463. /**
  56464. * 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.
  56465. */
  56466. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56467. /**
  56468. * Dispose and release the lens flare with its associated resources.
  56469. */
  56470. dispose(): void;
  56471. }
  56472. }
  56473. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56474. import { Nullable } from "babylonjs/types";
  56475. import { Scene } from "babylonjs/scene";
  56476. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56477. import { AbstractScene } from "babylonjs/abstractScene";
  56478. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56479. module "babylonjs/abstractScene" {
  56480. interface AbstractScene {
  56481. /**
  56482. * The list of lens flare system added to the scene
  56483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56484. */
  56485. lensFlareSystems: Array<LensFlareSystem>;
  56486. /**
  56487. * Removes the given lens flare system from this scene.
  56488. * @param toRemove The lens flare system to remove
  56489. * @returns The index of the removed lens flare system
  56490. */
  56491. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56492. /**
  56493. * Adds the given lens flare system to this scene
  56494. * @param newLensFlareSystem The lens flare system to add
  56495. */
  56496. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56497. /**
  56498. * Gets a lens flare system using its name
  56499. * @param name defines the name to look for
  56500. * @returns the lens flare system or null if not found
  56501. */
  56502. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56503. /**
  56504. * Gets a lens flare system using its id
  56505. * @param id defines the id to look for
  56506. * @returns the lens flare system or null if not found
  56507. */
  56508. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56509. }
  56510. }
  56511. /**
  56512. * Defines the lens flare scene component responsible to manage any lens flares
  56513. * in a given scene.
  56514. */
  56515. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56516. /**
  56517. * The component name helpfull to identify the component in the list of scene components.
  56518. */
  56519. readonly name: string;
  56520. /**
  56521. * The scene the component belongs to.
  56522. */
  56523. scene: Scene;
  56524. /**
  56525. * Creates a new instance of the component for the given scene
  56526. * @param scene Defines the scene to register the component in
  56527. */
  56528. constructor(scene: Scene);
  56529. /**
  56530. * Registers the component in a given scene
  56531. */
  56532. register(): void;
  56533. /**
  56534. * Rebuilds the elements related to this component in case of
  56535. * context lost for instance.
  56536. */
  56537. rebuild(): void;
  56538. /**
  56539. * Adds all the elements from the container to the scene
  56540. * @param container the container holding the elements
  56541. */
  56542. addFromContainer(container: AbstractScene): void;
  56543. /**
  56544. * Removes all the elements in the container from the scene
  56545. * @param container contains the elements to remove
  56546. * @param dispose if the removed element should be disposed (default: false)
  56547. */
  56548. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56549. /**
  56550. * Serializes the component data to the specified json object
  56551. * @param serializationObject The object to serialize to
  56552. */
  56553. serialize(serializationObject: any): void;
  56554. /**
  56555. * Disposes the component and the associated ressources.
  56556. */
  56557. dispose(): void;
  56558. private _draw;
  56559. }
  56560. }
  56561. declare module "babylonjs/LensFlares/index" {
  56562. export * from "babylonjs/LensFlares/lensFlare";
  56563. export * from "babylonjs/LensFlares/lensFlareSystem";
  56564. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56565. }
  56566. declare module "babylonjs/Shaders/depth.fragment" {
  56567. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56568. /** @hidden */
  56569. export var depthPixelShader: {
  56570. name: string;
  56571. shader: string;
  56572. };
  56573. }
  56574. declare module "babylonjs/Shaders/depth.vertex" {
  56575. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56576. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56578. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56580. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56581. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56582. /** @hidden */
  56583. export var depthVertexShader: {
  56584. name: string;
  56585. shader: string;
  56586. };
  56587. }
  56588. declare module "babylonjs/Rendering/depthRenderer" {
  56589. import { Nullable } from "babylonjs/types";
  56590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56591. import { Scene } from "babylonjs/scene";
  56592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56593. import { Camera } from "babylonjs/Cameras/camera";
  56594. import "babylonjs/Shaders/depth.fragment";
  56595. import "babylonjs/Shaders/depth.vertex";
  56596. /**
  56597. * This represents a depth renderer in Babylon.
  56598. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56599. */
  56600. export class DepthRenderer {
  56601. private _scene;
  56602. private _depthMap;
  56603. private _effect;
  56604. private readonly _storeNonLinearDepth;
  56605. private readonly _clearColor;
  56606. /** Get if the depth renderer is using packed depth or not */
  56607. readonly isPacked: boolean;
  56608. private _cachedDefines;
  56609. private _camera;
  56610. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56611. enabled: boolean;
  56612. /**
  56613. * Specifiess that the depth renderer will only be used within
  56614. * the camera it is created for.
  56615. * This can help forcing its rendering during the camera processing.
  56616. */
  56617. useOnlyInActiveCamera: boolean;
  56618. /** @hidden */
  56619. static _SceneComponentInitialization: (scene: Scene) => void;
  56620. /**
  56621. * Instantiates a depth renderer
  56622. * @param scene The scene the renderer belongs to
  56623. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56624. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56625. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56626. */
  56627. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56628. /**
  56629. * Creates the depth rendering effect and checks if the effect is ready.
  56630. * @param subMesh The submesh to be used to render the depth map of
  56631. * @param useInstances If multiple world instances should be used
  56632. * @returns if the depth renderer is ready to render the depth map
  56633. */
  56634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56635. /**
  56636. * Gets the texture which the depth map will be written to.
  56637. * @returns The depth map texture
  56638. */
  56639. getDepthMap(): RenderTargetTexture;
  56640. /**
  56641. * Disposes of the depth renderer.
  56642. */
  56643. dispose(): void;
  56644. }
  56645. }
  56646. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56647. /** @hidden */
  56648. export var minmaxReduxPixelShader: {
  56649. name: string;
  56650. shader: string;
  56651. };
  56652. }
  56653. declare module "babylonjs/Misc/minMaxReducer" {
  56654. import { Nullable } from "babylonjs/types";
  56655. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56656. import { Camera } from "babylonjs/Cameras/camera";
  56657. import { Observer } from "babylonjs/Misc/observable";
  56658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56659. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56660. import { Observable } from "babylonjs/Misc/observable";
  56661. import "babylonjs/Shaders/minmaxRedux.fragment";
  56662. /**
  56663. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56664. * and maximum values from all values of the texture.
  56665. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56666. * The source values are read from the red channel of the texture.
  56667. */
  56668. export class MinMaxReducer {
  56669. /**
  56670. * Observable triggered when the computation has been performed
  56671. */
  56672. onAfterReductionPerformed: Observable<{
  56673. min: number;
  56674. max: number;
  56675. }>;
  56676. protected _camera: Camera;
  56677. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56678. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56679. protected _postProcessManager: PostProcessManager;
  56680. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56681. protected _forceFullscreenViewport: boolean;
  56682. /**
  56683. * Creates a min/max reducer
  56684. * @param camera The camera to use for the post processes
  56685. */
  56686. constructor(camera: Camera);
  56687. /**
  56688. * Gets the texture used to read the values from.
  56689. */
  56690. get sourceTexture(): Nullable<RenderTargetTexture>;
  56691. /**
  56692. * Sets the source texture to read the values from.
  56693. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56694. * because in such textures '1' value must not be taken into account to compute the maximum
  56695. * as this value is used to clear the texture.
  56696. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56697. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56698. * @param depthRedux Indicates if the texture is a depth texture or not
  56699. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56700. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56701. */
  56702. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56703. /**
  56704. * Defines the refresh rate of the computation.
  56705. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56706. */
  56707. get refreshRate(): number;
  56708. set refreshRate(value: number);
  56709. protected _activated: boolean;
  56710. /**
  56711. * Gets the activation status of the reducer
  56712. */
  56713. get activated(): boolean;
  56714. /**
  56715. * Activates the reduction computation.
  56716. * When activated, the observers registered in onAfterReductionPerformed are
  56717. * called after the compuation is performed
  56718. */
  56719. activate(): void;
  56720. /**
  56721. * Deactivates the reduction computation.
  56722. */
  56723. deactivate(): void;
  56724. /**
  56725. * Disposes the min/max reducer
  56726. * @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.
  56727. */
  56728. dispose(disposeAll?: boolean): void;
  56729. }
  56730. }
  56731. declare module "babylonjs/Misc/depthReducer" {
  56732. import { Nullable } from "babylonjs/types";
  56733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56734. import { Camera } from "babylonjs/Cameras/camera";
  56735. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56736. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56737. /**
  56738. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56739. */
  56740. export class DepthReducer extends MinMaxReducer {
  56741. private _depthRenderer;
  56742. private _depthRendererId;
  56743. /**
  56744. * Gets the depth renderer used for the computation.
  56745. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56746. */
  56747. get depthRenderer(): Nullable<DepthRenderer>;
  56748. /**
  56749. * Creates a depth reducer
  56750. * @param camera The camera used to render the depth texture
  56751. */
  56752. constructor(camera: Camera);
  56753. /**
  56754. * Sets the depth renderer to use to generate the depth map
  56755. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56756. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56757. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56758. */
  56759. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56760. /** @hidden */
  56761. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56762. /**
  56763. * Activates the reduction computation.
  56764. * When activated, the observers registered in onAfterReductionPerformed are
  56765. * called after the compuation is performed
  56766. */
  56767. activate(): void;
  56768. /**
  56769. * Deactivates the reduction computation.
  56770. */
  56771. deactivate(): void;
  56772. /**
  56773. * Disposes the depth reducer
  56774. * @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.
  56775. */
  56776. dispose(disposeAll?: boolean): void;
  56777. }
  56778. }
  56779. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56780. import { Nullable } from "babylonjs/types";
  56781. import { Scene } from "babylonjs/scene";
  56782. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56784. import { Effect } from "babylonjs/Materials/effect";
  56785. import "babylonjs/Shaders/shadowMap.fragment";
  56786. import "babylonjs/Shaders/shadowMap.vertex";
  56787. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56788. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56789. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56790. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56791. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56792. /**
  56793. * A CSM implementation allowing casting shadows on large scenes.
  56794. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56795. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56796. */
  56797. export class CascadedShadowGenerator extends ShadowGenerator {
  56798. private static readonly frustumCornersNDCSpace;
  56799. /**
  56800. * Name of the CSM class
  56801. */
  56802. static CLASSNAME: string;
  56803. /**
  56804. * Defines the default number of cascades used by the CSM.
  56805. */
  56806. static readonly DEFAULT_CASCADES_COUNT: number;
  56807. /**
  56808. * Defines the minimum number of cascades used by the CSM.
  56809. */
  56810. static readonly MIN_CASCADES_COUNT: number;
  56811. /**
  56812. * Defines the maximum number of cascades used by the CSM.
  56813. */
  56814. static readonly MAX_CASCADES_COUNT: number;
  56815. protected _validateFilter(filter: number): number;
  56816. /**
  56817. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56818. */
  56819. penumbraDarkness: number;
  56820. private _numCascades;
  56821. /**
  56822. * Gets or set the number of cascades used by the CSM.
  56823. */
  56824. get numCascades(): number;
  56825. set numCascades(value: number);
  56826. /**
  56827. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56828. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56829. */
  56830. stabilizeCascades: boolean;
  56831. private _freezeShadowCastersBoundingInfo;
  56832. private _freezeShadowCastersBoundingInfoObservable;
  56833. /**
  56834. * Enables or disables the shadow casters bounding info computation.
  56835. * If your shadow casters don't move, you can disable this feature.
  56836. * If it is enabled, the bounding box computation is done every frame.
  56837. */
  56838. get freezeShadowCastersBoundingInfo(): boolean;
  56839. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56840. private _scbiMin;
  56841. private _scbiMax;
  56842. protected _computeShadowCastersBoundingInfo(): void;
  56843. protected _shadowCastersBoundingInfo: BoundingInfo;
  56844. /**
  56845. * Gets or sets the shadow casters bounding info.
  56846. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56847. * so that the system won't overwrite the bounds you provide
  56848. */
  56849. get shadowCastersBoundingInfo(): BoundingInfo;
  56850. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56851. protected _breaksAreDirty: boolean;
  56852. protected _minDistance: number;
  56853. protected _maxDistance: number;
  56854. /**
  56855. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56856. *
  56857. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56858. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56859. * @param min minimal distance for the breaks (default to 0.)
  56860. * @param max maximal distance for the breaks (default to 1.)
  56861. */
  56862. setMinMaxDistance(min: number, max: number): void;
  56863. /** Gets the minimal distance used in the cascade break computation */
  56864. get minDistance(): number;
  56865. /** Gets the maximal distance used in the cascade break computation */
  56866. get maxDistance(): number;
  56867. /**
  56868. * Gets the class name of that object
  56869. * @returns "CascadedShadowGenerator"
  56870. */
  56871. getClassName(): string;
  56872. private _cascadeMinExtents;
  56873. private _cascadeMaxExtents;
  56874. /**
  56875. * Gets a cascade minimum extents
  56876. * @param cascadeIndex index of the cascade
  56877. * @returns the minimum cascade extents
  56878. */
  56879. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56880. /**
  56881. * Gets a cascade maximum extents
  56882. * @param cascadeIndex index of the cascade
  56883. * @returns the maximum cascade extents
  56884. */
  56885. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56886. private _cascades;
  56887. private _currentLayer;
  56888. private _viewSpaceFrustumsZ;
  56889. private _viewMatrices;
  56890. private _projectionMatrices;
  56891. private _transformMatrices;
  56892. private _transformMatricesAsArray;
  56893. private _frustumLengths;
  56894. private _lightSizeUVCorrection;
  56895. private _depthCorrection;
  56896. private _frustumCornersWorldSpace;
  56897. private _frustumCenter;
  56898. private _shadowCameraPos;
  56899. private _shadowMaxZ;
  56900. /**
  56901. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56902. * It defaults to camera.maxZ
  56903. */
  56904. get shadowMaxZ(): number;
  56905. /**
  56906. * Sets the shadow max z distance.
  56907. */
  56908. set shadowMaxZ(value: number);
  56909. protected _debug: boolean;
  56910. /**
  56911. * Gets or sets the debug flag.
  56912. * When enabled, the cascades are materialized by different colors on the screen.
  56913. */
  56914. get debug(): boolean;
  56915. set debug(dbg: boolean);
  56916. private _depthClamp;
  56917. /**
  56918. * Gets or sets the depth clamping value.
  56919. *
  56920. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56921. * to account for the shadow casters far away.
  56922. *
  56923. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56924. */
  56925. get depthClamp(): boolean;
  56926. set depthClamp(value: boolean);
  56927. private _cascadeBlendPercentage;
  56928. /**
  56929. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56930. * It defaults to 0.1 (10% blending).
  56931. */
  56932. get cascadeBlendPercentage(): number;
  56933. set cascadeBlendPercentage(value: number);
  56934. private _lambda;
  56935. /**
  56936. * Gets or set the lambda parameter.
  56937. * This parameter is used to split the camera frustum and create the cascades.
  56938. * 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.
  56939. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56940. */
  56941. get lambda(): number;
  56942. set lambda(value: number);
  56943. /**
  56944. * Gets the view matrix corresponding to a given cascade
  56945. * @param cascadeNum cascade to retrieve the view matrix from
  56946. * @returns the cascade view matrix
  56947. */
  56948. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56949. /**
  56950. * Gets the projection matrix corresponding to a given cascade
  56951. * @param cascadeNum cascade to retrieve the projection matrix from
  56952. * @returns the cascade projection matrix
  56953. */
  56954. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56955. /**
  56956. * Gets the transformation matrix corresponding to a given cascade
  56957. * @param cascadeNum cascade to retrieve the transformation matrix from
  56958. * @returns the cascade transformation matrix
  56959. */
  56960. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56961. private _depthRenderer;
  56962. /**
  56963. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56964. *
  56965. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56966. *
  56967. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56968. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56969. * @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
  56970. */
  56971. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56972. private _depthReducer;
  56973. private _autoCalcDepthBounds;
  56974. /**
  56975. * Gets or sets the autoCalcDepthBounds property.
  56976. *
  56977. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56978. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56979. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56980. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56981. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56982. */
  56983. get autoCalcDepthBounds(): boolean;
  56984. set autoCalcDepthBounds(value: boolean);
  56985. /**
  56986. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56987. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56988. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56989. * for setting the refresh rate on the renderer yourself!
  56990. */
  56991. get autoCalcDepthBoundsRefreshRate(): number;
  56992. set autoCalcDepthBoundsRefreshRate(value: number);
  56993. /**
  56994. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56995. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56996. * you change the camera near/far planes!
  56997. */
  56998. splitFrustum(): void;
  56999. private _splitFrustum;
  57000. private _computeMatrices;
  57001. private _computeFrustumInWorldSpace;
  57002. private _computeCascadeFrustum;
  57003. /** @hidden */
  57004. static _SceneComponentInitialization: (scene: Scene) => void;
  57005. /**
  57006. * Creates a Cascaded Shadow Generator object.
  57007. * A ShadowGenerator is the required tool to use the shadows.
  57008. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57009. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57010. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57011. * @param light The directional light object generating the shadows.
  57012. * @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.
  57013. */
  57014. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57015. protected _initializeGenerator(): void;
  57016. protected _createTargetRenderTexture(): void;
  57017. protected _initializeShadowMap(): void;
  57018. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57019. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57020. /**
  57021. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57022. * @param defines Defines of the material we want to update
  57023. * @param lightIndex Index of the light in the enabled light list of the material
  57024. */
  57025. prepareDefines(defines: any, lightIndex: number): void;
  57026. /**
  57027. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57028. * defined in the generator but impacting the effect).
  57029. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57030. * @param effect The effect we are binfing the information for
  57031. */
  57032. bindShadowLight(lightIndex: string, effect: Effect): void;
  57033. /**
  57034. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57035. * (eq to view projection * shadow projection matrices)
  57036. * @returns The transform matrix used to create the shadow map
  57037. */
  57038. getTransformMatrix(): Matrix;
  57039. /**
  57040. * Disposes the ShadowGenerator.
  57041. * Returns nothing.
  57042. */
  57043. dispose(): void;
  57044. /**
  57045. * Serializes the shadow generator setup to a json object.
  57046. * @returns The serialized JSON object
  57047. */
  57048. serialize(): any;
  57049. /**
  57050. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57051. * @param parsedShadowGenerator The JSON object to parse
  57052. * @param scene The scene to create the shadow map for
  57053. * @returns The parsed shadow generator
  57054. */
  57055. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57056. }
  57057. }
  57058. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57059. import { Scene } from "babylonjs/scene";
  57060. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57061. import { AbstractScene } from "babylonjs/abstractScene";
  57062. /**
  57063. * Defines the shadow generator component responsible to manage any shadow generators
  57064. * in a given scene.
  57065. */
  57066. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57067. /**
  57068. * The component name helpfull to identify the component in the list of scene components.
  57069. */
  57070. readonly name: string;
  57071. /**
  57072. * The scene the component belongs to.
  57073. */
  57074. scene: Scene;
  57075. /**
  57076. * Creates a new instance of the component for the given scene
  57077. * @param scene Defines the scene to register the component in
  57078. */
  57079. constructor(scene: Scene);
  57080. /**
  57081. * Registers the component in a given scene
  57082. */
  57083. register(): void;
  57084. /**
  57085. * Rebuilds the elements related to this component in case of
  57086. * context lost for instance.
  57087. */
  57088. rebuild(): void;
  57089. /**
  57090. * Serializes the component data to the specified json object
  57091. * @param serializationObject The object to serialize to
  57092. */
  57093. serialize(serializationObject: any): void;
  57094. /**
  57095. * Adds all the elements from the container to the scene
  57096. * @param container the container holding the elements
  57097. */
  57098. addFromContainer(container: AbstractScene): void;
  57099. /**
  57100. * Removes all the elements in the container from the scene
  57101. * @param container contains the elements to remove
  57102. * @param dispose if the removed element should be disposed (default: false)
  57103. */
  57104. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57105. /**
  57106. * Rebuilds the elements related to this component in case of
  57107. * context lost for instance.
  57108. */
  57109. dispose(): void;
  57110. private _gatherRenderTargets;
  57111. }
  57112. }
  57113. declare module "babylonjs/Lights/Shadows/index" {
  57114. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57115. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57116. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57117. }
  57118. declare module "babylonjs/Lights/pointLight" {
  57119. import { Scene } from "babylonjs/scene";
  57120. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57122. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57123. import { Effect } from "babylonjs/Materials/effect";
  57124. /**
  57125. * A point light is a light defined by an unique point in world space.
  57126. * The light is emitted in every direction from this point.
  57127. * A good example of a point light is a standard light bulb.
  57128. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57129. */
  57130. export class PointLight extends ShadowLight {
  57131. private _shadowAngle;
  57132. /**
  57133. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57134. * This specifies what angle the shadow will use to be created.
  57135. *
  57136. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57137. */
  57138. get shadowAngle(): number;
  57139. /**
  57140. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57141. * This specifies what angle the shadow will use to be created.
  57142. *
  57143. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57144. */
  57145. set shadowAngle(value: number);
  57146. /**
  57147. * Gets the direction if it has been set.
  57148. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57149. */
  57150. get direction(): Vector3;
  57151. /**
  57152. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57153. */
  57154. set direction(value: Vector3);
  57155. /**
  57156. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57157. * A PointLight emits the light in every direction.
  57158. * It can cast shadows.
  57159. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57160. * ```javascript
  57161. * var pointLight = new PointLight("pl", camera.position, scene);
  57162. * ```
  57163. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57164. * @param name The light friendly name
  57165. * @param position The position of the point light in the scene
  57166. * @param scene The scene the lights belongs to
  57167. */
  57168. constructor(name: string, position: Vector3, scene: Scene);
  57169. /**
  57170. * Returns the string "PointLight"
  57171. * @returns the class name
  57172. */
  57173. getClassName(): string;
  57174. /**
  57175. * Returns the integer 0.
  57176. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57177. */
  57178. getTypeID(): number;
  57179. /**
  57180. * Specifies wether or not the shadowmap should be a cube texture.
  57181. * @returns true if the shadowmap needs to be a cube texture.
  57182. */
  57183. needCube(): boolean;
  57184. /**
  57185. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57188. */
  57189. getShadowDirection(faceIndex?: number): Vector3;
  57190. /**
  57191. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57192. * - fov = PI / 2
  57193. * - aspect ratio : 1.0
  57194. * - z-near and far equal to the active camera minZ and maxZ.
  57195. * Returns the PointLight.
  57196. */
  57197. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57198. protected _buildUniformLayout(): void;
  57199. /**
  57200. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57201. * @param effect The effect to update
  57202. * @param lightIndex The index of the light in the effect to update
  57203. * @returns The point light
  57204. */
  57205. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57206. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57207. /**
  57208. * Prepares the list of defines specific to the light type.
  57209. * @param defines the list of defines
  57210. * @param lightIndex defines the index of the light for the effect
  57211. */
  57212. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57213. }
  57214. }
  57215. declare module "babylonjs/Lights/index" {
  57216. export * from "babylonjs/Lights/light";
  57217. export * from "babylonjs/Lights/shadowLight";
  57218. export * from "babylonjs/Lights/Shadows/index";
  57219. export * from "babylonjs/Lights/directionalLight";
  57220. export * from "babylonjs/Lights/hemisphericLight";
  57221. export * from "babylonjs/Lights/pointLight";
  57222. export * from "babylonjs/Lights/spotLight";
  57223. }
  57224. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57225. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57226. /**
  57227. * Header information of HDR texture files.
  57228. */
  57229. export interface HDRInfo {
  57230. /**
  57231. * The height of the texture in pixels.
  57232. */
  57233. height: number;
  57234. /**
  57235. * The width of the texture in pixels.
  57236. */
  57237. width: number;
  57238. /**
  57239. * The index of the beginning of the data in the binary file.
  57240. */
  57241. dataPosition: number;
  57242. }
  57243. /**
  57244. * This groups tools to convert HDR texture to native colors array.
  57245. */
  57246. export class HDRTools {
  57247. private static Ldexp;
  57248. private static Rgbe2float;
  57249. private static readStringLine;
  57250. /**
  57251. * Reads header information from an RGBE texture stored in a native array.
  57252. * More information on this format are available here:
  57253. * https://en.wikipedia.org/wiki/RGBE_image_format
  57254. *
  57255. * @param uint8array The binary file stored in native array.
  57256. * @return The header information.
  57257. */
  57258. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57259. /**
  57260. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57261. * This RGBE texture needs to store the information as a panorama.
  57262. *
  57263. * More information on this format are available here:
  57264. * https://en.wikipedia.org/wiki/RGBE_image_format
  57265. *
  57266. * @param buffer The binary file stored in an array buffer.
  57267. * @param size The expected size of the extracted cubemap.
  57268. * @return The Cube Map information.
  57269. */
  57270. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57271. /**
  57272. * Returns the pixels data extracted from an RGBE texture.
  57273. * This pixels will be stored left to right up to down in the R G B order in one array.
  57274. *
  57275. * More information on this format are available here:
  57276. * https://en.wikipedia.org/wiki/RGBE_image_format
  57277. *
  57278. * @param uint8array The binary file stored in an array buffer.
  57279. * @param hdrInfo The header information of the file.
  57280. * @return The pixels data in RGB right to left up to down order.
  57281. */
  57282. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57283. private static RGBE_ReadPixels_RLE;
  57284. }
  57285. }
  57286. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57287. import { Nullable } from "babylonjs/types";
  57288. import { Scene } from "babylonjs/scene";
  57289. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57291. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57292. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57293. /**
  57294. * This represents a texture coming from an HDR input.
  57295. *
  57296. * The only supported format is currently panorama picture stored in RGBE format.
  57297. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57298. */
  57299. export class HDRCubeTexture extends BaseTexture {
  57300. private static _facesMapping;
  57301. private _generateHarmonics;
  57302. private _noMipmap;
  57303. private _textureMatrix;
  57304. private _size;
  57305. private _onLoad;
  57306. private _onError;
  57307. /**
  57308. * The texture URL.
  57309. */
  57310. url: string;
  57311. /**
  57312. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57313. */
  57314. coordinatesMode: number;
  57315. protected _isBlocking: boolean;
  57316. /**
  57317. * Sets wether or not the texture is blocking during loading.
  57318. */
  57319. set isBlocking(value: boolean);
  57320. /**
  57321. * Gets wether or not the texture is blocking during loading.
  57322. */
  57323. get isBlocking(): boolean;
  57324. protected _rotationY: number;
  57325. /**
  57326. * Sets texture matrix rotation angle around Y axis in radians.
  57327. */
  57328. set rotationY(value: number);
  57329. /**
  57330. * Gets texture matrix rotation angle around Y axis radians.
  57331. */
  57332. get rotationY(): number;
  57333. /**
  57334. * Gets or sets the center of the bounding box associated with the cube texture
  57335. * It must define where the camera used to render the texture was set
  57336. */
  57337. boundingBoxPosition: Vector3;
  57338. private _boundingBoxSize;
  57339. /**
  57340. * Gets or sets the size of the bounding box associated with the cube texture
  57341. * When defined, the cubemap will switch to local mode
  57342. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57343. * @example https://www.babylonjs-playground.com/#RNASML
  57344. */
  57345. set boundingBoxSize(value: Vector3);
  57346. get boundingBoxSize(): Vector3;
  57347. /**
  57348. * Instantiates an HDRTexture from the following parameters.
  57349. *
  57350. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57351. * @param scene The scene the texture will be used in
  57352. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57353. * @param noMipmap Forces to not generate the mipmap if true
  57354. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57355. * @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)
  57356. * @param reserved Reserved flag for internal use.
  57357. */
  57358. 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>);
  57359. /**
  57360. * Get the current class name of the texture useful for serialization or dynamic coding.
  57361. * @returns "HDRCubeTexture"
  57362. */
  57363. getClassName(): string;
  57364. /**
  57365. * Occurs when the file is raw .hdr file.
  57366. */
  57367. private loadTexture;
  57368. clone(): HDRCubeTexture;
  57369. delayLoad(): void;
  57370. /**
  57371. * Get the texture reflection matrix used to rotate/transform the reflection.
  57372. * @returns the reflection matrix
  57373. */
  57374. getReflectionTextureMatrix(): Matrix;
  57375. /**
  57376. * Set the texture reflection matrix used to rotate/transform the reflection.
  57377. * @param value Define the reflection matrix to set
  57378. */
  57379. setReflectionTextureMatrix(value: Matrix): void;
  57380. /**
  57381. * Parses a JSON representation of an HDR Texture in order to create the texture
  57382. * @param parsedTexture Define the JSON representation
  57383. * @param scene Define the scene the texture should be created in
  57384. * @param rootUrl Define the root url in case we need to load relative dependencies
  57385. * @returns the newly created texture after parsing
  57386. */
  57387. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57388. serialize(): any;
  57389. }
  57390. }
  57391. declare module "babylonjs/Physics/physicsEngine" {
  57392. import { Nullable } from "babylonjs/types";
  57393. import { Vector3 } from "babylonjs/Maths/math.vector";
  57394. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57395. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57396. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57397. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57398. /**
  57399. * Class used to control physics engine
  57400. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57401. */
  57402. export class PhysicsEngine implements IPhysicsEngine {
  57403. private _physicsPlugin;
  57404. /**
  57405. * Global value used to control the smallest number supported by the simulation
  57406. */
  57407. static Epsilon: number;
  57408. private _impostors;
  57409. private _joints;
  57410. private _subTimeStep;
  57411. /**
  57412. * Gets the gravity vector used by the simulation
  57413. */
  57414. gravity: Vector3;
  57415. /**
  57416. * Factory used to create the default physics plugin.
  57417. * @returns The default physics plugin
  57418. */
  57419. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57420. /**
  57421. * Creates a new Physics Engine
  57422. * @param gravity defines the gravity vector used by the simulation
  57423. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57424. */
  57425. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57426. /**
  57427. * Sets the gravity vector used by the simulation
  57428. * @param gravity defines the gravity vector to use
  57429. */
  57430. setGravity(gravity: Vector3): void;
  57431. /**
  57432. * Set the time step of the physics engine.
  57433. * Default is 1/60.
  57434. * To slow it down, enter 1/600 for example.
  57435. * To speed it up, 1/30
  57436. * @param newTimeStep defines the new timestep to apply to this world.
  57437. */
  57438. setTimeStep(newTimeStep?: number): void;
  57439. /**
  57440. * Get the time step of the physics engine.
  57441. * @returns the current time step
  57442. */
  57443. getTimeStep(): number;
  57444. /**
  57445. * Set the sub time step of the physics engine.
  57446. * Default is 0 meaning there is no sub steps
  57447. * To increase physics resolution precision, set a small value (like 1 ms)
  57448. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57449. */
  57450. setSubTimeStep(subTimeStep?: number): void;
  57451. /**
  57452. * Get the sub time step of the physics engine.
  57453. * @returns the current sub time step
  57454. */
  57455. getSubTimeStep(): number;
  57456. /**
  57457. * Release all resources
  57458. */
  57459. dispose(): void;
  57460. /**
  57461. * Gets the name of the current physics plugin
  57462. * @returns the name of the plugin
  57463. */
  57464. getPhysicsPluginName(): string;
  57465. /**
  57466. * Adding a new impostor for the impostor tracking.
  57467. * This will be done by the impostor itself.
  57468. * @param impostor the impostor to add
  57469. */
  57470. addImpostor(impostor: PhysicsImpostor): void;
  57471. /**
  57472. * Remove an impostor from the engine.
  57473. * This impostor and its mesh will not longer be updated by the physics engine.
  57474. * @param impostor the impostor to remove
  57475. */
  57476. removeImpostor(impostor: PhysicsImpostor): void;
  57477. /**
  57478. * Add a joint to the physics engine
  57479. * @param mainImpostor defines the main impostor to which the joint is added.
  57480. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57481. * @param joint defines the joint that will connect both impostors.
  57482. */
  57483. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57484. /**
  57485. * Removes a joint from the simulation
  57486. * @param mainImpostor defines the impostor used with the joint
  57487. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57488. * @param joint defines the joint to remove
  57489. */
  57490. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57491. /**
  57492. * Called by the scene. No need to call it.
  57493. * @param delta defines the timespam between frames
  57494. */
  57495. _step(delta: number): void;
  57496. /**
  57497. * Gets the current plugin used to run the simulation
  57498. * @returns current plugin
  57499. */
  57500. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57501. /**
  57502. * Gets the list of physic impostors
  57503. * @returns an array of PhysicsImpostor
  57504. */
  57505. getImpostors(): Array<PhysicsImpostor>;
  57506. /**
  57507. * Gets the impostor for a physics enabled object
  57508. * @param object defines the object impersonated by the impostor
  57509. * @returns the PhysicsImpostor or null if not found
  57510. */
  57511. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57512. /**
  57513. * Gets the impostor for a physics body object
  57514. * @param body defines physics body used by the impostor
  57515. * @returns the PhysicsImpostor or null if not found
  57516. */
  57517. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57518. /**
  57519. * Does a raycast in the physics world
  57520. * @param from when should the ray start?
  57521. * @param to when should the ray end?
  57522. * @returns PhysicsRaycastResult
  57523. */
  57524. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57525. }
  57526. }
  57527. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57528. import { Nullable } from "babylonjs/types";
  57529. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57531. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57532. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57533. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57534. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57535. /** @hidden */
  57536. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57537. private _useDeltaForWorldStep;
  57538. world: any;
  57539. name: string;
  57540. private _physicsMaterials;
  57541. private _fixedTimeStep;
  57542. private _cannonRaycastResult;
  57543. private _raycastResult;
  57544. private _physicsBodysToRemoveAfterStep;
  57545. BJSCANNON: any;
  57546. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57547. setGravity(gravity: Vector3): void;
  57548. setTimeStep(timeStep: number): void;
  57549. getTimeStep(): number;
  57550. executeStep(delta: number): void;
  57551. private _removeMarkedPhysicsBodiesFromWorld;
  57552. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57553. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57554. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57555. private _processChildMeshes;
  57556. removePhysicsBody(impostor: PhysicsImpostor): void;
  57557. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57558. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57559. private _addMaterial;
  57560. private _checkWithEpsilon;
  57561. private _createShape;
  57562. private _createHeightmap;
  57563. private _minus90X;
  57564. private _plus90X;
  57565. private _tmpPosition;
  57566. private _tmpDeltaPosition;
  57567. private _tmpUnityRotation;
  57568. private _updatePhysicsBodyTransformation;
  57569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57570. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57571. isSupported(): boolean;
  57572. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57573. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57574. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57575. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57576. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57577. getBodyMass(impostor: PhysicsImpostor): number;
  57578. getBodyFriction(impostor: PhysicsImpostor): number;
  57579. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57580. getBodyRestitution(impostor: PhysicsImpostor): number;
  57581. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57582. sleepBody(impostor: PhysicsImpostor): void;
  57583. wakeUpBody(impostor: PhysicsImpostor): void;
  57584. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57585. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57586. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57587. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57588. getRadius(impostor: PhysicsImpostor): number;
  57589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57590. dispose(): void;
  57591. private _extendNamespace;
  57592. /**
  57593. * Does a raycast in the physics world
  57594. * @param from when should the ray start?
  57595. * @param to when should the ray end?
  57596. * @returns PhysicsRaycastResult
  57597. */
  57598. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57599. }
  57600. }
  57601. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57602. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57603. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57604. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57606. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57607. import { Nullable } from "babylonjs/types";
  57608. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57609. /** @hidden */
  57610. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57611. world: any;
  57612. name: string;
  57613. BJSOIMO: any;
  57614. private _raycastResult;
  57615. constructor(iterations?: number, oimoInjection?: any);
  57616. setGravity(gravity: Vector3): void;
  57617. setTimeStep(timeStep: number): void;
  57618. getTimeStep(): number;
  57619. private _tmpImpostorsArray;
  57620. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57621. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57622. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57623. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57624. private _tmpPositionVector;
  57625. removePhysicsBody(impostor: PhysicsImpostor): void;
  57626. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57627. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57628. isSupported(): boolean;
  57629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57636. getBodyMass(impostor: PhysicsImpostor): number;
  57637. getBodyFriction(impostor: PhysicsImpostor): number;
  57638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57639. getBodyRestitution(impostor: PhysicsImpostor): number;
  57640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57641. sleepBody(impostor: PhysicsImpostor): void;
  57642. wakeUpBody(impostor: PhysicsImpostor): void;
  57643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57644. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57647. getRadius(impostor: PhysicsImpostor): number;
  57648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57649. dispose(): void;
  57650. /**
  57651. * Does a raycast in the physics world
  57652. * @param from when should the ray start?
  57653. * @param to when should the ray end?
  57654. * @returns PhysicsRaycastResult
  57655. */
  57656. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57657. }
  57658. }
  57659. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57660. import { Nullable } from "babylonjs/types";
  57661. import { Scene } from "babylonjs/scene";
  57662. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57663. import { Color4 } from "babylonjs/Maths/math.color";
  57664. import { Mesh } from "babylonjs/Meshes/mesh";
  57665. /**
  57666. * Class containing static functions to help procedurally build meshes
  57667. */
  57668. export class RibbonBuilder {
  57669. /**
  57670. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57671. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57672. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57673. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57674. * * 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
  57675. * * 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
  57676. * * 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
  57677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57680. * * 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
  57681. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57682. * * 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
  57683. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57685. * @param name defines the name of the mesh
  57686. * @param options defines the options used to create the mesh
  57687. * @param scene defines the hosting scene
  57688. * @returns the ribbon mesh
  57689. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57691. */
  57692. static CreateRibbon(name: string, options: {
  57693. pathArray: Vector3[][];
  57694. closeArray?: boolean;
  57695. closePath?: boolean;
  57696. offset?: number;
  57697. updatable?: boolean;
  57698. sideOrientation?: number;
  57699. frontUVs?: Vector4;
  57700. backUVs?: Vector4;
  57701. instance?: Mesh;
  57702. invertUV?: boolean;
  57703. uvs?: Vector2[];
  57704. colors?: Color4[];
  57705. }, scene?: Nullable<Scene>): Mesh;
  57706. }
  57707. }
  57708. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57709. import { Nullable } from "babylonjs/types";
  57710. import { Scene } from "babylonjs/scene";
  57711. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57712. import { Mesh } from "babylonjs/Meshes/mesh";
  57713. /**
  57714. * Class containing static functions to help procedurally build meshes
  57715. */
  57716. export class ShapeBuilder {
  57717. /**
  57718. * 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.
  57719. * * 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.
  57720. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57721. * * 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.
  57722. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57723. * * 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
  57724. * * 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
  57725. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57730. * @param name defines the name of the mesh
  57731. * @param options defines the options used to create the mesh
  57732. * @param scene defines the hosting scene
  57733. * @returns the extruded shape mesh
  57734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57736. */
  57737. static ExtrudeShape(name: string, options: {
  57738. shape: Vector3[];
  57739. path: Vector3[];
  57740. scale?: number;
  57741. rotation?: number;
  57742. cap?: number;
  57743. updatable?: boolean;
  57744. sideOrientation?: number;
  57745. frontUVs?: Vector4;
  57746. backUVs?: Vector4;
  57747. instance?: Mesh;
  57748. invertUV?: boolean;
  57749. }, scene?: Nullable<Scene>): Mesh;
  57750. /**
  57751. * Creates an custom extruded shape mesh.
  57752. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57753. * * 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.
  57754. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57755. * * 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
  57756. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57757. * * 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
  57758. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57759. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57760. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57761. * * 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
  57762. * * 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
  57763. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57768. * @param name defines the name of the mesh
  57769. * @param options defines the options used to create the mesh
  57770. * @param scene defines the hosting scene
  57771. * @returns the custom extruded shape mesh
  57772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57773. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57775. */
  57776. static ExtrudeShapeCustom(name: string, options: {
  57777. shape: Vector3[];
  57778. path: Vector3[];
  57779. scaleFunction?: any;
  57780. rotationFunction?: any;
  57781. ribbonCloseArray?: boolean;
  57782. ribbonClosePath?: boolean;
  57783. cap?: number;
  57784. updatable?: boolean;
  57785. sideOrientation?: number;
  57786. frontUVs?: Vector4;
  57787. backUVs?: Vector4;
  57788. instance?: Mesh;
  57789. invertUV?: boolean;
  57790. }, scene?: Nullable<Scene>): Mesh;
  57791. private static _ExtrudeShapeGeneric;
  57792. }
  57793. }
  57794. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57795. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57796. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57797. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57798. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57799. import { Nullable } from "babylonjs/types";
  57800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57801. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57802. /**
  57803. * AmmoJS Physics plugin
  57804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57805. * @see https://github.com/kripken/ammo.js/
  57806. */
  57807. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57808. private _useDeltaForWorldStep;
  57809. /**
  57810. * Reference to the Ammo library
  57811. */
  57812. bjsAMMO: any;
  57813. /**
  57814. * Created ammoJS world which physics bodies are added to
  57815. */
  57816. world: any;
  57817. /**
  57818. * Name of the plugin
  57819. */
  57820. name: string;
  57821. private _timeStep;
  57822. private _fixedTimeStep;
  57823. private _maxSteps;
  57824. private _tmpQuaternion;
  57825. private _tmpAmmoTransform;
  57826. private _tmpAmmoQuaternion;
  57827. private _tmpAmmoConcreteContactResultCallback;
  57828. private _collisionConfiguration;
  57829. private _dispatcher;
  57830. private _overlappingPairCache;
  57831. private _solver;
  57832. private _softBodySolver;
  57833. private _tmpAmmoVectorA;
  57834. private _tmpAmmoVectorB;
  57835. private _tmpAmmoVectorC;
  57836. private _tmpAmmoVectorD;
  57837. private _tmpContactCallbackResult;
  57838. private _tmpAmmoVectorRCA;
  57839. private _tmpAmmoVectorRCB;
  57840. private _raycastResult;
  57841. private static readonly DISABLE_COLLISION_FLAG;
  57842. private static readonly KINEMATIC_FLAG;
  57843. private static readonly DISABLE_DEACTIVATION_FLAG;
  57844. /**
  57845. * Initializes the ammoJS plugin
  57846. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57847. * @param ammoInjection can be used to inject your own ammo reference
  57848. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57849. */
  57850. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57851. /**
  57852. * Sets the gravity of the physics world (m/(s^2))
  57853. * @param gravity Gravity to set
  57854. */
  57855. setGravity(gravity: Vector3): void;
  57856. /**
  57857. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57858. * @param timeStep timestep to use in seconds
  57859. */
  57860. setTimeStep(timeStep: number): void;
  57861. /**
  57862. * 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)
  57863. * @param fixedTimeStep fixedTimeStep to use in seconds
  57864. */
  57865. setFixedTimeStep(fixedTimeStep: number): void;
  57866. /**
  57867. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57868. * @param maxSteps the maximum number of steps by the physics engine per frame
  57869. */
  57870. setMaxSteps(maxSteps: number): void;
  57871. /**
  57872. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57873. * @returns the current timestep in seconds
  57874. */
  57875. getTimeStep(): number;
  57876. /**
  57877. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57878. */
  57879. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57880. private _isImpostorInContact;
  57881. private _isImpostorPairInContact;
  57882. private _stepSimulation;
  57883. /**
  57884. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57885. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57886. * After the step the babylon meshes are set to the position of the physics imposters
  57887. * @param delta amount of time to step forward
  57888. * @param impostors array of imposters to update before/after the step
  57889. */
  57890. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57891. /**
  57892. * Update babylon mesh to match physics world object
  57893. * @param impostor imposter to match
  57894. */
  57895. private _afterSoftStep;
  57896. /**
  57897. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57898. * @param impostor imposter to match
  57899. */
  57900. private _ropeStep;
  57901. /**
  57902. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57903. * @param impostor imposter to match
  57904. */
  57905. private _softbodyOrClothStep;
  57906. private _tmpVector;
  57907. private _tmpMatrix;
  57908. /**
  57909. * Applies an impulse on the imposter
  57910. * @param impostor imposter to apply impulse to
  57911. * @param force amount of force to be applied to the imposter
  57912. * @param contactPoint the location to apply the impulse on the imposter
  57913. */
  57914. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57915. /**
  57916. * Applies a force on the imposter
  57917. * @param impostor imposter to apply force
  57918. * @param force amount of force to be applied to the imposter
  57919. * @param contactPoint the location to apply the force on the imposter
  57920. */
  57921. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57922. /**
  57923. * Creates a physics body using the plugin
  57924. * @param impostor the imposter to create the physics body on
  57925. */
  57926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57927. /**
  57928. * Removes the physics body from the imposter and disposes of the body's memory
  57929. * @param impostor imposter to remove the physics body from
  57930. */
  57931. removePhysicsBody(impostor: PhysicsImpostor): void;
  57932. /**
  57933. * Generates a joint
  57934. * @param impostorJoint the imposter joint to create the joint with
  57935. */
  57936. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57937. /**
  57938. * Removes a joint
  57939. * @param impostorJoint the imposter joint to remove the joint from
  57940. */
  57941. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57942. private _addMeshVerts;
  57943. /**
  57944. * Initialise the soft body vertices to match its object's (mesh) vertices
  57945. * Softbody vertices (nodes) are in world space and to match this
  57946. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57947. * @param impostor to create the softbody for
  57948. */
  57949. private _softVertexData;
  57950. /**
  57951. * Create an impostor's soft body
  57952. * @param impostor to create the softbody for
  57953. */
  57954. private _createSoftbody;
  57955. /**
  57956. * Create cloth for an impostor
  57957. * @param impostor to create the softbody for
  57958. */
  57959. private _createCloth;
  57960. /**
  57961. * Create rope for an impostor
  57962. * @param impostor to create the softbody for
  57963. */
  57964. private _createRope;
  57965. /**
  57966. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57967. * @param impostor to create the custom physics shape for
  57968. */
  57969. private _createCustom;
  57970. private _addHullVerts;
  57971. private _createShape;
  57972. /**
  57973. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57974. * @param impostor imposter containing the physics body and babylon object
  57975. */
  57976. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57977. /**
  57978. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57979. * @param impostor imposter containing the physics body and babylon object
  57980. * @param newPosition new position
  57981. * @param newRotation new rotation
  57982. */
  57983. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57984. /**
  57985. * If this plugin is supported
  57986. * @returns true if its supported
  57987. */
  57988. isSupported(): boolean;
  57989. /**
  57990. * Sets the linear velocity of the physics body
  57991. * @param impostor imposter to set the velocity on
  57992. * @param velocity velocity to set
  57993. */
  57994. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57995. /**
  57996. * Sets the angular velocity of the physics body
  57997. * @param impostor imposter to set the velocity on
  57998. * @param velocity velocity to set
  57999. */
  58000. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58001. /**
  58002. * gets the linear velocity
  58003. * @param impostor imposter to get linear velocity from
  58004. * @returns linear velocity
  58005. */
  58006. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58007. /**
  58008. * gets the angular velocity
  58009. * @param impostor imposter to get angular velocity from
  58010. * @returns angular velocity
  58011. */
  58012. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58013. /**
  58014. * Sets the mass of physics body
  58015. * @param impostor imposter to set the mass on
  58016. * @param mass mass to set
  58017. */
  58018. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58019. /**
  58020. * Gets the mass of the physics body
  58021. * @param impostor imposter to get the mass from
  58022. * @returns mass
  58023. */
  58024. getBodyMass(impostor: PhysicsImpostor): number;
  58025. /**
  58026. * Gets friction of the impostor
  58027. * @param impostor impostor to get friction from
  58028. * @returns friction value
  58029. */
  58030. getBodyFriction(impostor: PhysicsImpostor): number;
  58031. /**
  58032. * Sets friction of the impostor
  58033. * @param impostor impostor to set friction on
  58034. * @param friction friction value
  58035. */
  58036. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58037. /**
  58038. * Gets restitution of the impostor
  58039. * @param impostor impostor to get restitution from
  58040. * @returns restitution value
  58041. */
  58042. getBodyRestitution(impostor: PhysicsImpostor): number;
  58043. /**
  58044. * Sets resitution of the impostor
  58045. * @param impostor impostor to set resitution on
  58046. * @param restitution resitution value
  58047. */
  58048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58049. /**
  58050. * Gets pressure inside the impostor
  58051. * @param impostor impostor to get pressure from
  58052. * @returns pressure value
  58053. */
  58054. getBodyPressure(impostor: PhysicsImpostor): number;
  58055. /**
  58056. * Sets pressure inside a soft body impostor
  58057. * Cloth and rope must remain 0 pressure
  58058. * @param impostor impostor to set pressure on
  58059. * @param pressure pressure value
  58060. */
  58061. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58062. /**
  58063. * Gets stiffness of the impostor
  58064. * @param impostor impostor to get stiffness from
  58065. * @returns pressure value
  58066. */
  58067. getBodyStiffness(impostor: PhysicsImpostor): number;
  58068. /**
  58069. * Sets stiffness of the impostor
  58070. * @param impostor impostor to set stiffness on
  58071. * @param stiffness stiffness value from 0 to 1
  58072. */
  58073. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58074. /**
  58075. * Gets velocityIterations of the impostor
  58076. * @param impostor impostor to get velocity iterations from
  58077. * @returns velocityIterations value
  58078. */
  58079. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58080. /**
  58081. * Sets velocityIterations of the impostor
  58082. * @param impostor impostor to set velocity iterations on
  58083. * @param velocityIterations velocityIterations value
  58084. */
  58085. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58086. /**
  58087. * Gets positionIterations of the impostor
  58088. * @param impostor impostor to get position iterations from
  58089. * @returns positionIterations value
  58090. */
  58091. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58092. /**
  58093. * Sets positionIterations of the impostor
  58094. * @param impostor impostor to set position on
  58095. * @param positionIterations positionIterations value
  58096. */
  58097. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58098. /**
  58099. * Append an anchor to a cloth object
  58100. * @param impostor is the cloth impostor to add anchor to
  58101. * @param otherImpostor is the rigid impostor to anchor to
  58102. * @param width ratio across width from 0 to 1
  58103. * @param height ratio up height from 0 to 1
  58104. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58105. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58106. */
  58107. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58108. /**
  58109. * Append an hook to a rope object
  58110. * @param impostor is the rope impostor to add hook to
  58111. * @param otherImpostor is the rigid impostor to hook to
  58112. * @param length ratio along the rope from 0 to 1
  58113. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58114. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58115. */
  58116. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58117. /**
  58118. * Sleeps the physics body and stops it from being active
  58119. * @param impostor impostor to sleep
  58120. */
  58121. sleepBody(impostor: PhysicsImpostor): void;
  58122. /**
  58123. * Activates the physics body
  58124. * @param impostor impostor to activate
  58125. */
  58126. wakeUpBody(impostor: PhysicsImpostor): void;
  58127. /**
  58128. * Updates the distance parameters of the joint
  58129. * @param joint joint to update
  58130. * @param maxDistance maximum distance of the joint
  58131. * @param minDistance minimum distance of the joint
  58132. */
  58133. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58134. /**
  58135. * Sets a motor on the joint
  58136. * @param joint joint to set motor on
  58137. * @param speed speed of the motor
  58138. * @param maxForce maximum force of the motor
  58139. * @param motorIndex index of the motor
  58140. */
  58141. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58142. /**
  58143. * Sets the motors limit
  58144. * @param joint joint to set limit on
  58145. * @param upperLimit upper limit
  58146. * @param lowerLimit lower limit
  58147. */
  58148. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58149. /**
  58150. * Syncs the position and rotation of a mesh with the impostor
  58151. * @param mesh mesh to sync
  58152. * @param impostor impostor to update the mesh with
  58153. */
  58154. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58155. /**
  58156. * Gets the radius of the impostor
  58157. * @param impostor impostor to get radius from
  58158. * @returns the radius
  58159. */
  58160. getRadius(impostor: PhysicsImpostor): number;
  58161. /**
  58162. * Gets the box size of the impostor
  58163. * @param impostor impostor to get box size from
  58164. * @param result the resulting box size
  58165. */
  58166. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58167. /**
  58168. * Disposes of the impostor
  58169. */
  58170. dispose(): void;
  58171. /**
  58172. * Does a raycast in the physics world
  58173. * @param from when should the ray start?
  58174. * @param to when should the ray end?
  58175. * @returns PhysicsRaycastResult
  58176. */
  58177. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58178. }
  58179. }
  58180. declare module "babylonjs/Probes/reflectionProbe" {
  58181. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58182. import { Vector3 } from "babylonjs/Maths/math.vector";
  58183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58184. import { Nullable } from "babylonjs/types";
  58185. import { Scene } from "babylonjs/scene";
  58186. module "babylonjs/abstractScene" {
  58187. interface AbstractScene {
  58188. /**
  58189. * The list of reflection probes added to the scene
  58190. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58191. */
  58192. reflectionProbes: Array<ReflectionProbe>;
  58193. /**
  58194. * Removes the given reflection probe from this scene.
  58195. * @param toRemove The reflection probe to remove
  58196. * @returns The index of the removed reflection probe
  58197. */
  58198. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58199. /**
  58200. * Adds the given reflection probe to this scene.
  58201. * @param newReflectionProbe The reflection probe to add
  58202. */
  58203. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58204. }
  58205. }
  58206. /**
  58207. * Class used to generate realtime reflection / refraction cube textures
  58208. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58209. */
  58210. export class ReflectionProbe {
  58211. /** defines the name of the probe */
  58212. name: string;
  58213. private _scene;
  58214. private _renderTargetTexture;
  58215. private _projectionMatrix;
  58216. private _viewMatrix;
  58217. private _target;
  58218. private _add;
  58219. private _attachedMesh;
  58220. private _invertYAxis;
  58221. /** Gets or sets probe position (center of the cube map) */
  58222. position: Vector3;
  58223. /**
  58224. * Creates a new reflection probe
  58225. * @param name defines the name of the probe
  58226. * @param size defines the texture resolution (for each face)
  58227. * @param scene defines the hosting scene
  58228. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58229. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58230. */
  58231. constructor(
  58232. /** defines the name of the probe */
  58233. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58234. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58235. get samples(): number;
  58236. set samples(value: number);
  58237. /** Gets or sets the refresh rate to use (on every frame by default) */
  58238. get refreshRate(): number;
  58239. set refreshRate(value: number);
  58240. /**
  58241. * Gets the hosting scene
  58242. * @returns a Scene
  58243. */
  58244. getScene(): Scene;
  58245. /** Gets the internal CubeTexture used to render to */
  58246. get cubeTexture(): RenderTargetTexture;
  58247. /** Gets the list of meshes to render */
  58248. get renderList(): Nullable<AbstractMesh[]>;
  58249. /**
  58250. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58251. * @param mesh defines the mesh to attach to
  58252. */
  58253. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58254. /**
  58255. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58256. * @param renderingGroupId The rendering group id corresponding to its index
  58257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58258. */
  58259. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58260. /**
  58261. * Clean all associated resources
  58262. */
  58263. dispose(): void;
  58264. /**
  58265. * Converts the reflection probe information to a readable string for debug purpose.
  58266. * @param fullDetails Supports for multiple levels of logging within scene loading
  58267. * @returns the human readable reflection probe info
  58268. */
  58269. toString(fullDetails?: boolean): string;
  58270. /**
  58271. * Get the class name of the relfection probe.
  58272. * @returns "ReflectionProbe"
  58273. */
  58274. getClassName(): string;
  58275. /**
  58276. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58277. * @returns The JSON representation of the texture
  58278. */
  58279. serialize(): any;
  58280. /**
  58281. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58282. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58283. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58284. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58285. * @returns The parsed reflection probe if successful
  58286. */
  58287. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58288. }
  58289. }
  58290. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58291. /** @hidden */
  58292. export var _BabylonLoaderRegistered: boolean;
  58293. /**
  58294. * Helps setting up some configuration for the babylon file loader.
  58295. */
  58296. export class BabylonFileLoaderConfiguration {
  58297. /**
  58298. * The loader does not allow injecting custom physix engine into the plugins.
  58299. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58300. * So you could set this variable to your engine import to make it work.
  58301. */
  58302. static LoaderInjectedPhysicsEngine: any;
  58303. }
  58304. }
  58305. declare module "babylonjs/Loading/Plugins/index" {
  58306. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58307. }
  58308. declare module "babylonjs/Loading/index" {
  58309. export * from "babylonjs/Loading/loadingScreen";
  58310. export * from "babylonjs/Loading/Plugins/index";
  58311. export * from "babylonjs/Loading/sceneLoader";
  58312. export * from "babylonjs/Loading/sceneLoaderFlags";
  58313. }
  58314. declare module "babylonjs/Materials/Background/index" {
  58315. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58316. }
  58317. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58318. import { Scene } from "babylonjs/scene";
  58319. import { Color3 } from "babylonjs/Maths/math.color";
  58320. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58322. /**
  58323. * The Physically based simple base material of BJS.
  58324. *
  58325. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58326. * It is used as the base class for both the specGloss and metalRough conventions.
  58327. */
  58328. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58329. /**
  58330. * Number of Simultaneous lights allowed on the material.
  58331. */
  58332. maxSimultaneousLights: number;
  58333. /**
  58334. * If sets to true, disables all the lights affecting the material.
  58335. */
  58336. disableLighting: boolean;
  58337. /**
  58338. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58339. */
  58340. environmentTexture: BaseTexture;
  58341. /**
  58342. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58343. */
  58344. invertNormalMapX: boolean;
  58345. /**
  58346. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58347. */
  58348. invertNormalMapY: boolean;
  58349. /**
  58350. * Normal map used in the model.
  58351. */
  58352. normalTexture: BaseTexture;
  58353. /**
  58354. * Emissivie color used to self-illuminate the model.
  58355. */
  58356. emissiveColor: Color3;
  58357. /**
  58358. * Emissivie texture used to self-illuminate the model.
  58359. */
  58360. emissiveTexture: BaseTexture;
  58361. /**
  58362. * Occlusion Channel Strenght.
  58363. */
  58364. occlusionStrength: number;
  58365. /**
  58366. * Occlusion Texture of the material (adding extra occlusion effects).
  58367. */
  58368. occlusionTexture: BaseTexture;
  58369. /**
  58370. * Defines the alpha limits in alpha test mode.
  58371. */
  58372. alphaCutOff: number;
  58373. /**
  58374. * Gets the current double sided mode.
  58375. */
  58376. get doubleSided(): boolean;
  58377. /**
  58378. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58379. */
  58380. set doubleSided(value: boolean);
  58381. /**
  58382. * Stores the pre-calculated light information of a mesh in a texture.
  58383. */
  58384. lightmapTexture: BaseTexture;
  58385. /**
  58386. * If true, the light map contains occlusion information instead of lighting info.
  58387. */
  58388. useLightmapAsShadowmap: boolean;
  58389. /**
  58390. * Instantiates a new PBRMaterial instance.
  58391. *
  58392. * @param name The material name
  58393. * @param scene The scene the material will be use in.
  58394. */
  58395. constructor(name: string, scene: Scene);
  58396. getClassName(): string;
  58397. }
  58398. }
  58399. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58400. import { Scene } from "babylonjs/scene";
  58401. import { Color3 } from "babylonjs/Maths/math.color";
  58402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58403. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58404. /**
  58405. * The PBR material of BJS following the metal roughness convention.
  58406. *
  58407. * This fits to the PBR convention in the GLTF definition:
  58408. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58409. */
  58410. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58411. /**
  58412. * The base color has two different interpretations depending on the value of metalness.
  58413. * When the material is a metal, the base color is the specific measured reflectance value
  58414. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58415. * of the material.
  58416. */
  58417. baseColor: Color3;
  58418. /**
  58419. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58420. * well as opacity information in the alpha channel.
  58421. */
  58422. baseTexture: BaseTexture;
  58423. /**
  58424. * Specifies the metallic scalar value of the material.
  58425. * Can also be used to scale the metalness values of the metallic texture.
  58426. */
  58427. metallic: number;
  58428. /**
  58429. * Specifies the roughness scalar value of the material.
  58430. * Can also be used to scale the roughness values of the metallic texture.
  58431. */
  58432. roughness: number;
  58433. /**
  58434. * Texture containing both the metallic value in the B channel and the
  58435. * roughness value in the G channel to keep better precision.
  58436. */
  58437. metallicRoughnessTexture: BaseTexture;
  58438. /**
  58439. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58440. *
  58441. * @param name The material name
  58442. * @param scene The scene the material will be use in.
  58443. */
  58444. constructor(name: string, scene: Scene);
  58445. /**
  58446. * Return the currrent class name of the material.
  58447. */
  58448. getClassName(): string;
  58449. /**
  58450. * Makes a duplicate of the current material.
  58451. * @param name - name to use for the new material.
  58452. */
  58453. clone(name: string): PBRMetallicRoughnessMaterial;
  58454. /**
  58455. * Serialize the material to a parsable JSON object.
  58456. */
  58457. serialize(): any;
  58458. /**
  58459. * Parses a JSON object correponding to the serialize function.
  58460. */
  58461. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58462. }
  58463. }
  58464. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58465. import { Scene } from "babylonjs/scene";
  58466. import { Color3 } from "babylonjs/Maths/math.color";
  58467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58468. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58469. /**
  58470. * The PBR material of BJS following the specular glossiness convention.
  58471. *
  58472. * This fits to the PBR convention in the GLTF definition:
  58473. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58474. */
  58475. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58476. /**
  58477. * Specifies the diffuse color of the material.
  58478. */
  58479. diffuseColor: Color3;
  58480. /**
  58481. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58482. * channel.
  58483. */
  58484. diffuseTexture: BaseTexture;
  58485. /**
  58486. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58487. */
  58488. specularColor: Color3;
  58489. /**
  58490. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58491. */
  58492. glossiness: number;
  58493. /**
  58494. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58495. */
  58496. specularGlossinessTexture: BaseTexture;
  58497. /**
  58498. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58499. *
  58500. * @param name The material name
  58501. * @param scene The scene the material will be use in.
  58502. */
  58503. constructor(name: string, scene: Scene);
  58504. /**
  58505. * Return the currrent class name of the material.
  58506. */
  58507. getClassName(): string;
  58508. /**
  58509. * Makes a duplicate of the current material.
  58510. * @param name - name to use for the new material.
  58511. */
  58512. clone(name: string): PBRSpecularGlossinessMaterial;
  58513. /**
  58514. * Serialize the material to a parsable JSON object.
  58515. */
  58516. serialize(): any;
  58517. /**
  58518. * Parses a JSON object correponding to the serialize function.
  58519. */
  58520. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58521. }
  58522. }
  58523. declare module "babylonjs/Materials/PBR/index" {
  58524. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58525. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58526. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58527. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58528. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58529. }
  58530. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58531. import { Nullable } from "babylonjs/types";
  58532. import { Scene } from "babylonjs/scene";
  58533. import { Matrix } from "babylonjs/Maths/math.vector";
  58534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58535. /**
  58536. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58537. * It can help converting any input color in a desired output one. This can then be used to create effects
  58538. * from sepia, black and white to sixties or futuristic rendering...
  58539. *
  58540. * The only supported format is currently 3dl.
  58541. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58542. */
  58543. export class ColorGradingTexture extends BaseTexture {
  58544. /**
  58545. * The current texture matrix. (will always be identity in color grading texture)
  58546. */
  58547. private _textureMatrix;
  58548. /**
  58549. * The texture URL.
  58550. */
  58551. url: string;
  58552. /**
  58553. * Empty line regex stored for GC.
  58554. */
  58555. private static _noneEmptyLineRegex;
  58556. private _engine;
  58557. /**
  58558. * Instantiates a ColorGradingTexture from the following parameters.
  58559. *
  58560. * @param url The location of the color gradind data (currently only supporting 3dl)
  58561. * @param scene The scene the texture will be used in
  58562. */
  58563. constructor(url: string, scene: Scene);
  58564. /**
  58565. * Returns the texture matrix used in most of the material.
  58566. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58567. */
  58568. getTextureMatrix(): Matrix;
  58569. /**
  58570. * Occurs when the file being loaded is a .3dl LUT file.
  58571. */
  58572. private load3dlTexture;
  58573. /**
  58574. * Starts the loading process of the texture.
  58575. */
  58576. private loadTexture;
  58577. /**
  58578. * Clones the color gradind texture.
  58579. */
  58580. clone(): ColorGradingTexture;
  58581. /**
  58582. * Called during delayed load for textures.
  58583. */
  58584. delayLoad(): void;
  58585. /**
  58586. * Parses a color grading texture serialized by Babylon.
  58587. * @param parsedTexture The texture information being parsedTexture
  58588. * @param scene The scene to load the texture in
  58589. * @param rootUrl The root url of the data assets to load
  58590. * @return A color gradind texture
  58591. */
  58592. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58593. /**
  58594. * Serializes the LUT texture to json format.
  58595. */
  58596. serialize(): any;
  58597. }
  58598. }
  58599. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58601. import { Scene } from "babylonjs/scene";
  58602. import { Nullable } from "babylonjs/types";
  58603. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58604. /**
  58605. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58606. */
  58607. export class EquiRectangularCubeTexture extends BaseTexture {
  58608. /** The six faces of the cube. */
  58609. private static _FacesMapping;
  58610. private _noMipmap;
  58611. private _onLoad;
  58612. private _onError;
  58613. /** The size of the cubemap. */
  58614. private _size;
  58615. /** The buffer of the image. */
  58616. private _buffer;
  58617. /** The width of the input image. */
  58618. private _width;
  58619. /** The height of the input image. */
  58620. private _height;
  58621. /** The URL to the image. */
  58622. url: string;
  58623. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58624. coordinatesMode: number;
  58625. /**
  58626. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58627. * @param url The location of the image
  58628. * @param scene The scene the texture will be used in
  58629. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58630. * @param noMipmap Forces to not generate the mipmap if true
  58631. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58632. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58633. * @param onLoad — defines a callback called when texture is loaded
  58634. * @param onError — defines a callback called if there is an error
  58635. */
  58636. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58637. /**
  58638. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58639. */
  58640. private loadImage;
  58641. /**
  58642. * Convert the image buffer into a cubemap and create a CubeTexture.
  58643. */
  58644. private loadTexture;
  58645. /**
  58646. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58647. * @param buffer The ArrayBuffer that should be converted.
  58648. * @returns The buffer as Float32Array.
  58649. */
  58650. private getFloat32ArrayFromArrayBuffer;
  58651. /**
  58652. * Get the current class name of the texture useful for serialization or dynamic coding.
  58653. * @returns "EquiRectangularCubeTexture"
  58654. */
  58655. getClassName(): string;
  58656. /**
  58657. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58658. * @returns A clone of the current EquiRectangularCubeTexture.
  58659. */
  58660. clone(): EquiRectangularCubeTexture;
  58661. }
  58662. }
  58663. declare module "babylonjs/Misc/tga" {
  58664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58665. /**
  58666. * Based on jsTGALoader - Javascript loader for TGA file
  58667. * By Vincent Thibault
  58668. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58669. */
  58670. export class TGATools {
  58671. private static _TYPE_INDEXED;
  58672. private static _TYPE_RGB;
  58673. private static _TYPE_GREY;
  58674. private static _TYPE_RLE_INDEXED;
  58675. private static _TYPE_RLE_RGB;
  58676. private static _TYPE_RLE_GREY;
  58677. private static _ORIGIN_MASK;
  58678. private static _ORIGIN_SHIFT;
  58679. private static _ORIGIN_BL;
  58680. private static _ORIGIN_BR;
  58681. private static _ORIGIN_UL;
  58682. private static _ORIGIN_UR;
  58683. /**
  58684. * Gets the header of a TGA file
  58685. * @param data defines the TGA data
  58686. * @returns the header
  58687. */
  58688. static GetTGAHeader(data: Uint8Array): any;
  58689. /**
  58690. * Uploads TGA content to a Babylon Texture
  58691. * @hidden
  58692. */
  58693. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58694. /** @hidden */
  58695. 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;
  58696. /** @hidden */
  58697. 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;
  58698. /** @hidden */
  58699. 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;
  58700. /** @hidden */
  58701. 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;
  58702. /** @hidden */
  58703. 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;
  58704. /** @hidden */
  58705. 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;
  58706. }
  58707. }
  58708. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58709. import { Nullable } from "babylonjs/types";
  58710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58711. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58712. /**
  58713. * Implementation of the TGA Texture Loader.
  58714. * @hidden
  58715. */
  58716. export class _TGATextureLoader implements IInternalTextureLoader {
  58717. /**
  58718. * Defines wether the loader supports cascade loading the different faces.
  58719. */
  58720. readonly supportCascades: boolean;
  58721. /**
  58722. * This returns if the loader support the current file information.
  58723. * @param extension defines the file extension of the file being loaded
  58724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58725. * @param fallback defines the fallback internal texture if any
  58726. * @param isBase64 defines whether the texture is encoded as a base64
  58727. * @param isBuffer defines whether the texture data are stored as a buffer
  58728. * @returns true if the loader can load the specified file
  58729. */
  58730. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58731. /**
  58732. * Transform the url before loading if required.
  58733. * @param rootUrl the url of the texture
  58734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58735. * @returns the transformed texture
  58736. */
  58737. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58738. /**
  58739. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58740. * @param rootUrl the url of the texture
  58741. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58742. * @returns the fallback texture
  58743. */
  58744. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58745. /**
  58746. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58747. * @param data contains the texture data
  58748. * @param texture defines the BabylonJS internal texture
  58749. * @param createPolynomials will be true if polynomials have been requested
  58750. * @param onLoad defines the callback to trigger once the texture is ready
  58751. * @param onError defines the callback to trigger in case of error
  58752. */
  58753. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58754. /**
  58755. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58756. * @param data contains the texture data
  58757. * @param texture defines the BabylonJS internal texture
  58758. * @param callback defines the method to call once ready to upload
  58759. */
  58760. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58761. }
  58762. }
  58763. declare module "babylonjs/Misc/basis" {
  58764. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58765. /**
  58766. * Info about the .basis files
  58767. */
  58768. class BasisFileInfo {
  58769. /**
  58770. * If the file has alpha
  58771. */
  58772. hasAlpha: boolean;
  58773. /**
  58774. * Info about each image of the basis file
  58775. */
  58776. images: Array<{
  58777. levels: Array<{
  58778. width: number;
  58779. height: number;
  58780. transcodedPixels: ArrayBufferView;
  58781. }>;
  58782. }>;
  58783. }
  58784. /**
  58785. * Result of transcoding a basis file
  58786. */
  58787. class TranscodeResult {
  58788. /**
  58789. * Info about the .basis file
  58790. */
  58791. fileInfo: BasisFileInfo;
  58792. /**
  58793. * Format to use when loading the file
  58794. */
  58795. format: number;
  58796. }
  58797. /**
  58798. * Configuration options for the Basis transcoder
  58799. */
  58800. export class BasisTranscodeConfiguration {
  58801. /**
  58802. * Supported compression formats used to determine the supported output format of the transcoder
  58803. */
  58804. supportedCompressionFormats?: {
  58805. /**
  58806. * etc1 compression format
  58807. */
  58808. etc1?: boolean;
  58809. /**
  58810. * s3tc compression format
  58811. */
  58812. s3tc?: boolean;
  58813. /**
  58814. * pvrtc compression format
  58815. */
  58816. pvrtc?: boolean;
  58817. /**
  58818. * etc2 compression format
  58819. */
  58820. etc2?: boolean;
  58821. };
  58822. /**
  58823. * If mipmap levels should be loaded for transcoded images (Default: true)
  58824. */
  58825. loadMipmapLevels?: boolean;
  58826. /**
  58827. * Index of a single image to load (Default: all images)
  58828. */
  58829. loadSingleImage?: number;
  58830. }
  58831. /**
  58832. * Used to load .Basis files
  58833. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58834. */
  58835. export class BasisTools {
  58836. private static _IgnoreSupportedFormats;
  58837. /**
  58838. * URL to use when loading the basis transcoder
  58839. */
  58840. static JSModuleURL: string;
  58841. /**
  58842. * URL to use when loading the wasm module for the transcoder
  58843. */
  58844. static WasmModuleURL: string;
  58845. /**
  58846. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58847. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58848. * @returns internal format corresponding to the Basis format
  58849. */
  58850. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58851. private static _WorkerPromise;
  58852. private static _Worker;
  58853. private static _actionId;
  58854. private static _CreateWorkerAsync;
  58855. /**
  58856. * Transcodes a loaded image file to compressed pixel data
  58857. * @param imageData image data to transcode
  58858. * @param config configuration options for the transcoding
  58859. * @returns a promise resulting in the transcoded image
  58860. */
  58861. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58862. /**
  58863. * Loads a texture from the transcode result
  58864. * @param texture texture load to
  58865. * @param transcodeResult the result of transcoding the basis file to load from
  58866. */
  58867. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58868. }
  58869. }
  58870. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58871. import { Nullable } from "babylonjs/types";
  58872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58873. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58874. /**
  58875. * Loader for .basis file format
  58876. */
  58877. export class _BasisTextureLoader implements IInternalTextureLoader {
  58878. /**
  58879. * Defines whether the loader supports cascade loading the different faces.
  58880. */
  58881. readonly supportCascades: boolean;
  58882. /**
  58883. * This returns if the loader support the current file information.
  58884. * @param extension defines the file extension of the file being loaded
  58885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58886. * @param fallback defines the fallback internal texture if any
  58887. * @param isBase64 defines whether the texture is encoded as a base64
  58888. * @param isBuffer defines whether the texture data are stored as a buffer
  58889. * @returns true if the loader can load the specified file
  58890. */
  58891. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58892. /**
  58893. * Transform the url before loading if required.
  58894. * @param rootUrl the url of the texture
  58895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58896. * @returns the transformed texture
  58897. */
  58898. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58899. /**
  58900. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58901. * @param rootUrl the url of the texture
  58902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58903. * @returns the fallback texture
  58904. */
  58905. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58906. /**
  58907. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58908. * @param data contains the texture data
  58909. * @param texture defines the BabylonJS internal texture
  58910. * @param createPolynomials will be true if polynomials have been requested
  58911. * @param onLoad defines the callback to trigger once the texture is ready
  58912. * @param onError defines the callback to trigger in case of error
  58913. */
  58914. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58915. /**
  58916. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58917. * @param data contains the texture data
  58918. * @param texture defines the BabylonJS internal texture
  58919. * @param callback defines the method to call once ready to upload
  58920. */
  58921. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58922. }
  58923. }
  58924. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58925. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58926. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58927. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58928. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58929. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58930. }
  58931. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58932. import { Scene } from "babylonjs/scene";
  58933. import { Texture } from "babylonjs/Materials/Textures/texture";
  58934. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58935. /**
  58936. * 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.
  58937. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58938. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58939. */
  58940. export class CustomProceduralTexture extends ProceduralTexture {
  58941. private _animate;
  58942. private _time;
  58943. private _config;
  58944. private _texturePath;
  58945. /**
  58946. * Instantiates a new Custom Procedural Texture.
  58947. * 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.
  58948. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58949. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58950. * @param name Define the name of the texture
  58951. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58952. * @param size Define the size of the texture to create
  58953. * @param scene Define the scene the texture belongs to
  58954. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58955. * @param generateMipMaps Define if the texture should creates mip maps or not
  58956. */
  58957. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58958. private _loadJson;
  58959. /**
  58960. * Is the texture ready to be used ? (rendered at least once)
  58961. * @returns true if ready, otherwise, false.
  58962. */
  58963. isReady(): boolean;
  58964. /**
  58965. * Render the texture to its associated render target.
  58966. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58967. */
  58968. render(useCameraPostProcess?: boolean): void;
  58969. /**
  58970. * Update the list of dependant textures samplers in the shader.
  58971. */
  58972. updateTextures(): void;
  58973. /**
  58974. * Update the uniform values of the procedural texture in the shader.
  58975. */
  58976. updateShaderUniforms(): void;
  58977. /**
  58978. * Define if the texture animates or not.
  58979. */
  58980. get animate(): boolean;
  58981. set animate(value: boolean);
  58982. }
  58983. }
  58984. declare module "babylonjs/Shaders/noise.fragment" {
  58985. /** @hidden */
  58986. export var noisePixelShader: {
  58987. name: string;
  58988. shader: string;
  58989. };
  58990. }
  58991. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58992. import { Nullable } from "babylonjs/types";
  58993. import { Scene } from "babylonjs/scene";
  58994. import { Texture } from "babylonjs/Materials/Textures/texture";
  58995. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58996. import "babylonjs/Shaders/noise.fragment";
  58997. /**
  58998. * Class used to generate noise procedural textures
  58999. */
  59000. export class NoiseProceduralTexture extends ProceduralTexture {
  59001. private _time;
  59002. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59003. brightness: number;
  59004. /** Defines the number of octaves to process */
  59005. octaves: number;
  59006. /** Defines the level of persistence (0.8 by default) */
  59007. persistence: number;
  59008. /** Gets or sets animation speed factor (default is 1) */
  59009. animationSpeedFactor: number;
  59010. /**
  59011. * Creates a new NoiseProceduralTexture
  59012. * @param name defines the name fo the texture
  59013. * @param size defines the size of the texture (default is 256)
  59014. * @param scene defines the hosting scene
  59015. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59016. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59017. */
  59018. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59019. private _updateShaderUniforms;
  59020. protected _getDefines(): string;
  59021. /** Generate the current state of the procedural texture */
  59022. render(useCameraPostProcess?: boolean): void;
  59023. /**
  59024. * Serializes this noise procedural texture
  59025. * @returns a serialized noise procedural texture object
  59026. */
  59027. serialize(): any;
  59028. /**
  59029. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59030. * @param parsedTexture defines parsed texture data
  59031. * @param scene defines the current scene
  59032. * @param rootUrl defines the root URL containing noise procedural texture information
  59033. * @returns a parsed NoiseProceduralTexture
  59034. */
  59035. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59036. }
  59037. }
  59038. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59039. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59040. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59041. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59042. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59043. }
  59044. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59045. import { Nullable } from "babylonjs/types";
  59046. import { Scene } from "babylonjs/scene";
  59047. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59049. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59050. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59051. /**
  59052. * Raw cube texture where the raw buffers are passed in
  59053. */
  59054. export class RawCubeTexture extends CubeTexture {
  59055. /**
  59056. * Creates a cube texture where the raw buffers are passed in.
  59057. * @param scene defines the scene the texture is attached to
  59058. * @param data defines the array of data to use to create each face
  59059. * @param size defines the size of the textures
  59060. * @param format defines the format of the data
  59061. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59062. * @param generateMipMaps defines if the engine should generate the mip levels
  59063. * @param invertY defines if data must be stored with Y axis inverted
  59064. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59065. * @param compression defines the compression used (null by default)
  59066. */
  59067. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59068. /**
  59069. * Updates the raw cube texture.
  59070. * @param data defines the data to store
  59071. * @param format defines the data format
  59072. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59073. * @param invertY defines if data must be stored with Y axis inverted
  59074. * @param compression defines the compression used (null by default)
  59075. * @param level defines which level of the texture to update
  59076. */
  59077. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59078. /**
  59079. * Updates a raw cube texture with RGBD encoded data.
  59080. * @param data defines the array of data [mipmap][face] to use to create each face
  59081. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59082. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59083. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59084. * @returns a promsie that resolves when the operation is complete
  59085. */
  59086. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59087. /**
  59088. * Clones the raw cube texture.
  59089. * @return a new cube texture
  59090. */
  59091. clone(): CubeTexture;
  59092. /** @hidden */
  59093. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59094. }
  59095. }
  59096. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59097. import { Scene } from "babylonjs/scene";
  59098. import { Texture } from "babylonjs/Materials/Textures/texture";
  59099. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59100. /**
  59101. * Class used to store 3D textures containing user data
  59102. */
  59103. export class RawTexture3D extends Texture {
  59104. /** Gets or sets the texture format to use */
  59105. format: number;
  59106. private _engine;
  59107. /**
  59108. * Create a new RawTexture3D
  59109. * @param data defines the data of the texture
  59110. * @param width defines the width of the texture
  59111. * @param height defines the height of the texture
  59112. * @param depth defines the depth of the texture
  59113. * @param format defines the texture format to use
  59114. * @param scene defines the hosting scene
  59115. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59116. * @param invertY defines if texture must be stored with Y axis inverted
  59117. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59118. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59119. */
  59120. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59121. /** Gets or sets the texture format to use */
  59122. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59123. /**
  59124. * Update the texture with new data
  59125. * @param data defines the data to store in the texture
  59126. */
  59127. update(data: ArrayBufferView): void;
  59128. }
  59129. }
  59130. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59131. import { Scene } from "babylonjs/scene";
  59132. import { Texture } from "babylonjs/Materials/Textures/texture";
  59133. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59134. /**
  59135. * Class used to store 2D array textures containing user data
  59136. */
  59137. export class RawTexture2DArray extends Texture {
  59138. /** Gets or sets the texture format to use */
  59139. format: number;
  59140. private _engine;
  59141. /**
  59142. * Create a new RawTexture2DArray
  59143. * @param data defines the data of the texture
  59144. * @param width defines the width of the texture
  59145. * @param height defines the height of the texture
  59146. * @param depth defines the number of layers of the texture
  59147. * @param format defines the texture format to use
  59148. * @param scene defines the hosting scene
  59149. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59150. * @param invertY defines if texture must be stored with Y axis inverted
  59151. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59152. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59153. */
  59154. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59155. /** Gets or sets the texture format to use */
  59156. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59157. /**
  59158. * Update the texture with new data
  59159. * @param data defines the data to store in the texture
  59160. */
  59161. update(data: ArrayBufferView): void;
  59162. }
  59163. }
  59164. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59165. import { Scene } from "babylonjs/scene";
  59166. import { Plane } from "babylonjs/Maths/math.plane";
  59167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59168. /**
  59169. * Creates a refraction texture used by refraction channel of the standard material.
  59170. * It is like a mirror but to see through a material.
  59171. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59172. */
  59173. export class RefractionTexture extends RenderTargetTexture {
  59174. /**
  59175. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59176. * 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.
  59177. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59178. */
  59179. refractionPlane: Plane;
  59180. /**
  59181. * Define how deep under the surface we should see.
  59182. */
  59183. depth: number;
  59184. /**
  59185. * Creates a refraction texture used by refraction channel of the standard material.
  59186. * It is like a mirror but to see through a material.
  59187. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59188. * @param name Define the texture name
  59189. * @param size Define the size of the underlying texture
  59190. * @param scene Define the scene the refraction belongs to
  59191. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59192. */
  59193. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59194. /**
  59195. * Clone the refraction texture.
  59196. * @returns the cloned texture
  59197. */
  59198. clone(): RefractionTexture;
  59199. /**
  59200. * Serialize the texture to a JSON representation you could use in Parse later on
  59201. * @returns the serialized JSON representation
  59202. */
  59203. serialize(): any;
  59204. }
  59205. }
  59206. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59207. import { Nullable } from "babylonjs/types";
  59208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59209. import { Matrix } from "babylonjs/Maths/math.vector";
  59210. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59211. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59212. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59213. import { Scene } from "babylonjs/scene";
  59214. /**
  59215. * Defines the options related to the creation of an HtmlElementTexture
  59216. */
  59217. export interface IHtmlElementTextureOptions {
  59218. /**
  59219. * Defines wether mip maps should be created or not.
  59220. */
  59221. generateMipMaps?: boolean;
  59222. /**
  59223. * Defines the sampling mode of the texture.
  59224. */
  59225. samplingMode?: number;
  59226. /**
  59227. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59228. */
  59229. engine: Nullable<ThinEngine>;
  59230. /**
  59231. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59232. */
  59233. scene: Nullable<Scene>;
  59234. }
  59235. /**
  59236. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59237. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59238. * is automatically managed.
  59239. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59240. * in your application.
  59241. *
  59242. * As the update is not automatic, you need to call them manually.
  59243. */
  59244. export class HtmlElementTexture extends BaseTexture {
  59245. /**
  59246. * The texture URL.
  59247. */
  59248. element: HTMLVideoElement | HTMLCanvasElement;
  59249. private static readonly DefaultOptions;
  59250. private _textureMatrix;
  59251. private _engine;
  59252. private _isVideo;
  59253. private _generateMipMaps;
  59254. private _samplingMode;
  59255. /**
  59256. * Instantiates a HtmlElementTexture from the following parameters.
  59257. *
  59258. * @param name Defines the name of the texture
  59259. * @param element Defines the video or canvas the texture is filled with
  59260. * @param options Defines the other none mandatory texture creation options
  59261. */
  59262. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59263. private _createInternalTexture;
  59264. /**
  59265. * Returns the texture matrix used in most of the material.
  59266. */
  59267. getTextureMatrix(): Matrix;
  59268. /**
  59269. * Updates the content of the texture.
  59270. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59271. */
  59272. update(invertY?: Nullable<boolean>): void;
  59273. }
  59274. }
  59275. declare module "babylonjs/Materials/Textures/index" {
  59276. export * from "babylonjs/Materials/Textures/baseTexture";
  59277. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59278. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59279. export * from "babylonjs/Materials/Textures/cubeTexture";
  59280. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59281. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59282. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59283. export * from "babylonjs/Materials/Textures/internalTexture";
  59284. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59285. export * from "babylonjs/Materials/Textures/Loaders/index";
  59286. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59287. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59288. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59289. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59290. export * from "babylonjs/Materials/Textures/rawTexture";
  59291. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59292. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59293. export * from "babylonjs/Materials/Textures/refractionTexture";
  59294. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59295. export * from "babylonjs/Materials/Textures/texture";
  59296. export * from "babylonjs/Materials/Textures/videoTexture";
  59297. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59298. }
  59299. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59300. /**
  59301. * Enum used to define the target of a block
  59302. */
  59303. export enum NodeMaterialBlockTargets {
  59304. /** Vertex shader */
  59305. Vertex = 1,
  59306. /** Fragment shader */
  59307. Fragment = 2,
  59308. /** Neutral */
  59309. Neutral = 4,
  59310. /** Vertex and Fragment */
  59311. VertexAndFragment = 3
  59312. }
  59313. }
  59314. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59315. /**
  59316. * Defines the kind of connection point for node based material
  59317. */
  59318. export enum NodeMaterialBlockConnectionPointTypes {
  59319. /** Float */
  59320. Float = 1,
  59321. /** Int */
  59322. Int = 2,
  59323. /** Vector2 */
  59324. Vector2 = 4,
  59325. /** Vector3 */
  59326. Vector3 = 8,
  59327. /** Vector4 */
  59328. Vector4 = 16,
  59329. /** Color3 */
  59330. Color3 = 32,
  59331. /** Color4 */
  59332. Color4 = 64,
  59333. /** Matrix */
  59334. Matrix = 128,
  59335. /** Detect type based on connection */
  59336. AutoDetect = 1024,
  59337. /** Output type that will be defined by input type */
  59338. BasedOnInput = 2048
  59339. }
  59340. }
  59341. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59342. /**
  59343. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59344. */
  59345. export enum NodeMaterialBlockConnectionPointMode {
  59346. /** Value is an uniform */
  59347. Uniform = 0,
  59348. /** Value is a mesh attribute */
  59349. Attribute = 1,
  59350. /** Value is a varying between vertex and fragment shaders */
  59351. Varying = 2,
  59352. /** Mode is undefined */
  59353. Undefined = 3
  59354. }
  59355. }
  59356. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59357. /**
  59358. * Enum used to define system values e.g. values automatically provided by the system
  59359. */
  59360. export enum NodeMaterialSystemValues {
  59361. /** World */
  59362. World = 1,
  59363. /** View */
  59364. View = 2,
  59365. /** Projection */
  59366. Projection = 3,
  59367. /** ViewProjection */
  59368. ViewProjection = 4,
  59369. /** WorldView */
  59370. WorldView = 5,
  59371. /** WorldViewProjection */
  59372. WorldViewProjection = 6,
  59373. /** CameraPosition */
  59374. CameraPosition = 7,
  59375. /** Fog Color */
  59376. FogColor = 8,
  59377. /** Delta time */
  59378. DeltaTime = 9
  59379. }
  59380. }
  59381. declare module "babylonjs/Materials/Node/Enums/index" {
  59382. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59383. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59384. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59385. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59386. }
  59387. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59389. /**
  59390. * Root class for all node material optimizers
  59391. */
  59392. export class NodeMaterialOptimizer {
  59393. /**
  59394. * Function used to optimize a NodeMaterial graph
  59395. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59396. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59397. */
  59398. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59399. }
  59400. }
  59401. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59405. import { Scene } from "babylonjs/scene";
  59406. /**
  59407. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59408. */
  59409. export class TransformBlock extends NodeMaterialBlock {
  59410. /**
  59411. * Defines the value to use to complement W value to transform it to a Vector4
  59412. */
  59413. complementW: number;
  59414. /**
  59415. * Defines the value to use to complement z value to transform it to a Vector4
  59416. */
  59417. complementZ: number;
  59418. /**
  59419. * Creates a new TransformBlock
  59420. * @param name defines the block name
  59421. */
  59422. constructor(name: string);
  59423. /**
  59424. * Gets the current class name
  59425. * @returns the class name
  59426. */
  59427. getClassName(): string;
  59428. /**
  59429. * Gets the vector input
  59430. */
  59431. get vector(): NodeMaterialConnectionPoint;
  59432. /**
  59433. * Gets the output component
  59434. */
  59435. get output(): NodeMaterialConnectionPoint;
  59436. /**
  59437. * Gets the matrix transform input
  59438. */
  59439. get transform(): NodeMaterialConnectionPoint;
  59440. protected _buildBlock(state: NodeMaterialBuildState): this;
  59441. serialize(): any;
  59442. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59443. protected _dumpPropertiesCode(): string;
  59444. }
  59445. }
  59446. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59450. /**
  59451. * Block used to output the vertex position
  59452. */
  59453. export class VertexOutputBlock extends NodeMaterialBlock {
  59454. /**
  59455. * Creates a new VertexOutputBlock
  59456. * @param name defines the block name
  59457. */
  59458. constructor(name: string);
  59459. /**
  59460. * Gets the current class name
  59461. * @returns the class name
  59462. */
  59463. getClassName(): string;
  59464. /**
  59465. * Gets the vector input component
  59466. */
  59467. get vector(): NodeMaterialConnectionPoint;
  59468. protected _buildBlock(state: NodeMaterialBuildState): this;
  59469. }
  59470. }
  59471. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59475. /**
  59476. * Block used to output the final color
  59477. */
  59478. export class FragmentOutputBlock extends NodeMaterialBlock {
  59479. /**
  59480. * Create a new FragmentOutputBlock
  59481. * @param name defines the block name
  59482. */
  59483. constructor(name: string);
  59484. /**
  59485. * Gets the current class name
  59486. * @returns the class name
  59487. */
  59488. getClassName(): string;
  59489. /**
  59490. * Gets the rgba input component
  59491. */
  59492. get rgba(): NodeMaterialConnectionPoint;
  59493. /**
  59494. * Gets the rgb input component
  59495. */
  59496. get rgb(): NodeMaterialConnectionPoint;
  59497. /**
  59498. * Gets the a input component
  59499. */
  59500. get a(): NodeMaterialConnectionPoint;
  59501. protected _buildBlock(state: NodeMaterialBuildState): this;
  59502. }
  59503. }
  59504. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59510. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59511. import { Effect } from "babylonjs/Materials/effect";
  59512. import { Mesh } from "babylonjs/Meshes/mesh";
  59513. import { Nullable } from "babylonjs/types";
  59514. import { Scene } from "babylonjs/scene";
  59515. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59516. /**
  59517. * Block used to read a reflection texture from a sampler
  59518. */
  59519. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59520. private _define3DName;
  59521. private _defineCubicName;
  59522. private _defineExplicitName;
  59523. private _defineProjectionName;
  59524. private _defineLocalCubicName;
  59525. private _defineSphericalName;
  59526. private _definePlanarName;
  59527. private _defineEquirectangularName;
  59528. private _defineMirroredEquirectangularFixedName;
  59529. private _defineEquirectangularFixedName;
  59530. private _defineSkyboxName;
  59531. private _cubeSamplerName;
  59532. private _2DSamplerName;
  59533. private _positionUVWName;
  59534. private _directionWName;
  59535. private _reflectionCoordsName;
  59536. private _reflection2DCoordsName;
  59537. private _reflectionColorName;
  59538. private _reflectionMatrixName;
  59539. /**
  59540. * Gets or sets the texture associated with the node
  59541. */
  59542. texture: Nullable<BaseTexture>;
  59543. /**
  59544. * Create a new TextureBlock
  59545. * @param name defines the block name
  59546. */
  59547. constructor(name: string);
  59548. /**
  59549. * Gets the current class name
  59550. * @returns the class name
  59551. */
  59552. getClassName(): string;
  59553. /**
  59554. * Gets the world position input component
  59555. */
  59556. get position(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the world position input component
  59559. */
  59560. get worldPosition(): NodeMaterialConnectionPoint;
  59561. /**
  59562. * Gets the world normal input component
  59563. */
  59564. get worldNormal(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the world input component
  59567. */
  59568. get world(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the camera (or eye) position component
  59571. */
  59572. get cameraPosition(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the view input component
  59575. */
  59576. get view(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the rgb output component
  59579. */
  59580. get rgb(): NodeMaterialConnectionPoint;
  59581. /**
  59582. * Gets the r output component
  59583. */
  59584. get r(): NodeMaterialConnectionPoint;
  59585. /**
  59586. * Gets the g output component
  59587. */
  59588. get g(): NodeMaterialConnectionPoint;
  59589. /**
  59590. * Gets the b output component
  59591. */
  59592. get b(): NodeMaterialConnectionPoint;
  59593. autoConfigure(material: NodeMaterial): void;
  59594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59595. isReady(): boolean;
  59596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59597. private _injectVertexCode;
  59598. private _writeOutput;
  59599. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59600. protected _dumpPropertiesCode(): string;
  59601. serialize(): any;
  59602. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59603. }
  59604. }
  59605. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59607. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59608. import { Scene } from "babylonjs/scene";
  59609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59610. import { Matrix } from "babylonjs/Maths/math.vector";
  59611. import { Mesh } from "babylonjs/Meshes/mesh";
  59612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59613. import { Observable } from "babylonjs/Misc/observable";
  59614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59615. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59616. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59617. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59618. import { Nullable } from "babylonjs/types";
  59619. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59620. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59621. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59622. /**
  59623. * Interface used to configure the node material editor
  59624. */
  59625. export interface INodeMaterialEditorOptions {
  59626. /** Define the URl to load node editor script */
  59627. editorURL?: string;
  59628. }
  59629. /** @hidden */
  59630. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59631. NORMAL: boolean;
  59632. TANGENT: boolean;
  59633. UV1: boolean;
  59634. /** BONES */
  59635. NUM_BONE_INFLUENCERS: number;
  59636. BonesPerMesh: number;
  59637. BONETEXTURE: boolean;
  59638. /** MORPH TARGETS */
  59639. MORPHTARGETS: boolean;
  59640. MORPHTARGETS_NORMAL: boolean;
  59641. MORPHTARGETS_TANGENT: boolean;
  59642. MORPHTARGETS_UV: boolean;
  59643. NUM_MORPH_INFLUENCERS: number;
  59644. /** IMAGE PROCESSING */
  59645. IMAGEPROCESSING: boolean;
  59646. VIGNETTE: boolean;
  59647. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59648. VIGNETTEBLENDMODEOPAQUE: boolean;
  59649. TONEMAPPING: boolean;
  59650. TONEMAPPING_ACES: boolean;
  59651. CONTRAST: boolean;
  59652. EXPOSURE: boolean;
  59653. COLORCURVES: boolean;
  59654. COLORGRADING: boolean;
  59655. COLORGRADING3D: boolean;
  59656. SAMPLER3DGREENDEPTH: boolean;
  59657. SAMPLER3DBGRMAP: boolean;
  59658. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59659. /** MISC. */
  59660. BUMPDIRECTUV: number;
  59661. constructor();
  59662. setValue(name: string, value: boolean): void;
  59663. }
  59664. /**
  59665. * Class used to configure NodeMaterial
  59666. */
  59667. export interface INodeMaterialOptions {
  59668. /**
  59669. * Defines if blocks should emit comments
  59670. */
  59671. emitComments: boolean;
  59672. }
  59673. /**
  59674. * Class used to create a node based material built by assembling shader blocks
  59675. */
  59676. export class NodeMaterial extends PushMaterial {
  59677. private static _BuildIdGenerator;
  59678. private _options;
  59679. private _vertexCompilationState;
  59680. private _fragmentCompilationState;
  59681. private _sharedData;
  59682. private _buildId;
  59683. private _buildWasSuccessful;
  59684. private _cachedWorldViewMatrix;
  59685. private _cachedWorldViewProjectionMatrix;
  59686. private _optimizers;
  59687. private _animationFrame;
  59688. /** Define the Url to load node editor script */
  59689. static EditorURL: string;
  59690. /** Define the Url to load snippets */
  59691. static SnippetUrl: string;
  59692. private BJSNODEMATERIALEDITOR;
  59693. /** Get the inspector from bundle or global */
  59694. private _getGlobalNodeMaterialEditor;
  59695. /**
  59696. * Gets or sets data used by visual editor
  59697. * @see https://nme.babylonjs.com
  59698. */
  59699. editorData: any;
  59700. /**
  59701. * 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)
  59702. */
  59703. ignoreAlpha: boolean;
  59704. /**
  59705. * Defines the maximum number of lights that can be used in the material
  59706. */
  59707. maxSimultaneousLights: number;
  59708. /**
  59709. * Observable raised when the material is built
  59710. */
  59711. onBuildObservable: Observable<NodeMaterial>;
  59712. /**
  59713. * Gets or sets the root nodes of the material vertex shader
  59714. */
  59715. _vertexOutputNodes: NodeMaterialBlock[];
  59716. /**
  59717. * Gets or sets the root nodes of the material fragment (pixel) shader
  59718. */
  59719. _fragmentOutputNodes: NodeMaterialBlock[];
  59720. /** Gets or sets options to control the node material overall behavior */
  59721. get options(): INodeMaterialOptions;
  59722. set options(options: INodeMaterialOptions);
  59723. /**
  59724. * Default configuration related to image processing available in the standard Material.
  59725. */
  59726. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59727. /**
  59728. * Gets the image processing configuration used either in this material.
  59729. */
  59730. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59731. /**
  59732. * Sets the Default image processing configuration used either in the this material.
  59733. *
  59734. * If sets to null, the scene one is in use.
  59735. */
  59736. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59737. /**
  59738. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59739. */
  59740. attachedBlocks: NodeMaterialBlock[];
  59741. /**
  59742. * Create a new node based material
  59743. * @param name defines the material name
  59744. * @param scene defines the hosting scene
  59745. * @param options defines creation option
  59746. */
  59747. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59748. /**
  59749. * Gets the current class name of the material e.g. "NodeMaterial"
  59750. * @returns the class name
  59751. */
  59752. getClassName(): string;
  59753. /**
  59754. * Keep track of the image processing observer to allow dispose and replace.
  59755. */
  59756. private _imageProcessingObserver;
  59757. /**
  59758. * Attaches a new image processing configuration to the Standard Material.
  59759. * @param configuration
  59760. */
  59761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59762. /**
  59763. * Get a block by its name
  59764. * @param name defines the name of the block to retrieve
  59765. * @returns the required block or null if not found
  59766. */
  59767. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59768. /**
  59769. * Get a block by its name
  59770. * @param predicate defines the predicate used to find the good candidate
  59771. * @returns the required block or null if not found
  59772. */
  59773. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59774. /**
  59775. * Get an input block by its name
  59776. * @param predicate defines the predicate used to find the good candidate
  59777. * @returns the required input block or null if not found
  59778. */
  59779. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59780. /**
  59781. * Gets the list of input blocks attached to this material
  59782. * @returns an array of InputBlocks
  59783. */
  59784. getInputBlocks(): InputBlock[];
  59785. /**
  59786. * Adds a new optimizer to the list of optimizers
  59787. * @param optimizer defines the optimizers to add
  59788. * @returns the current material
  59789. */
  59790. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59791. /**
  59792. * Remove an optimizer from the list of optimizers
  59793. * @param optimizer defines the optimizers to remove
  59794. * @returns the current material
  59795. */
  59796. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59797. /**
  59798. * Add a new block to the list of output nodes
  59799. * @param node defines the node to add
  59800. * @returns the current material
  59801. */
  59802. addOutputNode(node: NodeMaterialBlock): this;
  59803. /**
  59804. * Remove a block from the list of root nodes
  59805. * @param node defines the node to remove
  59806. * @returns the current material
  59807. */
  59808. removeOutputNode(node: NodeMaterialBlock): this;
  59809. private _addVertexOutputNode;
  59810. private _removeVertexOutputNode;
  59811. private _addFragmentOutputNode;
  59812. private _removeFragmentOutputNode;
  59813. /**
  59814. * Specifies if the material will require alpha blending
  59815. * @returns a boolean specifying if alpha blending is needed
  59816. */
  59817. needAlphaBlending(): boolean;
  59818. /**
  59819. * Specifies if this material should be rendered in alpha test mode
  59820. * @returns a boolean specifying if an alpha test is needed.
  59821. */
  59822. needAlphaTesting(): boolean;
  59823. private _initializeBlock;
  59824. private _resetDualBlocks;
  59825. /**
  59826. * Remove a block from the current node material
  59827. * @param block defines the block to remove
  59828. */
  59829. removeBlock(block: NodeMaterialBlock): void;
  59830. /**
  59831. * Build the material and generates the inner effect
  59832. * @param verbose defines if the build should log activity
  59833. */
  59834. build(verbose?: boolean): void;
  59835. /**
  59836. * Runs an otpimization phase to try to improve the shader code
  59837. */
  59838. optimize(): void;
  59839. private _prepareDefinesForAttributes;
  59840. /**
  59841. * Get if the submesh is ready to be used and all its information available.
  59842. * Child classes can use it to update shaders
  59843. * @param mesh defines the mesh to check
  59844. * @param subMesh defines which submesh to check
  59845. * @param useInstances specifies that instances should be used
  59846. * @returns a boolean indicating that the submesh is ready or not
  59847. */
  59848. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59849. /**
  59850. * Get a string representing the shaders built by the current node graph
  59851. */
  59852. get compiledShaders(): string;
  59853. /**
  59854. * Binds the world matrix to the material
  59855. * @param world defines the world transformation matrix
  59856. */
  59857. bindOnlyWorldMatrix(world: Matrix): void;
  59858. /**
  59859. * Binds the submesh to this material by preparing the effect and shader to draw
  59860. * @param world defines the world transformation matrix
  59861. * @param mesh defines the mesh containing the submesh
  59862. * @param subMesh defines the submesh to bind the material to
  59863. */
  59864. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59865. /**
  59866. * Gets the active textures from the material
  59867. * @returns an array of textures
  59868. */
  59869. getActiveTextures(): BaseTexture[];
  59870. /**
  59871. * Gets the list of texture blocks
  59872. * @returns an array of texture blocks
  59873. */
  59874. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59875. /**
  59876. * Specifies if the material uses a texture
  59877. * @param texture defines the texture to check against the material
  59878. * @returns a boolean specifying if the material uses the texture
  59879. */
  59880. hasTexture(texture: BaseTexture): boolean;
  59881. /**
  59882. * Disposes the material
  59883. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59884. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59885. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59886. */
  59887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59888. /** Creates the node editor window. */
  59889. private _createNodeEditor;
  59890. /**
  59891. * Launch the node material editor
  59892. * @param config Define the configuration of the editor
  59893. * @return a promise fulfilled when the node editor is visible
  59894. */
  59895. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59896. /**
  59897. * Clear the current material
  59898. */
  59899. clear(): void;
  59900. /**
  59901. * Clear the current material and set it to a default state
  59902. */
  59903. setToDefault(): void;
  59904. /**
  59905. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59906. * @param url defines the url to load from
  59907. * @returns a promise that will fullfil when the material is fully loaded
  59908. */
  59909. loadAsync(url: string): Promise<void>;
  59910. private _gatherBlocks;
  59911. /**
  59912. * Generate a string containing the code declaration required to create an equivalent of this material
  59913. * @returns a string
  59914. */
  59915. generateCode(): string;
  59916. /**
  59917. * Serializes this material in a JSON representation
  59918. * @returns the serialized material object
  59919. */
  59920. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59921. private _restoreConnections;
  59922. /**
  59923. * Clear the current graph and load a new one from a serialization object
  59924. * @param source defines the JSON representation of the material
  59925. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59926. */
  59927. loadFromSerialization(source: any, rootUrl?: string): void;
  59928. /**
  59929. * Creates a node material from parsed material data
  59930. * @param source defines the JSON representation of the material
  59931. * @param scene defines the hosting scene
  59932. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59933. * @returns a new node material
  59934. */
  59935. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59936. /**
  59937. * Creates a node material from a snippet saved by the node material editor
  59938. * @param snippetId defines the snippet to load
  59939. * @param scene defines the hosting scene
  59940. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59941. * @returns a promise that will resolve to the new node material
  59942. */
  59943. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59944. /**
  59945. * Creates a new node material set to default basic configuration
  59946. * @param name defines the name of the material
  59947. * @param scene defines the hosting scene
  59948. * @returns a new NodeMaterial
  59949. */
  59950. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59951. }
  59952. }
  59953. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59956. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59959. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59960. import { Effect } from "babylonjs/Materials/effect";
  59961. import { Mesh } from "babylonjs/Meshes/mesh";
  59962. import { Nullable } from "babylonjs/types";
  59963. import { Texture } from "babylonjs/Materials/Textures/texture";
  59964. import { Scene } from "babylonjs/scene";
  59965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59966. /**
  59967. * Block used to read a texture from a sampler
  59968. */
  59969. export class TextureBlock extends NodeMaterialBlock {
  59970. private _defineName;
  59971. private _linearDefineName;
  59972. private _tempTextureRead;
  59973. private _samplerName;
  59974. private _transformedUVName;
  59975. private _textureTransformName;
  59976. private _textureInfoName;
  59977. private _mainUVName;
  59978. private _mainUVDefineName;
  59979. /**
  59980. * Gets or sets the texture associated with the node
  59981. */
  59982. texture: Nullable<Texture>;
  59983. /**
  59984. * Create a new TextureBlock
  59985. * @param name defines the block name
  59986. */
  59987. constructor(name: string);
  59988. /**
  59989. * Gets the current class name
  59990. * @returns the class name
  59991. */
  59992. getClassName(): string;
  59993. /**
  59994. * Gets the uv input component
  59995. */
  59996. get uv(): NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the rgba output component
  59999. */
  60000. get rgba(): NodeMaterialConnectionPoint;
  60001. /**
  60002. * Gets the rgb output component
  60003. */
  60004. get rgb(): NodeMaterialConnectionPoint;
  60005. /**
  60006. * Gets the r output component
  60007. */
  60008. get r(): NodeMaterialConnectionPoint;
  60009. /**
  60010. * Gets the g output component
  60011. */
  60012. get g(): NodeMaterialConnectionPoint;
  60013. /**
  60014. * Gets the b output component
  60015. */
  60016. get b(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the a output component
  60019. */
  60020. get a(): NodeMaterialConnectionPoint;
  60021. get target(): NodeMaterialBlockTargets;
  60022. autoConfigure(material: NodeMaterial): void;
  60023. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60025. isReady(): boolean;
  60026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60027. private get _isMixed();
  60028. private _injectVertexCode;
  60029. private _writeTextureRead;
  60030. private _writeOutput;
  60031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60032. protected _dumpPropertiesCode(): string;
  60033. serialize(): any;
  60034. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60035. }
  60036. }
  60037. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60040. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60041. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60042. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60043. import { Scene } from "babylonjs/scene";
  60044. /**
  60045. * Class used to store shared data between 2 NodeMaterialBuildState
  60046. */
  60047. export class NodeMaterialBuildStateSharedData {
  60048. /**
  60049. * Gets the list of emitted varyings
  60050. */
  60051. temps: string[];
  60052. /**
  60053. * Gets the list of emitted varyings
  60054. */
  60055. varyings: string[];
  60056. /**
  60057. * Gets the varying declaration string
  60058. */
  60059. varyingDeclaration: string;
  60060. /**
  60061. * Input blocks
  60062. */
  60063. inputBlocks: InputBlock[];
  60064. /**
  60065. * Input blocks
  60066. */
  60067. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60068. /**
  60069. * Bindable blocks (Blocks that need to set data to the effect)
  60070. */
  60071. bindableBlocks: NodeMaterialBlock[];
  60072. /**
  60073. * List of blocks that can provide a compilation fallback
  60074. */
  60075. blocksWithFallbacks: NodeMaterialBlock[];
  60076. /**
  60077. * List of blocks that can provide a define update
  60078. */
  60079. blocksWithDefines: NodeMaterialBlock[];
  60080. /**
  60081. * List of blocks that can provide a repeatable content
  60082. */
  60083. repeatableContentBlocks: NodeMaterialBlock[];
  60084. /**
  60085. * List of blocks that can provide a dynamic list of uniforms
  60086. */
  60087. dynamicUniformBlocks: NodeMaterialBlock[];
  60088. /**
  60089. * List of blocks that can block the isReady function for the material
  60090. */
  60091. blockingBlocks: NodeMaterialBlock[];
  60092. /**
  60093. * Gets the list of animated inputs
  60094. */
  60095. animatedInputs: InputBlock[];
  60096. /**
  60097. * Build Id used to avoid multiple recompilations
  60098. */
  60099. buildId: number;
  60100. /** List of emitted variables */
  60101. variableNames: {
  60102. [key: string]: number;
  60103. };
  60104. /** List of emitted defines */
  60105. defineNames: {
  60106. [key: string]: number;
  60107. };
  60108. /** Should emit comments? */
  60109. emitComments: boolean;
  60110. /** Emit build activity */
  60111. verbose: boolean;
  60112. /** Gets or sets the hosting scene */
  60113. scene: Scene;
  60114. /**
  60115. * Gets the compilation hints emitted at compilation time
  60116. */
  60117. hints: {
  60118. needWorldViewMatrix: boolean;
  60119. needWorldViewProjectionMatrix: boolean;
  60120. needAlphaBlending: boolean;
  60121. needAlphaTesting: boolean;
  60122. };
  60123. /**
  60124. * List of compilation checks
  60125. */
  60126. checks: {
  60127. emitVertex: boolean;
  60128. emitFragment: boolean;
  60129. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60130. };
  60131. /** Creates a new shared data */
  60132. constructor();
  60133. /**
  60134. * Emits console errors and exceptions if there is a failing check
  60135. */
  60136. emitErrors(): void;
  60137. }
  60138. }
  60139. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60140. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60141. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60142. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60143. /**
  60144. * Class used to store node based material build state
  60145. */
  60146. export class NodeMaterialBuildState {
  60147. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60148. supportUniformBuffers: boolean;
  60149. /**
  60150. * Gets the list of emitted attributes
  60151. */
  60152. attributes: string[];
  60153. /**
  60154. * Gets the list of emitted uniforms
  60155. */
  60156. uniforms: string[];
  60157. /**
  60158. * Gets the list of emitted constants
  60159. */
  60160. constants: string[];
  60161. /**
  60162. * Gets the list of emitted samplers
  60163. */
  60164. samplers: string[];
  60165. /**
  60166. * Gets the list of emitted functions
  60167. */
  60168. functions: {
  60169. [key: string]: string;
  60170. };
  60171. /**
  60172. * Gets the list of emitted extensions
  60173. */
  60174. extensions: {
  60175. [key: string]: string;
  60176. };
  60177. /**
  60178. * Gets the target of the compilation state
  60179. */
  60180. target: NodeMaterialBlockTargets;
  60181. /**
  60182. * Gets the list of emitted counters
  60183. */
  60184. counters: {
  60185. [key: string]: number;
  60186. };
  60187. /**
  60188. * Shared data between multiple NodeMaterialBuildState instances
  60189. */
  60190. sharedData: NodeMaterialBuildStateSharedData;
  60191. /** @hidden */
  60192. _vertexState: NodeMaterialBuildState;
  60193. /** @hidden */
  60194. _attributeDeclaration: string;
  60195. /** @hidden */
  60196. _uniformDeclaration: string;
  60197. /** @hidden */
  60198. _constantDeclaration: string;
  60199. /** @hidden */
  60200. _samplerDeclaration: string;
  60201. /** @hidden */
  60202. _varyingTransfer: string;
  60203. private _repeatableContentAnchorIndex;
  60204. /** @hidden */
  60205. _builtCompilationString: string;
  60206. /**
  60207. * Gets the emitted compilation strings
  60208. */
  60209. compilationString: string;
  60210. /**
  60211. * Finalize the compilation strings
  60212. * @param state defines the current compilation state
  60213. */
  60214. finalize(state: NodeMaterialBuildState): void;
  60215. /** @hidden */
  60216. get _repeatableContentAnchor(): string;
  60217. /** @hidden */
  60218. _getFreeVariableName(prefix: string): string;
  60219. /** @hidden */
  60220. _getFreeDefineName(prefix: string): string;
  60221. /** @hidden */
  60222. _excludeVariableName(name: string): void;
  60223. /** @hidden */
  60224. _emit2DSampler(name: string): void;
  60225. /** @hidden */
  60226. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60227. /** @hidden */
  60228. _emitExtension(name: string, extension: string): void;
  60229. /** @hidden */
  60230. _emitFunction(name: string, code: string, comments: string): void;
  60231. /** @hidden */
  60232. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60233. replaceStrings?: {
  60234. search: RegExp;
  60235. replace: string;
  60236. }[];
  60237. repeatKey?: string;
  60238. }): string;
  60239. /** @hidden */
  60240. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60241. repeatKey?: string;
  60242. removeAttributes?: boolean;
  60243. removeUniforms?: boolean;
  60244. removeVaryings?: boolean;
  60245. removeIfDef?: boolean;
  60246. replaceStrings?: {
  60247. search: RegExp;
  60248. replace: string;
  60249. }[];
  60250. }, storeKey?: string): void;
  60251. /** @hidden */
  60252. _registerTempVariable(name: string): boolean;
  60253. /** @hidden */
  60254. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60255. /** @hidden */
  60256. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60257. /** @hidden */
  60258. _emitFloat(value: number): string;
  60259. }
  60260. }
  60261. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60262. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60264. import { Nullable } from "babylonjs/types";
  60265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60266. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60267. import { Effect } from "babylonjs/Materials/effect";
  60268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60269. import { Mesh } from "babylonjs/Meshes/mesh";
  60270. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60271. import { Scene } from "babylonjs/scene";
  60272. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60273. /**
  60274. * Defines a block that can be used inside a node based material
  60275. */
  60276. export class NodeMaterialBlock {
  60277. private _buildId;
  60278. private _buildTarget;
  60279. private _target;
  60280. private _isFinalMerger;
  60281. private _isInput;
  60282. protected _isUnique: boolean;
  60283. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60284. inputsAreExclusive: boolean;
  60285. /** @hidden */
  60286. _codeVariableName: string;
  60287. /** @hidden */
  60288. _inputs: NodeMaterialConnectionPoint[];
  60289. /** @hidden */
  60290. _outputs: NodeMaterialConnectionPoint[];
  60291. /** @hidden */
  60292. _preparationId: number;
  60293. /**
  60294. * Gets or sets the name of the block
  60295. */
  60296. name: string;
  60297. /**
  60298. * Gets or sets the unique id of the node
  60299. */
  60300. uniqueId: number;
  60301. /**
  60302. * Gets or sets the comments associated with this block
  60303. */
  60304. comments: string;
  60305. /**
  60306. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60307. */
  60308. get isUnique(): boolean;
  60309. /**
  60310. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60311. */
  60312. get isFinalMerger(): boolean;
  60313. /**
  60314. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60315. */
  60316. get isInput(): boolean;
  60317. /**
  60318. * Gets or sets the build Id
  60319. */
  60320. get buildId(): number;
  60321. set buildId(value: number);
  60322. /**
  60323. * Gets or sets the target of the block
  60324. */
  60325. get target(): NodeMaterialBlockTargets;
  60326. set target(value: NodeMaterialBlockTargets);
  60327. /**
  60328. * Gets the list of input points
  60329. */
  60330. get inputs(): NodeMaterialConnectionPoint[];
  60331. /** Gets the list of output points */
  60332. get outputs(): NodeMaterialConnectionPoint[];
  60333. /**
  60334. * Find an input by its name
  60335. * @param name defines the name of the input to look for
  60336. * @returns the input or null if not found
  60337. */
  60338. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60339. /**
  60340. * Find an output by its name
  60341. * @param name defines the name of the outputto look for
  60342. * @returns the output or null if not found
  60343. */
  60344. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60345. /**
  60346. * Creates a new NodeMaterialBlock
  60347. * @param name defines the block name
  60348. * @param target defines the target of that block (Vertex by default)
  60349. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60350. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60351. */
  60352. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60353. /**
  60354. * Initialize the block and prepare the context for build
  60355. * @param state defines the state that will be used for the build
  60356. */
  60357. initialize(state: NodeMaterialBuildState): void;
  60358. /**
  60359. * Bind data to effect. Will only be called for blocks with isBindable === true
  60360. * @param effect defines the effect to bind data to
  60361. * @param nodeMaterial defines the hosting NodeMaterial
  60362. * @param mesh defines the mesh that will be rendered
  60363. */
  60364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60365. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60366. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60367. protected _writeFloat(value: number): string;
  60368. /**
  60369. * Gets the current class name e.g. "NodeMaterialBlock"
  60370. * @returns the class name
  60371. */
  60372. getClassName(): string;
  60373. /**
  60374. * Register a new input. Must be called inside a block constructor
  60375. * @param name defines the connection point name
  60376. * @param type defines the connection point type
  60377. * @param isOptional defines a boolean indicating that this input can be omitted
  60378. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60379. * @returns the current block
  60380. */
  60381. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60382. /**
  60383. * Register a new output. Must be called inside a block constructor
  60384. * @param name defines the connection point name
  60385. * @param type defines the connection point type
  60386. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60387. * @returns the current block
  60388. */
  60389. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60390. /**
  60391. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60392. * @param forOutput defines an optional connection point to check compatibility with
  60393. * @returns the first available input or null
  60394. */
  60395. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60396. /**
  60397. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60398. * @param forBlock defines an optional block to check compatibility with
  60399. * @returns the first available input or null
  60400. */
  60401. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60402. /**
  60403. * Gets the sibling of the given output
  60404. * @param current defines the current output
  60405. * @returns the next output in the list or null
  60406. */
  60407. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60408. /**
  60409. * Connect current block with another block
  60410. * @param other defines the block to connect with
  60411. * @param options define the various options to help pick the right connections
  60412. * @returns the current block
  60413. */
  60414. connectTo(other: NodeMaterialBlock, options?: {
  60415. input?: string;
  60416. output?: string;
  60417. outputSwizzle?: string;
  60418. }): this | undefined;
  60419. protected _buildBlock(state: NodeMaterialBuildState): void;
  60420. /**
  60421. * Add uniforms, samplers and uniform buffers at compilation time
  60422. * @param state defines the state to update
  60423. * @param nodeMaterial defines the node material requesting the update
  60424. * @param defines defines the material defines to update
  60425. * @param uniformBuffers defines the list of uniform buffer names
  60426. */
  60427. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60428. /**
  60429. * Add potential fallbacks if shader compilation fails
  60430. * @param mesh defines the mesh to be rendered
  60431. * @param fallbacks defines the current prioritized list of fallbacks
  60432. */
  60433. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60434. /**
  60435. * Initialize defines for shader compilation
  60436. * @param mesh defines the mesh to be rendered
  60437. * @param nodeMaterial defines the node material requesting the update
  60438. * @param defines defines the material defines to update
  60439. * @param useInstances specifies that instances should be used
  60440. */
  60441. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60442. /**
  60443. * Update defines for shader compilation
  60444. * @param mesh defines the mesh to be rendered
  60445. * @param nodeMaterial defines the node material requesting the update
  60446. * @param defines defines the material defines to update
  60447. * @param useInstances specifies that instances should be used
  60448. */
  60449. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60450. /**
  60451. * Lets the block try to connect some inputs automatically
  60452. * @param material defines the hosting NodeMaterial
  60453. */
  60454. autoConfigure(material: NodeMaterial): void;
  60455. /**
  60456. * Function called when a block is declared as repeatable content generator
  60457. * @param vertexShaderState defines the current compilation state for the vertex shader
  60458. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60459. * @param mesh defines the mesh to be rendered
  60460. * @param defines defines the material defines to update
  60461. */
  60462. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60463. /**
  60464. * Checks if the block is ready
  60465. * @param mesh defines the mesh to be rendered
  60466. * @param nodeMaterial defines the node material requesting the update
  60467. * @param defines defines the material defines to update
  60468. * @param useInstances specifies that instances should be used
  60469. * @returns true if the block is ready
  60470. */
  60471. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60472. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60473. private _processBuild;
  60474. /**
  60475. * Compile the current node and generate the shader code
  60476. * @param state defines the current compilation state (uniforms, samplers, current string)
  60477. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60478. * @returns true if already built
  60479. */
  60480. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60481. protected _inputRename(name: string): string;
  60482. protected _outputRename(name: string): string;
  60483. protected _dumpPropertiesCode(): string;
  60484. /** @hidden */
  60485. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60486. /** @hidden */
  60487. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60488. /**
  60489. * Clone the current block to a new identical block
  60490. * @param scene defines the hosting scene
  60491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60492. * @returns a copy of the current block
  60493. */
  60494. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60495. /**
  60496. * Serializes this block in a JSON representation
  60497. * @returns the serialized block object
  60498. */
  60499. serialize(): any;
  60500. /** @hidden */
  60501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60502. /**
  60503. * Release resources
  60504. */
  60505. dispose(): void;
  60506. }
  60507. }
  60508. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60509. /**
  60510. * Enum defining the type of animations supported by InputBlock
  60511. */
  60512. export enum AnimatedInputBlockTypes {
  60513. /** No animation */
  60514. None = 0,
  60515. /** Time based animation. Will only work for floats */
  60516. Time = 1
  60517. }
  60518. }
  60519. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60521. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60522. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60523. import { Nullable } from "babylonjs/types";
  60524. import { Effect } from "babylonjs/Materials/effect";
  60525. import { Matrix } from "babylonjs/Maths/math.vector";
  60526. import { Scene } from "babylonjs/scene";
  60527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60528. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60529. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60530. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60531. /**
  60532. * Block used to expose an input value
  60533. */
  60534. export class InputBlock extends NodeMaterialBlock {
  60535. private _mode;
  60536. private _associatedVariableName;
  60537. private _storedValue;
  60538. private _valueCallback;
  60539. private _type;
  60540. private _animationType;
  60541. /** Gets or set a value used to limit the range of float values */
  60542. min: number;
  60543. /** Gets or set a value used to limit the range of float values */
  60544. max: number;
  60545. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60546. isBoolean: boolean;
  60547. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60548. matrixMode: number;
  60549. /** @hidden */
  60550. _systemValue: Nullable<NodeMaterialSystemValues>;
  60551. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60552. visibleInInspector: boolean;
  60553. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60554. isConstant: boolean;
  60555. /** Gets or sets the group to use to display this block in the Inspector */
  60556. groupInInspector: string;
  60557. /**
  60558. * Gets or sets the connection point type (default is float)
  60559. */
  60560. get type(): NodeMaterialBlockConnectionPointTypes;
  60561. /**
  60562. * Creates a new InputBlock
  60563. * @param name defines the block name
  60564. * @param target defines the target of that block (Vertex by default)
  60565. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60566. */
  60567. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60568. /**
  60569. * Gets the output component
  60570. */
  60571. get output(): NodeMaterialConnectionPoint;
  60572. /**
  60573. * Set the source of this connection point to a vertex attribute
  60574. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60575. * @returns the current connection point
  60576. */
  60577. setAsAttribute(attributeName?: string): InputBlock;
  60578. /**
  60579. * Set the source of this connection point to a system value
  60580. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60581. * @returns the current connection point
  60582. */
  60583. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60584. /**
  60585. * Gets or sets the value of that point.
  60586. * Please note that this value will be ignored if valueCallback is defined
  60587. */
  60588. get value(): any;
  60589. set value(value: any);
  60590. /**
  60591. * Gets or sets a callback used to get the value of that point.
  60592. * Please note that setting this value will force the connection point to ignore the value property
  60593. */
  60594. get valueCallback(): () => any;
  60595. set valueCallback(value: () => any);
  60596. /**
  60597. * Gets or sets the associated variable name in the shader
  60598. */
  60599. get associatedVariableName(): string;
  60600. set associatedVariableName(value: string);
  60601. /** Gets or sets the type of animation applied to the input */
  60602. get animationType(): AnimatedInputBlockTypes;
  60603. set animationType(value: AnimatedInputBlockTypes);
  60604. /**
  60605. * Gets a boolean indicating that this connection point not defined yet
  60606. */
  60607. get isUndefined(): boolean;
  60608. /**
  60609. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60610. * In this case the connection point name must be the name of the uniform to use.
  60611. * Can only be set on inputs
  60612. */
  60613. get isUniform(): boolean;
  60614. set isUniform(value: boolean);
  60615. /**
  60616. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60617. * In this case the connection point name must be the name of the attribute to use
  60618. * Can only be set on inputs
  60619. */
  60620. get isAttribute(): boolean;
  60621. set isAttribute(value: boolean);
  60622. /**
  60623. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60624. * Can only be set on exit points
  60625. */
  60626. get isVarying(): boolean;
  60627. set isVarying(value: boolean);
  60628. /**
  60629. * Gets a boolean indicating that the current connection point is a system value
  60630. */
  60631. get isSystemValue(): boolean;
  60632. /**
  60633. * Gets or sets the current well known value or null if not defined as a system value
  60634. */
  60635. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60636. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60637. /**
  60638. * Gets the current class name
  60639. * @returns the class name
  60640. */
  60641. getClassName(): string;
  60642. /**
  60643. * Animate the input if animationType !== None
  60644. * @param scene defines the rendering scene
  60645. */
  60646. animate(scene: Scene): void;
  60647. private _emitDefine;
  60648. initialize(state: NodeMaterialBuildState): void;
  60649. /**
  60650. * Set the input block to its default value (based on its type)
  60651. */
  60652. setDefaultValue(): void;
  60653. private _emitConstant;
  60654. private _emit;
  60655. /** @hidden */
  60656. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60657. /** @hidden */
  60658. _transmit(effect: Effect, scene: Scene): void;
  60659. protected _buildBlock(state: NodeMaterialBuildState): void;
  60660. protected _dumpPropertiesCode(): string;
  60661. serialize(): any;
  60662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60663. }
  60664. }
  60665. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60666. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60667. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60668. import { Nullable } from "babylonjs/types";
  60669. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60670. import { Observable } from "babylonjs/Misc/observable";
  60671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60672. /**
  60673. * Enum used to define the compatibility state between two connection points
  60674. */
  60675. export enum NodeMaterialConnectionPointCompatibilityStates {
  60676. /** Points are compatibles */
  60677. Compatible = 0,
  60678. /** Points are incompatible because of their types */
  60679. TypeIncompatible = 1,
  60680. /** Points are incompatible because of their targets (vertex vs fragment) */
  60681. TargetIncompatible = 2
  60682. }
  60683. /**
  60684. * Defines the direction of a connection point
  60685. */
  60686. export enum NodeMaterialConnectionPointDirection {
  60687. /** Input */
  60688. Input = 0,
  60689. /** Output */
  60690. Output = 1
  60691. }
  60692. /**
  60693. * Defines a connection point for a block
  60694. */
  60695. export class NodeMaterialConnectionPoint {
  60696. /** @hidden */
  60697. _ownerBlock: NodeMaterialBlock;
  60698. /** @hidden */
  60699. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60700. private _endpoints;
  60701. private _associatedVariableName;
  60702. private _direction;
  60703. /** @hidden */
  60704. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60705. /** @hidden */
  60706. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60707. private _type;
  60708. /** @hidden */
  60709. _enforceAssociatedVariableName: boolean;
  60710. /** Gets the direction of the point */
  60711. get direction(): NodeMaterialConnectionPointDirection;
  60712. /**
  60713. * Gets or sets the additional types supported by this connection point
  60714. */
  60715. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60716. /**
  60717. * Gets or sets the additional types excluded by this connection point
  60718. */
  60719. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60720. /**
  60721. * Observable triggered when this point is connected
  60722. */
  60723. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60724. /**
  60725. * Gets or sets the associated variable name in the shader
  60726. */
  60727. get associatedVariableName(): string;
  60728. set associatedVariableName(value: string);
  60729. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60730. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60731. /**
  60732. * Gets or sets the connection point type (default is float)
  60733. */
  60734. get type(): NodeMaterialBlockConnectionPointTypes;
  60735. set type(value: NodeMaterialBlockConnectionPointTypes);
  60736. /**
  60737. * Gets or sets the connection point name
  60738. */
  60739. name: string;
  60740. /**
  60741. * Gets or sets a boolean indicating that this connection point can be omitted
  60742. */
  60743. isOptional: boolean;
  60744. /**
  60745. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60746. */
  60747. define: string;
  60748. /** @hidden */
  60749. _prioritizeVertex: boolean;
  60750. private _target;
  60751. /** Gets or sets the target of that connection point */
  60752. get target(): NodeMaterialBlockTargets;
  60753. set target(value: NodeMaterialBlockTargets);
  60754. /**
  60755. * Gets a boolean indicating that the current point is connected
  60756. */
  60757. get isConnected(): boolean;
  60758. /**
  60759. * Gets a boolean indicating that the current point is connected to an input block
  60760. */
  60761. get isConnectedToInputBlock(): boolean;
  60762. /**
  60763. * Gets a the connected input block (if any)
  60764. */
  60765. get connectInputBlock(): Nullable<InputBlock>;
  60766. /** Get the other side of the connection (if any) */
  60767. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60768. /** Get the block that owns this connection point */
  60769. get ownerBlock(): NodeMaterialBlock;
  60770. /** Get the block connected on the other side of this connection (if any) */
  60771. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60772. /** Get the block connected on the endpoints of this connection (if any) */
  60773. get connectedBlocks(): Array<NodeMaterialBlock>;
  60774. /** Gets the list of connected endpoints */
  60775. get endpoints(): NodeMaterialConnectionPoint[];
  60776. /** Gets a boolean indicating if that output point is connected to at least one input */
  60777. get hasEndpoints(): boolean;
  60778. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60779. get isConnectedInVertexShader(): boolean;
  60780. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60781. get isConnectedInFragmentShader(): boolean;
  60782. /**
  60783. * Creates a new connection point
  60784. * @param name defines the connection point name
  60785. * @param ownerBlock defines the block hosting this connection point
  60786. * @param direction defines the direction of the connection point
  60787. */
  60788. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60789. /**
  60790. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60791. * @returns the class name
  60792. */
  60793. getClassName(): string;
  60794. /**
  60795. * Gets a boolean indicating if the current point can be connected to another point
  60796. * @param connectionPoint defines the other connection point
  60797. * @returns a boolean
  60798. */
  60799. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60800. /**
  60801. * Gets a number indicating if the current point can be connected to another point
  60802. * @param connectionPoint defines the other connection point
  60803. * @returns a number defining the compatibility state
  60804. */
  60805. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60806. /**
  60807. * Connect this point to another connection point
  60808. * @param connectionPoint defines the other connection point
  60809. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60810. * @returns the current connection point
  60811. */
  60812. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60813. /**
  60814. * Disconnect this point from one of his endpoint
  60815. * @param endpoint defines the other connection point
  60816. * @returns the current connection point
  60817. */
  60818. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60819. /**
  60820. * Serializes this point in a JSON representation
  60821. * @returns the serialized point object
  60822. */
  60823. serialize(): any;
  60824. /**
  60825. * Release resources
  60826. */
  60827. dispose(): void;
  60828. }
  60829. }
  60830. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60834. import { Mesh } from "babylonjs/Meshes/mesh";
  60835. import { Effect } from "babylonjs/Materials/effect";
  60836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60837. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60838. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60839. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60840. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60841. /**
  60842. * Block used to add support for vertex skinning (bones)
  60843. */
  60844. export class BonesBlock extends NodeMaterialBlock {
  60845. /**
  60846. * Creates a new BonesBlock
  60847. * @param name defines the block name
  60848. */
  60849. constructor(name: string);
  60850. /**
  60851. * Initialize the block and prepare the context for build
  60852. * @param state defines the state that will be used for the build
  60853. */
  60854. initialize(state: NodeMaterialBuildState): void;
  60855. /**
  60856. * Gets the current class name
  60857. * @returns the class name
  60858. */
  60859. getClassName(): string;
  60860. /**
  60861. * Gets the matrix indices input component
  60862. */
  60863. get matricesIndices(): NodeMaterialConnectionPoint;
  60864. /**
  60865. * Gets the matrix weights input component
  60866. */
  60867. get matricesWeights(): NodeMaterialConnectionPoint;
  60868. /**
  60869. * Gets the extra matrix indices input component
  60870. */
  60871. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60872. /**
  60873. * Gets the extra matrix weights input component
  60874. */
  60875. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60876. /**
  60877. * Gets the world input component
  60878. */
  60879. get world(): NodeMaterialConnectionPoint;
  60880. /**
  60881. * Gets the output component
  60882. */
  60883. get output(): NodeMaterialConnectionPoint;
  60884. autoConfigure(material: NodeMaterial): void;
  60885. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60888. protected _buildBlock(state: NodeMaterialBuildState): this;
  60889. }
  60890. }
  60891. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60896. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60897. /**
  60898. * Block used to add support for instances
  60899. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60900. */
  60901. export class InstancesBlock extends NodeMaterialBlock {
  60902. /**
  60903. * Creates a new InstancesBlock
  60904. * @param name defines the block name
  60905. */
  60906. constructor(name: string);
  60907. /**
  60908. * Gets the current class name
  60909. * @returns the class name
  60910. */
  60911. getClassName(): string;
  60912. /**
  60913. * Gets the first world row input component
  60914. */
  60915. get world0(): NodeMaterialConnectionPoint;
  60916. /**
  60917. * Gets the second world row input component
  60918. */
  60919. get world1(): NodeMaterialConnectionPoint;
  60920. /**
  60921. * Gets the third world row input component
  60922. */
  60923. get world2(): NodeMaterialConnectionPoint;
  60924. /**
  60925. * Gets the forth world row input component
  60926. */
  60927. get world3(): NodeMaterialConnectionPoint;
  60928. /**
  60929. * Gets the world input component
  60930. */
  60931. get world(): NodeMaterialConnectionPoint;
  60932. /**
  60933. * Gets the output component
  60934. */
  60935. get output(): NodeMaterialConnectionPoint;
  60936. autoConfigure(material: NodeMaterial): void;
  60937. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60938. protected _buildBlock(state: NodeMaterialBuildState): this;
  60939. }
  60940. }
  60941. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60946. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60947. import { Effect } from "babylonjs/Materials/effect";
  60948. import { Mesh } from "babylonjs/Meshes/mesh";
  60949. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60951. /**
  60952. * Block used to add morph targets support to vertex shader
  60953. */
  60954. export class MorphTargetsBlock extends NodeMaterialBlock {
  60955. private _repeatableContentAnchor;
  60956. /**
  60957. * Create a new MorphTargetsBlock
  60958. * @param name defines the block name
  60959. */
  60960. constructor(name: string);
  60961. /**
  60962. * Gets the current class name
  60963. * @returns the class name
  60964. */
  60965. getClassName(): string;
  60966. /**
  60967. * Gets the position input component
  60968. */
  60969. get position(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the normal input component
  60972. */
  60973. get normal(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the tangent input component
  60976. */
  60977. get tangent(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the tangent input component
  60980. */
  60981. get uv(): NodeMaterialConnectionPoint;
  60982. /**
  60983. * Gets the position output component
  60984. */
  60985. get positionOutput(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the normal output component
  60988. */
  60989. get normalOutput(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the tangent output component
  60992. */
  60993. get tangentOutput(): NodeMaterialConnectionPoint;
  60994. /**
  60995. * Gets the tangent output component
  60996. */
  60997. get uvOutput(): NodeMaterialConnectionPoint;
  60998. initialize(state: NodeMaterialBuildState): void;
  60999. autoConfigure(material: NodeMaterial): void;
  61000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61002. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61003. protected _buildBlock(state: NodeMaterialBuildState): this;
  61004. }
  61005. }
  61006. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61010. import { Nullable } from "babylonjs/types";
  61011. import { Scene } from "babylonjs/scene";
  61012. import { Effect } from "babylonjs/Materials/effect";
  61013. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61014. import { Mesh } from "babylonjs/Meshes/mesh";
  61015. import { Light } from "babylonjs/Lights/light";
  61016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61017. /**
  61018. * Block used to get data information from a light
  61019. */
  61020. export class LightInformationBlock extends NodeMaterialBlock {
  61021. private _lightDataUniformName;
  61022. private _lightColorUniformName;
  61023. private _lightTypeDefineName;
  61024. /**
  61025. * Gets or sets the light associated with this block
  61026. */
  61027. light: Nullable<Light>;
  61028. /**
  61029. * Creates a new LightInformationBlock
  61030. * @param name defines the block name
  61031. */
  61032. constructor(name: string);
  61033. /**
  61034. * Gets the current class name
  61035. * @returns the class name
  61036. */
  61037. getClassName(): string;
  61038. /**
  61039. * Gets the world position input component
  61040. */
  61041. get worldPosition(): NodeMaterialConnectionPoint;
  61042. /**
  61043. * Gets the direction output component
  61044. */
  61045. get direction(): NodeMaterialConnectionPoint;
  61046. /**
  61047. * Gets the direction output component
  61048. */
  61049. get color(): NodeMaterialConnectionPoint;
  61050. /**
  61051. * Gets the direction output component
  61052. */
  61053. get intensity(): NodeMaterialConnectionPoint;
  61054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61056. protected _buildBlock(state: NodeMaterialBuildState): this;
  61057. serialize(): any;
  61058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61059. }
  61060. }
  61061. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61062. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61063. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61064. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61065. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61066. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61067. }
  61068. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61073. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61074. import { Effect } from "babylonjs/Materials/effect";
  61075. import { Mesh } from "babylonjs/Meshes/mesh";
  61076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61077. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61078. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61079. /**
  61080. * Block used to add image processing support to fragment shader
  61081. */
  61082. export class ImageProcessingBlock extends NodeMaterialBlock {
  61083. /**
  61084. * Create a new ImageProcessingBlock
  61085. * @param name defines the block name
  61086. */
  61087. constructor(name: string);
  61088. /**
  61089. * Gets the current class name
  61090. * @returns the class name
  61091. */
  61092. getClassName(): string;
  61093. /**
  61094. * Gets the color input component
  61095. */
  61096. get color(): NodeMaterialConnectionPoint;
  61097. /**
  61098. * Gets the output component
  61099. */
  61100. get output(): NodeMaterialConnectionPoint;
  61101. /**
  61102. * Initialize the block and prepare the context for build
  61103. * @param state defines the state that will be used for the build
  61104. */
  61105. initialize(state: NodeMaterialBuildState): void;
  61106. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61109. protected _buildBlock(state: NodeMaterialBuildState): this;
  61110. }
  61111. }
  61112. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61116. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61118. import { Effect } from "babylonjs/Materials/effect";
  61119. import { Mesh } from "babylonjs/Meshes/mesh";
  61120. import { Scene } from "babylonjs/scene";
  61121. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61122. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61123. /**
  61124. * Block used to pertub normals based on a normal map
  61125. */
  61126. export class PerturbNormalBlock extends NodeMaterialBlock {
  61127. private _tangentSpaceParameterName;
  61128. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61129. invertX: boolean;
  61130. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61131. invertY: boolean;
  61132. /**
  61133. * Create a new PerturbNormalBlock
  61134. * @param name defines the block name
  61135. */
  61136. constructor(name: string);
  61137. /**
  61138. * Gets the current class name
  61139. * @returns the class name
  61140. */
  61141. getClassName(): string;
  61142. /**
  61143. * Gets the world position input component
  61144. */
  61145. get worldPosition(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the world normal input component
  61148. */
  61149. get worldNormal(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the uv input component
  61152. */
  61153. get uv(): NodeMaterialConnectionPoint;
  61154. /**
  61155. * Gets the normal map color input component
  61156. */
  61157. get normalMapColor(): NodeMaterialConnectionPoint;
  61158. /**
  61159. * Gets the strength input component
  61160. */
  61161. get strength(): NodeMaterialConnectionPoint;
  61162. /**
  61163. * Gets the output component
  61164. */
  61165. get output(): NodeMaterialConnectionPoint;
  61166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61168. autoConfigure(material: NodeMaterial): void;
  61169. protected _buildBlock(state: NodeMaterialBuildState): this;
  61170. protected _dumpPropertiesCode(): string;
  61171. serialize(): any;
  61172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61173. }
  61174. }
  61175. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61179. /**
  61180. * Block used to discard a pixel if a value is smaller than a cutoff
  61181. */
  61182. export class DiscardBlock extends NodeMaterialBlock {
  61183. /**
  61184. * Create a new DiscardBlock
  61185. * @param name defines the block name
  61186. */
  61187. constructor(name: string);
  61188. /**
  61189. * Gets the current class name
  61190. * @returns the class name
  61191. */
  61192. getClassName(): string;
  61193. /**
  61194. * Gets the color input component
  61195. */
  61196. get value(): NodeMaterialConnectionPoint;
  61197. /**
  61198. * Gets the cutoff input component
  61199. */
  61200. get cutoff(): NodeMaterialConnectionPoint;
  61201. protected _buildBlock(state: NodeMaterialBuildState): this;
  61202. }
  61203. }
  61204. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61208. /**
  61209. * Block used to test if the fragment shader is front facing
  61210. */
  61211. export class FrontFacingBlock extends NodeMaterialBlock {
  61212. /**
  61213. * Creates a new FrontFacingBlock
  61214. * @param name defines the block name
  61215. */
  61216. constructor(name: string);
  61217. /**
  61218. * Gets the current class name
  61219. * @returns the class name
  61220. */
  61221. getClassName(): string;
  61222. /**
  61223. * Gets the output component
  61224. */
  61225. get output(): NodeMaterialConnectionPoint;
  61226. protected _buildBlock(state: NodeMaterialBuildState): this;
  61227. }
  61228. }
  61229. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61233. /**
  61234. * Block used to get the derivative value on x and y of a given input
  61235. */
  61236. export class DerivativeBlock extends NodeMaterialBlock {
  61237. /**
  61238. * Create a new DerivativeBlock
  61239. * @param name defines the block name
  61240. */
  61241. constructor(name: string);
  61242. /**
  61243. * Gets the current class name
  61244. * @returns the class name
  61245. */
  61246. getClassName(): string;
  61247. /**
  61248. * Gets the input component
  61249. */
  61250. get input(): NodeMaterialConnectionPoint;
  61251. /**
  61252. * Gets the derivative output on x
  61253. */
  61254. get dx(): NodeMaterialConnectionPoint;
  61255. /**
  61256. * Gets the derivative output on y
  61257. */
  61258. get dy(): NodeMaterialConnectionPoint;
  61259. protected _buildBlock(state: NodeMaterialBuildState): this;
  61260. }
  61261. }
  61262. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61263. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61264. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61265. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61266. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61267. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61268. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61269. }
  61270. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61273. import { Mesh } from "babylonjs/Meshes/mesh";
  61274. import { Effect } from "babylonjs/Materials/effect";
  61275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61277. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61278. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61279. /**
  61280. * Block used to add support for scene fog
  61281. */
  61282. export class FogBlock extends NodeMaterialBlock {
  61283. private _fogDistanceName;
  61284. private _fogParameters;
  61285. /**
  61286. * Create a new FogBlock
  61287. * @param name defines the block name
  61288. */
  61289. constructor(name: string);
  61290. /**
  61291. * Gets the current class name
  61292. * @returns the class name
  61293. */
  61294. getClassName(): string;
  61295. /**
  61296. * Gets the world position input component
  61297. */
  61298. get worldPosition(): NodeMaterialConnectionPoint;
  61299. /**
  61300. * Gets the view input component
  61301. */
  61302. get view(): NodeMaterialConnectionPoint;
  61303. /**
  61304. * Gets the color input component
  61305. */
  61306. get input(): NodeMaterialConnectionPoint;
  61307. /**
  61308. * Gets the fog color input component
  61309. */
  61310. get fogColor(): NodeMaterialConnectionPoint;
  61311. /**
  61312. * Gets the output component
  61313. */
  61314. get output(): NodeMaterialConnectionPoint;
  61315. autoConfigure(material: NodeMaterial): void;
  61316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61317. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61318. protected _buildBlock(state: NodeMaterialBuildState): this;
  61319. }
  61320. }
  61321. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61326. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61327. import { Effect } from "babylonjs/Materials/effect";
  61328. import { Mesh } from "babylonjs/Meshes/mesh";
  61329. import { Light } from "babylonjs/Lights/light";
  61330. import { Nullable } from "babylonjs/types";
  61331. import { Scene } from "babylonjs/scene";
  61332. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61333. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61334. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61335. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61336. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61337. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61338. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61339. /**
  61340. * Block used to add light in the fragment shader
  61341. */
  61342. export class LightBlock extends NodeMaterialBlock {
  61343. private _lightId;
  61344. /**
  61345. * Gets or sets the light associated with this block
  61346. */
  61347. light: Nullable<Light>;
  61348. /**
  61349. * Create a new LightBlock
  61350. * @param name defines the block name
  61351. */
  61352. constructor(name: string);
  61353. /**
  61354. * Gets the current class name
  61355. * @returns the class name
  61356. */
  61357. getClassName(): string;
  61358. /**
  61359. * Gets the world position input component
  61360. */
  61361. get worldPosition(): NodeMaterialConnectionPoint;
  61362. /**
  61363. * Gets the world normal input component
  61364. */
  61365. get worldNormal(): NodeMaterialConnectionPoint;
  61366. /**
  61367. * Gets the camera (or eye) position component
  61368. */
  61369. get cameraPosition(): NodeMaterialConnectionPoint;
  61370. /**
  61371. * Gets the glossiness component
  61372. */
  61373. get glossiness(): NodeMaterialConnectionPoint;
  61374. /**
  61375. * Gets the glossinness power component
  61376. */
  61377. get glossPower(): NodeMaterialConnectionPoint;
  61378. /**
  61379. * Gets the diffuse color component
  61380. */
  61381. get diffuseColor(): NodeMaterialConnectionPoint;
  61382. /**
  61383. * Gets the specular color component
  61384. */
  61385. get specularColor(): NodeMaterialConnectionPoint;
  61386. /**
  61387. * Gets the diffuse output component
  61388. */
  61389. get diffuseOutput(): NodeMaterialConnectionPoint;
  61390. /**
  61391. * Gets the specular output component
  61392. */
  61393. get specularOutput(): NodeMaterialConnectionPoint;
  61394. /**
  61395. * Gets the shadow output component
  61396. */
  61397. get shadow(): NodeMaterialConnectionPoint;
  61398. autoConfigure(material: NodeMaterial): void;
  61399. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61400. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61401. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61402. private _injectVertexCode;
  61403. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61404. serialize(): any;
  61405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61406. }
  61407. }
  61408. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61409. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61410. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61411. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61412. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61413. }
  61414. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61415. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61416. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61417. }
  61418. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61422. /**
  61423. * Block used to multiply 2 values
  61424. */
  61425. export class MultiplyBlock extends NodeMaterialBlock {
  61426. /**
  61427. * Creates a new MultiplyBlock
  61428. * @param name defines the block name
  61429. */
  61430. constructor(name: string);
  61431. /**
  61432. * Gets the current class name
  61433. * @returns the class name
  61434. */
  61435. getClassName(): string;
  61436. /**
  61437. * Gets the left operand input component
  61438. */
  61439. get left(): NodeMaterialConnectionPoint;
  61440. /**
  61441. * Gets the right operand input component
  61442. */
  61443. get right(): NodeMaterialConnectionPoint;
  61444. /**
  61445. * Gets the output component
  61446. */
  61447. get output(): NodeMaterialConnectionPoint;
  61448. protected _buildBlock(state: NodeMaterialBuildState): this;
  61449. }
  61450. }
  61451. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61455. /**
  61456. * Block used to add 2 vectors
  61457. */
  61458. export class AddBlock extends NodeMaterialBlock {
  61459. /**
  61460. * Creates a new AddBlock
  61461. * @param name defines the block name
  61462. */
  61463. constructor(name: string);
  61464. /**
  61465. * Gets the current class name
  61466. * @returns the class name
  61467. */
  61468. getClassName(): string;
  61469. /**
  61470. * Gets the left operand input component
  61471. */
  61472. get left(): NodeMaterialConnectionPoint;
  61473. /**
  61474. * Gets the right operand input component
  61475. */
  61476. get right(): NodeMaterialConnectionPoint;
  61477. /**
  61478. * Gets the output component
  61479. */
  61480. get output(): NodeMaterialConnectionPoint;
  61481. protected _buildBlock(state: NodeMaterialBuildState): this;
  61482. }
  61483. }
  61484. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61488. /**
  61489. * Block used to scale a vector by a float
  61490. */
  61491. export class ScaleBlock extends NodeMaterialBlock {
  61492. /**
  61493. * Creates a new ScaleBlock
  61494. * @param name defines the block name
  61495. */
  61496. constructor(name: string);
  61497. /**
  61498. * Gets the current class name
  61499. * @returns the class name
  61500. */
  61501. getClassName(): string;
  61502. /**
  61503. * Gets the input component
  61504. */
  61505. get input(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Gets the factor input component
  61508. */
  61509. get factor(): NodeMaterialConnectionPoint;
  61510. /**
  61511. * Gets the output component
  61512. */
  61513. get output(): NodeMaterialConnectionPoint;
  61514. protected _buildBlock(state: NodeMaterialBuildState): this;
  61515. }
  61516. }
  61517. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61521. import { Scene } from "babylonjs/scene";
  61522. /**
  61523. * Block used to clamp a float
  61524. */
  61525. export class ClampBlock extends NodeMaterialBlock {
  61526. /** Gets or sets the minimum range */
  61527. minimum: number;
  61528. /** Gets or sets the maximum range */
  61529. maximum: number;
  61530. /**
  61531. * Creates a new ClampBlock
  61532. * @param name defines the block name
  61533. */
  61534. constructor(name: string);
  61535. /**
  61536. * Gets the current class name
  61537. * @returns the class name
  61538. */
  61539. getClassName(): string;
  61540. /**
  61541. * Gets the value input component
  61542. */
  61543. get value(): NodeMaterialConnectionPoint;
  61544. /**
  61545. * Gets the output component
  61546. */
  61547. get output(): NodeMaterialConnectionPoint;
  61548. protected _buildBlock(state: NodeMaterialBuildState): this;
  61549. protected _dumpPropertiesCode(): string;
  61550. serialize(): any;
  61551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61552. }
  61553. }
  61554. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61558. /**
  61559. * Block used to apply a cross product between 2 vectors
  61560. */
  61561. export class CrossBlock extends NodeMaterialBlock {
  61562. /**
  61563. * Creates a new CrossBlock
  61564. * @param name defines the block name
  61565. */
  61566. constructor(name: string);
  61567. /**
  61568. * Gets the current class name
  61569. * @returns the class name
  61570. */
  61571. getClassName(): string;
  61572. /**
  61573. * Gets the left operand input component
  61574. */
  61575. get left(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the right operand input component
  61578. */
  61579. get right(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the output component
  61582. */
  61583. get output(): NodeMaterialConnectionPoint;
  61584. protected _buildBlock(state: NodeMaterialBuildState): this;
  61585. }
  61586. }
  61587. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61591. /**
  61592. * Block used to apply a dot product between 2 vectors
  61593. */
  61594. export class DotBlock extends NodeMaterialBlock {
  61595. /**
  61596. * Creates a new DotBlock
  61597. * @param name defines the block name
  61598. */
  61599. constructor(name: string);
  61600. /**
  61601. * Gets the current class name
  61602. * @returns the class name
  61603. */
  61604. getClassName(): string;
  61605. /**
  61606. * Gets the left operand input component
  61607. */
  61608. get left(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the right operand input component
  61611. */
  61612. get right(): NodeMaterialConnectionPoint;
  61613. /**
  61614. * Gets the output component
  61615. */
  61616. get output(): NodeMaterialConnectionPoint;
  61617. protected _buildBlock(state: NodeMaterialBuildState): this;
  61618. }
  61619. }
  61620. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61624. import { Vector2 } from "babylonjs/Maths/math.vector";
  61625. import { Scene } from "babylonjs/scene";
  61626. /**
  61627. * Block used to remap a float from a range to a new one
  61628. */
  61629. export class RemapBlock extends NodeMaterialBlock {
  61630. /**
  61631. * Gets or sets the source range
  61632. */
  61633. sourceRange: Vector2;
  61634. /**
  61635. * Gets or sets the target range
  61636. */
  61637. targetRange: Vector2;
  61638. /**
  61639. * Creates a new RemapBlock
  61640. * @param name defines the block name
  61641. */
  61642. constructor(name: string);
  61643. /**
  61644. * Gets the current class name
  61645. * @returns the class name
  61646. */
  61647. getClassName(): string;
  61648. /**
  61649. * Gets the input component
  61650. */
  61651. get input(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the source min input component
  61654. */
  61655. get sourceMin(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the source max input component
  61658. */
  61659. get sourceMax(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the target min input component
  61662. */
  61663. get targetMin(): NodeMaterialConnectionPoint;
  61664. /**
  61665. * Gets the target max input component
  61666. */
  61667. get targetMax(): NodeMaterialConnectionPoint;
  61668. /**
  61669. * Gets the output component
  61670. */
  61671. get output(): NodeMaterialConnectionPoint;
  61672. protected _buildBlock(state: NodeMaterialBuildState): this;
  61673. protected _dumpPropertiesCode(): string;
  61674. serialize(): any;
  61675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61676. }
  61677. }
  61678. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61682. /**
  61683. * Block used to normalize a vector
  61684. */
  61685. export class NormalizeBlock extends NodeMaterialBlock {
  61686. /**
  61687. * Creates a new NormalizeBlock
  61688. * @param name defines the block name
  61689. */
  61690. constructor(name: string);
  61691. /**
  61692. * Gets the current class name
  61693. * @returns the class name
  61694. */
  61695. getClassName(): string;
  61696. /**
  61697. * Gets the input component
  61698. */
  61699. get input(): NodeMaterialConnectionPoint;
  61700. /**
  61701. * Gets the output component
  61702. */
  61703. get output(): NodeMaterialConnectionPoint;
  61704. protected _buildBlock(state: NodeMaterialBuildState): this;
  61705. }
  61706. }
  61707. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61711. import { Scene } from "babylonjs/scene";
  61712. /**
  61713. * Operations supported by the Trigonometry block
  61714. */
  61715. export enum TrigonometryBlockOperations {
  61716. /** Cos */
  61717. Cos = 0,
  61718. /** Sin */
  61719. Sin = 1,
  61720. /** Abs */
  61721. Abs = 2,
  61722. /** Exp */
  61723. Exp = 3,
  61724. /** Exp2 */
  61725. Exp2 = 4,
  61726. /** Round */
  61727. Round = 5,
  61728. /** Floor */
  61729. Floor = 6,
  61730. /** Ceiling */
  61731. Ceiling = 7,
  61732. /** Square root */
  61733. Sqrt = 8,
  61734. /** Log */
  61735. Log = 9,
  61736. /** Tangent */
  61737. Tan = 10,
  61738. /** Arc tangent */
  61739. ArcTan = 11,
  61740. /** Arc cosinus */
  61741. ArcCos = 12,
  61742. /** Arc sinus */
  61743. ArcSin = 13,
  61744. /** Fraction */
  61745. Fract = 14,
  61746. /** Sign */
  61747. Sign = 15,
  61748. /** To radians (from degrees) */
  61749. Radians = 16,
  61750. /** To degrees (from radians) */
  61751. Degrees = 17
  61752. }
  61753. /**
  61754. * Block used to apply trigonometry operation to floats
  61755. */
  61756. export class TrigonometryBlock extends NodeMaterialBlock {
  61757. /**
  61758. * Gets or sets the operation applied by the block
  61759. */
  61760. operation: TrigonometryBlockOperations;
  61761. /**
  61762. * Creates a new TrigonometryBlock
  61763. * @param name defines the block name
  61764. */
  61765. constructor(name: string);
  61766. /**
  61767. * Gets the current class name
  61768. * @returns the class name
  61769. */
  61770. getClassName(): string;
  61771. /**
  61772. * Gets the input component
  61773. */
  61774. get input(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the output component
  61777. */
  61778. get output(): NodeMaterialConnectionPoint;
  61779. protected _buildBlock(state: NodeMaterialBuildState): this;
  61780. serialize(): any;
  61781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61782. protected _dumpPropertiesCode(): string;
  61783. }
  61784. }
  61785. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61789. /**
  61790. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61791. */
  61792. export class ColorMergerBlock extends NodeMaterialBlock {
  61793. /**
  61794. * Create a new ColorMergerBlock
  61795. * @param name defines the block name
  61796. */
  61797. constructor(name: string);
  61798. /**
  61799. * Gets the current class name
  61800. * @returns the class name
  61801. */
  61802. getClassName(): string;
  61803. /**
  61804. * Gets the rgb component (input)
  61805. */
  61806. get rgbIn(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the r component (input)
  61809. */
  61810. get r(): NodeMaterialConnectionPoint;
  61811. /**
  61812. * Gets the g component (input)
  61813. */
  61814. get g(): NodeMaterialConnectionPoint;
  61815. /**
  61816. * Gets the b component (input)
  61817. */
  61818. get b(): NodeMaterialConnectionPoint;
  61819. /**
  61820. * Gets the a component (input)
  61821. */
  61822. get a(): NodeMaterialConnectionPoint;
  61823. /**
  61824. * Gets the rgba component (output)
  61825. */
  61826. get rgba(): NodeMaterialConnectionPoint;
  61827. /**
  61828. * Gets the rgb component (output)
  61829. */
  61830. get rgbOut(): NodeMaterialConnectionPoint;
  61831. /**
  61832. * Gets the rgb component (output)
  61833. * @deprecated Please use rgbOut instead.
  61834. */
  61835. get rgb(): NodeMaterialConnectionPoint;
  61836. protected _buildBlock(state: NodeMaterialBuildState): this;
  61837. }
  61838. }
  61839. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61843. /**
  61844. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61845. */
  61846. export class VectorMergerBlock extends NodeMaterialBlock {
  61847. /**
  61848. * Create a new VectorMergerBlock
  61849. * @param name defines the block name
  61850. */
  61851. constructor(name: string);
  61852. /**
  61853. * Gets the current class name
  61854. * @returns the class name
  61855. */
  61856. getClassName(): string;
  61857. /**
  61858. * Gets the xyz component (input)
  61859. */
  61860. get xyzIn(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the xy component (input)
  61863. */
  61864. get xyIn(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the x component (input)
  61867. */
  61868. get x(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the y component (input)
  61871. */
  61872. get y(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the z component (input)
  61875. */
  61876. get z(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the w component (input)
  61879. */
  61880. get w(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the xyzw component (output)
  61883. */
  61884. get xyzw(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the xyz component (output)
  61887. */
  61888. get xyzOut(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the xy component (output)
  61891. */
  61892. get xyOut(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the xy component (output)
  61895. * @deprecated Please use xyOut instead.
  61896. */
  61897. get xy(): NodeMaterialConnectionPoint;
  61898. /**
  61899. * Gets the xyz component (output)
  61900. * @deprecated Please use xyzOut instead.
  61901. */
  61902. get xyz(): NodeMaterialConnectionPoint;
  61903. protected _buildBlock(state: NodeMaterialBuildState): this;
  61904. }
  61905. }
  61906. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61910. /**
  61911. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61912. */
  61913. export class ColorSplitterBlock extends NodeMaterialBlock {
  61914. /**
  61915. * Create a new ColorSplitterBlock
  61916. * @param name defines the block name
  61917. */
  61918. constructor(name: string);
  61919. /**
  61920. * Gets the current class name
  61921. * @returns the class name
  61922. */
  61923. getClassName(): string;
  61924. /**
  61925. * Gets the rgba component (input)
  61926. */
  61927. get rgba(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the rgb component (input)
  61930. */
  61931. get rgbIn(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the rgb component (output)
  61934. */
  61935. get rgbOut(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the r component (output)
  61938. */
  61939. get r(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the g component (output)
  61942. */
  61943. get g(): NodeMaterialConnectionPoint;
  61944. /**
  61945. * Gets the b component (output)
  61946. */
  61947. get b(): NodeMaterialConnectionPoint;
  61948. /**
  61949. * Gets the a component (output)
  61950. */
  61951. get a(): NodeMaterialConnectionPoint;
  61952. protected _inputRename(name: string): string;
  61953. protected _outputRename(name: string): string;
  61954. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61955. }
  61956. }
  61957. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61961. /**
  61962. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61963. */
  61964. export class VectorSplitterBlock extends NodeMaterialBlock {
  61965. /**
  61966. * Create a new VectorSplitterBlock
  61967. * @param name defines the block name
  61968. */
  61969. constructor(name: string);
  61970. /**
  61971. * Gets the current class name
  61972. * @returns the class name
  61973. */
  61974. getClassName(): string;
  61975. /**
  61976. * Gets the xyzw component (input)
  61977. */
  61978. get xyzw(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the xyz component (input)
  61981. */
  61982. get xyzIn(): NodeMaterialConnectionPoint;
  61983. /**
  61984. * Gets the xy component (input)
  61985. */
  61986. get xyIn(): NodeMaterialConnectionPoint;
  61987. /**
  61988. * Gets the xyz component (output)
  61989. */
  61990. get xyzOut(): NodeMaterialConnectionPoint;
  61991. /**
  61992. * Gets the xy component (output)
  61993. */
  61994. get xyOut(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Gets the x component (output)
  61997. */
  61998. get x(): NodeMaterialConnectionPoint;
  61999. /**
  62000. * Gets the y component (output)
  62001. */
  62002. get y(): NodeMaterialConnectionPoint;
  62003. /**
  62004. * Gets the z component (output)
  62005. */
  62006. get z(): NodeMaterialConnectionPoint;
  62007. /**
  62008. * Gets the w component (output)
  62009. */
  62010. get w(): NodeMaterialConnectionPoint;
  62011. protected _inputRename(name: string): string;
  62012. protected _outputRename(name: string): string;
  62013. protected _buildBlock(state: NodeMaterialBuildState): this;
  62014. }
  62015. }
  62016. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62020. /**
  62021. * Block used to lerp between 2 values
  62022. */
  62023. export class LerpBlock extends NodeMaterialBlock {
  62024. /**
  62025. * Creates a new LerpBlock
  62026. * @param name defines the block name
  62027. */
  62028. constructor(name: string);
  62029. /**
  62030. * Gets the current class name
  62031. * @returns the class name
  62032. */
  62033. getClassName(): string;
  62034. /**
  62035. * Gets the left operand input component
  62036. */
  62037. get left(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the right operand input component
  62040. */
  62041. get right(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the gradient operand input component
  62044. */
  62045. get gradient(): NodeMaterialConnectionPoint;
  62046. /**
  62047. * Gets the output component
  62048. */
  62049. get output(): NodeMaterialConnectionPoint;
  62050. protected _buildBlock(state: NodeMaterialBuildState): this;
  62051. }
  62052. }
  62053. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62057. /**
  62058. * Block used to divide 2 vectors
  62059. */
  62060. export class DivideBlock extends NodeMaterialBlock {
  62061. /**
  62062. * Creates a new DivideBlock
  62063. * @param name defines the block name
  62064. */
  62065. constructor(name: string);
  62066. /**
  62067. * Gets the current class name
  62068. * @returns the class name
  62069. */
  62070. getClassName(): string;
  62071. /**
  62072. * Gets the left operand input component
  62073. */
  62074. get left(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the right operand input component
  62077. */
  62078. get right(): NodeMaterialConnectionPoint;
  62079. /**
  62080. * Gets the output component
  62081. */
  62082. get output(): NodeMaterialConnectionPoint;
  62083. protected _buildBlock(state: NodeMaterialBuildState): this;
  62084. }
  62085. }
  62086. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62090. /**
  62091. * Block used to subtract 2 vectors
  62092. */
  62093. export class SubtractBlock extends NodeMaterialBlock {
  62094. /**
  62095. * Creates a new SubtractBlock
  62096. * @param name defines the block name
  62097. */
  62098. constructor(name: string);
  62099. /**
  62100. * Gets the current class name
  62101. * @returns the class name
  62102. */
  62103. getClassName(): string;
  62104. /**
  62105. * Gets the left operand input component
  62106. */
  62107. get left(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the right operand input component
  62110. */
  62111. get right(): NodeMaterialConnectionPoint;
  62112. /**
  62113. * Gets the output component
  62114. */
  62115. get output(): NodeMaterialConnectionPoint;
  62116. protected _buildBlock(state: NodeMaterialBuildState): this;
  62117. }
  62118. }
  62119. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62123. /**
  62124. * Block used to step a value
  62125. */
  62126. export class StepBlock extends NodeMaterialBlock {
  62127. /**
  62128. * Creates a new StepBlock
  62129. * @param name defines the block name
  62130. */
  62131. constructor(name: string);
  62132. /**
  62133. * Gets the current class name
  62134. * @returns the class name
  62135. */
  62136. getClassName(): string;
  62137. /**
  62138. * Gets the value operand input component
  62139. */
  62140. get value(): NodeMaterialConnectionPoint;
  62141. /**
  62142. * Gets the edge operand input component
  62143. */
  62144. get edge(): NodeMaterialConnectionPoint;
  62145. /**
  62146. * Gets the output component
  62147. */
  62148. get output(): NodeMaterialConnectionPoint;
  62149. protected _buildBlock(state: NodeMaterialBuildState): this;
  62150. }
  62151. }
  62152. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62156. /**
  62157. * Block used to get the opposite (1 - x) of a value
  62158. */
  62159. export class OneMinusBlock extends NodeMaterialBlock {
  62160. /**
  62161. * Creates a new OneMinusBlock
  62162. * @param name defines the block name
  62163. */
  62164. constructor(name: string);
  62165. /**
  62166. * Gets the current class name
  62167. * @returns the class name
  62168. */
  62169. getClassName(): string;
  62170. /**
  62171. * Gets the input component
  62172. */
  62173. get input(): NodeMaterialConnectionPoint;
  62174. /**
  62175. * Gets the output component
  62176. */
  62177. get output(): NodeMaterialConnectionPoint;
  62178. protected _buildBlock(state: NodeMaterialBuildState): this;
  62179. }
  62180. }
  62181. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62185. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62186. /**
  62187. * Block used to get the view direction
  62188. */
  62189. export class ViewDirectionBlock extends NodeMaterialBlock {
  62190. /**
  62191. * Creates a new ViewDirectionBlock
  62192. * @param name defines the block name
  62193. */
  62194. constructor(name: string);
  62195. /**
  62196. * Gets the current class name
  62197. * @returns the class name
  62198. */
  62199. getClassName(): string;
  62200. /**
  62201. * Gets the world position component
  62202. */
  62203. get worldPosition(): NodeMaterialConnectionPoint;
  62204. /**
  62205. * Gets the camera position component
  62206. */
  62207. get cameraPosition(): NodeMaterialConnectionPoint;
  62208. /**
  62209. * Gets the output component
  62210. */
  62211. get output(): NodeMaterialConnectionPoint;
  62212. autoConfigure(material: NodeMaterial): void;
  62213. protected _buildBlock(state: NodeMaterialBuildState): this;
  62214. }
  62215. }
  62216. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62220. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62221. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62222. /**
  62223. * Block used to compute fresnel value
  62224. */
  62225. export class FresnelBlock extends NodeMaterialBlock {
  62226. /**
  62227. * Create a new FresnelBlock
  62228. * @param name defines the block name
  62229. */
  62230. constructor(name: string);
  62231. /**
  62232. * Gets the current class name
  62233. * @returns the class name
  62234. */
  62235. getClassName(): string;
  62236. /**
  62237. * Gets the world normal input component
  62238. */
  62239. get worldNormal(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the view direction input component
  62242. */
  62243. get viewDirection(): NodeMaterialConnectionPoint;
  62244. /**
  62245. * Gets the bias input component
  62246. */
  62247. get bias(): NodeMaterialConnectionPoint;
  62248. /**
  62249. * Gets the camera (or eye) position component
  62250. */
  62251. get power(): NodeMaterialConnectionPoint;
  62252. /**
  62253. * Gets the fresnel output component
  62254. */
  62255. get fresnel(): NodeMaterialConnectionPoint;
  62256. autoConfigure(material: NodeMaterial): void;
  62257. protected _buildBlock(state: NodeMaterialBuildState): this;
  62258. }
  62259. }
  62260. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62264. /**
  62265. * Block used to get the max of 2 values
  62266. */
  62267. export class MaxBlock extends NodeMaterialBlock {
  62268. /**
  62269. * Creates a new MaxBlock
  62270. * @param name defines the block name
  62271. */
  62272. constructor(name: string);
  62273. /**
  62274. * Gets the current class name
  62275. * @returns the class name
  62276. */
  62277. getClassName(): string;
  62278. /**
  62279. * Gets the left operand input component
  62280. */
  62281. get left(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the right operand input component
  62284. */
  62285. get right(): NodeMaterialConnectionPoint;
  62286. /**
  62287. * Gets the output component
  62288. */
  62289. get output(): NodeMaterialConnectionPoint;
  62290. protected _buildBlock(state: NodeMaterialBuildState): this;
  62291. }
  62292. }
  62293. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62297. /**
  62298. * Block used to get the min of 2 values
  62299. */
  62300. export class MinBlock extends NodeMaterialBlock {
  62301. /**
  62302. * Creates a new MinBlock
  62303. * @param name defines the block name
  62304. */
  62305. constructor(name: string);
  62306. /**
  62307. * Gets the current class name
  62308. * @returns the class name
  62309. */
  62310. getClassName(): string;
  62311. /**
  62312. * Gets the left operand input component
  62313. */
  62314. get left(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the right operand input component
  62317. */
  62318. get right(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the output component
  62321. */
  62322. get output(): NodeMaterialConnectionPoint;
  62323. protected _buildBlock(state: NodeMaterialBuildState): this;
  62324. }
  62325. }
  62326. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62330. /**
  62331. * Block used to get the distance between 2 values
  62332. */
  62333. export class DistanceBlock extends NodeMaterialBlock {
  62334. /**
  62335. * Creates a new DistanceBlock
  62336. * @param name defines the block name
  62337. */
  62338. constructor(name: string);
  62339. /**
  62340. * Gets the current class name
  62341. * @returns the class name
  62342. */
  62343. getClassName(): string;
  62344. /**
  62345. * Gets the left operand input component
  62346. */
  62347. get left(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the right operand input component
  62350. */
  62351. get right(): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Gets the output component
  62354. */
  62355. get output(): NodeMaterialConnectionPoint;
  62356. protected _buildBlock(state: NodeMaterialBuildState): this;
  62357. }
  62358. }
  62359. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62363. /**
  62364. * Block used to get the length of a vector
  62365. */
  62366. export class LengthBlock extends NodeMaterialBlock {
  62367. /**
  62368. * Creates a new LengthBlock
  62369. * @param name defines the block name
  62370. */
  62371. constructor(name: string);
  62372. /**
  62373. * Gets the current class name
  62374. * @returns the class name
  62375. */
  62376. getClassName(): string;
  62377. /**
  62378. * Gets the value input component
  62379. */
  62380. get value(): NodeMaterialConnectionPoint;
  62381. /**
  62382. * Gets the output component
  62383. */
  62384. get output(): NodeMaterialConnectionPoint;
  62385. protected _buildBlock(state: NodeMaterialBuildState): this;
  62386. }
  62387. }
  62388. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62389. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62392. /**
  62393. * Block used to get negative version of a value (i.e. x * -1)
  62394. */
  62395. export class NegateBlock extends NodeMaterialBlock {
  62396. /**
  62397. * Creates a new NegateBlock
  62398. * @param name defines the block name
  62399. */
  62400. constructor(name: string);
  62401. /**
  62402. * Gets the current class name
  62403. * @returns the class name
  62404. */
  62405. getClassName(): string;
  62406. /**
  62407. * Gets the value input component
  62408. */
  62409. get value(): NodeMaterialConnectionPoint;
  62410. /**
  62411. * Gets the output component
  62412. */
  62413. get output(): NodeMaterialConnectionPoint;
  62414. protected _buildBlock(state: NodeMaterialBuildState): this;
  62415. }
  62416. }
  62417. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62421. /**
  62422. * Block used to get the value of the first parameter raised to the power of the second
  62423. */
  62424. export class PowBlock extends NodeMaterialBlock {
  62425. /**
  62426. * Creates a new PowBlock
  62427. * @param name defines the block name
  62428. */
  62429. constructor(name: string);
  62430. /**
  62431. * Gets the current class name
  62432. * @returns the class name
  62433. */
  62434. getClassName(): string;
  62435. /**
  62436. * Gets the value operand input component
  62437. */
  62438. get value(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the power operand input component
  62441. */
  62442. get power(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the output component
  62445. */
  62446. get output(): NodeMaterialConnectionPoint;
  62447. protected _buildBlock(state: NodeMaterialBuildState): this;
  62448. }
  62449. }
  62450. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62455. /**
  62456. * Block used to get a random number
  62457. */
  62458. export class RandomNumberBlock extends NodeMaterialBlock {
  62459. /**
  62460. * Creates a new RandomNumberBlock
  62461. * @param name defines the block name
  62462. */
  62463. constructor(name: string);
  62464. /**
  62465. * Gets the current class name
  62466. * @returns the class name
  62467. */
  62468. getClassName(): string;
  62469. /**
  62470. * Gets the seed input component
  62471. */
  62472. get seed(): NodeMaterialConnectionPoint;
  62473. /**
  62474. * Gets the output component
  62475. */
  62476. get output(): NodeMaterialConnectionPoint;
  62477. protected _buildBlock(state: NodeMaterialBuildState): this;
  62478. }
  62479. }
  62480. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62484. /**
  62485. * Block used to compute arc tangent of 2 values
  62486. */
  62487. export class ArcTan2Block extends NodeMaterialBlock {
  62488. /**
  62489. * Creates a new ArcTan2Block
  62490. * @param name defines the block name
  62491. */
  62492. constructor(name: string);
  62493. /**
  62494. * Gets the current class name
  62495. * @returns the class name
  62496. */
  62497. getClassName(): string;
  62498. /**
  62499. * Gets the x operand input component
  62500. */
  62501. get x(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the y operand input component
  62504. */
  62505. get y(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the output component
  62508. */
  62509. get output(): NodeMaterialConnectionPoint;
  62510. protected _buildBlock(state: NodeMaterialBuildState): this;
  62511. }
  62512. }
  62513. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62517. /**
  62518. * Block used to smooth step a value
  62519. */
  62520. export class SmoothStepBlock extends NodeMaterialBlock {
  62521. /**
  62522. * Creates a new SmoothStepBlock
  62523. * @param name defines the block name
  62524. */
  62525. constructor(name: string);
  62526. /**
  62527. * Gets the current class name
  62528. * @returns the class name
  62529. */
  62530. getClassName(): string;
  62531. /**
  62532. * Gets the value operand input component
  62533. */
  62534. get value(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the first edge operand input component
  62537. */
  62538. get edge0(): NodeMaterialConnectionPoint;
  62539. /**
  62540. * Gets the second edge operand input component
  62541. */
  62542. get edge1(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the output component
  62545. */
  62546. get output(): NodeMaterialConnectionPoint;
  62547. protected _buildBlock(state: NodeMaterialBuildState): this;
  62548. }
  62549. }
  62550. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62554. /**
  62555. * Block used to get the reciprocal (1 / x) of a value
  62556. */
  62557. export class ReciprocalBlock extends NodeMaterialBlock {
  62558. /**
  62559. * Creates a new ReciprocalBlock
  62560. * @param name defines the block name
  62561. */
  62562. constructor(name: string);
  62563. /**
  62564. * Gets the current class name
  62565. * @returns the class name
  62566. */
  62567. getClassName(): string;
  62568. /**
  62569. * Gets the input component
  62570. */
  62571. get input(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the output component
  62574. */
  62575. get output(): NodeMaterialConnectionPoint;
  62576. protected _buildBlock(state: NodeMaterialBuildState): this;
  62577. }
  62578. }
  62579. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62583. /**
  62584. * Block used to replace a color by another one
  62585. */
  62586. export class ReplaceColorBlock extends NodeMaterialBlock {
  62587. /**
  62588. * Creates a new ReplaceColorBlock
  62589. * @param name defines the block name
  62590. */
  62591. constructor(name: string);
  62592. /**
  62593. * Gets the current class name
  62594. * @returns the class name
  62595. */
  62596. getClassName(): string;
  62597. /**
  62598. * Gets the value input component
  62599. */
  62600. get value(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the reference input component
  62603. */
  62604. get reference(): NodeMaterialConnectionPoint;
  62605. /**
  62606. * Gets the distance input component
  62607. */
  62608. get distance(): NodeMaterialConnectionPoint;
  62609. /**
  62610. * Gets the replacement input component
  62611. */
  62612. get replacement(): NodeMaterialConnectionPoint;
  62613. /**
  62614. * Gets the output component
  62615. */
  62616. get output(): NodeMaterialConnectionPoint;
  62617. protected _buildBlock(state: NodeMaterialBuildState): this;
  62618. }
  62619. }
  62620. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62624. /**
  62625. * Block used to posterize a value
  62626. * @see https://en.wikipedia.org/wiki/Posterization
  62627. */
  62628. export class PosterizeBlock extends NodeMaterialBlock {
  62629. /**
  62630. * Creates a new PosterizeBlock
  62631. * @param name defines the block name
  62632. */
  62633. constructor(name: string);
  62634. /**
  62635. * Gets the current class name
  62636. * @returns the class name
  62637. */
  62638. getClassName(): string;
  62639. /**
  62640. * Gets the value input component
  62641. */
  62642. get value(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the steps input component
  62645. */
  62646. get steps(): NodeMaterialConnectionPoint;
  62647. /**
  62648. * Gets the output component
  62649. */
  62650. get output(): NodeMaterialConnectionPoint;
  62651. protected _buildBlock(state: NodeMaterialBuildState): this;
  62652. }
  62653. }
  62654. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62658. import { Scene } from "babylonjs/scene";
  62659. /**
  62660. * Operations supported by the Wave block
  62661. */
  62662. export enum WaveBlockKind {
  62663. /** SawTooth */
  62664. SawTooth = 0,
  62665. /** Square */
  62666. Square = 1,
  62667. /** Triangle */
  62668. Triangle = 2
  62669. }
  62670. /**
  62671. * Block used to apply wave operation to floats
  62672. */
  62673. export class WaveBlock extends NodeMaterialBlock {
  62674. /**
  62675. * Gets or sets the kibnd of wave to be applied by the block
  62676. */
  62677. kind: WaveBlockKind;
  62678. /**
  62679. * Creates a new WaveBlock
  62680. * @param name defines the block name
  62681. */
  62682. constructor(name: string);
  62683. /**
  62684. * Gets the current class name
  62685. * @returns the class name
  62686. */
  62687. getClassName(): string;
  62688. /**
  62689. * Gets the input component
  62690. */
  62691. get input(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the output component
  62694. */
  62695. get output(): NodeMaterialConnectionPoint;
  62696. protected _buildBlock(state: NodeMaterialBuildState): this;
  62697. serialize(): any;
  62698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62699. }
  62700. }
  62701. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62705. import { Color3 } from "babylonjs/Maths/math.color";
  62706. import { Scene } from "babylonjs/scene";
  62707. /**
  62708. * Class used to store a color step for the GradientBlock
  62709. */
  62710. export class GradientBlockColorStep {
  62711. /**
  62712. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62713. */
  62714. step: number;
  62715. /**
  62716. * Gets or sets the color associated with this step
  62717. */
  62718. color: Color3;
  62719. /**
  62720. * Creates a new GradientBlockColorStep
  62721. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62722. * @param color defines the color associated with this step
  62723. */
  62724. constructor(
  62725. /**
  62726. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62727. */
  62728. step: number,
  62729. /**
  62730. * Gets or sets the color associated with this step
  62731. */
  62732. color: Color3);
  62733. }
  62734. /**
  62735. * Block used to return a color from a gradient based on an input value between 0 and 1
  62736. */
  62737. export class GradientBlock extends NodeMaterialBlock {
  62738. /**
  62739. * Gets or sets the list of color steps
  62740. */
  62741. colorSteps: GradientBlockColorStep[];
  62742. /**
  62743. * Creates a new GradientBlock
  62744. * @param name defines the block name
  62745. */
  62746. constructor(name: string);
  62747. /**
  62748. * Gets the current class name
  62749. * @returns the class name
  62750. */
  62751. getClassName(): string;
  62752. /**
  62753. * Gets the gradient input component
  62754. */
  62755. get gradient(): NodeMaterialConnectionPoint;
  62756. /**
  62757. * Gets the output component
  62758. */
  62759. get output(): NodeMaterialConnectionPoint;
  62760. private _writeColorConstant;
  62761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62762. serialize(): any;
  62763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62764. protected _dumpPropertiesCode(): string;
  62765. }
  62766. }
  62767. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62771. /**
  62772. * Block used to normalize lerp between 2 values
  62773. */
  62774. export class NLerpBlock extends NodeMaterialBlock {
  62775. /**
  62776. * Creates a new NLerpBlock
  62777. * @param name defines the block name
  62778. */
  62779. constructor(name: string);
  62780. /**
  62781. * Gets the current class name
  62782. * @returns the class name
  62783. */
  62784. getClassName(): string;
  62785. /**
  62786. * Gets the left operand input component
  62787. */
  62788. get left(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the right operand input component
  62791. */
  62792. get right(): NodeMaterialConnectionPoint;
  62793. /**
  62794. * Gets the gradient operand input component
  62795. */
  62796. get gradient(): NodeMaterialConnectionPoint;
  62797. /**
  62798. * Gets the output component
  62799. */
  62800. get output(): NodeMaterialConnectionPoint;
  62801. protected _buildBlock(state: NodeMaterialBuildState): this;
  62802. }
  62803. }
  62804. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62808. import { Scene } from "babylonjs/scene";
  62809. /**
  62810. * block used to Generate a Worley Noise 3D Noise Pattern
  62811. */
  62812. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62813. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62814. manhattanDistance: boolean;
  62815. /**
  62816. * Creates a new WorleyNoise3DBlock
  62817. * @param name defines the block name
  62818. */
  62819. constructor(name: string);
  62820. /**
  62821. * Gets the current class name
  62822. * @returns the class name
  62823. */
  62824. getClassName(): string;
  62825. /**
  62826. * Gets the seed input component
  62827. */
  62828. get seed(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the jitter input component
  62831. */
  62832. get jitter(): NodeMaterialConnectionPoint;
  62833. /**
  62834. * Gets the output component
  62835. */
  62836. get output(): NodeMaterialConnectionPoint;
  62837. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62838. /**
  62839. * Exposes the properties to the UI?
  62840. */
  62841. protected _dumpPropertiesCode(): string;
  62842. /**
  62843. * Exposes the properties to the Seralize?
  62844. */
  62845. serialize(): any;
  62846. /**
  62847. * Exposes the properties to the deseralize?
  62848. */
  62849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62850. }
  62851. }
  62852. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62856. /**
  62857. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62858. */
  62859. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62860. /**
  62861. * Creates a new SimplexPerlin3DBlock
  62862. * @param name defines the block name
  62863. */
  62864. constructor(name: string);
  62865. /**
  62866. * Gets the current class name
  62867. * @returns the class name
  62868. */
  62869. getClassName(): string;
  62870. /**
  62871. * Gets the seed operand input component
  62872. */
  62873. get seed(): NodeMaterialConnectionPoint;
  62874. /**
  62875. * Gets the output component
  62876. */
  62877. get output(): NodeMaterialConnectionPoint;
  62878. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62879. }
  62880. }
  62881. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62885. /**
  62886. * Block used to blend normals
  62887. */
  62888. export class NormalBlendBlock extends NodeMaterialBlock {
  62889. /**
  62890. * Creates a new NormalBlendBlock
  62891. * @param name defines the block name
  62892. */
  62893. constructor(name: string);
  62894. /**
  62895. * Gets the current class name
  62896. * @returns the class name
  62897. */
  62898. getClassName(): string;
  62899. /**
  62900. * Gets the first input component
  62901. */
  62902. get normalMap0(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the second input component
  62905. */
  62906. get normalMap1(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the output component
  62909. */
  62910. get output(): NodeMaterialConnectionPoint;
  62911. protected _buildBlock(state: NodeMaterialBuildState): this;
  62912. }
  62913. }
  62914. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62918. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62919. /**
  62920. * Block used to rotate a 2d vector by a given angle
  62921. */
  62922. export class Rotate2dBlock extends NodeMaterialBlock {
  62923. /**
  62924. * Creates a new Rotate2dBlock
  62925. * @param name defines the block name
  62926. */
  62927. constructor(name: string);
  62928. /**
  62929. * Gets the current class name
  62930. * @returns the class name
  62931. */
  62932. getClassName(): string;
  62933. /**
  62934. * Gets the input vector
  62935. */
  62936. get input(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the input angle
  62939. */
  62940. get angle(): NodeMaterialConnectionPoint;
  62941. /**
  62942. * Gets the output component
  62943. */
  62944. get output(): NodeMaterialConnectionPoint;
  62945. autoConfigure(material: NodeMaterial): void;
  62946. protected _buildBlock(state: NodeMaterialBuildState): this;
  62947. }
  62948. }
  62949. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62953. /**
  62954. * Block used to get the reflected vector from a direction and a normal
  62955. */
  62956. export class ReflectBlock extends NodeMaterialBlock {
  62957. /**
  62958. * Creates a new ReflectBlock
  62959. * @param name defines the block name
  62960. */
  62961. constructor(name: string);
  62962. /**
  62963. * Gets the current class name
  62964. * @returns the class name
  62965. */
  62966. getClassName(): string;
  62967. /**
  62968. * Gets the incident component
  62969. */
  62970. get incident(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the normal component
  62973. */
  62974. get normal(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the output component
  62977. */
  62978. get output(): NodeMaterialConnectionPoint;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62986. /**
  62987. * Block used to get the refracted vector from a direction and a normal
  62988. */
  62989. export class RefractBlock extends NodeMaterialBlock {
  62990. /**
  62991. * Creates a new RefractBlock
  62992. * @param name defines the block name
  62993. */
  62994. constructor(name: string);
  62995. /**
  62996. * Gets the current class name
  62997. * @returns the class name
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * Gets the incident component
  63002. */
  63003. get incident(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the normal component
  63006. */
  63007. get normal(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the index of refraction component
  63010. */
  63011. get ior(): NodeMaterialConnectionPoint;
  63012. /**
  63013. * Gets the output component
  63014. */
  63015. get output(): NodeMaterialConnectionPoint;
  63016. protected _buildBlock(state: NodeMaterialBuildState): this;
  63017. }
  63018. }
  63019. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63023. /**
  63024. * Block used to desaturate a color
  63025. */
  63026. export class DesaturateBlock extends NodeMaterialBlock {
  63027. /**
  63028. * Creates a new DesaturateBlock
  63029. * @param name defines the block name
  63030. */
  63031. constructor(name: string);
  63032. /**
  63033. * Gets the current class name
  63034. * @returns the class name
  63035. */
  63036. getClassName(): string;
  63037. /**
  63038. * Gets the color operand input component
  63039. */
  63040. get color(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the level operand input component
  63043. */
  63044. get level(): NodeMaterialConnectionPoint;
  63045. /**
  63046. * Gets the output component
  63047. */
  63048. get output(): NodeMaterialConnectionPoint;
  63049. protected _buildBlock(state: NodeMaterialBuildState): this;
  63050. }
  63051. }
  63052. declare module "babylonjs/Materials/Node/Blocks/index" {
  63053. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63054. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63055. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63056. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63057. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63086. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63097. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63098. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63099. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63100. }
  63101. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63102. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63103. }
  63104. declare module "babylonjs/Materials/Node/index" {
  63105. export * from "babylonjs/Materials/Node/Enums/index";
  63106. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63107. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63108. export * from "babylonjs/Materials/Node/nodeMaterial";
  63109. export * from "babylonjs/Materials/Node/Blocks/index";
  63110. export * from "babylonjs/Materials/Node/Optimizers/index";
  63111. }
  63112. declare module "babylonjs/Materials/effectRenderer" {
  63113. import { Nullable } from "babylonjs/types";
  63114. import { Texture } from "babylonjs/Materials/Textures/texture";
  63115. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63116. import { Viewport } from "babylonjs/Maths/math.viewport";
  63117. import { Observable } from "babylonjs/Misc/observable";
  63118. import { Effect } from "babylonjs/Materials/effect";
  63119. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63120. import "babylonjs/Shaders/postprocess.vertex";
  63121. /**
  63122. * Effect Render Options
  63123. */
  63124. export interface IEffectRendererOptions {
  63125. /**
  63126. * Defines the vertices positions.
  63127. */
  63128. positions?: number[];
  63129. /**
  63130. * Defines the indices.
  63131. */
  63132. indices?: number[];
  63133. }
  63134. /**
  63135. * Helper class to render one or more effects
  63136. */
  63137. export class EffectRenderer {
  63138. private engine;
  63139. private static _DefaultOptions;
  63140. private _vertexBuffers;
  63141. private _indexBuffer;
  63142. private _ringBufferIndex;
  63143. private _ringScreenBuffer;
  63144. private _fullscreenViewport;
  63145. private _getNextFrameBuffer;
  63146. /**
  63147. * Creates an effect renderer
  63148. * @param engine the engine to use for rendering
  63149. * @param options defines the options of the effect renderer
  63150. */
  63151. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63152. /**
  63153. * Sets the current viewport in normalized coordinates 0-1
  63154. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63155. */
  63156. setViewport(viewport?: Viewport): void;
  63157. /**
  63158. * Binds the embedded attributes buffer to the effect.
  63159. * @param effect Defines the effect to bind the attributes for
  63160. */
  63161. bindBuffers(effect: Effect): void;
  63162. /**
  63163. * Sets the current effect wrapper to use during draw.
  63164. * The effect needs to be ready before calling this api.
  63165. * This also sets the default full screen position attribute.
  63166. * @param effectWrapper Defines the effect to draw with
  63167. */
  63168. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63169. /**
  63170. * Draws a full screen quad.
  63171. */
  63172. draw(): void;
  63173. /**
  63174. * renders one or more effects to a specified texture
  63175. * @param effectWrappers list of effects to renderer
  63176. * @param outputTexture texture to draw to, if null it will render to the screen
  63177. */
  63178. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63179. /**
  63180. * Disposes of the effect renderer
  63181. */
  63182. dispose(): void;
  63183. }
  63184. /**
  63185. * Options to create an EffectWrapper
  63186. */
  63187. interface EffectWrapperCreationOptions {
  63188. /**
  63189. * Engine to use to create the effect
  63190. */
  63191. engine: ThinEngine;
  63192. /**
  63193. * Fragment shader for the effect
  63194. */
  63195. fragmentShader: string;
  63196. /**
  63197. * Vertex shader for the effect
  63198. */
  63199. vertexShader?: string;
  63200. /**
  63201. * Attributes to use in the shader
  63202. */
  63203. attributeNames?: Array<string>;
  63204. /**
  63205. * Uniforms to use in the shader
  63206. */
  63207. uniformNames?: Array<string>;
  63208. /**
  63209. * Texture sampler names to use in the shader
  63210. */
  63211. samplerNames?: Array<string>;
  63212. /**
  63213. * The friendly name of the effect displayed in Spector.
  63214. */
  63215. name?: string;
  63216. }
  63217. /**
  63218. * Wraps an effect to be used for rendering
  63219. */
  63220. export class EffectWrapper {
  63221. /**
  63222. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63223. */
  63224. onApplyObservable: Observable<{}>;
  63225. /**
  63226. * The underlying effect
  63227. */
  63228. effect: Effect;
  63229. /**
  63230. * Creates an effect to be renderer
  63231. * @param creationOptions options to create the effect
  63232. */
  63233. constructor(creationOptions: EffectWrapperCreationOptions);
  63234. /**
  63235. * Disposes of the effect wrapper
  63236. */
  63237. dispose(): void;
  63238. }
  63239. }
  63240. declare module "babylonjs/Materials/index" {
  63241. export * from "babylonjs/Materials/Background/index";
  63242. export * from "babylonjs/Materials/colorCurves";
  63243. export * from "babylonjs/Materials/iEffectFallbacks";
  63244. export * from "babylonjs/Materials/effectFallbacks";
  63245. export * from "babylonjs/Materials/effect";
  63246. export * from "babylonjs/Materials/fresnelParameters";
  63247. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63248. export * from "babylonjs/Materials/material";
  63249. export * from "babylonjs/Materials/materialDefines";
  63250. export * from "babylonjs/Materials/materialHelper";
  63251. export * from "babylonjs/Materials/multiMaterial";
  63252. export * from "babylonjs/Materials/PBR/index";
  63253. export * from "babylonjs/Materials/pushMaterial";
  63254. export * from "babylonjs/Materials/shaderMaterial";
  63255. export * from "babylonjs/Materials/standardMaterial";
  63256. export * from "babylonjs/Materials/Textures/index";
  63257. export * from "babylonjs/Materials/uniformBuffer";
  63258. export * from "babylonjs/Materials/materialFlags";
  63259. export * from "babylonjs/Materials/Node/index";
  63260. export * from "babylonjs/Materials/effectRenderer";
  63261. }
  63262. declare module "babylonjs/Maths/index" {
  63263. export * from "babylonjs/Maths/math.scalar";
  63264. export * from "babylonjs/Maths/math";
  63265. export * from "babylonjs/Maths/sphericalPolynomial";
  63266. }
  63267. declare module "babylonjs/Misc/workerPool" {
  63268. import { IDisposable } from "babylonjs/scene";
  63269. /**
  63270. * Helper class to push actions to a pool of workers.
  63271. */
  63272. export class WorkerPool implements IDisposable {
  63273. private _workerInfos;
  63274. private _pendingActions;
  63275. /**
  63276. * Constructor
  63277. * @param workers Array of workers to use for actions
  63278. */
  63279. constructor(workers: Array<Worker>);
  63280. /**
  63281. * Terminates all workers and clears any pending actions.
  63282. */
  63283. dispose(): void;
  63284. /**
  63285. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63286. * pended until a worker has completed its action.
  63287. * @param action The action to perform. Call onComplete when the action is complete.
  63288. */
  63289. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63290. private _execute;
  63291. }
  63292. }
  63293. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63294. import { IDisposable } from "babylonjs/scene";
  63295. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63296. /**
  63297. * Configuration for Draco compression
  63298. */
  63299. export interface IDracoCompressionConfiguration {
  63300. /**
  63301. * Configuration for the decoder.
  63302. */
  63303. decoder: {
  63304. /**
  63305. * The url to the WebAssembly module.
  63306. */
  63307. wasmUrl?: string;
  63308. /**
  63309. * The url to the WebAssembly binary.
  63310. */
  63311. wasmBinaryUrl?: string;
  63312. /**
  63313. * The url to the fallback JavaScript module.
  63314. */
  63315. fallbackUrl?: string;
  63316. };
  63317. }
  63318. /**
  63319. * Draco compression (https://google.github.io/draco/)
  63320. *
  63321. * This class wraps the Draco module.
  63322. *
  63323. * **Encoder**
  63324. *
  63325. * The encoder is not currently implemented.
  63326. *
  63327. * **Decoder**
  63328. *
  63329. * 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.
  63330. *
  63331. * To update the configuration, use the following code:
  63332. * ```javascript
  63333. * DracoCompression.Configuration = {
  63334. * decoder: {
  63335. * wasmUrl: "<url to the WebAssembly library>",
  63336. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63337. * fallbackUrl: "<url to the fallback JavaScript library>",
  63338. * }
  63339. * };
  63340. * ```
  63341. *
  63342. * 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.
  63343. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63344. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63345. *
  63346. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63347. * ```javascript
  63348. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63349. * ```
  63350. *
  63351. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63352. */
  63353. export class DracoCompression implements IDisposable {
  63354. private _workerPoolPromise?;
  63355. private _decoderModulePromise?;
  63356. /**
  63357. * The configuration. Defaults to the following urls:
  63358. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63359. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63360. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63361. */
  63362. static Configuration: IDracoCompressionConfiguration;
  63363. /**
  63364. * Returns true if the decoder configuration is available.
  63365. */
  63366. static get DecoderAvailable(): boolean;
  63367. /**
  63368. * Default number of workers to create when creating the draco compression object.
  63369. */
  63370. static DefaultNumWorkers: number;
  63371. private static GetDefaultNumWorkers;
  63372. private static _Default;
  63373. /**
  63374. * Default instance for the draco compression object.
  63375. */
  63376. static get Default(): DracoCompression;
  63377. /**
  63378. * Constructor
  63379. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63380. */
  63381. constructor(numWorkers?: number);
  63382. /**
  63383. * Stop all async operations and release resources.
  63384. */
  63385. dispose(): void;
  63386. /**
  63387. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63388. * @returns a promise that resolves when ready
  63389. */
  63390. whenReadyAsync(): Promise<void>;
  63391. /**
  63392. * Decode Draco compressed mesh data to vertex data.
  63393. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63394. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63395. * @returns A promise that resolves with the decoded vertex data
  63396. */
  63397. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63398. [kind: string]: number;
  63399. }): Promise<VertexData>;
  63400. }
  63401. }
  63402. declare module "babylonjs/Meshes/Compression/index" {
  63403. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63404. }
  63405. declare module "babylonjs/Meshes/csg" {
  63406. import { Nullable } from "babylonjs/types";
  63407. import { Scene } from "babylonjs/scene";
  63408. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63409. import { Mesh } from "babylonjs/Meshes/mesh";
  63410. import { Material } from "babylonjs/Materials/material";
  63411. /**
  63412. * Class for building Constructive Solid Geometry
  63413. */
  63414. export class CSG {
  63415. private polygons;
  63416. /**
  63417. * The world matrix
  63418. */
  63419. matrix: Matrix;
  63420. /**
  63421. * Stores the position
  63422. */
  63423. position: Vector3;
  63424. /**
  63425. * Stores the rotation
  63426. */
  63427. rotation: Vector3;
  63428. /**
  63429. * Stores the rotation quaternion
  63430. */
  63431. rotationQuaternion: Nullable<Quaternion>;
  63432. /**
  63433. * Stores the scaling vector
  63434. */
  63435. scaling: Vector3;
  63436. /**
  63437. * Convert the Mesh to CSG
  63438. * @param mesh The Mesh to convert to CSG
  63439. * @returns A new CSG from the Mesh
  63440. */
  63441. static FromMesh(mesh: Mesh): CSG;
  63442. /**
  63443. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63444. * @param polygons Polygons used to construct a CSG solid
  63445. */
  63446. private static FromPolygons;
  63447. /**
  63448. * Clones, or makes a deep copy, of the CSG
  63449. * @returns A new CSG
  63450. */
  63451. clone(): CSG;
  63452. /**
  63453. * Unions this CSG with another CSG
  63454. * @param csg The CSG to union against this CSG
  63455. * @returns The unioned CSG
  63456. */
  63457. union(csg: CSG): CSG;
  63458. /**
  63459. * Unions this CSG with another CSG in place
  63460. * @param csg The CSG to union against this CSG
  63461. */
  63462. unionInPlace(csg: CSG): void;
  63463. /**
  63464. * Subtracts this CSG with another CSG
  63465. * @param csg The CSG to subtract against this CSG
  63466. * @returns A new CSG
  63467. */
  63468. subtract(csg: CSG): CSG;
  63469. /**
  63470. * Subtracts this CSG with another CSG in place
  63471. * @param csg The CSG to subtact against this CSG
  63472. */
  63473. subtractInPlace(csg: CSG): void;
  63474. /**
  63475. * Intersect this CSG with another CSG
  63476. * @param csg The CSG to intersect against this CSG
  63477. * @returns A new CSG
  63478. */
  63479. intersect(csg: CSG): CSG;
  63480. /**
  63481. * Intersects this CSG with another CSG in place
  63482. * @param csg The CSG to intersect against this CSG
  63483. */
  63484. intersectInPlace(csg: CSG): void;
  63485. /**
  63486. * Return a new CSG solid with solid and empty space switched. This solid is
  63487. * not modified.
  63488. * @returns A new CSG solid with solid and empty space switched
  63489. */
  63490. inverse(): CSG;
  63491. /**
  63492. * Inverses the CSG in place
  63493. */
  63494. inverseInPlace(): void;
  63495. /**
  63496. * This is used to keep meshes transformations so they can be restored
  63497. * when we build back a Babylon Mesh
  63498. * NB : All CSG operations are performed in world coordinates
  63499. * @param csg The CSG to copy the transform attributes from
  63500. * @returns This CSG
  63501. */
  63502. copyTransformAttributes(csg: CSG): CSG;
  63503. /**
  63504. * Build Raw mesh from CSG
  63505. * Coordinates here are in world space
  63506. * @param name The name of the mesh geometry
  63507. * @param scene The Scene
  63508. * @param keepSubMeshes Specifies if the submeshes should be kept
  63509. * @returns A new Mesh
  63510. */
  63511. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63512. /**
  63513. * Build Mesh from CSG taking material and transforms into account
  63514. * @param name The name of the Mesh
  63515. * @param material The material of the Mesh
  63516. * @param scene The Scene
  63517. * @param keepSubMeshes Specifies if submeshes should be kept
  63518. * @returns The new Mesh
  63519. */
  63520. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63521. }
  63522. }
  63523. declare module "babylonjs/Meshes/trailMesh" {
  63524. import { Mesh } from "babylonjs/Meshes/mesh";
  63525. import { Scene } from "babylonjs/scene";
  63526. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63527. /**
  63528. * Class used to create a trail following a mesh
  63529. */
  63530. export class TrailMesh extends Mesh {
  63531. private _generator;
  63532. private _autoStart;
  63533. private _running;
  63534. private _diameter;
  63535. private _length;
  63536. private _sectionPolygonPointsCount;
  63537. private _sectionVectors;
  63538. private _sectionNormalVectors;
  63539. private _beforeRenderObserver;
  63540. /**
  63541. * @constructor
  63542. * @param name The value used by scene.getMeshByName() to do a lookup.
  63543. * @param generator The mesh or transform node to generate a trail.
  63544. * @param scene The scene to add this mesh to.
  63545. * @param diameter Diameter of trailing mesh. Default is 1.
  63546. * @param length Length of trailing mesh. Default is 60.
  63547. * @param autoStart Automatically start trailing mesh. Default true.
  63548. */
  63549. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63550. /**
  63551. * "TrailMesh"
  63552. * @returns "TrailMesh"
  63553. */
  63554. getClassName(): string;
  63555. private _createMesh;
  63556. /**
  63557. * Start trailing mesh.
  63558. */
  63559. start(): void;
  63560. /**
  63561. * Stop trailing mesh.
  63562. */
  63563. stop(): void;
  63564. /**
  63565. * Update trailing mesh geometry.
  63566. */
  63567. update(): void;
  63568. /**
  63569. * Returns a new TrailMesh object.
  63570. * @param name is a string, the name given to the new mesh
  63571. * @param newGenerator use new generator object for cloned trail mesh
  63572. * @returns a new mesh
  63573. */
  63574. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63575. /**
  63576. * Serializes this trail mesh
  63577. * @param serializationObject object to write serialization to
  63578. */
  63579. serialize(serializationObject: any): void;
  63580. /**
  63581. * Parses a serialized trail mesh
  63582. * @param parsedMesh the serialized mesh
  63583. * @param scene the scene to create the trail mesh in
  63584. * @returns the created trail mesh
  63585. */
  63586. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63587. }
  63588. }
  63589. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63590. import { Nullable } from "babylonjs/types";
  63591. import { Scene } from "babylonjs/scene";
  63592. import { Vector4 } from "babylonjs/Maths/math.vector";
  63593. import { Color4 } from "babylonjs/Maths/math.color";
  63594. import { Mesh } from "babylonjs/Meshes/mesh";
  63595. /**
  63596. * Class containing static functions to help procedurally build meshes
  63597. */
  63598. export class TiledBoxBuilder {
  63599. /**
  63600. * Creates a box mesh
  63601. * 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)
  63602. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63606. * @param name defines the name of the mesh
  63607. * @param options defines the options used to create the mesh
  63608. * @param scene defines the hosting scene
  63609. * @returns the box mesh
  63610. */
  63611. static CreateTiledBox(name: string, options: {
  63612. pattern?: number;
  63613. width?: number;
  63614. height?: number;
  63615. depth?: number;
  63616. tileSize?: number;
  63617. tileWidth?: number;
  63618. tileHeight?: number;
  63619. alignHorizontal?: number;
  63620. alignVertical?: number;
  63621. faceUV?: Vector4[];
  63622. faceColors?: Color4[];
  63623. sideOrientation?: number;
  63624. updatable?: boolean;
  63625. }, scene?: Nullable<Scene>): Mesh;
  63626. }
  63627. }
  63628. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63629. import { Vector4 } from "babylonjs/Maths/math.vector";
  63630. import { Mesh } from "babylonjs/Meshes/mesh";
  63631. /**
  63632. * Class containing static functions to help procedurally build meshes
  63633. */
  63634. export class TorusKnotBuilder {
  63635. /**
  63636. * Creates a torus knot mesh
  63637. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63638. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63639. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63640. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63644. * @param name defines the name of the mesh
  63645. * @param options defines the options used to create the mesh
  63646. * @param scene defines the hosting scene
  63647. * @returns the torus knot mesh
  63648. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63649. */
  63650. static CreateTorusKnot(name: string, options: {
  63651. radius?: number;
  63652. tube?: number;
  63653. radialSegments?: number;
  63654. tubularSegments?: number;
  63655. p?: number;
  63656. q?: number;
  63657. updatable?: boolean;
  63658. sideOrientation?: number;
  63659. frontUVs?: Vector4;
  63660. backUVs?: Vector4;
  63661. }, scene: any): Mesh;
  63662. }
  63663. }
  63664. declare module "babylonjs/Meshes/polygonMesh" {
  63665. import { Scene } from "babylonjs/scene";
  63666. import { Vector2 } from "babylonjs/Maths/math.vector";
  63667. import { Mesh } from "babylonjs/Meshes/mesh";
  63668. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63669. import { Path2 } from "babylonjs/Maths/math.path";
  63670. /**
  63671. * Polygon
  63672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63673. */
  63674. export class Polygon {
  63675. /**
  63676. * Creates a rectangle
  63677. * @param xmin bottom X coord
  63678. * @param ymin bottom Y coord
  63679. * @param xmax top X coord
  63680. * @param ymax top Y coord
  63681. * @returns points that make the resulting rectation
  63682. */
  63683. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63684. /**
  63685. * Creates a circle
  63686. * @param radius radius of circle
  63687. * @param cx scale in x
  63688. * @param cy scale in y
  63689. * @param numberOfSides number of sides that make up the circle
  63690. * @returns points that make the resulting circle
  63691. */
  63692. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63693. /**
  63694. * Creates a polygon from input string
  63695. * @param input Input polygon data
  63696. * @returns the parsed points
  63697. */
  63698. static Parse(input: string): Vector2[];
  63699. /**
  63700. * Starts building a polygon from x and y coordinates
  63701. * @param x x coordinate
  63702. * @param y y coordinate
  63703. * @returns the started path2
  63704. */
  63705. static StartingAt(x: number, y: number): Path2;
  63706. }
  63707. /**
  63708. * Builds a polygon
  63709. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63710. */
  63711. export class PolygonMeshBuilder {
  63712. private _points;
  63713. private _outlinepoints;
  63714. private _holes;
  63715. private _name;
  63716. private _scene;
  63717. private _epoints;
  63718. private _eholes;
  63719. private _addToepoint;
  63720. /**
  63721. * Babylon reference to the earcut plugin.
  63722. */
  63723. bjsEarcut: any;
  63724. /**
  63725. * Creates a PolygonMeshBuilder
  63726. * @param name name of the builder
  63727. * @param contours Path of the polygon
  63728. * @param scene scene to add to when creating the mesh
  63729. * @param earcutInjection can be used to inject your own earcut reference
  63730. */
  63731. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63732. /**
  63733. * Adds a whole within the polygon
  63734. * @param hole Array of points defining the hole
  63735. * @returns this
  63736. */
  63737. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63738. /**
  63739. * Creates the polygon
  63740. * @param updatable If the mesh should be updatable
  63741. * @param depth The depth of the mesh created
  63742. * @returns the created mesh
  63743. */
  63744. build(updatable?: boolean, depth?: number): Mesh;
  63745. /**
  63746. * Creates the polygon
  63747. * @param depth The depth of the mesh created
  63748. * @returns the created VertexData
  63749. */
  63750. buildVertexData(depth?: number): VertexData;
  63751. /**
  63752. * Adds a side to the polygon
  63753. * @param positions points that make the polygon
  63754. * @param normals normals of the polygon
  63755. * @param uvs uvs of the polygon
  63756. * @param indices indices of the polygon
  63757. * @param bounds bounds of the polygon
  63758. * @param points points of the polygon
  63759. * @param depth depth of the polygon
  63760. * @param flip flip of the polygon
  63761. */
  63762. private addSide;
  63763. }
  63764. }
  63765. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63766. import { Scene } from "babylonjs/scene";
  63767. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63768. import { Color4 } from "babylonjs/Maths/math.color";
  63769. import { Mesh } from "babylonjs/Meshes/mesh";
  63770. import { Nullable } from "babylonjs/types";
  63771. /**
  63772. * Class containing static functions to help procedurally build meshes
  63773. */
  63774. export class PolygonBuilder {
  63775. /**
  63776. * Creates a polygon mesh
  63777. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63778. * * 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
  63779. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63782. * * Remember you can only change the shape positions, not their number when updating a polygon
  63783. * @param name defines the name of the mesh
  63784. * @param options defines the options used to create the mesh
  63785. * @param scene defines the hosting scene
  63786. * @param earcutInjection can be used to inject your own earcut reference
  63787. * @returns the polygon mesh
  63788. */
  63789. static CreatePolygon(name: string, options: {
  63790. shape: Vector3[];
  63791. holes?: Vector3[][];
  63792. depth?: number;
  63793. faceUV?: Vector4[];
  63794. faceColors?: Color4[];
  63795. updatable?: boolean;
  63796. sideOrientation?: number;
  63797. frontUVs?: Vector4;
  63798. backUVs?: Vector4;
  63799. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63800. /**
  63801. * Creates an extruded polygon mesh, with depth in the Y direction.
  63802. * * 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)
  63803. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63804. * @param name defines the name of the mesh
  63805. * @param options defines the options used to create the mesh
  63806. * @param scene defines the hosting scene
  63807. * @param earcutInjection can be used to inject your own earcut reference
  63808. * @returns the polygon mesh
  63809. */
  63810. static ExtrudePolygon(name: string, options: {
  63811. shape: Vector3[];
  63812. holes?: Vector3[][];
  63813. depth?: number;
  63814. faceUV?: Vector4[];
  63815. faceColors?: Color4[];
  63816. updatable?: boolean;
  63817. sideOrientation?: number;
  63818. frontUVs?: Vector4;
  63819. backUVs?: Vector4;
  63820. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63821. }
  63822. }
  63823. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63824. import { Scene } from "babylonjs/scene";
  63825. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63826. import { Mesh } from "babylonjs/Meshes/mesh";
  63827. import { Nullable } from "babylonjs/types";
  63828. /**
  63829. * Class containing static functions to help procedurally build meshes
  63830. */
  63831. export class LatheBuilder {
  63832. /**
  63833. * Creates lathe mesh.
  63834. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63835. * * 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
  63836. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63837. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63838. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63839. * * 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
  63840. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63841. * * 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
  63842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63846. * @param name defines the name of the mesh
  63847. * @param options defines the options used to create the mesh
  63848. * @param scene defines the hosting scene
  63849. * @returns the lathe mesh
  63850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63851. */
  63852. static CreateLathe(name: string, options: {
  63853. shape: Vector3[];
  63854. radius?: number;
  63855. tessellation?: number;
  63856. clip?: number;
  63857. arc?: number;
  63858. closed?: boolean;
  63859. updatable?: boolean;
  63860. sideOrientation?: number;
  63861. frontUVs?: Vector4;
  63862. backUVs?: Vector4;
  63863. cap?: number;
  63864. invertUV?: boolean;
  63865. }, scene?: Nullable<Scene>): Mesh;
  63866. }
  63867. }
  63868. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63869. import { Nullable } from "babylonjs/types";
  63870. import { Scene } from "babylonjs/scene";
  63871. import { Vector4 } from "babylonjs/Maths/math.vector";
  63872. import { Mesh } from "babylonjs/Meshes/mesh";
  63873. /**
  63874. * Class containing static functions to help procedurally build meshes
  63875. */
  63876. export class TiledPlaneBuilder {
  63877. /**
  63878. * Creates a tiled plane mesh
  63879. * * The parameter `pattern` will, depending on value, do nothing or
  63880. * * * flip (reflect about central vertical) alternate tiles across and up
  63881. * * * flip every tile on alternate rows
  63882. * * * rotate (180 degs) alternate tiles across and up
  63883. * * * rotate every tile on alternate rows
  63884. * * * flip and rotate alternate tiles across and up
  63885. * * * flip and rotate every tile on alternate rows
  63886. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63887. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63890. * * 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)
  63891. * * 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)
  63892. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63893. * @param name defines the name of the mesh
  63894. * @param options defines the options used to create the mesh
  63895. * @param scene defines the hosting scene
  63896. * @returns the box mesh
  63897. */
  63898. static CreateTiledPlane(name: string, options: {
  63899. pattern?: number;
  63900. tileSize?: number;
  63901. tileWidth?: number;
  63902. tileHeight?: number;
  63903. size?: number;
  63904. width?: number;
  63905. height?: number;
  63906. alignHorizontal?: number;
  63907. alignVertical?: number;
  63908. sideOrientation?: number;
  63909. frontUVs?: Vector4;
  63910. backUVs?: Vector4;
  63911. updatable?: boolean;
  63912. }, scene?: Nullable<Scene>): Mesh;
  63913. }
  63914. }
  63915. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63916. import { Nullable } from "babylonjs/types";
  63917. import { Scene } from "babylonjs/scene";
  63918. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63919. import { Mesh } from "babylonjs/Meshes/mesh";
  63920. /**
  63921. * Class containing static functions to help procedurally build meshes
  63922. */
  63923. export class TubeBuilder {
  63924. /**
  63925. * Creates a tube mesh.
  63926. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63927. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63928. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63929. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63930. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63931. * * 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)
  63932. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63933. * * 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
  63934. * * 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
  63935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63939. * @param name defines the name of the mesh
  63940. * @param options defines the options used to create the mesh
  63941. * @param scene defines the hosting scene
  63942. * @returns the tube mesh
  63943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63944. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63945. */
  63946. static CreateTube(name: string, options: {
  63947. path: Vector3[];
  63948. radius?: number;
  63949. tessellation?: number;
  63950. radiusFunction?: {
  63951. (i: number, distance: number): number;
  63952. };
  63953. cap?: number;
  63954. arc?: number;
  63955. updatable?: boolean;
  63956. sideOrientation?: number;
  63957. frontUVs?: Vector4;
  63958. backUVs?: Vector4;
  63959. instance?: Mesh;
  63960. invertUV?: boolean;
  63961. }, scene?: Nullable<Scene>): Mesh;
  63962. }
  63963. }
  63964. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63965. import { Scene } from "babylonjs/scene";
  63966. import { Vector4 } from "babylonjs/Maths/math.vector";
  63967. import { Mesh } from "babylonjs/Meshes/mesh";
  63968. import { Nullable } from "babylonjs/types";
  63969. /**
  63970. * Class containing static functions to help procedurally build meshes
  63971. */
  63972. export class IcoSphereBuilder {
  63973. /**
  63974. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63975. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63976. * * 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`)
  63977. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63978. * * 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
  63979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63982. * @param name defines the name of the mesh
  63983. * @param options defines the options used to create the mesh
  63984. * @param scene defines the hosting scene
  63985. * @returns the icosahedron mesh
  63986. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63987. */
  63988. static CreateIcoSphere(name: string, options: {
  63989. radius?: number;
  63990. radiusX?: number;
  63991. radiusY?: number;
  63992. radiusZ?: number;
  63993. flat?: boolean;
  63994. subdivisions?: number;
  63995. sideOrientation?: number;
  63996. frontUVs?: Vector4;
  63997. backUVs?: Vector4;
  63998. updatable?: boolean;
  63999. }, scene?: Nullable<Scene>): Mesh;
  64000. }
  64001. }
  64002. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64003. import { Vector3 } from "babylonjs/Maths/math.vector";
  64004. import { Mesh } from "babylonjs/Meshes/mesh";
  64005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64006. /**
  64007. * Class containing static functions to help procedurally build meshes
  64008. */
  64009. export class DecalBuilder {
  64010. /**
  64011. * Creates a decal mesh.
  64012. * 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
  64013. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64014. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64015. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64016. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64017. * @param name defines the name of the mesh
  64018. * @param sourceMesh defines the mesh where the decal must be applied
  64019. * @param options defines the options used to create the mesh
  64020. * @param scene defines the hosting scene
  64021. * @returns the decal mesh
  64022. * @see https://doc.babylonjs.com/how_to/decals
  64023. */
  64024. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64025. position?: Vector3;
  64026. normal?: Vector3;
  64027. size?: Vector3;
  64028. angle?: number;
  64029. }): Mesh;
  64030. }
  64031. }
  64032. declare module "babylonjs/Meshes/meshBuilder" {
  64033. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64034. import { Nullable } from "babylonjs/types";
  64035. import { Scene } from "babylonjs/scene";
  64036. import { Mesh } from "babylonjs/Meshes/mesh";
  64037. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64038. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64040. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64041. import { Plane } from "babylonjs/Maths/math.plane";
  64042. /**
  64043. * Class containing static functions to help procedurally build meshes
  64044. */
  64045. export class MeshBuilder {
  64046. /**
  64047. * Creates a box mesh
  64048. * * The parameter `size` sets the size (float) of each box side (default 1)
  64049. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64050. * * 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)
  64051. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64055. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64056. * @param name defines the name of the mesh
  64057. * @param options defines the options used to create the mesh
  64058. * @param scene defines the hosting scene
  64059. * @returns the box mesh
  64060. */
  64061. static CreateBox(name: string, options: {
  64062. size?: number;
  64063. width?: number;
  64064. height?: number;
  64065. depth?: number;
  64066. faceUV?: Vector4[];
  64067. faceColors?: Color4[];
  64068. sideOrientation?: number;
  64069. frontUVs?: Vector4;
  64070. backUVs?: Vector4;
  64071. updatable?: boolean;
  64072. }, scene?: Nullable<Scene>): Mesh;
  64073. /**
  64074. * Creates a tiled box mesh
  64075. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64077. * @param name defines the name of the mesh
  64078. * @param options defines the options used to create the mesh
  64079. * @param scene defines the hosting scene
  64080. * @returns the tiled box mesh
  64081. */
  64082. static CreateTiledBox(name: string, options: {
  64083. pattern?: number;
  64084. size?: number;
  64085. width?: number;
  64086. height?: number;
  64087. depth: number;
  64088. tileSize?: number;
  64089. tileWidth?: number;
  64090. tileHeight?: number;
  64091. faceUV?: Vector4[];
  64092. faceColors?: Color4[];
  64093. alignHorizontal?: number;
  64094. alignVertical?: number;
  64095. sideOrientation?: number;
  64096. updatable?: boolean;
  64097. }, scene?: Nullable<Scene>): Mesh;
  64098. /**
  64099. * Creates a sphere mesh
  64100. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64101. * * 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`)
  64102. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64103. * * 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
  64104. * * 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)
  64105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64108. * @param name defines the name of the mesh
  64109. * @param options defines the options used to create the mesh
  64110. * @param scene defines the hosting scene
  64111. * @returns the sphere mesh
  64112. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64113. */
  64114. static CreateSphere(name: string, options: {
  64115. segments?: number;
  64116. diameter?: number;
  64117. diameterX?: number;
  64118. diameterY?: number;
  64119. diameterZ?: number;
  64120. arc?: number;
  64121. slice?: number;
  64122. sideOrientation?: number;
  64123. frontUVs?: Vector4;
  64124. backUVs?: Vector4;
  64125. updatable?: boolean;
  64126. }, scene?: Nullable<Scene>): Mesh;
  64127. /**
  64128. * Creates a plane polygonal mesh. By default, this is a disc
  64129. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64130. * * 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
  64131. * * 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
  64132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64135. * @param name defines the name of the mesh
  64136. * @param options defines the options used to create the mesh
  64137. * @param scene defines the hosting scene
  64138. * @returns the plane polygonal mesh
  64139. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64140. */
  64141. static CreateDisc(name: string, options: {
  64142. radius?: number;
  64143. tessellation?: number;
  64144. arc?: number;
  64145. updatable?: boolean;
  64146. sideOrientation?: number;
  64147. frontUVs?: Vector4;
  64148. backUVs?: Vector4;
  64149. }, scene?: Nullable<Scene>): Mesh;
  64150. /**
  64151. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64152. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64153. * * 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`)
  64154. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64155. * * 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
  64156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64159. * @param name defines the name of the mesh
  64160. * @param options defines the options used to create the mesh
  64161. * @param scene defines the hosting scene
  64162. * @returns the icosahedron mesh
  64163. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64164. */
  64165. static CreateIcoSphere(name: string, options: {
  64166. radius?: number;
  64167. radiusX?: number;
  64168. radiusY?: number;
  64169. radiusZ?: number;
  64170. flat?: boolean;
  64171. subdivisions?: number;
  64172. sideOrientation?: number;
  64173. frontUVs?: Vector4;
  64174. backUVs?: Vector4;
  64175. updatable?: boolean;
  64176. }, scene?: Nullable<Scene>): Mesh;
  64177. /**
  64178. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64179. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64180. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64181. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64182. * * 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
  64183. * * 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
  64184. * * 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
  64185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64188. * * 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
  64189. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64190. * * 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
  64191. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64193. * @param name defines the name of the mesh
  64194. * @param options defines the options used to create the mesh
  64195. * @param scene defines the hosting scene
  64196. * @returns the ribbon mesh
  64197. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64199. */
  64200. static CreateRibbon(name: string, options: {
  64201. pathArray: Vector3[][];
  64202. closeArray?: boolean;
  64203. closePath?: boolean;
  64204. offset?: number;
  64205. updatable?: boolean;
  64206. sideOrientation?: number;
  64207. frontUVs?: Vector4;
  64208. backUVs?: Vector4;
  64209. instance?: Mesh;
  64210. invertUV?: boolean;
  64211. uvs?: Vector2[];
  64212. colors?: Color4[];
  64213. }, scene?: Nullable<Scene>): Mesh;
  64214. /**
  64215. * Creates a cylinder or a cone mesh
  64216. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64217. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64218. * * 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.
  64219. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64220. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64221. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64222. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64223. * * 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).
  64224. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64225. * * 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).
  64226. * * 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
  64227. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64228. * * 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
  64229. * * 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.
  64230. * * If `enclose` is false, a ring surface is one element.
  64231. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64232. * * 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
  64233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64236. * @param name defines the name of the mesh
  64237. * @param options defines the options used to create the mesh
  64238. * @param scene defines the hosting scene
  64239. * @returns the cylinder mesh
  64240. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64241. */
  64242. static CreateCylinder(name: string, options: {
  64243. height?: number;
  64244. diameterTop?: number;
  64245. diameterBottom?: number;
  64246. diameter?: number;
  64247. tessellation?: number;
  64248. subdivisions?: number;
  64249. arc?: number;
  64250. faceColors?: Color4[];
  64251. faceUV?: Vector4[];
  64252. updatable?: boolean;
  64253. hasRings?: boolean;
  64254. enclose?: boolean;
  64255. cap?: number;
  64256. sideOrientation?: number;
  64257. frontUVs?: Vector4;
  64258. backUVs?: Vector4;
  64259. }, scene?: Nullable<Scene>): Mesh;
  64260. /**
  64261. * Creates a torus mesh
  64262. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64263. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64264. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64268. * @param name defines the name of the mesh
  64269. * @param options defines the options used to create the mesh
  64270. * @param scene defines the hosting scene
  64271. * @returns the torus mesh
  64272. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64273. */
  64274. static CreateTorus(name: string, options: {
  64275. diameter?: number;
  64276. thickness?: number;
  64277. tessellation?: number;
  64278. updatable?: boolean;
  64279. sideOrientation?: number;
  64280. frontUVs?: Vector4;
  64281. backUVs?: Vector4;
  64282. }, scene?: Nullable<Scene>): Mesh;
  64283. /**
  64284. * Creates a torus knot mesh
  64285. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64286. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64287. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64288. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64292. * @param name defines the name of the mesh
  64293. * @param options defines the options used to create the mesh
  64294. * @param scene defines the hosting scene
  64295. * @returns the torus knot mesh
  64296. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64297. */
  64298. static CreateTorusKnot(name: string, options: {
  64299. radius?: number;
  64300. tube?: number;
  64301. radialSegments?: number;
  64302. tubularSegments?: number;
  64303. p?: number;
  64304. q?: number;
  64305. updatable?: boolean;
  64306. sideOrientation?: number;
  64307. frontUVs?: Vector4;
  64308. backUVs?: Vector4;
  64309. }, scene?: Nullable<Scene>): Mesh;
  64310. /**
  64311. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64312. * * 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
  64313. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64314. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64315. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64316. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64317. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64318. * * 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
  64319. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64322. * @param name defines the name of the new line system
  64323. * @param options defines the options used to create the line system
  64324. * @param scene defines the hosting scene
  64325. * @returns a new line system mesh
  64326. */
  64327. static CreateLineSystem(name: string, options: {
  64328. lines: Vector3[][];
  64329. updatable?: boolean;
  64330. instance?: Nullable<LinesMesh>;
  64331. colors?: Nullable<Color4[][]>;
  64332. useVertexAlpha?: boolean;
  64333. }, scene: Nullable<Scene>): LinesMesh;
  64334. /**
  64335. * Creates a line mesh
  64336. * 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
  64337. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64338. * * The parameter `points` is an array successive Vector3
  64339. * * 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
  64340. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64341. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64342. * * When updating an instance, remember that only point positions can change, not the number of points
  64343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64345. * @param name defines the name of the new line system
  64346. * @param options defines the options used to create the line system
  64347. * @param scene defines the hosting scene
  64348. * @returns a new line mesh
  64349. */
  64350. static CreateLines(name: string, options: {
  64351. points: Vector3[];
  64352. updatable?: boolean;
  64353. instance?: Nullable<LinesMesh>;
  64354. colors?: Color4[];
  64355. useVertexAlpha?: boolean;
  64356. }, scene?: Nullable<Scene>): LinesMesh;
  64357. /**
  64358. * Creates a dashed line mesh
  64359. * * 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
  64360. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64361. * * The parameter `points` is an array successive Vector3
  64362. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64363. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64364. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64365. * * 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
  64366. * * When updating an instance, remember that only point positions can change, not the number of points
  64367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64368. * @param name defines the name of the mesh
  64369. * @param options defines the options used to create the mesh
  64370. * @param scene defines the hosting scene
  64371. * @returns the dashed line mesh
  64372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64373. */
  64374. static CreateDashedLines(name: string, options: {
  64375. points: Vector3[];
  64376. dashSize?: number;
  64377. gapSize?: number;
  64378. dashNb?: number;
  64379. updatable?: boolean;
  64380. instance?: LinesMesh;
  64381. }, scene?: Nullable<Scene>): LinesMesh;
  64382. /**
  64383. * 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.
  64384. * * 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.
  64385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64386. * * 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.
  64387. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64388. * * 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
  64389. * * 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
  64390. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64395. * @param name defines the name of the mesh
  64396. * @param options defines the options used to create the mesh
  64397. * @param scene defines the hosting scene
  64398. * @returns the extruded shape mesh
  64399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64401. */
  64402. static ExtrudeShape(name: string, options: {
  64403. shape: Vector3[];
  64404. path: Vector3[];
  64405. scale?: number;
  64406. rotation?: number;
  64407. cap?: number;
  64408. updatable?: boolean;
  64409. sideOrientation?: number;
  64410. frontUVs?: Vector4;
  64411. backUVs?: Vector4;
  64412. instance?: Mesh;
  64413. invertUV?: boolean;
  64414. }, scene?: Nullable<Scene>): Mesh;
  64415. /**
  64416. * Creates an custom extruded shape mesh.
  64417. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64418. * * 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.
  64419. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64420. * * 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
  64421. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64422. * * 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
  64423. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64424. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64425. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64426. * * 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
  64427. * * 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
  64428. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64433. * @param name defines the name of the mesh
  64434. * @param options defines the options used to create the mesh
  64435. * @param scene defines the hosting scene
  64436. * @returns the custom extruded shape mesh
  64437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64440. */
  64441. static ExtrudeShapeCustom(name: string, options: {
  64442. shape: Vector3[];
  64443. path: Vector3[];
  64444. scaleFunction?: any;
  64445. rotationFunction?: any;
  64446. ribbonCloseArray?: boolean;
  64447. ribbonClosePath?: boolean;
  64448. cap?: number;
  64449. updatable?: boolean;
  64450. sideOrientation?: number;
  64451. frontUVs?: Vector4;
  64452. backUVs?: Vector4;
  64453. instance?: Mesh;
  64454. invertUV?: boolean;
  64455. }, scene?: Nullable<Scene>): Mesh;
  64456. /**
  64457. * Creates lathe mesh.
  64458. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64459. * * 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
  64460. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64461. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64462. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64463. * * 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
  64464. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64465. * * 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
  64466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64468. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64470. * @param name defines the name of the mesh
  64471. * @param options defines the options used to create the mesh
  64472. * @param scene defines the hosting scene
  64473. * @returns the lathe mesh
  64474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64475. */
  64476. static CreateLathe(name: string, options: {
  64477. shape: Vector3[];
  64478. radius?: number;
  64479. tessellation?: number;
  64480. clip?: number;
  64481. arc?: number;
  64482. closed?: boolean;
  64483. updatable?: boolean;
  64484. sideOrientation?: number;
  64485. frontUVs?: Vector4;
  64486. backUVs?: Vector4;
  64487. cap?: number;
  64488. invertUV?: boolean;
  64489. }, scene?: Nullable<Scene>): Mesh;
  64490. /**
  64491. * Creates a tiled plane mesh
  64492. * * You can set a limited pattern arrangement with the tiles
  64493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64496. * @param name defines the name of the mesh
  64497. * @param options defines the options used to create the mesh
  64498. * @param scene defines the hosting scene
  64499. * @returns the plane mesh
  64500. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64501. */
  64502. static CreateTiledPlane(name: string, options: {
  64503. pattern?: number;
  64504. tileSize?: number;
  64505. tileWidth?: number;
  64506. tileHeight?: number;
  64507. size?: number;
  64508. width?: number;
  64509. height?: number;
  64510. alignHorizontal?: number;
  64511. alignVertical?: number;
  64512. sideOrientation?: number;
  64513. frontUVs?: Vector4;
  64514. backUVs?: Vector4;
  64515. updatable?: boolean;
  64516. }, scene?: Nullable<Scene>): Mesh;
  64517. /**
  64518. * Creates a plane mesh
  64519. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64520. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64521. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64525. * @param name defines the name of the mesh
  64526. * @param options defines the options used to create the mesh
  64527. * @param scene defines the hosting scene
  64528. * @returns the plane mesh
  64529. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64530. */
  64531. static CreatePlane(name: string, options: {
  64532. size?: number;
  64533. width?: number;
  64534. height?: number;
  64535. sideOrientation?: number;
  64536. frontUVs?: Vector4;
  64537. backUVs?: Vector4;
  64538. updatable?: boolean;
  64539. sourcePlane?: Plane;
  64540. }, scene?: Nullable<Scene>): Mesh;
  64541. /**
  64542. * Creates a ground mesh
  64543. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64544. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64546. * @param name defines the name of the mesh
  64547. * @param options defines the options used to create the mesh
  64548. * @param scene defines the hosting scene
  64549. * @returns the ground mesh
  64550. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64551. */
  64552. static CreateGround(name: string, options: {
  64553. width?: number;
  64554. height?: number;
  64555. subdivisions?: number;
  64556. subdivisionsX?: number;
  64557. subdivisionsY?: number;
  64558. updatable?: boolean;
  64559. }, scene?: Nullable<Scene>): Mesh;
  64560. /**
  64561. * Creates a tiled ground mesh
  64562. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64563. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64564. * * 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
  64565. * * 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
  64566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64567. * @param name defines the name of the mesh
  64568. * @param options defines the options used to create the mesh
  64569. * @param scene defines the hosting scene
  64570. * @returns the tiled ground mesh
  64571. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64572. */
  64573. static CreateTiledGround(name: string, options: {
  64574. xmin: number;
  64575. zmin: number;
  64576. xmax: number;
  64577. zmax: number;
  64578. subdivisions?: {
  64579. w: number;
  64580. h: number;
  64581. };
  64582. precision?: {
  64583. w: number;
  64584. h: number;
  64585. };
  64586. updatable?: boolean;
  64587. }, scene?: Nullable<Scene>): Mesh;
  64588. /**
  64589. * Creates a ground mesh from a height map
  64590. * * The parameter `url` sets the URL of the height map image resource.
  64591. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64592. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64593. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64594. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64595. * * 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.
  64596. * * 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).
  64597. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64599. * @param name defines the name of the mesh
  64600. * @param url defines the url to the height map
  64601. * @param options defines the options used to create the mesh
  64602. * @param scene defines the hosting scene
  64603. * @returns the ground mesh
  64604. * @see https://doc.babylonjs.com/babylon101/height_map
  64605. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64606. */
  64607. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64608. width?: number;
  64609. height?: number;
  64610. subdivisions?: number;
  64611. minHeight?: number;
  64612. maxHeight?: number;
  64613. colorFilter?: Color3;
  64614. alphaFilter?: number;
  64615. updatable?: boolean;
  64616. onReady?: (mesh: GroundMesh) => void;
  64617. }, scene?: Nullable<Scene>): GroundMesh;
  64618. /**
  64619. * Creates a polygon mesh
  64620. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64621. * * 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
  64622. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64625. * * Remember you can only change the shape positions, not their number when updating a polygon
  64626. * @param name defines the name of the mesh
  64627. * @param options defines the options used to create the mesh
  64628. * @param scene defines the hosting scene
  64629. * @param earcutInjection can be used to inject your own earcut reference
  64630. * @returns the polygon mesh
  64631. */
  64632. static CreatePolygon(name: string, options: {
  64633. shape: Vector3[];
  64634. holes?: Vector3[][];
  64635. depth?: number;
  64636. faceUV?: Vector4[];
  64637. faceColors?: Color4[];
  64638. updatable?: boolean;
  64639. sideOrientation?: number;
  64640. frontUVs?: Vector4;
  64641. backUVs?: Vector4;
  64642. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64643. /**
  64644. * Creates an extruded polygon mesh, with depth in the Y direction.
  64645. * * 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)
  64646. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64647. * @param name defines the name of the mesh
  64648. * @param options defines the options used to create the mesh
  64649. * @param scene defines the hosting scene
  64650. * @param earcutInjection can be used to inject your own earcut reference
  64651. * @returns the polygon mesh
  64652. */
  64653. static ExtrudePolygon(name: string, options: {
  64654. shape: Vector3[];
  64655. holes?: Vector3[][];
  64656. depth?: number;
  64657. faceUV?: Vector4[];
  64658. faceColors?: Color4[];
  64659. updatable?: boolean;
  64660. sideOrientation?: number;
  64661. frontUVs?: Vector4;
  64662. backUVs?: Vector4;
  64663. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64664. /**
  64665. * Creates a tube mesh.
  64666. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64667. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64668. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64669. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64670. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64671. * * 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)
  64672. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64673. * * 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
  64674. * * 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
  64675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64679. * @param name defines the name of the mesh
  64680. * @param options defines the options used to create the mesh
  64681. * @param scene defines the hosting scene
  64682. * @returns the tube mesh
  64683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64684. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64685. */
  64686. static CreateTube(name: string, options: {
  64687. path: Vector3[];
  64688. radius?: number;
  64689. tessellation?: number;
  64690. radiusFunction?: {
  64691. (i: number, distance: number): number;
  64692. };
  64693. cap?: number;
  64694. arc?: number;
  64695. updatable?: boolean;
  64696. sideOrientation?: number;
  64697. frontUVs?: Vector4;
  64698. backUVs?: Vector4;
  64699. instance?: Mesh;
  64700. invertUV?: boolean;
  64701. }, scene?: Nullable<Scene>): Mesh;
  64702. /**
  64703. * Creates a polyhedron mesh
  64704. * * 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
  64705. * * The parameter `size` (positive float, default 1) sets the polygon size
  64706. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64707. * * 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`
  64708. * * 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
  64709. * * 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)`)
  64710. * * 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
  64711. * * 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
  64712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64715. * @param name defines the name of the mesh
  64716. * @param options defines the options used to create the mesh
  64717. * @param scene defines the hosting scene
  64718. * @returns the polyhedron mesh
  64719. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64720. */
  64721. static CreatePolyhedron(name: string, options: {
  64722. type?: number;
  64723. size?: number;
  64724. sizeX?: number;
  64725. sizeY?: number;
  64726. sizeZ?: number;
  64727. custom?: any;
  64728. faceUV?: Vector4[];
  64729. faceColors?: Color4[];
  64730. flat?: boolean;
  64731. updatable?: boolean;
  64732. sideOrientation?: number;
  64733. frontUVs?: Vector4;
  64734. backUVs?: Vector4;
  64735. }, scene?: Nullable<Scene>): Mesh;
  64736. /**
  64737. * Creates a decal mesh.
  64738. * 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
  64739. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64740. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64741. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64742. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64743. * @param name defines the name of the mesh
  64744. * @param sourceMesh defines the mesh where the decal must be applied
  64745. * @param options defines the options used to create the mesh
  64746. * @param scene defines the hosting scene
  64747. * @returns the decal mesh
  64748. * @see https://doc.babylonjs.com/how_to/decals
  64749. */
  64750. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64751. position?: Vector3;
  64752. normal?: Vector3;
  64753. size?: Vector3;
  64754. angle?: number;
  64755. }): Mesh;
  64756. }
  64757. }
  64758. declare module "babylonjs/Meshes/meshSimplification" {
  64759. import { Mesh } from "babylonjs/Meshes/mesh";
  64760. /**
  64761. * A simplifier interface for future simplification implementations
  64762. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64763. */
  64764. export interface ISimplifier {
  64765. /**
  64766. * Simplification of a given mesh according to the given settings.
  64767. * Since this requires computation, it is assumed that the function runs async.
  64768. * @param settings The settings of the simplification, including quality and distance
  64769. * @param successCallback A callback that will be called after the mesh was simplified.
  64770. * @param errorCallback in case of an error, this callback will be called. optional.
  64771. */
  64772. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64773. }
  64774. /**
  64775. * Expected simplification settings.
  64776. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64777. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64778. */
  64779. export interface ISimplificationSettings {
  64780. /**
  64781. * Gets or sets the expected quality
  64782. */
  64783. quality: number;
  64784. /**
  64785. * Gets or sets the distance when this optimized version should be used
  64786. */
  64787. distance: number;
  64788. /**
  64789. * Gets an already optimized mesh
  64790. */
  64791. optimizeMesh?: boolean;
  64792. }
  64793. /**
  64794. * Class used to specify simplification options
  64795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64796. */
  64797. export class SimplificationSettings implements ISimplificationSettings {
  64798. /** expected quality */
  64799. quality: number;
  64800. /** distance when this optimized version should be used */
  64801. distance: number;
  64802. /** already optimized mesh */
  64803. optimizeMesh?: boolean | undefined;
  64804. /**
  64805. * Creates a SimplificationSettings
  64806. * @param quality expected quality
  64807. * @param distance distance when this optimized version should be used
  64808. * @param optimizeMesh already optimized mesh
  64809. */
  64810. constructor(
  64811. /** expected quality */
  64812. quality: number,
  64813. /** distance when this optimized version should be used */
  64814. distance: number,
  64815. /** already optimized mesh */
  64816. optimizeMesh?: boolean | undefined);
  64817. }
  64818. /**
  64819. * Interface used to define a simplification task
  64820. */
  64821. export interface ISimplificationTask {
  64822. /**
  64823. * Array of settings
  64824. */
  64825. settings: Array<ISimplificationSettings>;
  64826. /**
  64827. * Simplification type
  64828. */
  64829. simplificationType: SimplificationType;
  64830. /**
  64831. * Mesh to simplify
  64832. */
  64833. mesh: Mesh;
  64834. /**
  64835. * Callback called on success
  64836. */
  64837. successCallback?: () => void;
  64838. /**
  64839. * Defines if parallel processing can be used
  64840. */
  64841. parallelProcessing: boolean;
  64842. }
  64843. /**
  64844. * Queue used to order the simplification tasks
  64845. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64846. */
  64847. export class SimplificationQueue {
  64848. private _simplificationArray;
  64849. /**
  64850. * Gets a boolean indicating that the process is still running
  64851. */
  64852. running: boolean;
  64853. /**
  64854. * Creates a new queue
  64855. */
  64856. constructor();
  64857. /**
  64858. * Adds a new simplification task
  64859. * @param task defines a task to add
  64860. */
  64861. addTask(task: ISimplificationTask): void;
  64862. /**
  64863. * Execute next task
  64864. */
  64865. executeNext(): void;
  64866. /**
  64867. * Execute a simplification task
  64868. * @param task defines the task to run
  64869. */
  64870. runSimplification(task: ISimplificationTask): void;
  64871. private getSimplifier;
  64872. }
  64873. /**
  64874. * The implemented types of simplification
  64875. * At the moment only Quadratic Error Decimation is implemented
  64876. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64877. */
  64878. export enum SimplificationType {
  64879. /** Quadratic error decimation */
  64880. QUADRATIC = 0
  64881. }
  64882. }
  64883. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64884. import { Scene } from "babylonjs/scene";
  64885. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64886. import { ISceneComponent } from "babylonjs/sceneComponent";
  64887. module "babylonjs/scene" {
  64888. interface Scene {
  64889. /** @hidden (Backing field) */
  64890. _simplificationQueue: SimplificationQueue;
  64891. /**
  64892. * Gets or sets the simplification queue attached to the scene
  64893. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64894. */
  64895. simplificationQueue: SimplificationQueue;
  64896. }
  64897. }
  64898. module "babylonjs/Meshes/mesh" {
  64899. interface Mesh {
  64900. /**
  64901. * Simplify the mesh according to the given array of settings.
  64902. * Function will return immediately and will simplify async
  64903. * @param settings a collection of simplification settings
  64904. * @param parallelProcessing should all levels calculate parallel or one after the other
  64905. * @param simplificationType the type of simplification to run
  64906. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64907. * @returns the current mesh
  64908. */
  64909. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64910. }
  64911. }
  64912. /**
  64913. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64914. * created in a scene
  64915. */
  64916. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64917. /**
  64918. * The component name helpfull to identify the component in the list of scene components.
  64919. */
  64920. readonly name: string;
  64921. /**
  64922. * The scene the component belongs to.
  64923. */
  64924. scene: Scene;
  64925. /**
  64926. * Creates a new instance of the component for the given scene
  64927. * @param scene Defines the scene to register the component in
  64928. */
  64929. constructor(scene: Scene);
  64930. /**
  64931. * Registers the component in a given scene
  64932. */
  64933. register(): void;
  64934. /**
  64935. * Rebuilds the elements related to this component in case of
  64936. * context lost for instance.
  64937. */
  64938. rebuild(): void;
  64939. /**
  64940. * Disposes the component and the associated ressources
  64941. */
  64942. dispose(): void;
  64943. private _beforeCameraUpdate;
  64944. }
  64945. }
  64946. declare module "babylonjs/Meshes/Builders/index" {
  64947. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64948. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64949. export * from "babylonjs/Meshes/Builders/discBuilder";
  64950. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64951. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64952. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64953. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64954. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64955. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64956. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64957. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64958. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64959. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64960. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64961. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64962. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64963. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64964. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64965. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64966. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64967. }
  64968. declare module "babylonjs/Meshes/index" {
  64969. export * from "babylonjs/Meshes/abstractMesh";
  64970. export * from "babylonjs/Meshes/buffer";
  64971. export * from "babylonjs/Meshes/Compression/index";
  64972. export * from "babylonjs/Meshes/csg";
  64973. export * from "babylonjs/Meshes/geometry";
  64974. export * from "babylonjs/Meshes/groundMesh";
  64975. export * from "babylonjs/Meshes/trailMesh";
  64976. export * from "babylonjs/Meshes/instancedMesh";
  64977. export * from "babylonjs/Meshes/linesMesh";
  64978. export * from "babylonjs/Meshes/mesh";
  64979. export * from "babylonjs/Meshes/mesh.vertexData";
  64980. export * from "babylonjs/Meshes/meshBuilder";
  64981. export * from "babylonjs/Meshes/meshSimplification";
  64982. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64983. export * from "babylonjs/Meshes/polygonMesh";
  64984. export * from "babylonjs/Meshes/subMesh";
  64985. export * from "babylonjs/Meshes/meshLODLevel";
  64986. export * from "babylonjs/Meshes/transformNode";
  64987. export * from "babylonjs/Meshes/Builders/index";
  64988. export * from "babylonjs/Meshes/dataBuffer";
  64989. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64990. }
  64991. declare module "babylonjs/Morph/index" {
  64992. export * from "babylonjs/Morph/morphTarget";
  64993. export * from "babylonjs/Morph/morphTargetManager";
  64994. }
  64995. declare module "babylonjs/Navigation/INavigationEngine" {
  64996. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64997. import { Vector3 } from "babylonjs/Maths/math";
  64998. import { Mesh } from "babylonjs/Meshes/mesh";
  64999. import { Scene } from "babylonjs/scene";
  65000. /**
  65001. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65002. */
  65003. export interface INavigationEnginePlugin {
  65004. /**
  65005. * plugin name
  65006. */
  65007. name: string;
  65008. /**
  65009. * Creates a navigation mesh
  65010. * @param meshes array of all the geometry used to compute the navigatio mesh
  65011. * @param parameters bunch of parameters used to filter geometry
  65012. */
  65013. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65014. /**
  65015. * Create a navigation mesh debug mesh
  65016. * @param scene is where the mesh will be added
  65017. * @returns debug display mesh
  65018. */
  65019. createDebugNavMesh(scene: Scene): Mesh;
  65020. /**
  65021. * Get a navigation mesh constrained position, closest to the parameter position
  65022. * @param position world position
  65023. * @returns the closest point to position constrained by the navigation mesh
  65024. */
  65025. getClosestPoint(position: Vector3): Vector3;
  65026. /**
  65027. * Get a navigation mesh constrained position, within a particular radius
  65028. * @param position world position
  65029. * @param maxRadius the maximum distance to the constrained world position
  65030. * @returns the closest point to position constrained by the navigation mesh
  65031. */
  65032. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65033. /**
  65034. * Compute the final position from a segment made of destination-position
  65035. * @param position world position
  65036. * @param destination world position
  65037. * @returns the resulting point along the navmesh
  65038. */
  65039. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65040. /**
  65041. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65042. * @param start world position
  65043. * @param end world position
  65044. * @returns array containing world position composing the path
  65045. */
  65046. computePath(start: Vector3, end: Vector3): Vector3[];
  65047. /**
  65048. * If this plugin is supported
  65049. * @returns true if plugin is supported
  65050. */
  65051. isSupported(): boolean;
  65052. /**
  65053. * Create a new Crowd so you can add agents
  65054. * @param maxAgents the maximum agent count in the crowd
  65055. * @param maxAgentRadius the maximum radius an agent can have
  65056. * @param scene to attach the crowd to
  65057. * @returns the crowd you can add agents to
  65058. */
  65059. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65060. /**
  65061. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65062. * The queries will try to find a solution within those bounds
  65063. * default is (1,1,1)
  65064. * @param extent x,y,z value that define the extent around the queries point of reference
  65065. */
  65066. setDefaultQueryExtent(extent: Vector3): void;
  65067. /**
  65068. * Get the Bounding box extent specified by setDefaultQueryExtent
  65069. * @returns the box extent values
  65070. */
  65071. getDefaultQueryExtent(): Vector3;
  65072. /**
  65073. * Release all resources
  65074. */
  65075. dispose(): void;
  65076. }
  65077. /**
  65078. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65079. */
  65080. export interface ICrowd {
  65081. /**
  65082. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65083. * You can attach anything to that node. The node position is updated in the scene update tick.
  65084. * @param pos world position that will be constrained by the navigation mesh
  65085. * @param parameters agent parameters
  65086. * @param transform hooked to the agent that will be update by the scene
  65087. * @returns agent index
  65088. */
  65089. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65090. /**
  65091. * Returns the agent position in world space
  65092. * @param index agent index returned by addAgent
  65093. * @returns world space position
  65094. */
  65095. getAgentPosition(index: number): Vector3;
  65096. /**
  65097. * Gets the agent velocity in world space
  65098. * @param index agent index returned by addAgent
  65099. * @returns world space velocity
  65100. */
  65101. getAgentVelocity(index: number): Vector3;
  65102. /**
  65103. * remove a particular agent previously created
  65104. * @param index agent index returned by addAgent
  65105. */
  65106. removeAgent(index: number): void;
  65107. /**
  65108. * get the list of all agents attached to this crowd
  65109. * @returns list of agent indices
  65110. */
  65111. getAgents(): number[];
  65112. /**
  65113. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65114. * @param deltaTime in seconds
  65115. */
  65116. update(deltaTime: number): void;
  65117. /**
  65118. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65119. * @param index agent index returned by addAgent
  65120. * @param destination targeted world position
  65121. */
  65122. agentGoto(index: number, destination: Vector3): void;
  65123. /**
  65124. * Teleport the agent to a new position
  65125. * @param index agent index returned by addAgent
  65126. * @param destination targeted world position
  65127. */
  65128. agentTeleport(index: number, destination: Vector3): void;
  65129. /**
  65130. * Update agent parameters
  65131. * @param index agent index returned by addAgent
  65132. * @param parameters agent parameters
  65133. */
  65134. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65135. /**
  65136. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65137. * The queries will try to find a solution within those bounds
  65138. * default is (1,1,1)
  65139. * @param extent x,y,z value that define the extent around the queries point of reference
  65140. */
  65141. setDefaultQueryExtent(extent: Vector3): void;
  65142. /**
  65143. * Get the Bounding box extent specified by setDefaultQueryExtent
  65144. * @returns the box extent values
  65145. */
  65146. getDefaultQueryExtent(): Vector3;
  65147. /**
  65148. * Release all resources
  65149. */
  65150. dispose(): void;
  65151. }
  65152. /**
  65153. * Configures an agent
  65154. */
  65155. export interface IAgentParameters {
  65156. /**
  65157. * Agent radius. [Limit: >= 0]
  65158. */
  65159. radius: number;
  65160. /**
  65161. * Agent height. [Limit: > 0]
  65162. */
  65163. height: number;
  65164. /**
  65165. * Maximum allowed acceleration. [Limit: >= 0]
  65166. */
  65167. maxAcceleration: number;
  65168. /**
  65169. * Maximum allowed speed. [Limit: >= 0]
  65170. */
  65171. maxSpeed: number;
  65172. /**
  65173. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65174. */
  65175. collisionQueryRange: number;
  65176. /**
  65177. * The path visibility optimization range. [Limit: > 0]
  65178. */
  65179. pathOptimizationRange: number;
  65180. /**
  65181. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65182. */
  65183. separationWeight: number;
  65184. }
  65185. /**
  65186. * Configures the navigation mesh creation
  65187. */
  65188. export interface INavMeshParameters {
  65189. /**
  65190. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65191. */
  65192. cs: number;
  65193. /**
  65194. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65195. */
  65196. ch: number;
  65197. /**
  65198. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65199. */
  65200. walkableSlopeAngle: number;
  65201. /**
  65202. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65203. * be considered walkable. [Limit: >= 3] [Units: vx]
  65204. */
  65205. walkableHeight: number;
  65206. /**
  65207. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65208. */
  65209. walkableClimb: number;
  65210. /**
  65211. * The distance to erode/shrink the walkable area of the heightfield away from
  65212. * obstructions. [Limit: >=0] [Units: vx]
  65213. */
  65214. walkableRadius: number;
  65215. /**
  65216. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65217. */
  65218. maxEdgeLen: number;
  65219. /**
  65220. * The maximum distance a simplfied contour's border edges should deviate
  65221. * the original raw contour. [Limit: >=0] [Units: vx]
  65222. */
  65223. maxSimplificationError: number;
  65224. /**
  65225. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65226. */
  65227. minRegionArea: number;
  65228. /**
  65229. * Any regions with a span count smaller than this value will, if possible,
  65230. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65231. */
  65232. mergeRegionArea: number;
  65233. /**
  65234. * The maximum number of vertices allowed for polygons generated during the
  65235. * contour to polygon conversion process. [Limit: >= 3]
  65236. */
  65237. maxVertsPerPoly: number;
  65238. /**
  65239. * Sets the sampling distance to use when generating the detail mesh.
  65240. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65241. */
  65242. detailSampleDist: number;
  65243. /**
  65244. * The maximum distance the detail mesh surface should deviate from heightfield
  65245. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65246. */
  65247. detailSampleMaxError: number;
  65248. }
  65249. }
  65250. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65251. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65252. import { Mesh } from "babylonjs/Meshes/mesh";
  65253. import { Scene } from "babylonjs/scene";
  65254. import { Vector3 } from "babylonjs/Maths/math";
  65255. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65256. /**
  65257. * RecastJS navigation plugin
  65258. */
  65259. export class RecastJSPlugin implements INavigationEnginePlugin {
  65260. /**
  65261. * Reference to the Recast library
  65262. */
  65263. bjsRECAST: any;
  65264. /**
  65265. * plugin name
  65266. */
  65267. name: string;
  65268. /**
  65269. * the first navmesh created. We might extend this to support multiple navmeshes
  65270. */
  65271. navMesh: any;
  65272. /**
  65273. * Initializes the recastJS plugin
  65274. * @param recastInjection can be used to inject your own recast reference
  65275. */
  65276. constructor(recastInjection?: any);
  65277. /**
  65278. * Creates a navigation mesh
  65279. * @param meshes array of all the geometry used to compute the navigatio mesh
  65280. * @param parameters bunch of parameters used to filter geometry
  65281. */
  65282. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65283. /**
  65284. * Create a navigation mesh debug mesh
  65285. * @param scene is where the mesh will be added
  65286. * @returns debug display mesh
  65287. */
  65288. createDebugNavMesh(scene: Scene): Mesh;
  65289. /**
  65290. * Get a navigation mesh constrained position, closest to the parameter position
  65291. * @param position world position
  65292. * @returns the closest point to position constrained by the navigation mesh
  65293. */
  65294. getClosestPoint(position: Vector3): Vector3;
  65295. /**
  65296. * Get a navigation mesh constrained position, within a particular radius
  65297. * @param position world position
  65298. * @param maxRadius the maximum distance to the constrained world position
  65299. * @returns the closest point to position constrained by the navigation mesh
  65300. */
  65301. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65302. /**
  65303. * Compute the final position from a segment made of destination-position
  65304. * @param position world position
  65305. * @param destination world position
  65306. * @returns the resulting point along the navmesh
  65307. */
  65308. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65309. /**
  65310. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65311. * @param start world position
  65312. * @param end world position
  65313. * @returns array containing world position composing the path
  65314. */
  65315. computePath(start: Vector3, end: Vector3): Vector3[];
  65316. /**
  65317. * Create a new Crowd so you can add agents
  65318. * @param maxAgents the maximum agent count in the crowd
  65319. * @param maxAgentRadius the maximum radius an agent can have
  65320. * @param scene to attach the crowd to
  65321. * @returns the crowd you can add agents to
  65322. */
  65323. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65324. /**
  65325. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65326. * The queries will try to find a solution within those bounds
  65327. * default is (1,1,1)
  65328. * @param extent x,y,z value that define the extent around the queries point of reference
  65329. */
  65330. setDefaultQueryExtent(extent: Vector3): void;
  65331. /**
  65332. * Get the Bounding box extent specified by setDefaultQueryExtent
  65333. * @returns the box extent values
  65334. */
  65335. getDefaultQueryExtent(): Vector3;
  65336. /**
  65337. * Disposes
  65338. */
  65339. dispose(): void;
  65340. /**
  65341. * If this plugin is supported
  65342. * @returns true if plugin is supported
  65343. */
  65344. isSupported(): boolean;
  65345. }
  65346. /**
  65347. * Recast detour crowd implementation
  65348. */
  65349. export class RecastJSCrowd implements ICrowd {
  65350. /**
  65351. * Recast/detour plugin
  65352. */
  65353. bjsRECASTPlugin: RecastJSPlugin;
  65354. /**
  65355. * Link to the detour crowd
  65356. */
  65357. recastCrowd: any;
  65358. /**
  65359. * One transform per agent
  65360. */
  65361. transforms: TransformNode[];
  65362. /**
  65363. * All agents created
  65364. */
  65365. agents: number[];
  65366. /**
  65367. * Link to the scene is kept to unregister the crowd from the scene
  65368. */
  65369. private _scene;
  65370. /**
  65371. * Observer for crowd updates
  65372. */
  65373. private _onBeforeAnimationsObserver;
  65374. /**
  65375. * Constructor
  65376. * @param plugin recastJS plugin
  65377. * @param maxAgents the maximum agent count in the crowd
  65378. * @param maxAgentRadius the maximum radius an agent can have
  65379. * @param scene to attach the crowd to
  65380. * @returns the crowd you can add agents to
  65381. */
  65382. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65383. /**
  65384. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65385. * You can attach anything to that node. The node position is updated in the scene update tick.
  65386. * @param pos world position that will be constrained by the navigation mesh
  65387. * @param parameters agent parameters
  65388. * @param transform hooked to the agent that will be update by the scene
  65389. * @returns agent index
  65390. */
  65391. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65392. /**
  65393. * Returns the agent position in world space
  65394. * @param index agent index returned by addAgent
  65395. * @returns world space position
  65396. */
  65397. getAgentPosition(index: number): Vector3;
  65398. /**
  65399. * Returns the agent velocity in world space
  65400. * @param index agent index returned by addAgent
  65401. * @returns world space velocity
  65402. */
  65403. getAgentVelocity(index: number): Vector3;
  65404. /**
  65405. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65406. * @param index agent index returned by addAgent
  65407. * @param destination targeted world position
  65408. */
  65409. agentGoto(index: number, destination: Vector3): void;
  65410. /**
  65411. * Teleport the agent to a new position
  65412. * @param index agent index returned by addAgent
  65413. * @param destination targeted world position
  65414. */
  65415. agentTeleport(index: number, destination: Vector3): void;
  65416. /**
  65417. * Update agent parameters
  65418. * @param index agent index returned by addAgent
  65419. * @param parameters agent parameters
  65420. */
  65421. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65422. /**
  65423. * remove a particular agent previously created
  65424. * @param index agent index returned by addAgent
  65425. */
  65426. removeAgent(index: number): void;
  65427. /**
  65428. * get the list of all agents attached to this crowd
  65429. * @returns list of agent indices
  65430. */
  65431. getAgents(): number[];
  65432. /**
  65433. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65434. * @param deltaTime in seconds
  65435. */
  65436. update(deltaTime: number): void;
  65437. /**
  65438. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65439. * The queries will try to find a solution within those bounds
  65440. * default is (1,1,1)
  65441. * @param extent x,y,z value that define the extent around the queries point of reference
  65442. */
  65443. setDefaultQueryExtent(extent: Vector3): void;
  65444. /**
  65445. * Get the Bounding box extent specified by setDefaultQueryExtent
  65446. * @returns the box extent values
  65447. */
  65448. getDefaultQueryExtent(): Vector3;
  65449. /**
  65450. * Release all resources
  65451. */
  65452. dispose(): void;
  65453. }
  65454. }
  65455. declare module "babylonjs/Navigation/Plugins/index" {
  65456. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65457. }
  65458. declare module "babylonjs/Navigation/index" {
  65459. export * from "babylonjs/Navigation/INavigationEngine";
  65460. export * from "babylonjs/Navigation/Plugins/index";
  65461. }
  65462. declare module "babylonjs/Offline/database" {
  65463. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65464. /**
  65465. * Class used to enable access to IndexedDB
  65466. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65467. */
  65468. export class Database implements IOfflineProvider {
  65469. private _callbackManifestChecked;
  65470. private _currentSceneUrl;
  65471. private _db;
  65472. private _enableSceneOffline;
  65473. private _enableTexturesOffline;
  65474. private _manifestVersionFound;
  65475. private _mustUpdateRessources;
  65476. private _hasReachedQuota;
  65477. private _isSupported;
  65478. private _idbFactory;
  65479. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65480. private static IsUASupportingBlobStorage;
  65481. /**
  65482. * Gets a boolean indicating if Database storate is enabled (off by default)
  65483. */
  65484. static IDBStorageEnabled: boolean;
  65485. /**
  65486. * Gets a boolean indicating if scene must be saved in the database
  65487. */
  65488. get enableSceneOffline(): boolean;
  65489. /**
  65490. * Gets a boolean indicating if textures must be saved in the database
  65491. */
  65492. get enableTexturesOffline(): boolean;
  65493. /**
  65494. * Creates a new Database
  65495. * @param urlToScene defines the url to load the scene
  65496. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65497. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65498. */
  65499. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65500. private static _ParseURL;
  65501. private static _ReturnFullUrlLocation;
  65502. private _checkManifestFile;
  65503. /**
  65504. * Open the database and make it available
  65505. * @param successCallback defines the callback to call on success
  65506. * @param errorCallback defines the callback to call on error
  65507. */
  65508. open(successCallback: () => void, errorCallback: () => void): void;
  65509. /**
  65510. * Loads an image from the database
  65511. * @param url defines the url to load from
  65512. * @param image defines the target DOM image
  65513. */
  65514. loadImage(url: string, image: HTMLImageElement): void;
  65515. private _loadImageFromDBAsync;
  65516. private _saveImageIntoDBAsync;
  65517. private _checkVersionFromDB;
  65518. private _loadVersionFromDBAsync;
  65519. private _saveVersionIntoDBAsync;
  65520. /**
  65521. * Loads a file from database
  65522. * @param url defines the URL to load from
  65523. * @param sceneLoaded defines a callback to call on success
  65524. * @param progressCallBack defines a callback to call when progress changed
  65525. * @param errorCallback defines a callback to call on error
  65526. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65527. */
  65528. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65529. private _loadFileAsync;
  65530. private _saveFileAsync;
  65531. /**
  65532. * Validates if xhr data is correct
  65533. * @param xhr defines the request to validate
  65534. * @param dataType defines the expected data type
  65535. * @returns true if data is correct
  65536. */
  65537. private static _ValidateXHRData;
  65538. }
  65539. }
  65540. declare module "babylonjs/Offline/index" {
  65541. export * from "babylonjs/Offline/database";
  65542. export * from "babylonjs/Offline/IOfflineProvider";
  65543. }
  65544. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65545. /** @hidden */
  65546. export var gpuUpdateParticlesPixelShader: {
  65547. name: string;
  65548. shader: string;
  65549. };
  65550. }
  65551. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65552. /** @hidden */
  65553. export var gpuUpdateParticlesVertexShader: {
  65554. name: string;
  65555. shader: string;
  65556. };
  65557. }
  65558. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65559. /** @hidden */
  65560. export var clipPlaneFragmentDeclaration2: {
  65561. name: string;
  65562. shader: string;
  65563. };
  65564. }
  65565. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65567. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65568. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65569. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65570. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65571. /** @hidden */
  65572. export var gpuRenderParticlesPixelShader: {
  65573. name: string;
  65574. shader: string;
  65575. };
  65576. }
  65577. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65578. /** @hidden */
  65579. export var clipPlaneVertexDeclaration2: {
  65580. name: string;
  65581. shader: string;
  65582. };
  65583. }
  65584. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65586. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65587. /** @hidden */
  65588. export var gpuRenderParticlesVertexShader: {
  65589. name: string;
  65590. shader: string;
  65591. };
  65592. }
  65593. declare module "babylonjs/Particles/gpuParticleSystem" {
  65594. import { Nullable } from "babylonjs/types";
  65595. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65596. import { Observable } from "babylonjs/Misc/observable";
  65597. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65598. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65599. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65600. import { Scene, IDisposable } from "babylonjs/scene";
  65601. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65602. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65603. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65604. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65605. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65606. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65607. /**
  65608. * This represents a GPU particle system in Babylon
  65609. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65610. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65611. */
  65612. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65613. /**
  65614. * The layer mask we are rendering the particles through.
  65615. */
  65616. layerMask: number;
  65617. private _capacity;
  65618. private _activeCount;
  65619. private _currentActiveCount;
  65620. private _accumulatedCount;
  65621. private _renderEffect;
  65622. private _updateEffect;
  65623. private _buffer0;
  65624. private _buffer1;
  65625. private _spriteBuffer;
  65626. private _updateVAO;
  65627. private _renderVAO;
  65628. private _targetIndex;
  65629. private _sourceBuffer;
  65630. private _targetBuffer;
  65631. private _engine;
  65632. private _currentRenderId;
  65633. private _started;
  65634. private _stopped;
  65635. private _timeDelta;
  65636. private _randomTexture;
  65637. private _randomTexture2;
  65638. private _attributesStrideSize;
  65639. private _updateEffectOptions;
  65640. private _randomTextureSize;
  65641. private _actualFrame;
  65642. private readonly _rawTextureWidth;
  65643. /**
  65644. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65645. */
  65646. static get IsSupported(): boolean;
  65647. /**
  65648. * An event triggered when the system is disposed.
  65649. */
  65650. onDisposeObservable: Observable<GPUParticleSystem>;
  65651. /**
  65652. * Gets the maximum number of particles active at the same time.
  65653. * @returns The max number of active particles.
  65654. */
  65655. getCapacity(): number;
  65656. /**
  65657. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65658. * to override the particles.
  65659. */
  65660. forceDepthWrite: boolean;
  65661. /**
  65662. * Gets or set the number of active particles
  65663. */
  65664. get activeParticleCount(): number;
  65665. set activeParticleCount(value: number);
  65666. private _preWarmDone;
  65667. /**
  65668. * Is this system ready to be used/rendered
  65669. * @return true if the system is ready
  65670. */
  65671. isReady(): boolean;
  65672. /**
  65673. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65674. * @returns True if it has been started, otherwise false.
  65675. */
  65676. isStarted(): boolean;
  65677. /**
  65678. * Starts the particle system and begins to emit
  65679. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65680. */
  65681. start(delay?: number): void;
  65682. /**
  65683. * Stops the particle system.
  65684. */
  65685. stop(): void;
  65686. /**
  65687. * Remove all active particles
  65688. */
  65689. reset(): void;
  65690. /**
  65691. * Returns the string "GPUParticleSystem"
  65692. * @returns a string containing the class name
  65693. */
  65694. getClassName(): string;
  65695. private _colorGradientsTexture;
  65696. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65697. /**
  65698. * Adds a new color gradient
  65699. * @param gradient defines the gradient to use (between 0 and 1)
  65700. * @param color1 defines the color to affect to the specified gradient
  65701. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65702. * @returns the current particle system
  65703. */
  65704. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65705. /**
  65706. * Remove a specific color gradient
  65707. * @param gradient defines the gradient to remove
  65708. * @returns the current particle system
  65709. */
  65710. removeColorGradient(gradient: number): GPUParticleSystem;
  65711. private _angularSpeedGradientsTexture;
  65712. private _sizeGradientsTexture;
  65713. private _velocityGradientsTexture;
  65714. private _limitVelocityGradientsTexture;
  65715. private _dragGradientsTexture;
  65716. private _addFactorGradient;
  65717. /**
  65718. * Adds a new size gradient
  65719. * @param gradient defines the gradient to use (between 0 and 1)
  65720. * @param factor defines the size factor to affect to the specified gradient
  65721. * @returns the current particle system
  65722. */
  65723. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65724. /**
  65725. * Remove a specific size gradient
  65726. * @param gradient defines the gradient to remove
  65727. * @returns the current particle system
  65728. */
  65729. removeSizeGradient(gradient: number): GPUParticleSystem;
  65730. /**
  65731. * Adds a new angular speed gradient
  65732. * @param gradient defines the gradient to use (between 0 and 1)
  65733. * @param factor defines the angular speed to affect to the specified gradient
  65734. * @returns the current particle system
  65735. */
  65736. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65737. /**
  65738. * Remove a specific angular speed gradient
  65739. * @param gradient defines the gradient to remove
  65740. * @returns the current particle system
  65741. */
  65742. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65743. /**
  65744. * Adds a new velocity gradient
  65745. * @param gradient defines the gradient to use (between 0 and 1)
  65746. * @param factor defines the velocity to affect to the specified gradient
  65747. * @returns the current particle system
  65748. */
  65749. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65750. /**
  65751. * Remove a specific velocity gradient
  65752. * @param gradient defines the gradient to remove
  65753. * @returns the current particle system
  65754. */
  65755. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65756. /**
  65757. * Adds a new limit velocity gradient
  65758. * @param gradient defines the gradient to use (between 0 and 1)
  65759. * @param factor defines the limit velocity value to affect to the specified gradient
  65760. * @returns the current particle system
  65761. */
  65762. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65763. /**
  65764. * Remove a specific limit velocity gradient
  65765. * @param gradient defines the gradient to remove
  65766. * @returns the current particle system
  65767. */
  65768. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65769. /**
  65770. * Adds a new drag gradient
  65771. * @param gradient defines the gradient to use (between 0 and 1)
  65772. * @param factor defines the drag value to affect to the specified gradient
  65773. * @returns the current particle system
  65774. */
  65775. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65776. /**
  65777. * Remove a specific drag gradient
  65778. * @param gradient defines the gradient to remove
  65779. * @returns the current particle system
  65780. */
  65781. removeDragGradient(gradient: number): GPUParticleSystem;
  65782. /**
  65783. * Not supported by GPUParticleSystem
  65784. * @param gradient defines the gradient to use (between 0 and 1)
  65785. * @param factor defines the emit rate value to affect to the specified gradient
  65786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65787. * @returns the current particle system
  65788. */
  65789. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65790. /**
  65791. * Not supported by GPUParticleSystem
  65792. * @param gradient defines the gradient to remove
  65793. * @returns the current particle system
  65794. */
  65795. removeEmitRateGradient(gradient: number): IParticleSystem;
  65796. /**
  65797. * Not supported by GPUParticleSystem
  65798. * @param gradient defines the gradient to use (between 0 and 1)
  65799. * @param factor defines the start size value to affect to the specified gradient
  65800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65801. * @returns the current particle system
  65802. */
  65803. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65804. /**
  65805. * Not supported by GPUParticleSystem
  65806. * @param gradient defines the gradient to remove
  65807. * @returns the current particle system
  65808. */
  65809. removeStartSizeGradient(gradient: number): IParticleSystem;
  65810. /**
  65811. * Not supported by GPUParticleSystem
  65812. * @param gradient defines the gradient to use (between 0 and 1)
  65813. * @param min defines the color remap minimal range
  65814. * @param max defines the color remap maximal range
  65815. * @returns the current particle system
  65816. */
  65817. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65818. /**
  65819. * Not supported by GPUParticleSystem
  65820. * @param gradient defines the gradient to remove
  65821. * @returns the current particle system
  65822. */
  65823. removeColorRemapGradient(): IParticleSystem;
  65824. /**
  65825. * Not supported by GPUParticleSystem
  65826. * @param gradient defines the gradient to use (between 0 and 1)
  65827. * @param min defines the alpha remap minimal range
  65828. * @param max defines the alpha remap maximal range
  65829. * @returns the current particle system
  65830. */
  65831. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65832. /**
  65833. * Not supported by GPUParticleSystem
  65834. * @param gradient defines the gradient to remove
  65835. * @returns the current particle system
  65836. */
  65837. removeAlphaRemapGradient(): IParticleSystem;
  65838. /**
  65839. * Not supported by GPUParticleSystem
  65840. * @param gradient defines the gradient to use (between 0 and 1)
  65841. * @param color defines the color to affect to the specified gradient
  65842. * @returns the current particle system
  65843. */
  65844. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65845. /**
  65846. * Not supported by GPUParticleSystem
  65847. * @param gradient defines the gradient to remove
  65848. * @returns the current particle system
  65849. */
  65850. removeRampGradient(): IParticleSystem;
  65851. /**
  65852. * Not supported by GPUParticleSystem
  65853. * @returns the list of ramp gradients
  65854. */
  65855. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65856. /**
  65857. * Not supported by GPUParticleSystem
  65858. * Gets or sets a boolean indicating that ramp gradients must be used
  65859. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65860. */
  65861. get useRampGradients(): boolean;
  65862. set useRampGradients(value: boolean);
  65863. /**
  65864. * Not supported by GPUParticleSystem
  65865. * @param gradient defines the gradient to use (between 0 and 1)
  65866. * @param factor defines the life time factor to affect to the specified gradient
  65867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65868. * @returns the current particle system
  65869. */
  65870. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65871. /**
  65872. * Not supported by GPUParticleSystem
  65873. * @param gradient defines the gradient to remove
  65874. * @returns the current particle system
  65875. */
  65876. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65877. /**
  65878. * Instantiates a GPU particle system.
  65879. * 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.
  65880. * @param name The name of the particle system
  65881. * @param options The options used to create the system
  65882. * @param scene The scene the particle system belongs to
  65883. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65884. */
  65885. constructor(name: string, options: Partial<{
  65886. capacity: number;
  65887. randomTextureSize: number;
  65888. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65889. protected _reset(): void;
  65890. private _createUpdateVAO;
  65891. private _createRenderVAO;
  65892. private _initialize;
  65893. /** @hidden */
  65894. _recreateUpdateEffect(): void;
  65895. /** @hidden */
  65896. _recreateRenderEffect(): void;
  65897. /**
  65898. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65899. * @param preWarm defines if we are in the pre-warmimg phase
  65900. */
  65901. animate(preWarm?: boolean): void;
  65902. private _createFactorGradientTexture;
  65903. private _createSizeGradientTexture;
  65904. private _createAngularSpeedGradientTexture;
  65905. private _createVelocityGradientTexture;
  65906. private _createLimitVelocityGradientTexture;
  65907. private _createDragGradientTexture;
  65908. private _createColorGradientTexture;
  65909. /**
  65910. * Renders the particle system in its current state
  65911. * @param preWarm defines if the system should only update the particles but not render them
  65912. * @returns the current number of particles
  65913. */
  65914. render(preWarm?: boolean): number;
  65915. /**
  65916. * Rebuilds the particle system
  65917. */
  65918. rebuild(): void;
  65919. private _releaseBuffers;
  65920. private _releaseVAOs;
  65921. /**
  65922. * Disposes the particle system and free the associated resources
  65923. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65924. */
  65925. dispose(disposeTexture?: boolean): void;
  65926. /**
  65927. * Clones the particle system.
  65928. * @param name The name of the cloned object
  65929. * @param newEmitter The new emitter to use
  65930. * @returns the cloned particle system
  65931. */
  65932. clone(name: string, newEmitter: any): GPUParticleSystem;
  65933. /**
  65934. * Serializes the particle system to a JSON object.
  65935. * @returns the JSON object
  65936. */
  65937. serialize(): any;
  65938. /**
  65939. * Parses a JSON object to create a GPU particle system.
  65940. * @param parsedParticleSystem The JSON object to parse
  65941. * @param scene The scene to create the particle system in
  65942. * @param rootUrl The root url to use to load external dependencies like texture
  65943. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65944. * @returns the parsed GPU particle system
  65945. */
  65946. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65947. }
  65948. }
  65949. declare module "babylonjs/Particles/particleSystemSet" {
  65950. import { Nullable } from "babylonjs/types";
  65951. import { Color3 } from "babylonjs/Maths/math.color";
  65952. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65954. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65955. import { Scene, IDisposable } from "babylonjs/scene";
  65956. /**
  65957. * Represents a set of particle systems working together to create a specific effect
  65958. */
  65959. export class ParticleSystemSet implements IDisposable {
  65960. /**
  65961. * Gets or sets base Assets URL
  65962. */
  65963. static BaseAssetsUrl: string;
  65964. private _emitterCreationOptions;
  65965. private _emitterNode;
  65966. /**
  65967. * Gets the particle system list
  65968. */
  65969. systems: IParticleSystem[];
  65970. /**
  65971. * Gets the emitter node used with this set
  65972. */
  65973. get emitterNode(): Nullable<TransformNode>;
  65974. /**
  65975. * Creates a new emitter mesh as a sphere
  65976. * @param options defines the options used to create the sphere
  65977. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65978. * @param scene defines the hosting scene
  65979. */
  65980. setEmitterAsSphere(options: {
  65981. diameter: number;
  65982. segments: number;
  65983. color: Color3;
  65984. }, renderingGroupId: number, scene: Scene): void;
  65985. /**
  65986. * Starts all particle systems of the set
  65987. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65988. */
  65989. start(emitter?: AbstractMesh): void;
  65990. /**
  65991. * Release all associated resources
  65992. */
  65993. dispose(): void;
  65994. /**
  65995. * Serialize the set into a JSON compatible object
  65996. * @returns a JSON compatible representation of the set
  65997. */
  65998. serialize(): any;
  65999. /**
  66000. * Parse a new ParticleSystemSet from a serialized source
  66001. * @param data defines a JSON compatible representation of the set
  66002. * @param scene defines the hosting scene
  66003. * @param gpu defines if we want GPU particles or CPU particles
  66004. * @returns a new ParticleSystemSet
  66005. */
  66006. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66007. }
  66008. }
  66009. declare module "babylonjs/Particles/particleHelper" {
  66010. import { Nullable } from "babylonjs/types";
  66011. import { Scene } from "babylonjs/scene";
  66012. import { Vector3 } from "babylonjs/Maths/math.vector";
  66013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66014. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66015. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66016. /**
  66017. * This class is made for on one-liner static method to help creating particle system set.
  66018. */
  66019. export class ParticleHelper {
  66020. /**
  66021. * Gets or sets base Assets URL
  66022. */
  66023. static BaseAssetsUrl: string;
  66024. /**
  66025. * Create a default particle system that you can tweak
  66026. * @param emitter defines the emitter to use
  66027. * @param capacity defines the system capacity (default is 500 particles)
  66028. * @param scene defines the hosting scene
  66029. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66030. * @returns the new Particle system
  66031. */
  66032. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66033. /**
  66034. * This is the main static method (one-liner) of this helper to create different particle systems
  66035. * @param type This string represents the type to the particle system to create
  66036. * @param scene The scene where the particle system should live
  66037. * @param gpu If the system will use gpu
  66038. * @returns the ParticleSystemSet created
  66039. */
  66040. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66041. /**
  66042. * Static function used to export a particle system to a ParticleSystemSet variable.
  66043. * Please note that the emitter shape is not exported
  66044. * @param systems defines the particle systems to export
  66045. * @returns the created particle system set
  66046. */
  66047. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66048. }
  66049. }
  66050. declare module "babylonjs/Particles/particleSystemComponent" {
  66051. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66052. import { Effect } from "babylonjs/Materials/effect";
  66053. import "babylonjs/Shaders/particles.vertex";
  66054. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66055. module "babylonjs/Engines/engine" {
  66056. interface Engine {
  66057. /**
  66058. * Create an effect to use with particle systems.
  66059. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66060. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66061. * @param uniformsNames defines a list of attribute names
  66062. * @param samplers defines an array of string used to represent textures
  66063. * @param defines defines the string containing the defines to use to compile the shaders
  66064. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66065. * @param onCompiled defines a function to call when the effect creation is successful
  66066. * @param onError defines a function to call when the effect creation has failed
  66067. * @returns the new Effect
  66068. */
  66069. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66070. }
  66071. }
  66072. module "babylonjs/Meshes/mesh" {
  66073. interface Mesh {
  66074. /**
  66075. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66076. * @returns an array of IParticleSystem
  66077. */
  66078. getEmittedParticleSystems(): IParticleSystem[];
  66079. /**
  66080. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66081. * @returns an array of IParticleSystem
  66082. */
  66083. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66084. }
  66085. }
  66086. /**
  66087. * @hidden
  66088. */
  66089. export var _IDoNeedToBeInTheBuild: number;
  66090. }
  66091. declare module "babylonjs/Particles/pointsCloudSystem" {
  66092. import { Color4 } from "babylonjs/Maths/math";
  66093. import { Mesh } from "babylonjs/Meshes/mesh";
  66094. import { Scene, IDisposable } from "babylonjs/scene";
  66095. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66096. /** Defines the 4 color options */
  66097. export enum PointColor {
  66098. /** color value */
  66099. Color = 2,
  66100. /** uv value */
  66101. UV = 1,
  66102. /** random value */
  66103. Random = 0,
  66104. /** stated value */
  66105. Stated = 3
  66106. }
  66107. /**
  66108. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66109. * 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.
  66110. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66111. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66112. *
  66113. * Full documentation here : TO BE ENTERED
  66114. */
  66115. export class PointsCloudSystem implements IDisposable {
  66116. /**
  66117. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66118. * Example : var p = SPS.particles[i];
  66119. */
  66120. particles: CloudPoint[];
  66121. /**
  66122. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66123. */
  66124. nbParticles: number;
  66125. /**
  66126. * This a counter for your own usage. It's not set by any SPS functions.
  66127. */
  66128. counter: number;
  66129. /**
  66130. * The PCS name. This name is also given to the underlying mesh.
  66131. */
  66132. name: string;
  66133. /**
  66134. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66135. */
  66136. mesh: Mesh;
  66137. /**
  66138. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66139. * Please read :
  66140. */
  66141. vars: any;
  66142. /**
  66143. * @hidden
  66144. */
  66145. _size: number;
  66146. private _scene;
  66147. private _promises;
  66148. private _positions;
  66149. private _indices;
  66150. private _normals;
  66151. private _colors;
  66152. private _uvs;
  66153. private _indices32;
  66154. private _positions32;
  66155. private _colors32;
  66156. private _uvs32;
  66157. private _updatable;
  66158. private _isVisibilityBoxLocked;
  66159. private _alwaysVisible;
  66160. private _groups;
  66161. private _groupCounter;
  66162. private _computeParticleColor;
  66163. private _computeParticleTexture;
  66164. private _computeParticleRotation;
  66165. private _computeBoundingBox;
  66166. private _isReady;
  66167. /**
  66168. * Creates a PCS (Points Cloud System) object
  66169. * @param name (String) is the PCS name, this will be the underlying mesh name
  66170. * @param pointSize (number) is the size for each point
  66171. * @param scene (Scene) is the scene in which the PCS is added
  66172. * @param options defines the options of the PCS e.g.
  66173. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66174. */
  66175. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66176. updatable?: boolean;
  66177. });
  66178. /**
  66179. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66180. * If no points were added to the PCS, the returned mesh is just a single point.
  66181. * @returns a promise for the created mesh
  66182. */
  66183. buildMeshAsync(): Promise<Mesh>;
  66184. /**
  66185. * @hidden
  66186. */
  66187. private _buildMesh;
  66188. private _addParticle;
  66189. private _randomUnitVector;
  66190. private _getColorIndicesForCoord;
  66191. private _setPointsColorOrUV;
  66192. private _colorFromTexture;
  66193. private _calculateDensity;
  66194. /**
  66195. * Adds points to the PCS in random positions within a unit sphere
  66196. * @param nb (positive integer) the number of particles to be created from this model
  66197. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66198. * @returns the number of groups in the system
  66199. */
  66200. addPoints(nb: number, pointFunction?: any): number;
  66201. /**
  66202. * Adds points to the PCS from the surface of the model shape
  66203. * @param mesh is any Mesh object that will be used as a surface model for the points
  66204. * @param nb (positive integer) the number of particles to be created from this model
  66205. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66206. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66207. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66208. * @returns the number of groups in the system
  66209. */
  66210. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66211. /**
  66212. * Adds points to the PCS inside the model shape
  66213. * @param mesh is any Mesh object that will be used as a surface model for the points
  66214. * @param nb (positive integer) the number of particles to be created from this model
  66215. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66216. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66217. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66218. * @returns the number of groups in the system
  66219. */
  66220. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66221. /**
  66222. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66223. * This method calls `updateParticle()` for each particle of the SPS.
  66224. * For an animated SPS, it is usually called within the render loop.
  66225. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66226. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66227. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66228. * @returns the PCS.
  66229. */
  66230. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66231. /**
  66232. * Disposes the PCS.
  66233. */
  66234. dispose(): void;
  66235. /**
  66236. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66237. * doc :
  66238. * @returns the PCS.
  66239. */
  66240. refreshVisibleSize(): PointsCloudSystem;
  66241. /**
  66242. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66243. * @param size the size (float) of the visibility box
  66244. * note : this doesn't lock the PCS mesh bounding box.
  66245. * doc :
  66246. */
  66247. setVisibilityBox(size: number): void;
  66248. /**
  66249. * Gets whether the PCS is always visible or not
  66250. * doc :
  66251. */
  66252. get isAlwaysVisible(): boolean;
  66253. /**
  66254. * Sets the PCS as always visible or not
  66255. * doc :
  66256. */
  66257. set isAlwaysVisible(val: boolean);
  66258. /**
  66259. * Tells to `setParticles()` to compute the particle rotations or not
  66260. * Default value : false. The PCS is faster when it's set to false
  66261. * Note : particle rotations are only applied to parent particles
  66262. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66263. */
  66264. set computeParticleRotation(val: boolean);
  66265. /**
  66266. * Tells to `setParticles()` to compute the particle colors or not.
  66267. * Default value : true. The PCS is faster when it's set to false.
  66268. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66269. */
  66270. set computeParticleColor(val: boolean);
  66271. set computeParticleTexture(val: boolean);
  66272. /**
  66273. * Gets if `setParticles()` computes the particle colors or not.
  66274. * Default value : false. The PCS is faster when it's set to false.
  66275. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66276. */
  66277. get computeParticleColor(): boolean;
  66278. /**
  66279. * Gets if `setParticles()` computes the particle textures or not.
  66280. * Default value : false. The PCS is faster when it's set to false.
  66281. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66282. */
  66283. get computeParticleTexture(): boolean;
  66284. /**
  66285. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66286. */
  66287. set computeBoundingBox(val: boolean);
  66288. /**
  66289. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66290. */
  66291. get computeBoundingBox(): boolean;
  66292. /**
  66293. * This function does nothing. It may be overwritten to set all the particle first values.
  66294. * The PCS doesn't call this function, you may have to call it by your own.
  66295. * doc :
  66296. */
  66297. initParticles(): void;
  66298. /**
  66299. * This function does nothing. It may be overwritten to recycle a particle
  66300. * The PCS doesn't call this function, you can to call it
  66301. * doc :
  66302. * @param particle The particle to recycle
  66303. * @returns the recycled particle
  66304. */
  66305. recycleParticle(particle: CloudPoint): CloudPoint;
  66306. /**
  66307. * Updates a particle : this function should be overwritten by the user.
  66308. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66309. * doc :
  66310. * @example : just set a particle position or velocity and recycle conditions
  66311. * @param particle The particle to update
  66312. * @returns the updated particle
  66313. */
  66314. updateParticle(particle: CloudPoint): CloudPoint;
  66315. /**
  66316. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66317. * This does nothing and may be overwritten by the user.
  66318. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66319. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66320. * @param update the boolean update value actually passed to setParticles()
  66321. */
  66322. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66323. /**
  66324. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66325. * This will be passed three parameters.
  66326. * This does nothing and may be overwritten by the user.
  66327. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66328. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66329. * @param update the boolean update value actually passed to setParticles()
  66330. */
  66331. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66332. }
  66333. }
  66334. declare module "babylonjs/Particles/cloudPoint" {
  66335. import { Nullable } from "babylonjs/types";
  66336. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66337. import { Mesh } from "babylonjs/Meshes/mesh";
  66338. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66339. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66340. /**
  66341. * Represents one particle of a points cloud system.
  66342. */
  66343. export class CloudPoint {
  66344. /**
  66345. * particle global index
  66346. */
  66347. idx: number;
  66348. /**
  66349. * The color of the particle
  66350. */
  66351. color: Nullable<Color4>;
  66352. /**
  66353. * The world space position of the particle.
  66354. */
  66355. position: Vector3;
  66356. /**
  66357. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66358. */
  66359. rotation: Vector3;
  66360. /**
  66361. * The world space rotation quaternion of the particle.
  66362. */
  66363. rotationQuaternion: Nullable<Quaternion>;
  66364. /**
  66365. * The uv of the particle.
  66366. */
  66367. uv: Nullable<Vector2>;
  66368. /**
  66369. * The current speed of the particle.
  66370. */
  66371. velocity: Vector3;
  66372. /**
  66373. * The pivot point in the particle local space.
  66374. */
  66375. pivot: Vector3;
  66376. /**
  66377. * Must the particle be translated from its pivot point in its local space ?
  66378. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66379. * Default : false
  66380. */
  66381. translateFromPivot: boolean;
  66382. /**
  66383. * Index of this particle in the global "positions" array (Internal use)
  66384. * @hidden
  66385. */
  66386. _pos: number;
  66387. /**
  66388. * @hidden Index of this particle in the global "indices" array (Internal use)
  66389. */
  66390. _ind: number;
  66391. /**
  66392. * Group this particle belongs to
  66393. */
  66394. _group: PointsGroup;
  66395. /**
  66396. * Group id of this particle
  66397. */
  66398. groupId: number;
  66399. /**
  66400. * Index of the particle in its group id (Internal use)
  66401. */
  66402. idxInGroup: number;
  66403. /**
  66404. * @hidden Particle BoundingInfo object (Internal use)
  66405. */
  66406. _boundingInfo: BoundingInfo;
  66407. /**
  66408. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66409. */
  66410. _pcs: PointsCloudSystem;
  66411. /**
  66412. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66413. */
  66414. _stillInvisible: boolean;
  66415. /**
  66416. * @hidden Last computed particle rotation matrix
  66417. */
  66418. _rotationMatrix: number[];
  66419. /**
  66420. * Parent particle Id, if any.
  66421. * Default null.
  66422. */
  66423. parentId: Nullable<number>;
  66424. /**
  66425. * @hidden Internal global position in the PCS.
  66426. */
  66427. _globalPosition: Vector3;
  66428. /**
  66429. * Creates a Point Cloud object.
  66430. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66431. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66432. * @param group (PointsGroup) is the group the particle belongs to
  66433. * @param groupId (integer) is the group identifier in the PCS.
  66434. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66435. * @param pcs defines the PCS it is associated to
  66436. */
  66437. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66438. /**
  66439. * get point size
  66440. */
  66441. get size(): Vector3;
  66442. /**
  66443. * Set point size
  66444. */
  66445. set size(scale: Vector3);
  66446. /**
  66447. * Legacy support, changed quaternion to rotationQuaternion
  66448. */
  66449. get quaternion(): Nullable<Quaternion>;
  66450. /**
  66451. * Legacy support, changed quaternion to rotationQuaternion
  66452. */
  66453. set quaternion(q: Nullable<Quaternion>);
  66454. /**
  66455. * Returns a boolean. True if the particle intersects a mesh, else false
  66456. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66457. * @param target is the object (point or mesh) what the intersection is computed against
  66458. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66459. * @returns true if it intersects
  66460. */
  66461. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66462. /**
  66463. * get the rotation matrix of the particle
  66464. * @hidden
  66465. */
  66466. getRotationMatrix(m: Matrix): void;
  66467. }
  66468. /**
  66469. * Represents a group of points in a points cloud system
  66470. * * PCS internal tool, don't use it manually.
  66471. */
  66472. export class PointsGroup {
  66473. /**
  66474. * The group id
  66475. * @hidden
  66476. */
  66477. groupID: number;
  66478. /**
  66479. * image data for group (internal use)
  66480. * @hidden
  66481. */
  66482. _groupImageData: Nullable<ArrayBufferView>;
  66483. /**
  66484. * Image Width (internal use)
  66485. * @hidden
  66486. */
  66487. _groupImgWidth: number;
  66488. /**
  66489. * Image Height (internal use)
  66490. * @hidden
  66491. */
  66492. _groupImgHeight: number;
  66493. /**
  66494. * Custom position function (internal use)
  66495. * @hidden
  66496. */
  66497. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66498. /**
  66499. * density per facet for surface points
  66500. * @hidden
  66501. */
  66502. _groupDensity: number[];
  66503. /**
  66504. * Only when points are colored by texture carries pointer to texture list array
  66505. * @hidden
  66506. */
  66507. _textureNb: number;
  66508. /**
  66509. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66510. * PCS internal tool, don't use it manually.
  66511. * @hidden
  66512. */
  66513. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66514. }
  66515. }
  66516. declare module "babylonjs/Particles/index" {
  66517. export * from "babylonjs/Particles/baseParticleSystem";
  66518. export * from "babylonjs/Particles/EmitterTypes/index";
  66519. export * from "babylonjs/Particles/gpuParticleSystem";
  66520. export * from "babylonjs/Particles/IParticleSystem";
  66521. export * from "babylonjs/Particles/particle";
  66522. export * from "babylonjs/Particles/particleHelper";
  66523. export * from "babylonjs/Particles/particleSystem";
  66524. export * from "babylonjs/Particles/particleSystemComponent";
  66525. export * from "babylonjs/Particles/particleSystemSet";
  66526. export * from "babylonjs/Particles/solidParticle";
  66527. export * from "babylonjs/Particles/solidParticleSystem";
  66528. export * from "babylonjs/Particles/cloudPoint";
  66529. export * from "babylonjs/Particles/pointsCloudSystem";
  66530. export * from "babylonjs/Particles/subEmitter";
  66531. }
  66532. declare module "babylonjs/Physics/physicsEngineComponent" {
  66533. import { Nullable } from "babylonjs/types";
  66534. import { Observable, Observer } from "babylonjs/Misc/observable";
  66535. import { Vector3 } from "babylonjs/Maths/math.vector";
  66536. import { Mesh } from "babylonjs/Meshes/mesh";
  66537. import { ISceneComponent } from "babylonjs/sceneComponent";
  66538. import { Scene } from "babylonjs/scene";
  66539. import { Node } from "babylonjs/node";
  66540. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66541. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66542. module "babylonjs/scene" {
  66543. interface Scene {
  66544. /** @hidden (Backing field) */
  66545. _physicsEngine: Nullable<IPhysicsEngine>;
  66546. /** @hidden */
  66547. _physicsTimeAccumulator: number;
  66548. /**
  66549. * Gets the current physics engine
  66550. * @returns a IPhysicsEngine or null if none attached
  66551. */
  66552. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66553. /**
  66554. * Enables physics to the current scene
  66555. * @param gravity defines the scene's gravity for the physics engine
  66556. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66557. * @return a boolean indicating if the physics engine was initialized
  66558. */
  66559. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66560. /**
  66561. * Disables and disposes the physics engine associated with the scene
  66562. */
  66563. disablePhysicsEngine(): void;
  66564. /**
  66565. * Gets a boolean indicating if there is an active physics engine
  66566. * @returns a boolean indicating if there is an active physics engine
  66567. */
  66568. isPhysicsEnabled(): boolean;
  66569. /**
  66570. * Deletes a physics compound impostor
  66571. * @param compound defines the compound to delete
  66572. */
  66573. deleteCompoundImpostor(compound: any): void;
  66574. /**
  66575. * An event triggered when physic simulation is about to be run
  66576. */
  66577. onBeforePhysicsObservable: Observable<Scene>;
  66578. /**
  66579. * An event triggered when physic simulation has been done
  66580. */
  66581. onAfterPhysicsObservable: Observable<Scene>;
  66582. }
  66583. }
  66584. module "babylonjs/Meshes/abstractMesh" {
  66585. interface AbstractMesh {
  66586. /** @hidden */
  66587. _physicsImpostor: Nullable<PhysicsImpostor>;
  66588. /**
  66589. * Gets or sets impostor used for physic simulation
  66590. * @see http://doc.babylonjs.com/features/physics_engine
  66591. */
  66592. physicsImpostor: Nullable<PhysicsImpostor>;
  66593. /**
  66594. * Gets the current physics impostor
  66595. * @see http://doc.babylonjs.com/features/physics_engine
  66596. * @returns a physics impostor or null
  66597. */
  66598. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66599. /** Apply a physic impulse to the mesh
  66600. * @param force defines the force to apply
  66601. * @param contactPoint defines where to apply the force
  66602. * @returns the current mesh
  66603. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66604. */
  66605. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66606. /**
  66607. * Creates a physic joint between two meshes
  66608. * @param otherMesh defines the other mesh to use
  66609. * @param pivot1 defines the pivot to use on this mesh
  66610. * @param pivot2 defines the pivot to use on the other mesh
  66611. * @param options defines additional options (can be plugin dependent)
  66612. * @returns the current mesh
  66613. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66614. */
  66615. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66616. /** @hidden */
  66617. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66618. }
  66619. }
  66620. /**
  66621. * Defines the physics engine scene component responsible to manage a physics engine
  66622. */
  66623. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66624. /**
  66625. * The component name helpful to identify the component in the list of scene components.
  66626. */
  66627. readonly name: string;
  66628. /**
  66629. * The scene the component belongs to.
  66630. */
  66631. scene: Scene;
  66632. /**
  66633. * Creates a new instance of the component for the given scene
  66634. * @param scene Defines the scene to register the component in
  66635. */
  66636. constructor(scene: Scene);
  66637. /**
  66638. * Registers the component in a given scene
  66639. */
  66640. register(): void;
  66641. /**
  66642. * Rebuilds the elements related to this component in case of
  66643. * context lost for instance.
  66644. */
  66645. rebuild(): void;
  66646. /**
  66647. * Disposes the component and the associated ressources
  66648. */
  66649. dispose(): void;
  66650. }
  66651. }
  66652. declare module "babylonjs/Physics/physicsHelper" {
  66653. import { Nullable } from "babylonjs/types";
  66654. import { Vector3 } from "babylonjs/Maths/math.vector";
  66655. import { Mesh } from "babylonjs/Meshes/mesh";
  66656. import { Scene } from "babylonjs/scene";
  66657. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66658. /**
  66659. * A helper for physics simulations
  66660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66661. */
  66662. export class PhysicsHelper {
  66663. private _scene;
  66664. private _physicsEngine;
  66665. /**
  66666. * Initializes the Physics helper
  66667. * @param scene Babylon.js scene
  66668. */
  66669. constructor(scene: Scene);
  66670. /**
  66671. * Applies a radial explosion impulse
  66672. * @param origin the origin of the explosion
  66673. * @param radiusOrEventOptions the radius or the options of radial explosion
  66674. * @param strength the explosion strength
  66675. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66676. * @returns A physics radial explosion event, or null
  66677. */
  66678. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66679. /**
  66680. * Applies a radial explosion force
  66681. * @param origin the origin of the explosion
  66682. * @param radiusOrEventOptions the radius or the options of radial explosion
  66683. * @param strength the explosion strength
  66684. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66685. * @returns A physics radial explosion event, or null
  66686. */
  66687. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66688. /**
  66689. * Creates a gravitational field
  66690. * @param origin the origin of the explosion
  66691. * @param radiusOrEventOptions the radius or the options of radial explosion
  66692. * @param strength the explosion strength
  66693. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66694. * @returns A physics gravitational field event, or null
  66695. */
  66696. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66697. /**
  66698. * Creates a physics updraft event
  66699. * @param origin the origin of the updraft
  66700. * @param radiusOrEventOptions the radius or the options of the updraft
  66701. * @param strength the strength of the updraft
  66702. * @param height the height of the updraft
  66703. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66704. * @returns A physics updraft event, or null
  66705. */
  66706. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66707. /**
  66708. * Creates a physics vortex event
  66709. * @param origin the of the vortex
  66710. * @param radiusOrEventOptions the radius or the options of the vortex
  66711. * @param strength the strength of the vortex
  66712. * @param height the height of the vortex
  66713. * @returns a Physics vortex event, or null
  66714. * A physics vortex event or null
  66715. */
  66716. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66717. }
  66718. /**
  66719. * Represents a physics radial explosion event
  66720. */
  66721. class PhysicsRadialExplosionEvent {
  66722. private _scene;
  66723. private _options;
  66724. private _sphere;
  66725. private _dataFetched;
  66726. /**
  66727. * Initializes a radial explosioin event
  66728. * @param _scene BabylonJS scene
  66729. * @param _options The options for the vortex event
  66730. */
  66731. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66732. /**
  66733. * Returns the data related to the radial explosion event (sphere).
  66734. * @returns The radial explosion event data
  66735. */
  66736. getData(): PhysicsRadialExplosionEventData;
  66737. /**
  66738. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66739. * @param impostor A physics imposter
  66740. * @param origin the origin of the explosion
  66741. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66742. */
  66743. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66744. /**
  66745. * Triggers affecterd impostors callbacks
  66746. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66747. */
  66748. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66749. /**
  66750. * Disposes the sphere.
  66751. * @param force Specifies if the sphere should be disposed by force
  66752. */
  66753. dispose(force?: boolean): void;
  66754. /*** Helpers ***/
  66755. private _prepareSphere;
  66756. private _intersectsWithSphere;
  66757. }
  66758. /**
  66759. * Represents a gravitational field event
  66760. */
  66761. class PhysicsGravitationalFieldEvent {
  66762. private _physicsHelper;
  66763. private _scene;
  66764. private _origin;
  66765. private _options;
  66766. private _tickCallback;
  66767. private _sphere;
  66768. private _dataFetched;
  66769. /**
  66770. * Initializes the physics gravitational field event
  66771. * @param _physicsHelper A physics helper
  66772. * @param _scene BabylonJS scene
  66773. * @param _origin The origin position of the gravitational field event
  66774. * @param _options The options for the vortex event
  66775. */
  66776. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66777. /**
  66778. * Returns the data related to the gravitational field event (sphere).
  66779. * @returns A gravitational field event
  66780. */
  66781. getData(): PhysicsGravitationalFieldEventData;
  66782. /**
  66783. * Enables the gravitational field.
  66784. */
  66785. enable(): void;
  66786. /**
  66787. * Disables the gravitational field.
  66788. */
  66789. disable(): void;
  66790. /**
  66791. * Disposes the sphere.
  66792. * @param force The force to dispose from the gravitational field event
  66793. */
  66794. dispose(force?: boolean): void;
  66795. private _tick;
  66796. }
  66797. /**
  66798. * Represents a physics updraft event
  66799. */
  66800. class PhysicsUpdraftEvent {
  66801. private _scene;
  66802. private _origin;
  66803. private _options;
  66804. private _physicsEngine;
  66805. private _originTop;
  66806. private _originDirection;
  66807. private _tickCallback;
  66808. private _cylinder;
  66809. private _cylinderPosition;
  66810. private _dataFetched;
  66811. /**
  66812. * Initializes the physics updraft event
  66813. * @param _scene BabylonJS scene
  66814. * @param _origin The origin position of the updraft
  66815. * @param _options The options for the updraft event
  66816. */
  66817. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66818. /**
  66819. * Returns the data related to the updraft event (cylinder).
  66820. * @returns A physics updraft event
  66821. */
  66822. getData(): PhysicsUpdraftEventData;
  66823. /**
  66824. * Enables the updraft.
  66825. */
  66826. enable(): void;
  66827. /**
  66828. * Disables the updraft.
  66829. */
  66830. disable(): void;
  66831. /**
  66832. * Disposes the cylinder.
  66833. * @param force Specifies if the updraft should be disposed by force
  66834. */
  66835. dispose(force?: boolean): void;
  66836. private getImpostorHitData;
  66837. private _tick;
  66838. /*** Helpers ***/
  66839. private _prepareCylinder;
  66840. private _intersectsWithCylinder;
  66841. }
  66842. /**
  66843. * Represents a physics vortex event
  66844. */
  66845. class PhysicsVortexEvent {
  66846. private _scene;
  66847. private _origin;
  66848. private _options;
  66849. private _physicsEngine;
  66850. private _originTop;
  66851. private _tickCallback;
  66852. private _cylinder;
  66853. private _cylinderPosition;
  66854. private _dataFetched;
  66855. /**
  66856. * Initializes the physics vortex event
  66857. * @param _scene The BabylonJS scene
  66858. * @param _origin The origin position of the vortex
  66859. * @param _options The options for the vortex event
  66860. */
  66861. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66862. /**
  66863. * Returns the data related to the vortex event (cylinder).
  66864. * @returns The physics vortex event data
  66865. */
  66866. getData(): PhysicsVortexEventData;
  66867. /**
  66868. * Enables the vortex.
  66869. */
  66870. enable(): void;
  66871. /**
  66872. * Disables the cortex.
  66873. */
  66874. disable(): void;
  66875. /**
  66876. * Disposes the sphere.
  66877. * @param force
  66878. */
  66879. dispose(force?: boolean): void;
  66880. private getImpostorHitData;
  66881. private _tick;
  66882. /*** Helpers ***/
  66883. private _prepareCylinder;
  66884. private _intersectsWithCylinder;
  66885. }
  66886. /**
  66887. * Options fot the radial explosion event
  66888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66889. */
  66890. export class PhysicsRadialExplosionEventOptions {
  66891. /**
  66892. * The radius of the sphere for the radial explosion.
  66893. */
  66894. radius: number;
  66895. /**
  66896. * The strenth of the explosion.
  66897. */
  66898. strength: number;
  66899. /**
  66900. * The strenght of the force in correspondence to the distance of the affected object
  66901. */
  66902. falloff: PhysicsRadialImpulseFalloff;
  66903. /**
  66904. * Sphere options for the radial explosion.
  66905. */
  66906. sphere: {
  66907. segments: number;
  66908. diameter: number;
  66909. };
  66910. /**
  66911. * Sphere options for the radial explosion.
  66912. */
  66913. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66914. }
  66915. /**
  66916. * Options fot the updraft event
  66917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66918. */
  66919. export class PhysicsUpdraftEventOptions {
  66920. /**
  66921. * The radius of the cylinder for the vortex
  66922. */
  66923. radius: number;
  66924. /**
  66925. * The strenth of the updraft.
  66926. */
  66927. strength: number;
  66928. /**
  66929. * The height of the cylinder for the updraft.
  66930. */
  66931. height: number;
  66932. /**
  66933. * The mode for the the updraft.
  66934. */
  66935. updraftMode: PhysicsUpdraftMode;
  66936. }
  66937. /**
  66938. * Options fot the vortex event
  66939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66940. */
  66941. export class PhysicsVortexEventOptions {
  66942. /**
  66943. * The radius of the cylinder for the vortex
  66944. */
  66945. radius: number;
  66946. /**
  66947. * The strenth of the vortex.
  66948. */
  66949. strength: number;
  66950. /**
  66951. * The height of the cylinder for the vortex.
  66952. */
  66953. height: number;
  66954. /**
  66955. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66956. */
  66957. centripetalForceThreshold: number;
  66958. /**
  66959. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66960. */
  66961. centripetalForceMultiplier: number;
  66962. /**
  66963. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66964. */
  66965. centrifugalForceMultiplier: number;
  66966. /**
  66967. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66968. */
  66969. updraftForceMultiplier: number;
  66970. }
  66971. /**
  66972. * The strenght of the force in correspondence to the distance of the affected object
  66973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66974. */
  66975. export enum PhysicsRadialImpulseFalloff {
  66976. /** Defines that impulse is constant in strength across it's whole radius */
  66977. Constant = 0,
  66978. /** Defines that impulse gets weaker if it's further from the origin */
  66979. Linear = 1
  66980. }
  66981. /**
  66982. * The strength of the force in correspondence to the distance of the affected object
  66983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66984. */
  66985. export enum PhysicsUpdraftMode {
  66986. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66987. Center = 0,
  66988. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66989. Perpendicular = 1
  66990. }
  66991. /**
  66992. * Interface for a physics hit data
  66993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66994. */
  66995. export interface PhysicsHitData {
  66996. /**
  66997. * The force applied at the contact point
  66998. */
  66999. force: Vector3;
  67000. /**
  67001. * The contact point
  67002. */
  67003. contactPoint: Vector3;
  67004. /**
  67005. * The distance from the origin to the contact point
  67006. */
  67007. distanceFromOrigin: number;
  67008. }
  67009. /**
  67010. * Interface for radial explosion event data
  67011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67012. */
  67013. export interface PhysicsRadialExplosionEventData {
  67014. /**
  67015. * A sphere used for the radial explosion event
  67016. */
  67017. sphere: Mesh;
  67018. }
  67019. /**
  67020. * Interface for gravitational field event data
  67021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67022. */
  67023. export interface PhysicsGravitationalFieldEventData {
  67024. /**
  67025. * A sphere mesh used for the gravitational field event
  67026. */
  67027. sphere: Mesh;
  67028. }
  67029. /**
  67030. * Interface for updraft event data
  67031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67032. */
  67033. export interface PhysicsUpdraftEventData {
  67034. /**
  67035. * A cylinder used for the updraft event
  67036. */
  67037. cylinder: Mesh;
  67038. }
  67039. /**
  67040. * Interface for vortex event data
  67041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67042. */
  67043. export interface PhysicsVortexEventData {
  67044. /**
  67045. * A cylinder used for the vortex event
  67046. */
  67047. cylinder: Mesh;
  67048. }
  67049. /**
  67050. * Interface for an affected physics impostor
  67051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67052. */
  67053. export interface PhysicsAffectedImpostorWithData {
  67054. /**
  67055. * The impostor affected by the effect
  67056. */
  67057. impostor: PhysicsImpostor;
  67058. /**
  67059. * The data about the hit/horce from the explosion
  67060. */
  67061. hitData: PhysicsHitData;
  67062. }
  67063. }
  67064. declare module "babylonjs/Physics/Plugins/index" {
  67065. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67066. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67067. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67068. }
  67069. declare module "babylonjs/Physics/index" {
  67070. export * from "babylonjs/Physics/IPhysicsEngine";
  67071. export * from "babylonjs/Physics/physicsEngine";
  67072. export * from "babylonjs/Physics/physicsEngineComponent";
  67073. export * from "babylonjs/Physics/physicsHelper";
  67074. export * from "babylonjs/Physics/physicsImpostor";
  67075. export * from "babylonjs/Physics/physicsJoint";
  67076. export * from "babylonjs/Physics/Plugins/index";
  67077. }
  67078. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67079. /** @hidden */
  67080. export var blackAndWhitePixelShader: {
  67081. name: string;
  67082. shader: string;
  67083. };
  67084. }
  67085. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67087. import { Camera } from "babylonjs/Cameras/camera";
  67088. import { Engine } from "babylonjs/Engines/engine";
  67089. import "babylonjs/Shaders/blackAndWhite.fragment";
  67090. /**
  67091. * Post process used to render in black and white
  67092. */
  67093. export class BlackAndWhitePostProcess extends PostProcess {
  67094. /**
  67095. * Linear about to convert he result to black and white (default: 1)
  67096. */
  67097. degree: number;
  67098. /**
  67099. * Creates a black and white post process
  67100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67101. * @param name The name of the effect.
  67102. * @param options The required width/height ratio to downsize to before computing the render pass.
  67103. * @param camera The camera to apply the render pass to.
  67104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67105. * @param engine The engine which the post process will be applied. (default: current engine)
  67106. * @param reusable If the post process can be reused on the same frame. (default: false)
  67107. */
  67108. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67109. }
  67110. }
  67111. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67112. import { Nullable } from "babylonjs/types";
  67113. import { Camera } from "babylonjs/Cameras/camera";
  67114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67115. import { Engine } from "babylonjs/Engines/engine";
  67116. /**
  67117. * This represents a set of one or more post processes in Babylon.
  67118. * A post process can be used to apply a shader to a texture after it is rendered.
  67119. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67120. */
  67121. export class PostProcessRenderEffect {
  67122. private _postProcesses;
  67123. private _getPostProcesses;
  67124. private _singleInstance;
  67125. private _cameras;
  67126. private _indicesForCamera;
  67127. /**
  67128. * Name of the effect
  67129. * @hidden
  67130. */
  67131. _name: string;
  67132. /**
  67133. * Instantiates a post process render effect.
  67134. * A post process can be used to apply a shader to a texture after it is rendered.
  67135. * @param engine The engine the effect is tied to
  67136. * @param name The name of the effect
  67137. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67138. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67139. */
  67140. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67141. /**
  67142. * Checks if all the post processes in the effect are supported.
  67143. */
  67144. get isSupported(): boolean;
  67145. /**
  67146. * Updates the current state of the effect
  67147. * @hidden
  67148. */
  67149. _update(): void;
  67150. /**
  67151. * Attaches the effect on cameras
  67152. * @param cameras The camera to attach to.
  67153. * @hidden
  67154. */
  67155. _attachCameras(cameras: Camera): void;
  67156. /**
  67157. * Attaches the effect on cameras
  67158. * @param cameras The camera to attach to.
  67159. * @hidden
  67160. */
  67161. _attachCameras(cameras: Camera[]): void;
  67162. /**
  67163. * Detaches the effect on cameras
  67164. * @param cameras The camera to detatch from.
  67165. * @hidden
  67166. */
  67167. _detachCameras(cameras: Camera): void;
  67168. /**
  67169. * Detatches the effect on cameras
  67170. * @param cameras The camera to detatch from.
  67171. * @hidden
  67172. */
  67173. _detachCameras(cameras: Camera[]): void;
  67174. /**
  67175. * Enables the effect on given cameras
  67176. * @param cameras The camera to enable.
  67177. * @hidden
  67178. */
  67179. _enable(cameras: Camera): void;
  67180. /**
  67181. * Enables the effect on given cameras
  67182. * @param cameras The camera to enable.
  67183. * @hidden
  67184. */
  67185. _enable(cameras: Nullable<Camera[]>): void;
  67186. /**
  67187. * Disables the effect on the given cameras
  67188. * @param cameras The camera to disable.
  67189. * @hidden
  67190. */
  67191. _disable(cameras: Camera): void;
  67192. /**
  67193. * Disables the effect on the given cameras
  67194. * @param cameras The camera to disable.
  67195. * @hidden
  67196. */
  67197. _disable(cameras: Nullable<Camera[]>): void;
  67198. /**
  67199. * Gets a list of the post processes contained in the effect.
  67200. * @param camera The camera to get the post processes on.
  67201. * @returns The list of the post processes in the effect.
  67202. */
  67203. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67204. }
  67205. }
  67206. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67208. /** @hidden */
  67209. export var extractHighlightsPixelShader: {
  67210. name: string;
  67211. shader: string;
  67212. };
  67213. }
  67214. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67215. import { Nullable } from "babylonjs/types";
  67216. import { Camera } from "babylonjs/Cameras/camera";
  67217. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67218. import { Engine } from "babylonjs/Engines/engine";
  67219. import "babylonjs/Shaders/extractHighlights.fragment";
  67220. /**
  67221. * 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.
  67222. */
  67223. export class ExtractHighlightsPostProcess extends PostProcess {
  67224. /**
  67225. * The luminance threshold, pixels below this value will be set to black.
  67226. */
  67227. threshold: number;
  67228. /** @hidden */
  67229. _exposure: number;
  67230. /**
  67231. * Post process which has the input texture to be used when performing highlight extraction
  67232. * @hidden
  67233. */
  67234. _inputPostProcess: Nullable<PostProcess>;
  67235. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67236. }
  67237. }
  67238. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67239. /** @hidden */
  67240. export var bloomMergePixelShader: {
  67241. name: string;
  67242. shader: string;
  67243. };
  67244. }
  67245. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67247. import { Nullable } from "babylonjs/types";
  67248. import { Engine } from "babylonjs/Engines/engine";
  67249. import { Camera } from "babylonjs/Cameras/camera";
  67250. import "babylonjs/Shaders/bloomMerge.fragment";
  67251. /**
  67252. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67253. */
  67254. export class BloomMergePostProcess extends PostProcess {
  67255. /** Weight of the bloom to be added to the original input. */
  67256. weight: number;
  67257. /**
  67258. * Creates a new instance of @see BloomMergePostProcess
  67259. * @param name The name of the effect.
  67260. * @param originalFromInput Post process which's input will be used for the merge.
  67261. * @param blurred Blurred highlights post process which's output will be used.
  67262. * @param weight Weight of the bloom to be added to the original input.
  67263. * @param options The required width/height ratio to downsize to before computing the render pass.
  67264. * @param camera The camera to apply the render pass to.
  67265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67266. * @param engine The engine which the post process will be applied. (default: current engine)
  67267. * @param reusable If the post process can be reused on the same frame. (default: false)
  67268. * @param textureType Type of textures used when performing the post process. (default: 0)
  67269. * @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)
  67270. */
  67271. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67272. /** Weight of the bloom to be added to the original input. */
  67273. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67274. }
  67275. }
  67276. declare module "babylonjs/PostProcesses/bloomEffect" {
  67277. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67278. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67279. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67280. import { Camera } from "babylonjs/Cameras/camera";
  67281. import { Scene } from "babylonjs/scene";
  67282. /**
  67283. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67284. */
  67285. export class BloomEffect extends PostProcessRenderEffect {
  67286. private bloomScale;
  67287. /**
  67288. * @hidden Internal
  67289. */
  67290. _effects: Array<PostProcess>;
  67291. /**
  67292. * @hidden Internal
  67293. */
  67294. _downscale: ExtractHighlightsPostProcess;
  67295. private _blurX;
  67296. private _blurY;
  67297. private _merge;
  67298. /**
  67299. * The luminance threshold to find bright areas of the image to bloom.
  67300. */
  67301. get threshold(): number;
  67302. set threshold(value: number);
  67303. /**
  67304. * The strength of the bloom.
  67305. */
  67306. get weight(): number;
  67307. set weight(value: number);
  67308. /**
  67309. * Specifies the size of the bloom blur kernel, relative to the final output size
  67310. */
  67311. get kernel(): number;
  67312. set kernel(value: number);
  67313. /**
  67314. * Creates a new instance of @see BloomEffect
  67315. * @param scene The scene the effect belongs to.
  67316. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67317. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67318. * @param bloomWeight The the strength of bloom.
  67319. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67320. * @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)
  67321. */
  67322. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67323. /**
  67324. * Disposes each of the internal effects for a given camera.
  67325. * @param camera The camera to dispose the effect on.
  67326. */
  67327. disposeEffects(camera: Camera): void;
  67328. /**
  67329. * @hidden Internal
  67330. */
  67331. _updateEffects(): void;
  67332. /**
  67333. * Internal
  67334. * @returns if all the contained post processes are ready.
  67335. * @hidden
  67336. */
  67337. _isReady(): boolean;
  67338. }
  67339. }
  67340. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67341. /** @hidden */
  67342. export var chromaticAberrationPixelShader: {
  67343. name: string;
  67344. shader: string;
  67345. };
  67346. }
  67347. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67348. import { Vector2 } from "babylonjs/Maths/math.vector";
  67349. import { Nullable } from "babylonjs/types";
  67350. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67351. import { Camera } from "babylonjs/Cameras/camera";
  67352. import { Engine } from "babylonjs/Engines/engine";
  67353. import "babylonjs/Shaders/chromaticAberration.fragment";
  67354. /**
  67355. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67356. */
  67357. export class ChromaticAberrationPostProcess extends PostProcess {
  67358. /**
  67359. * The amount of seperation of rgb channels (default: 30)
  67360. */
  67361. aberrationAmount: number;
  67362. /**
  67363. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67364. */
  67365. radialIntensity: number;
  67366. /**
  67367. * 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))
  67368. */
  67369. direction: Vector2;
  67370. /**
  67371. * 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))
  67372. */
  67373. centerPosition: Vector2;
  67374. /**
  67375. * Creates a new instance ChromaticAberrationPostProcess
  67376. * @param name The name of the effect.
  67377. * @param screenWidth The width of the screen to apply the effect on.
  67378. * @param screenHeight The height of the screen to apply the effect on.
  67379. * @param options The required width/height ratio to downsize to before computing the render pass.
  67380. * @param camera The camera to apply the render pass to.
  67381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67382. * @param engine The engine which the post process will be applied. (default: current engine)
  67383. * @param reusable If the post process can be reused on the same frame. (default: false)
  67384. * @param textureType Type of textures used when performing the post process. (default: 0)
  67385. * @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)
  67386. */
  67387. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67388. }
  67389. }
  67390. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67391. /** @hidden */
  67392. export var circleOfConfusionPixelShader: {
  67393. name: string;
  67394. shader: string;
  67395. };
  67396. }
  67397. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67398. import { Nullable } from "babylonjs/types";
  67399. import { Engine } from "babylonjs/Engines/engine";
  67400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67402. import { Camera } from "babylonjs/Cameras/camera";
  67403. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67404. /**
  67405. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67406. */
  67407. export class CircleOfConfusionPostProcess extends PostProcess {
  67408. /**
  67409. * 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.
  67410. */
  67411. lensSize: number;
  67412. /**
  67413. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67414. */
  67415. fStop: number;
  67416. /**
  67417. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67418. */
  67419. focusDistance: number;
  67420. /**
  67421. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67422. */
  67423. focalLength: number;
  67424. private _depthTexture;
  67425. /**
  67426. * Creates a new instance CircleOfConfusionPostProcess
  67427. * @param name The name of the effect.
  67428. * @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.
  67429. * @param options The required width/height ratio to downsize to before computing the render pass.
  67430. * @param camera The camera to apply the render pass to.
  67431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67432. * @param engine The engine which the post process will be applied. (default: current engine)
  67433. * @param reusable If the post process can be reused on the same frame. (default: false)
  67434. * @param textureType Type of textures used when performing the post process. (default: 0)
  67435. * @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)
  67436. */
  67437. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67438. /**
  67439. * 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.
  67440. */
  67441. set depthTexture(value: RenderTargetTexture);
  67442. }
  67443. }
  67444. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67445. /** @hidden */
  67446. export var colorCorrectionPixelShader: {
  67447. name: string;
  67448. shader: string;
  67449. };
  67450. }
  67451. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67453. import { Engine } from "babylonjs/Engines/engine";
  67454. import { Camera } from "babylonjs/Cameras/camera";
  67455. import "babylonjs/Shaders/colorCorrection.fragment";
  67456. /**
  67457. *
  67458. * This post-process allows the modification of rendered colors by using
  67459. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67460. *
  67461. * The object needs to be provided an url to a texture containing the color
  67462. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67463. * Use an image editing software to tweak the LUT to match your needs.
  67464. *
  67465. * For an example of a color LUT, see here:
  67466. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67467. * For explanations on color grading, see here:
  67468. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67469. *
  67470. */
  67471. export class ColorCorrectionPostProcess extends PostProcess {
  67472. private _colorTableTexture;
  67473. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67474. }
  67475. }
  67476. declare module "babylonjs/Shaders/convolution.fragment" {
  67477. /** @hidden */
  67478. export var convolutionPixelShader: {
  67479. name: string;
  67480. shader: string;
  67481. };
  67482. }
  67483. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67485. import { Nullable } from "babylonjs/types";
  67486. import { Camera } from "babylonjs/Cameras/camera";
  67487. import { Engine } from "babylonjs/Engines/engine";
  67488. import "babylonjs/Shaders/convolution.fragment";
  67489. /**
  67490. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67491. * input texture to perform effects such as edge detection or sharpening
  67492. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67493. */
  67494. export class ConvolutionPostProcess extends PostProcess {
  67495. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67496. kernel: number[];
  67497. /**
  67498. * Creates a new instance ConvolutionPostProcess
  67499. * @param name The name of the effect.
  67500. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67501. * @param options The required width/height ratio to downsize to before computing the render pass.
  67502. * @param camera The camera to apply the render pass to.
  67503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67504. * @param engine The engine which the post process will be applied. (default: current engine)
  67505. * @param reusable If the post process can be reused on the same frame. (default: false)
  67506. * @param textureType Type of textures used when performing the post process. (default: 0)
  67507. */
  67508. constructor(name: string,
  67509. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67510. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67511. /**
  67512. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67513. */
  67514. static EdgeDetect0Kernel: number[];
  67515. /**
  67516. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67517. */
  67518. static EdgeDetect1Kernel: number[];
  67519. /**
  67520. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67521. */
  67522. static EdgeDetect2Kernel: number[];
  67523. /**
  67524. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67525. */
  67526. static SharpenKernel: number[];
  67527. /**
  67528. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67529. */
  67530. static EmbossKernel: number[];
  67531. /**
  67532. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67533. */
  67534. static GaussianKernel: number[];
  67535. }
  67536. }
  67537. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67538. import { Nullable } from "babylonjs/types";
  67539. import { Vector2 } from "babylonjs/Maths/math.vector";
  67540. import { Camera } from "babylonjs/Cameras/camera";
  67541. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67542. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67543. import { Engine } from "babylonjs/Engines/engine";
  67544. import { Scene } from "babylonjs/scene";
  67545. /**
  67546. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67547. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67548. * based on samples that have a large difference in distance than the center pixel.
  67549. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67550. */
  67551. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67552. direction: Vector2;
  67553. /**
  67554. * Creates a new instance CircleOfConfusionPostProcess
  67555. * @param name The name of the effect.
  67556. * @param scene The scene the effect belongs to.
  67557. * @param direction The direction the blur should be applied.
  67558. * @param kernel The size of the kernel used to blur.
  67559. * @param options The required width/height ratio to downsize to before computing the render pass.
  67560. * @param camera The camera to apply the render pass to.
  67561. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67562. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67564. * @param engine The engine which the post process will be applied. (default: current engine)
  67565. * @param reusable If the post process can be reused on the same frame. (default: false)
  67566. * @param textureType Type of textures used when performing the post process. (default: 0)
  67567. * @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)
  67568. */
  67569. 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);
  67570. }
  67571. }
  67572. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67573. /** @hidden */
  67574. export var depthOfFieldMergePixelShader: {
  67575. name: string;
  67576. shader: string;
  67577. };
  67578. }
  67579. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67580. import { Nullable } from "babylonjs/types";
  67581. import { Camera } from "babylonjs/Cameras/camera";
  67582. import { Effect } from "babylonjs/Materials/effect";
  67583. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67584. import { Engine } from "babylonjs/Engines/engine";
  67585. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67586. /**
  67587. * Options to be set when merging outputs from the default pipeline.
  67588. */
  67589. export class DepthOfFieldMergePostProcessOptions {
  67590. /**
  67591. * The original image to merge on top of
  67592. */
  67593. originalFromInput: PostProcess;
  67594. /**
  67595. * Parameters to perform the merge of the depth of field effect
  67596. */
  67597. depthOfField?: {
  67598. circleOfConfusion: PostProcess;
  67599. blurSteps: Array<PostProcess>;
  67600. };
  67601. /**
  67602. * Parameters to perform the merge of bloom effect
  67603. */
  67604. bloom?: {
  67605. blurred: PostProcess;
  67606. weight: number;
  67607. };
  67608. }
  67609. /**
  67610. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67611. */
  67612. export class DepthOfFieldMergePostProcess extends PostProcess {
  67613. private blurSteps;
  67614. /**
  67615. * Creates a new instance of DepthOfFieldMergePostProcess
  67616. * @param name The name of the effect.
  67617. * @param originalFromInput Post process which's input will be used for the merge.
  67618. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67619. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67620. * @param options The required width/height ratio to downsize to before computing the render pass.
  67621. * @param camera The camera to apply the render pass to.
  67622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67623. * @param engine The engine which the post process will be applied. (default: current engine)
  67624. * @param reusable If the post process can be reused on the same frame. (default: false)
  67625. * @param textureType Type of textures used when performing the post process. (default: 0)
  67626. * @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)
  67627. */
  67628. 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);
  67629. /**
  67630. * Updates the effect with the current post process compile time values and recompiles the shader.
  67631. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67632. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67633. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67634. * @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
  67635. * @param onCompiled Called when the shader has been compiled.
  67636. * @param onError Called if there is an error when compiling a shader.
  67637. */
  67638. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67639. }
  67640. }
  67641. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67642. import { Nullable } from "babylonjs/types";
  67643. import { Camera } from "babylonjs/Cameras/camera";
  67644. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67646. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67647. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67648. import { Scene } from "babylonjs/scene";
  67649. /**
  67650. * Specifies the level of max blur that should be applied when using the depth of field effect
  67651. */
  67652. export enum DepthOfFieldEffectBlurLevel {
  67653. /**
  67654. * Subtle blur
  67655. */
  67656. Low = 0,
  67657. /**
  67658. * Medium blur
  67659. */
  67660. Medium = 1,
  67661. /**
  67662. * Large blur
  67663. */
  67664. High = 2
  67665. }
  67666. /**
  67667. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67668. */
  67669. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67670. private _circleOfConfusion;
  67671. /**
  67672. * @hidden Internal, blurs from high to low
  67673. */
  67674. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67675. private _depthOfFieldBlurY;
  67676. private _dofMerge;
  67677. /**
  67678. * @hidden Internal post processes in depth of field effect
  67679. */
  67680. _effects: Array<PostProcess>;
  67681. /**
  67682. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67683. */
  67684. set focalLength(value: number);
  67685. get focalLength(): number;
  67686. /**
  67687. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67688. */
  67689. set fStop(value: number);
  67690. get fStop(): number;
  67691. /**
  67692. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67693. */
  67694. set focusDistance(value: number);
  67695. get focusDistance(): number;
  67696. /**
  67697. * 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.
  67698. */
  67699. set lensSize(value: number);
  67700. get lensSize(): number;
  67701. /**
  67702. * Creates a new instance DepthOfFieldEffect
  67703. * @param scene The scene the effect belongs to.
  67704. * @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.
  67705. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67706. * @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)
  67707. */
  67708. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67709. /**
  67710. * Get the current class name of the current effet
  67711. * @returns "DepthOfFieldEffect"
  67712. */
  67713. getClassName(): string;
  67714. /**
  67715. * 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.
  67716. */
  67717. set depthTexture(value: RenderTargetTexture);
  67718. /**
  67719. * Disposes each of the internal effects for a given camera.
  67720. * @param camera The camera to dispose the effect on.
  67721. */
  67722. disposeEffects(camera: Camera): void;
  67723. /**
  67724. * @hidden Internal
  67725. */
  67726. _updateEffects(): void;
  67727. /**
  67728. * Internal
  67729. * @returns if all the contained post processes are ready.
  67730. * @hidden
  67731. */
  67732. _isReady(): boolean;
  67733. }
  67734. }
  67735. declare module "babylonjs/Shaders/displayPass.fragment" {
  67736. /** @hidden */
  67737. export var displayPassPixelShader: {
  67738. name: string;
  67739. shader: string;
  67740. };
  67741. }
  67742. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67743. import { Nullable } from "babylonjs/types";
  67744. import { Camera } from "babylonjs/Cameras/camera";
  67745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67746. import { Engine } from "babylonjs/Engines/engine";
  67747. import "babylonjs/Shaders/displayPass.fragment";
  67748. /**
  67749. * DisplayPassPostProcess which produces an output the same as it's input
  67750. */
  67751. export class DisplayPassPostProcess extends PostProcess {
  67752. /**
  67753. * Creates the DisplayPassPostProcess
  67754. * @param name The name of the effect.
  67755. * @param options The required width/height ratio to downsize to before computing the render pass.
  67756. * @param camera The camera to apply the render pass to.
  67757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67758. * @param engine The engine which the post process will be applied. (default: current engine)
  67759. * @param reusable If the post process can be reused on the same frame. (default: false)
  67760. */
  67761. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67762. }
  67763. }
  67764. declare module "babylonjs/Shaders/filter.fragment" {
  67765. /** @hidden */
  67766. export var filterPixelShader: {
  67767. name: string;
  67768. shader: string;
  67769. };
  67770. }
  67771. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67772. import { Nullable } from "babylonjs/types";
  67773. import { Matrix } from "babylonjs/Maths/math.vector";
  67774. import { Camera } from "babylonjs/Cameras/camera";
  67775. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67776. import { Engine } from "babylonjs/Engines/engine";
  67777. import "babylonjs/Shaders/filter.fragment";
  67778. /**
  67779. * Applies a kernel filter to the image
  67780. */
  67781. export class FilterPostProcess extends PostProcess {
  67782. /** The matrix to be applied to the image */
  67783. kernelMatrix: Matrix;
  67784. /**
  67785. *
  67786. * @param name The name of the effect.
  67787. * @param kernelMatrix The matrix to be applied to the image
  67788. * @param options The required width/height ratio to downsize to before computing the render pass.
  67789. * @param camera The camera to apply the render pass to.
  67790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67791. * @param engine The engine which the post process will be applied. (default: current engine)
  67792. * @param reusable If the post process can be reused on the same frame. (default: false)
  67793. */
  67794. constructor(name: string,
  67795. /** The matrix to be applied to the image */
  67796. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67797. }
  67798. }
  67799. declare module "babylonjs/Shaders/fxaa.fragment" {
  67800. /** @hidden */
  67801. export var fxaaPixelShader: {
  67802. name: string;
  67803. shader: string;
  67804. };
  67805. }
  67806. declare module "babylonjs/Shaders/fxaa.vertex" {
  67807. /** @hidden */
  67808. export var fxaaVertexShader: {
  67809. name: string;
  67810. shader: string;
  67811. };
  67812. }
  67813. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67814. import { Nullable } from "babylonjs/types";
  67815. import { Camera } from "babylonjs/Cameras/camera";
  67816. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67817. import { Engine } from "babylonjs/Engines/engine";
  67818. import "babylonjs/Shaders/fxaa.fragment";
  67819. import "babylonjs/Shaders/fxaa.vertex";
  67820. /**
  67821. * Fxaa post process
  67822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67823. */
  67824. export class FxaaPostProcess extends PostProcess {
  67825. /** @hidden */
  67826. texelWidth: number;
  67827. /** @hidden */
  67828. texelHeight: number;
  67829. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67830. private _getDefines;
  67831. }
  67832. }
  67833. declare module "babylonjs/Shaders/grain.fragment" {
  67834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67835. /** @hidden */
  67836. export var grainPixelShader: {
  67837. name: string;
  67838. shader: string;
  67839. };
  67840. }
  67841. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67842. import { Nullable } from "babylonjs/types";
  67843. import { Camera } from "babylonjs/Cameras/camera";
  67844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67845. import { Engine } from "babylonjs/Engines/engine";
  67846. import "babylonjs/Shaders/grain.fragment";
  67847. /**
  67848. * The GrainPostProcess adds noise to the image at mid luminance levels
  67849. */
  67850. export class GrainPostProcess extends PostProcess {
  67851. /**
  67852. * The intensity of the grain added (default: 30)
  67853. */
  67854. intensity: number;
  67855. /**
  67856. * If the grain should be randomized on every frame
  67857. */
  67858. animated: boolean;
  67859. /**
  67860. * Creates a new instance of @see GrainPostProcess
  67861. * @param name The name of the effect.
  67862. * @param options The required width/height ratio to downsize to before computing the render pass.
  67863. * @param camera The camera to apply the render pass to.
  67864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67865. * @param engine The engine which the post process will be applied. (default: current engine)
  67866. * @param reusable If the post process can be reused on the same frame. (default: false)
  67867. * @param textureType Type of textures used when performing the post process. (default: 0)
  67868. * @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)
  67869. */
  67870. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67871. }
  67872. }
  67873. declare module "babylonjs/Shaders/highlights.fragment" {
  67874. /** @hidden */
  67875. export var highlightsPixelShader: {
  67876. name: string;
  67877. shader: string;
  67878. };
  67879. }
  67880. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67881. import { Nullable } from "babylonjs/types";
  67882. import { Camera } from "babylonjs/Cameras/camera";
  67883. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67884. import { Engine } from "babylonjs/Engines/engine";
  67885. import "babylonjs/Shaders/highlights.fragment";
  67886. /**
  67887. * Extracts highlights from the image
  67888. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67889. */
  67890. export class HighlightsPostProcess extends PostProcess {
  67891. /**
  67892. * Extracts highlights from the image
  67893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67894. * @param name The name of the effect.
  67895. * @param options The required width/height ratio to downsize to before computing the render pass.
  67896. * @param camera The camera to apply the render pass to.
  67897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67898. * @param engine The engine which the post process will be applied. (default: current engine)
  67899. * @param reusable If the post process can be reused on the same frame. (default: false)
  67900. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67901. */
  67902. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67903. }
  67904. }
  67905. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67906. /** @hidden */
  67907. export var mrtFragmentDeclaration: {
  67908. name: string;
  67909. shader: string;
  67910. };
  67911. }
  67912. declare module "babylonjs/Shaders/geometry.fragment" {
  67913. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67914. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67915. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67916. /** @hidden */
  67917. export var geometryPixelShader: {
  67918. name: string;
  67919. shader: string;
  67920. };
  67921. }
  67922. declare module "babylonjs/Shaders/geometry.vertex" {
  67923. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67926. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67928. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67929. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67930. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67931. /** @hidden */
  67932. export var geometryVertexShader: {
  67933. name: string;
  67934. shader: string;
  67935. };
  67936. }
  67937. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67938. import { Matrix } from "babylonjs/Maths/math.vector";
  67939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67940. import { Mesh } from "babylonjs/Meshes/mesh";
  67941. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67942. import { Effect } from "babylonjs/Materials/effect";
  67943. import { Scene } from "babylonjs/scene";
  67944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67945. import "babylonjs/Shaders/geometry.fragment";
  67946. import "babylonjs/Shaders/geometry.vertex";
  67947. /** @hidden */
  67948. interface ISavedTransformationMatrix {
  67949. world: Matrix;
  67950. viewProjection: Matrix;
  67951. }
  67952. /**
  67953. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67954. */
  67955. export class GeometryBufferRenderer {
  67956. /**
  67957. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67958. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67959. */
  67960. static readonly POSITION_TEXTURE_TYPE: number;
  67961. /**
  67962. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67963. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67964. */
  67965. static readonly VELOCITY_TEXTURE_TYPE: number;
  67966. /**
  67967. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67968. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67969. */
  67970. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67971. /**
  67972. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67973. * in order to compute objects velocities when enableVelocity is set to "true"
  67974. * @hidden
  67975. */
  67976. _previousTransformationMatrices: {
  67977. [index: number]: ISavedTransformationMatrix;
  67978. };
  67979. /**
  67980. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67981. * in order to compute objects velocities when enableVelocity is set to "true"
  67982. * @hidden
  67983. */
  67984. _previousBonesTransformationMatrices: {
  67985. [index: number]: Float32Array;
  67986. };
  67987. /**
  67988. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67989. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67990. */
  67991. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67992. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67993. renderTransparentMeshes: boolean;
  67994. private _scene;
  67995. private _multiRenderTarget;
  67996. private _ratio;
  67997. private _enablePosition;
  67998. private _enableVelocity;
  67999. private _enableReflectivity;
  68000. private _positionIndex;
  68001. private _velocityIndex;
  68002. private _reflectivityIndex;
  68003. protected _effect: Effect;
  68004. protected _cachedDefines: string;
  68005. /**
  68006. * Set the render list (meshes to be rendered) used in the G buffer.
  68007. */
  68008. set renderList(meshes: Mesh[]);
  68009. /**
  68010. * Gets wether or not G buffer are supported by the running hardware.
  68011. * This requires draw buffer supports
  68012. */
  68013. get isSupported(): boolean;
  68014. /**
  68015. * Returns the index of the given texture type in the G-Buffer textures array
  68016. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68017. * @returns the index of the given texture type in the G-Buffer textures array
  68018. */
  68019. getTextureIndex(textureType: number): number;
  68020. /**
  68021. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68022. */
  68023. get enablePosition(): boolean;
  68024. /**
  68025. * Sets whether or not objects positions are enabled for the G buffer.
  68026. */
  68027. set enablePosition(enable: boolean);
  68028. /**
  68029. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68030. */
  68031. get enableVelocity(): boolean;
  68032. /**
  68033. * Sets wether or not objects velocities are enabled for the G buffer.
  68034. */
  68035. set enableVelocity(enable: boolean);
  68036. /**
  68037. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68038. */
  68039. get enableReflectivity(): boolean;
  68040. /**
  68041. * Sets wether or not objects roughness are enabled for the G buffer.
  68042. */
  68043. set enableReflectivity(enable: boolean);
  68044. /**
  68045. * Gets the scene associated with the buffer.
  68046. */
  68047. get scene(): Scene;
  68048. /**
  68049. * Gets the ratio used by the buffer during its creation.
  68050. * How big is the buffer related to the main canvas.
  68051. */
  68052. get ratio(): number;
  68053. /** @hidden */
  68054. static _SceneComponentInitialization: (scene: Scene) => void;
  68055. /**
  68056. * Creates a new G Buffer for the scene
  68057. * @param scene The scene the buffer belongs to
  68058. * @param ratio How big is the buffer related to the main canvas.
  68059. */
  68060. constructor(scene: Scene, ratio?: number);
  68061. /**
  68062. * Checks wether everything is ready to render a submesh to the G buffer.
  68063. * @param subMesh the submesh to check readiness for
  68064. * @param useInstances is the mesh drawn using instance or not
  68065. * @returns true if ready otherwise false
  68066. */
  68067. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68068. /**
  68069. * Gets the current underlying G Buffer.
  68070. * @returns the buffer
  68071. */
  68072. getGBuffer(): MultiRenderTarget;
  68073. /**
  68074. * Gets the number of samples used to render the buffer (anti aliasing).
  68075. */
  68076. get samples(): number;
  68077. /**
  68078. * Sets the number of samples used to render the buffer (anti aliasing).
  68079. */
  68080. set samples(value: number);
  68081. /**
  68082. * Disposes the renderer and frees up associated resources.
  68083. */
  68084. dispose(): void;
  68085. protected _createRenderTargets(): void;
  68086. private _copyBonesTransformationMatrices;
  68087. }
  68088. }
  68089. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68090. import { Nullable } from "babylonjs/types";
  68091. import { Scene } from "babylonjs/scene";
  68092. import { ISceneComponent } from "babylonjs/sceneComponent";
  68093. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68094. module "babylonjs/scene" {
  68095. interface Scene {
  68096. /** @hidden (Backing field) */
  68097. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68098. /**
  68099. * Gets or Sets the current geometry buffer associated to the scene.
  68100. */
  68101. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68102. /**
  68103. * Enables a GeometryBufferRender and associates it with the scene
  68104. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68105. * @returns the GeometryBufferRenderer
  68106. */
  68107. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68108. /**
  68109. * Disables the GeometryBufferRender associated with the scene
  68110. */
  68111. disableGeometryBufferRenderer(): void;
  68112. }
  68113. }
  68114. /**
  68115. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68116. * in several rendering techniques.
  68117. */
  68118. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68119. /**
  68120. * The component name helpful to identify the component in the list of scene components.
  68121. */
  68122. readonly name: string;
  68123. /**
  68124. * The scene the component belongs to.
  68125. */
  68126. scene: Scene;
  68127. /**
  68128. * Creates a new instance of the component for the given scene
  68129. * @param scene Defines the scene to register the component in
  68130. */
  68131. constructor(scene: Scene);
  68132. /**
  68133. * Registers the component in a given scene
  68134. */
  68135. register(): void;
  68136. /**
  68137. * Rebuilds the elements related to this component in case of
  68138. * context lost for instance.
  68139. */
  68140. rebuild(): void;
  68141. /**
  68142. * Disposes the component and the associated ressources
  68143. */
  68144. dispose(): void;
  68145. private _gatherRenderTargets;
  68146. }
  68147. }
  68148. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68149. /** @hidden */
  68150. export var motionBlurPixelShader: {
  68151. name: string;
  68152. shader: string;
  68153. };
  68154. }
  68155. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68156. import { Nullable } from "babylonjs/types";
  68157. import { Camera } from "babylonjs/Cameras/camera";
  68158. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68159. import { Scene } from "babylonjs/scene";
  68160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68161. import "babylonjs/Animations/animatable";
  68162. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68163. import "babylonjs/Shaders/motionBlur.fragment";
  68164. import { Engine } from "babylonjs/Engines/engine";
  68165. /**
  68166. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68167. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68168. * As an example, all you have to do is to create the post-process:
  68169. * var mb = new BABYLON.MotionBlurPostProcess(
  68170. * 'mb', // The name of the effect.
  68171. * scene, // The scene containing the objects to blur according to their velocity.
  68172. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68173. * camera // The camera to apply the render pass to.
  68174. * );
  68175. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68176. */
  68177. export class MotionBlurPostProcess extends PostProcess {
  68178. /**
  68179. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68180. */
  68181. motionStrength: number;
  68182. /**
  68183. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68184. */
  68185. get motionBlurSamples(): number;
  68186. /**
  68187. * Sets the number of iterations to be used for motion blur quality
  68188. */
  68189. set motionBlurSamples(samples: number);
  68190. private _motionBlurSamples;
  68191. private _geometryBufferRenderer;
  68192. /**
  68193. * Creates a new instance MotionBlurPostProcess
  68194. * @param name The name of the effect.
  68195. * @param scene The scene containing the objects to blur according to their velocity.
  68196. * @param options The required width/height ratio to downsize to before computing the render pass.
  68197. * @param camera The camera to apply the render pass to.
  68198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68199. * @param engine The engine which the post process will be applied. (default: current engine)
  68200. * @param reusable If the post process can be reused on the same frame. (default: false)
  68201. * @param textureType Type of textures used when performing the post process. (default: 0)
  68202. * @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)
  68203. */
  68204. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68205. /**
  68206. * Excludes the given skinned mesh from computing bones velocities.
  68207. * 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.
  68208. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68209. */
  68210. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68211. /**
  68212. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68213. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68214. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68215. */
  68216. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68217. /**
  68218. * Disposes the post process.
  68219. * @param camera The camera to dispose the post process on.
  68220. */
  68221. dispose(camera?: Camera): void;
  68222. }
  68223. }
  68224. declare module "babylonjs/Shaders/refraction.fragment" {
  68225. /** @hidden */
  68226. export var refractionPixelShader: {
  68227. name: string;
  68228. shader: string;
  68229. };
  68230. }
  68231. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68232. import { Color3 } from "babylonjs/Maths/math.color";
  68233. import { Camera } from "babylonjs/Cameras/camera";
  68234. import { Texture } from "babylonjs/Materials/Textures/texture";
  68235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68236. import { Engine } from "babylonjs/Engines/engine";
  68237. import "babylonjs/Shaders/refraction.fragment";
  68238. /**
  68239. * Post process which applies a refractin texture
  68240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68241. */
  68242. export class RefractionPostProcess extends PostProcess {
  68243. /** the base color of the refraction (used to taint the rendering) */
  68244. color: Color3;
  68245. /** simulated refraction depth */
  68246. depth: number;
  68247. /** the coefficient of the base color (0 to remove base color tainting) */
  68248. colorLevel: number;
  68249. private _refTexture;
  68250. private _ownRefractionTexture;
  68251. /**
  68252. * Gets or sets the refraction texture
  68253. * Please note that you are responsible for disposing the texture if you set it manually
  68254. */
  68255. get refractionTexture(): Texture;
  68256. set refractionTexture(value: Texture);
  68257. /**
  68258. * Initializes the RefractionPostProcess
  68259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68260. * @param name The name of the effect.
  68261. * @param refractionTextureUrl Url of the refraction texture to use
  68262. * @param color the base color of the refraction (used to taint the rendering)
  68263. * @param depth simulated refraction depth
  68264. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68265. * @param camera The camera to apply the render pass to.
  68266. * @param options The required width/height ratio to downsize to before computing the render pass.
  68267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68268. * @param engine The engine which the post process will be applied. (default: current engine)
  68269. * @param reusable If the post process can be reused on the same frame. (default: false)
  68270. */
  68271. constructor(name: string, refractionTextureUrl: string,
  68272. /** the base color of the refraction (used to taint the rendering) */
  68273. color: Color3,
  68274. /** simulated refraction depth */
  68275. depth: number,
  68276. /** the coefficient of the base color (0 to remove base color tainting) */
  68277. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68278. /**
  68279. * Disposes of the post process
  68280. * @param camera Camera to dispose post process on
  68281. */
  68282. dispose(camera: Camera): void;
  68283. }
  68284. }
  68285. declare module "babylonjs/Shaders/sharpen.fragment" {
  68286. /** @hidden */
  68287. export var sharpenPixelShader: {
  68288. name: string;
  68289. shader: string;
  68290. };
  68291. }
  68292. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68293. import { Nullable } from "babylonjs/types";
  68294. import { Camera } from "babylonjs/Cameras/camera";
  68295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68296. import "babylonjs/Shaders/sharpen.fragment";
  68297. import { Engine } from "babylonjs/Engines/engine";
  68298. /**
  68299. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68300. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68301. */
  68302. export class SharpenPostProcess extends PostProcess {
  68303. /**
  68304. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68305. */
  68306. colorAmount: number;
  68307. /**
  68308. * How much sharpness should be applied (default: 0.3)
  68309. */
  68310. edgeAmount: number;
  68311. /**
  68312. * Creates a new instance ConvolutionPostProcess
  68313. * @param name The name of the effect.
  68314. * @param options The required width/height ratio to downsize to before computing the render pass.
  68315. * @param camera The camera to apply the render pass to.
  68316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68317. * @param engine The engine which the post process will be applied. (default: current engine)
  68318. * @param reusable If the post process can be reused on the same frame. (default: false)
  68319. * @param textureType Type of textures used when performing the post process. (default: 0)
  68320. * @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)
  68321. */
  68322. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68323. }
  68324. }
  68325. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68326. import { Nullable } from "babylonjs/types";
  68327. import { Camera } from "babylonjs/Cameras/camera";
  68328. import { Engine } from "babylonjs/Engines/engine";
  68329. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68330. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68331. /**
  68332. * PostProcessRenderPipeline
  68333. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68334. */
  68335. export class PostProcessRenderPipeline {
  68336. private engine;
  68337. private _renderEffects;
  68338. private _renderEffectsForIsolatedPass;
  68339. /**
  68340. * List of inspectable custom properties (used by the Inspector)
  68341. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68342. */
  68343. inspectableCustomProperties: IInspectable[];
  68344. /**
  68345. * @hidden
  68346. */
  68347. protected _cameras: Camera[];
  68348. /** @hidden */
  68349. _name: string;
  68350. /**
  68351. * Gets pipeline name
  68352. */
  68353. get name(): string;
  68354. /** Gets the list of attached cameras */
  68355. get cameras(): Camera[];
  68356. /**
  68357. * Initializes a PostProcessRenderPipeline
  68358. * @param engine engine to add the pipeline to
  68359. * @param name name of the pipeline
  68360. */
  68361. constructor(engine: Engine, name: string);
  68362. /**
  68363. * Gets the class name
  68364. * @returns "PostProcessRenderPipeline"
  68365. */
  68366. getClassName(): string;
  68367. /**
  68368. * If all the render effects in the pipeline are supported
  68369. */
  68370. get isSupported(): boolean;
  68371. /**
  68372. * Adds an effect to the pipeline
  68373. * @param renderEffect the effect to add
  68374. */
  68375. addEffect(renderEffect: PostProcessRenderEffect): void;
  68376. /** @hidden */
  68377. _rebuild(): void;
  68378. /** @hidden */
  68379. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68380. /** @hidden */
  68381. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68382. /** @hidden */
  68383. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68384. /** @hidden */
  68385. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68386. /** @hidden */
  68387. _attachCameras(cameras: Camera, unique: boolean): void;
  68388. /** @hidden */
  68389. _attachCameras(cameras: Camera[], unique: boolean): void;
  68390. /** @hidden */
  68391. _detachCameras(cameras: Camera): void;
  68392. /** @hidden */
  68393. _detachCameras(cameras: Nullable<Camera[]>): void;
  68394. /** @hidden */
  68395. _update(): void;
  68396. /** @hidden */
  68397. _reset(): void;
  68398. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68399. /**
  68400. * Disposes of the pipeline
  68401. */
  68402. dispose(): void;
  68403. }
  68404. }
  68405. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68406. import { Camera } from "babylonjs/Cameras/camera";
  68407. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68408. /**
  68409. * PostProcessRenderPipelineManager class
  68410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68411. */
  68412. export class PostProcessRenderPipelineManager {
  68413. private _renderPipelines;
  68414. /**
  68415. * Initializes a PostProcessRenderPipelineManager
  68416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68417. */
  68418. constructor();
  68419. /**
  68420. * Gets the list of supported render pipelines
  68421. */
  68422. get supportedPipelines(): PostProcessRenderPipeline[];
  68423. /**
  68424. * Adds a pipeline to the manager
  68425. * @param renderPipeline The pipeline to add
  68426. */
  68427. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68428. /**
  68429. * Attaches a camera to the pipeline
  68430. * @param renderPipelineName The name of the pipeline to attach to
  68431. * @param cameras the camera to attach
  68432. * @param unique if the camera can be attached multiple times to the pipeline
  68433. */
  68434. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68435. /**
  68436. * Detaches a camera from the pipeline
  68437. * @param renderPipelineName The name of the pipeline to detach from
  68438. * @param cameras the camera to detach
  68439. */
  68440. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68441. /**
  68442. * Enables an effect by name on a pipeline
  68443. * @param renderPipelineName the name of the pipeline to enable the effect in
  68444. * @param renderEffectName the name of the effect to enable
  68445. * @param cameras the cameras that the effect should be enabled on
  68446. */
  68447. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68448. /**
  68449. * Disables an effect by name on a pipeline
  68450. * @param renderPipelineName the name of the pipeline to disable the effect in
  68451. * @param renderEffectName the name of the effect to disable
  68452. * @param cameras the cameras that the effect should be disabled on
  68453. */
  68454. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68455. /**
  68456. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68457. */
  68458. update(): void;
  68459. /** @hidden */
  68460. _rebuild(): void;
  68461. /**
  68462. * Disposes of the manager and pipelines
  68463. */
  68464. dispose(): void;
  68465. }
  68466. }
  68467. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68468. import { ISceneComponent } from "babylonjs/sceneComponent";
  68469. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68470. import { Scene } from "babylonjs/scene";
  68471. module "babylonjs/scene" {
  68472. interface Scene {
  68473. /** @hidden (Backing field) */
  68474. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68475. /**
  68476. * Gets the postprocess render pipeline manager
  68477. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68478. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68479. */
  68480. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68481. }
  68482. }
  68483. /**
  68484. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68485. */
  68486. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68487. /**
  68488. * The component name helpfull to identify the component in the list of scene components.
  68489. */
  68490. readonly name: string;
  68491. /**
  68492. * The scene the component belongs to.
  68493. */
  68494. scene: Scene;
  68495. /**
  68496. * Creates a new instance of the component for the given scene
  68497. * @param scene Defines the scene to register the component in
  68498. */
  68499. constructor(scene: Scene);
  68500. /**
  68501. * Registers the component in a given scene
  68502. */
  68503. register(): void;
  68504. /**
  68505. * Rebuilds the elements related to this component in case of
  68506. * context lost for instance.
  68507. */
  68508. rebuild(): void;
  68509. /**
  68510. * Disposes the component and the associated ressources
  68511. */
  68512. dispose(): void;
  68513. private _gatherRenderTargets;
  68514. }
  68515. }
  68516. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68517. import { Nullable } from "babylonjs/types";
  68518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68519. import { Camera } from "babylonjs/Cameras/camera";
  68520. import { IDisposable } from "babylonjs/scene";
  68521. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68522. import { Scene } from "babylonjs/scene";
  68523. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68524. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68525. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68526. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68527. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68528. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68529. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68530. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68531. import { Animation } from "babylonjs/Animations/animation";
  68532. /**
  68533. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68534. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68535. */
  68536. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68537. private _scene;
  68538. private _camerasToBeAttached;
  68539. /**
  68540. * ID of the sharpen post process,
  68541. */
  68542. private readonly SharpenPostProcessId;
  68543. /**
  68544. * @ignore
  68545. * ID of the image processing post process;
  68546. */
  68547. readonly ImageProcessingPostProcessId: string;
  68548. /**
  68549. * @ignore
  68550. * ID of the Fast Approximate Anti-Aliasing post process;
  68551. */
  68552. readonly FxaaPostProcessId: string;
  68553. /**
  68554. * ID of the chromatic aberration post process,
  68555. */
  68556. private readonly ChromaticAberrationPostProcessId;
  68557. /**
  68558. * ID of the grain post process
  68559. */
  68560. private readonly GrainPostProcessId;
  68561. /**
  68562. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68563. */
  68564. sharpen: SharpenPostProcess;
  68565. private _sharpenEffect;
  68566. private bloom;
  68567. /**
  68568. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68569. */
  68570. depthOfField: DepthOfFieldEffect;
  68571. /**
  68572. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68573. */
  68574. fxaa: FxaaPostProcess;
  68575. /**
  68576. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68577. */
  68578. imageProcessing: ImageProcessingPostProcess;
  68579. /**
  68580. * Chromatic aberration post process which will shift rgb colors in the image
  68581. */
  68582. chromaticAberration: ChromaticAberrationPostProcess;
  68583. private _chromaticAberrationEffect;
  68584. /**
  68585. * Grain post process which add noise to the image
  68586. */
  68587. grain: GrainPostProcess;
  68588. private _grainEffect;
  68589. /**
  68590. * Glow post process which adds a glow to emissive areas of the image
  68591. */
  68592. private _glowLayer;
  68593. /**
  68594. * Animations which can be used to tweak settings over a period of time
  68595. */
  68596. animations: Animation[];
  68597. private _imageProcessingConfigurationObserver;
  68598. private _sharpenEnabled;
  68599. private _bloomEnabled;
  68600. private _depthOfFieldEnabled;
  68601. private _depthOfFieldBlurLevel;
  68602. private _fxaaEnabled;
  68603. private _imageProcessingEnabled;
  68604. private _defaultPipelineTextureType;
  68605. private _bloomScale;
  68606. private _chromaticAberrationEnabled;
  68607. private _grainEnabled;
  68608. private _buildAllowed;
  68609. /**
  68610. * Gets active scene
  68611. */
  68612. get scene(): Scene;
  68613. /**
  68614. * Enable or disable the sharpen process from the pipeline
  68615. */
  68616. set sharpenEnabled(enabled: boolean);
  68617. get sharpenEnabled(): boolean;
  68618. private _resizeObserver;
  68619. private _hardwareScaleLevel;
  68620. private _bloomKernel;
  68621. /**
  68622. * Specifies the size of the bloom blur kernel, relative to the final output size
  68623. */
  68624. get bloomKernel(): number;
  68625. set bloomKernel(value: number);
  68626. /**
  68627. * Specifies the weight of the bloom in the final rendering
  68628. */
  68629. private _bloomWeight;
  68630. /**
  68631. * Specifies the luma threshold for the area that will be blurred by the bloom
  68632. */
  68633. private _bloomThreshold;
  68634. private _hdr;
  68635. /**
  68636. * The strength of the bloom.
  68637. */
  68638. set bloomWeight(value: number);
  68639. get bloomWeight(): number;
  68640. /**
  68641. * The strength of the bloom.
  68642. */
  68643. set bloomThreshold(value: number);
  68644. get bloomThreshold(): number;
  68645. /**
  68646. * The scale of the bloom, lower value will provide better performance.
  68647. */
  68648. set bloomScale(value: number);
  68649. get bloomScale(): number;
  68650. /**
  68651. * Enable or disable the bloom from the pipeline
  68652. */
  68653. set bloomEnabled(enabled: boolean);
  68654. get bloomEnabled(): boolean;
  68655. private _rebuildBloom;
  68656. /**
  68657. * If the depth of field is enabled.
  68658. */
  68659. get depthOfFieldEnabled(): boolean;
  68660. set depthOfFieldEnabled(enabled: boolean);
  68661. /**
  68662. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68663. */
  68664. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68665. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68666. /**
  68667. * If the anti aliasing is enabled.
  68668. */
  68669. set fxaaEnabled(enabled: boolean);
  68670. get fxaaEnabled(): boolean;
  68671. private _samples;
  68672. /**
  68673. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68674. */
  68675. set samples(sampleCount: number);
  68676. get samples(): number;
  68677. /**
  68678. * If image processing is enabled.
  68679. */
  68680. set imageProcessingEnabled(enabled: boolean);
  68681. get imageProcessingEnabled(): boolean;
  68682. /**
  68683. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68684. */
  68685. set glowLayerEnabled(enabled: boolean);
  68686. get glowLayerEnabled(): boolean;
  68687. /**
  68688. * Gets the glow layer (or null if not defined)
  68689. */
  68690. get glowLayer(): Nullable<GlowLayer>;
  68691. /**
  68692. * Enable or disable the chromaticAberration process from the pipeline
  68693. */
  68694. set chromaticAberrationEnabled(enabled: boolean);
  68695. get chromaticAberrationEnabled(): boolean;
  68696. /**
  68697. * Enable or disable the grain process from the pipeline
  68698. */
  68699. set grainEnabled(enabled: boolean);
  68700. get grainEnabled(): boolean;
  68701. /**
  68702. * @constructor
  68703. * @param name - The rendering pipeline name (default: "")
  68704. * @param hdr - If high dynamic range textures should be used (default: true)
  68705. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68706. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68707. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68708. */
  68709. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68710. /**
  68711. * Get the class name
  68712. * @returns "DefaultRenderingPipeline"
  68713. */
  68714. getClassName(): string;
  68715. /**
  68716. * Force the compilation of the entire pipeline.
  68717. */
  68718. prepare(): void;
  68719. private _hasCleared;
  68720. private _prevPostProcess;
  68721. private _prevPrevPostProcess;
  68722. private _setAutoClearAndTextureSharing;
  68723. private _depthOfFieldSceneObserver;
  68724. private _buildPipeline;
  68725. private _disposePostProcesses;
  68726. /**
  68727. * Adds a camera to the pipeline
  68728. * @param camera the camera to be added
  68729. */
  68730. addCamera(camera: Camera): void;
  68731. /**
  68732. * Removes a camera from the pipeline
  68733. * @param camera the camera to remove
  68734. */
  68735. removeCamera(camera: Camera): void;
  68736. /**
  68737. * Dispose of the pipeline and stop all post processes
  68738. */
  68739. dispose(): void;
  68740. /**
  68741. * Serialize the rendering pipeline (Used when exporting)
  68742. * @returns the serialized object
  68743. */
  68744. serialize(): any;
  68745. /**
  68746. * Parse the serialized pipeline
  68747. * @param source Source pipeline.
  68748. * @param scene The scene to load the pipeline to.
  68749. * @param rootUrl The URL of the serialized pipeline.
  68750. * @returns An instantiated pipeline from the serialized object.
  68751. */
  68752. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68753. }
  68754. }
  68755. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68756. /** @hidden */
  68757. export var lensHighlightsPixelShader: {
  68758. name: string;
  68759. shader: string;
  68760. };
  68761. }
  68762. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68763. /** @hidden */
  68764. export var depthOfFieldPixelShader: {
  68765. name: string;
  68766. shader: string;
  68767. };
  68768. }
  68769. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68770. import { Camera } from "babylonjs/Cameras/camera";
  68771. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68772. import { Scene } from "babylonjs/scene";
  68773. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68774. import "babylonjs/Shaders/chromaticAberration.fragment";
  68775. import "babylonjs/Shaders/lensHighlights.fragment";
  68776. import "babylonjs/Shaders/depthOfField.fragment";
  68777. /**
  68778. * BABYLON.JS Chromatic Aberration GLSL Shader
  68779. * Author: Olivier Guyot
  68780. * Separates very slightly R, G and B colors on the edges of the screen
  68781. * Inspired by Francois Tarlier & Martins Upitis
  68782. */
  68783. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68784. /**
  68785. * @ignore
  68786. * The chromatic aberration PostProcess id in the pipeline
  68787. */
  68788. LensChromaticAberrationEffect: string;
  68789. /**
  68790. * @ignore
  68791. * The highlights enhancing PostProcess id in the pipeline
  68792. */
  68793. HighlightsEnhancingEffect: string;
  68794. /**
  68795. * @ignore
  68796. * The depth-of-field PostProcess id in the pipeline
  68797. */
  68798. LensDepthOfFieldEffect: string;
  68799. private _scene;
  68800. private _depthTexture;
  68801. private _grainTexture;
  68802. private _chromaticAberrationPostProcess;
  68803. private _highlightsPostProcess;
  68804. private _depthOfFieldPostProcess;
  68805. private _edgeBlur;
  68806. private _grainAmount;
  68807. private _chromaticAberration;
  68808. private _distortion;
  68809. private _highlightsGain;
  68810. private _highlightsThreshold;
  68811. private _dofDistance;
  68812. private _dofAperture;
  68813. private _dofDarken;
  68814. private _dofPentagon;
  68815. private _blurNoise;
  68816. /**
  68817. * @constructor
  68818. *
  68819. * Effect parameters are as follow:
  68820. * {
  68821. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68822. * edge_blur: number; // from 0 to x (1 for realism)
  68823. * distortion: number; // from 0 to x (1 for realism)
  68824. * grain_amount: number; // from 0 to 1
  68825. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68826. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68827. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68828. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68829. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68830. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68831. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68832. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68833. * }
  68834. * Note: if an effect parameter is unset, effect is disabled
  68835. *
  68836. * @param name The rendering pipeline name
  68837. * @param parameters - An object containing all parameters (see above)
  68838. * @param scene The scene linked to this pipeline
  68839. * @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)
  68840. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68841. */
  68842. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68843. /**
  68844. * Get the class name
  68845. * @returns "LensRenderingPipeline"
  68846. */
  68847. getClassName(): string;
  68848. /**
  68849. * Gets associated scene
  68850. */
  68851. get scene(): Scene;
  68852. /**
  68853. * Gets or sets the edge blur
  68854. */
  68855. get edgeBlur(): number;
  68856. set edgeBlur(value: number);
  68857. /**
  68858. * Gets or sets the grain amount
  68859. */
  68860. get grainAmount(): number;
  68861. set grainAmount(value: number);
  68862. /**
  68863. * Gets or sets the chromatic aberration amount
  68864. */
  68865. get chromaticAberration(): number;
  68866. set chromaticAberration(value: number);
  68867. /**
  68868. * Gets or sets the depth of field aperture
  68869. */
  68870. get dofAperture(): number;
  68871. set dofAperture(value: number);
  68872. /**
  68873. * Gets or sets the edge distortion
  68874. */
  68875. get edgeDistortion(): number;
  68876. set edgeDistortion(value: number);
  68877. /**
  68878. * Gets or sets the depth of field distortion
  68879. */
  68880. get dofDistortion(): number;
  68881. set dofDistortion(value: number);
  68882. /**
  68883. * Gets or sets the darken out of focus amount
  68884. */
  68885. get darkenOutOfFocus(): number;
  68886. set darkenOutOfFocus(value: number);
  68887. /**
  68888. * Gets or sets a boolean indicating if blur noise is enabled
  68889. */
  68890. get blurNoise(): boolean;
  68891. set blurNoise(value: boolean);
  68892. /**
  68893. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68894. */
  68895. get pentagonBokeh(): boolean;
  68896. set pentagonBokeh(value: boolean);
  68897. /**
  68898. * Gets or sets the highlight grain amount
  68899. */
  68900. get highlightsGain(): number;
  68901. set highlightsGain(value: number);
  68902. /**
  68903. * Gets or sets the highlight threshold
  68904. */
  68905. get highlightsThreshold(): number;
  68906. set highlightsThreshold(value: number);
  68907. /**
  68908. * Sets the amount of blur at the edges
  68909. * @param amount blur amount
  68910. */
  68911. setEdgeBlur(amount: number): void;
  68912. /**
  68913. * Sets edge blur to 0
  68914. */
  68915. disableEdgeBlur(): void;
  68916. /**
  68917. * Sets the amout of grain
  68918. * @param amount Amount of grain
  68919. */
  68920. setGrainAmount(amount: number): void;
  68921. /**
  68922. * Set grain amount to 0
  68923. */
  68924. disableGrain(): void;
  68925. /**
  68926. * Sets the chromatic aberration amount
  68927. * @param amount amount of chromatic aberration
  68928. */
  68929. setChromaticAberration(amount: number): void;
  68930. /**
  68931. * Sets chromatic aberration amount to 0
  68932. */
  68933. disableChromaticAberration(): void;
  68934. /**
  68935. * Sets the EdgeDistortion amount
  68936. * @param amount amount of EdgeDistortion
  68937. */
  68938. setEdgeDistortion(amount: number): void;
  68939. /**
  68940. * Sets edge distortion to 0
  68941. */
  68942. disableEdgeDistortion(): void;
  68943. /**
  68944. * Sets the FocusDistance amount
  68945. * @param amount amount of FocusDistance
  68946. */
  68947. setFocusDistance(amount: number): void;
  68948. /**
  68949. * Disables depth of field
  68950. */
  68951. disableDepthOfField(): void;
  68952. /**
  68953. * Sets the Aperture amount
  68954. * @param amount amount of Aperture
  68955. */
  68956. setAperture(amount: number): void;
  68957. /**
  68958. * Sets the DarkenOutOfFocus amount
  68959. * @param amount amount of DarkenOutOfFocus
  68960. */
  68961. setDarkenOutOfFocus(amount: number): void;
  68962. private _pentagonBokehIsEnabled;
  68963. /**
  68964. * Creates a pentagon bokeh effect
  68965. */
  68966. enablePentagonBokeh(): void;
  68967. /**
  68968. * Disables the pentagon bokeh effect
  68969. */
  68970. disablePentagonBokeh(): void;
  68971. /**
  68972. * Enables noise blur
  68973. */
  68974. enableNoiseBlur(): void;
  68975. /**
  68976. * Disables noise blur
  68977. */
  68978. disableNoiseBlur(): void;
  68979. /**
  68980. * Sets the HighlightsGain amount
  68981. * @param amount amount of HighlightsGain
  68982. */
  68983. setHighlightsGain(amount: number): void;
  68984. /**
  68985. * Sets the HighlightsThreshold amount
  68986. * @param amount amount of HighlightsThreshold
  68987. */
  68988. setHighlightsThreshold(amount: number): void;
  68989. /**
  68990. * Disables highlights
  68991. */
  68992. disableHighlights(): void;
  68993. /**
  68994. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68995. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68996. */
  68997. dispose(disableDepthRender?: boolean): void;
  68998. private _createChromaticAberrationPostProcess;
  68999. private _createHighlightsPostProcess;
  69000. private _createDepthOfFieldPostProcess;
  69001. private _createGrainTexture;
  69002. }
  69003. }
  69004. declare module "babylonjs/Shaders/ssao2.fragment" {
  69005. /** @hidden */
  69006. export var ssao2PixelShader: {
  69007. name: string;
  69008. shader: string;
  69009. };
  69010. }
  69011. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69012. /** @hidden */
  69013. export var ssaoCombinePixelShader: {
  69014. name: string;
  69015. shader: string;
  69016. };
  69017. }
  69018. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69019. import { Camera } from "babylonjs/Cameras/camera";
  69020. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69021. import { Scene } from "babylonjs/scene";
  69022. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69023. import "babylonjs/Shaders/ssao2.fragment";
  69024. import "babylonjs/Shaders/ssaoCombine.fragment";
  69025. /**
  69026. * Render pipeline to produce ssao effect
  69027. */
  69028. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69029. /**
  69030. * @ignore
  69031. * The PassPostProcess id in the pipeline that contains the original scene color
  69032. */
  69033. SSAOOriginalSceneColorEffect: string;
  69034. /**
  69035. * @ignore
  69036. * The SSAO PostProcess id in the pipeline
  69037. */
  69038. SSAORenderEffect: string;
  69039. /**
  69040. * @ignore
  69041. * The horizontal blur PostProcess id in the pipeline
  69042. */
  69043. SSAOBlurHRenderEffect: string;
  69044. /**
  69045. * @ignore
  69046. * The vertical blur PostProcess id in the pipeline
  69047. */
  69048. SSAOBlurVRenderEffect: string;
  69049. /**
  69050. * @ignore
  69051. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69052. */
  69053. SSAOCombineRenderEffect: string;
  69054. /**
  69055. * The output strength of the SSAO post-process. Default value is 1.0.
  69056. */
  69057. totalStrength: number;
  69058. /**
  69059. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69060. */
  69061. maxZ: number;
  69062. /**
  69063. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69064. */
  69065. minZAspect: number;
  69066. private _samples;
  69067. /**
  69068. * Number of samples used for the SSAO calculations. Default value is 8
  69069. */
  69070. set samples(n: number);
  69071. get samples(): number;
  69072. private _textureSamples;
  69073. /**
  69074. * Number of samples to use for antialiasing
  69075. */
  69076. set textureSamples(n: number);
  69077. get textureSamples(): number;
  69078. /**
  69079. * Ratio object used for SSAO ratio and blur ratio
  69080. */
  69081. private _ratio;
  69082. /**
  69083. * Dynamically generated sphere sampler.
  69084. */
  69085. private _sampleSphere;
  69086. /**
  69087. * Blur filter offsets
  69088. */
  69089. private _samplerOffsets;
  69090. private _expensiveBlur;
  69091. /**
  69092. * If bilateral blur should be used
  69093. */
  69094. set expensiveBlur(b: boolean);
  69095. get expensiveBlur(): boolean;
  69096. /**
  69097. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69098. */
  69099. radius: number;
  69100. /**
  69101. * The base color of the SSAO post-process
  69102. * The final result is "base + ssao" between [0, 1]
  69103. */
  69104. base: number;
  69105. /**
  69106. * Support test.
  69107. */
  69108. static get IsSupported(): boolean;
  69109. private _scene;
  69110. private _depthTexture;
  69111. private _normalTexture;
  69112. private _randomTexture;
  69113. private _originalColorPostProcess;
  69114. private _ssaoPostProcess;
  69115. private _blurHPostProcess;
  69116. private _blurVPostProcess;
  69117. private _ssaoCombinePostProcess;
  69118. /**
  69119. * Gets active scene
  69120. */
  69121. get scene(): Scene;
  69122. /**
  69123. * @constructor
  69124. * @param name The rendering pipeline name
  69125. * @param scene The scene linked to this pipeline
  69126. * @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 }
  69127. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69128. */
  69129. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69130. /**
  69131. * Get the class name
  69132. * @returns "SSAO2RenderingPipeline"
  69133. */
  69134. getClassName(): string;
  69135. /**
  69136. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69137. */
  69138. dispose(disableGeometryBufferRenderer?: boolean): void;
  69139. private _createBlurPostProcess;
  69140. /** @hidden */
  69141. _rebuild(): void;
  69142. private _bits;
  69143. private _radicalInverse_VdC;
  69144. private _hammersley;
  69145. private _hemisphereSample_uniform;
  69146. private _generateHemisphere;
  69147. private _createSSAOPostProcess;
  69148. private _createSSAOCombinePostProcess;
  69149. private _createRandomTexture;
  69150. /**
  69151. * Serialize the rendering pipeline (Used when exporting)
  69152. * @returns the serialized object
  69153. */
  69154. serialize(): any;
  69155. /**
  69156. * Parse the serialized pipeline
  69157. * @param source Source pipeline.
  69158. * @param scene The scene to load the pipeline to.
  69159. * @param rootUrl The URL of the serialized pipeline.
  69160. * @returns An instantiated pipeline from the serialized object.
  69161. */
  69162. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69163. }
  69164. }
  69165. declare module "babylonjs/Shaders/ssao.fragment" {
  69166. /** @hidden */
  69167. export var ssaoPixelShader: {
  69168. name: string;
  69169. shader: string;
  69170. };
  69171. }
  69172. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69173. import { Camera } from "babylonjs/Cameras/camera";
  69174. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69175. import { Scene } from "babylonjs/scene";
  69176. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69177. import "babylonjs/Shaders/ssao.fragment";
  69178. import "babylonjs/Shaders/ssaoCombine.fragment";
  69179. /**
  69180. * Render pipeline to produce ssao effect
  69181. */
  69182. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69183. /**
  69184. * @ignore
  69185. * The PassPostProcess id in the pipeline that contains the original scene color
  69186. */
  69187. SSAOOriginalSceneColorEffect: string;
  69188. /**
  69189. * @ignore
  69190. * The SSAO PostProcess id in the pipeline
  69191. */
  69192. SSAORenderEffect: string;
  69193. /**
  69194. * @ignore
  69195. * The horizontal blur PostProcess id in the pipeline
  69196. */
  69197. SSAOBlurHRenderEffect: string;
  69198. /**
  69199. * @ignore
  69200. * The vertical blur PostProcess id in the pipeline
  69201. */
  69202. SSAOBlurVRenderEffect: string;
  69203. /**
  69204. * @ignore
  69205. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69206. */
  69207. SSAOCombineRenderEffect: string;
  69208. /**
  69209. * The output strength of the SSAO post-process. Default value is 1.0.
  69210. */
  69211. totalStrength: number;
  69212. /**
  69213. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69214. */
  69215. radius: number;
  69216. /**
  69217. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69218. * Must not be equal to fallOff and superior to fallOff.
  69219. * Default value is 0.0075
  69220. */
  69221. area: number;
  69222. /**
  69223. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69224. * Must not be equal to area and inferior to area.
  69225. * Default value is 0.000001
  69226. */
  69227. fallOff: number;
  69228. /**
  69229. * The base color of the SSAO post-process
  69230. * The final result is "base + ssao" between [0, 1]
  69231. */
  69232. base: number;
  69233. private _scene;
  69234. private _depthTexture;
  69235. private _randomTexture;
  69236. private _originalColorPostProcess;
  69237. private _ssaoPostProcess;
  69238. private _blurHPostProcess;
  69239. private _blurVPostProcess;
  69240. private _ssaoCombinePostProcess;
  69241. private _firstUpdate;
  69242. /**
  69243. * Gets active scene
  69244. */
  69245. get scene(): Scene;
  69246. /**
  69247. * @constructor
  69248. * @param name - The rendering pipeline name
  69249. * @param scene - The scene linked to this pipeline
  69250. * @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 }
  69251. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69252. */
  69253. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69254. /**
  69255. * Get the class name
  69256. * @returns "SSAORenderingPipeline"
  69257. */
  69258. getClassName(): string;
  69259. /**
  69260. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69261. */
  69262. dispose(disableDepthRender?: boolean): void;
  69263. private _createBlurPostProcess;
  69264. /** @hidden */
  69265. _rebuild(): void;
  69266. private _createSSAOPostProcess;
  69267. private _createSSAOCombinePostProcess;
  69268. private _createRandomTexture;
  69269. }
  69270. }
  69271. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69272. /** @hidden */
  69273. export var screenSpaceReflectionPixelShader: {
  69274. name: string;
  69275. shader: string;
  69276. };
  69277. }
  69278. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69279. import { Nullable } from "babylonjs/types";
  69280. import { Camera } from "babylonjs/Cameras/camera";
  69281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69282. import { Scene } from "babylonjs/scene";
  69283. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69284. import { Engine } from "babylonjs/Engines/engine";
  69285. /**
  69286. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69287. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69288. */
  69289. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69290. /**
  69291. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69292. */
  69293. threshold: number;
  69294. /**
  69295. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69296. */
  69297. strength: number;
  69298. /**
  69299. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69300. */
  69301. reflectionSpecularFalloffExponent: number;
  69302. /**
  69303. * 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]
  69304. */
  69305. step: number;
  69306. /**
  69307. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69308. */
  69309. roughnessFactor: number;
  69310. private _geometryBufferRenderer;
  69311. private _enableSmoothReflections;
  69312. private _reflectionSamples;
  69313. private _smoothSteps;
  69314. /**
  69315. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69316. * @param name The name of the effect.
  69317. * @param scene The scene containing the objects to calculate reflections.
  69318. * @param options The required width/height ratio to downsize to before computing the render pass.
  69319. * @param camera The camera to apply the render pass to.
  69320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69321. * @param engine The engine which the post process will be applied. (default: current engine)
  69322. * @param reusable If the post process can be reused on the same frame. (default: false)
  69323. * @param textureType Type of textures used when performing the post process. (default: 0)
  69324. * @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)
  69325. */
  69326. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69327. /**
  69328. * Gets wether or not smoothing reflections is enabled.
  69329. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69330. */
  69331. get enableSmoothReflections(): boolean;
  69332. /**
  69333. * Sets wether or not smoothing reflections is enabled.
  69334. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69335. */
  69336. set enableSmoothReflections(enabled: boolean);
  69337. /**
  69338. * Gets the number of samples taken while computing reflections. More samples count is high,
  69339. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69340. */
  69341. get reflectionSamples(): number;
  69342. /**
  69343. * Sets the number of samples taken while computing reflections. More samples count is high,
  69344. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69345. */
  69346. set reflectionSamples(samples: number);
  69347. /**
  69348. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69349. * more the post-process will require GPU power and can generate a drop in FPS.
  69350. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69351. */
  69352. get smoothSteps(): number;
  69353. set smoothSteps(steps: number);
  69354. private _updateEffectDefines;
  69355. }
  69356. }
  69357. declare module "babylonjs/Shaders/standard.fragment" {
  69358. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69359. /** @hidden */
  69360. export var standardPixelShader: {
  69361. name: string;
  69362. shader: string;
  69363. };
  69364. }
  69365. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69366. import { Nullable } from "babylonjs/types";
  69367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69368. import { Camera } from "babylonjs/Cameras/camera";
  69369. import { Texture } from "babylonjs/Materials/Textures/texture";
  69370. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69371. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69372. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69373. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69374. import { IDisposable } from "babylonjs/scene";
  69375. import { SpotLight } from "babylonjs/Lights/spotLight";
  69376. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69377. import { Scene } from "babylonjs/scene";
  69378. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69379. import { Animation } from "babylonjs/Animations/animation";
  69380. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69381. import "babylonjs/Shaders/standard.fragment";
  69382. /**
  69383. * Standard rendering pipeline
  69384. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69385. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69386. */
  69387. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69388. /**
  69389. * Public members
  69390. */
  69391. /**
  69392. * Post-process which contains the original scene color before the pipeline applies all the effects
  69393. */
  69394. originalPostProcess: Nullable<PostProcess>;
  69395. /**
  69396. * Post-process used to down scale an image x4
  69397. */
  69398. downSampleX4PostProcess: Nullable<PostProcess>;
  69399. /**
  69400. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69401. */
  69402. brightPassPostProcess: Nullable<PostProcess>;
  69403. /**
  69404. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69405. */
  69406. blurHPostProcesses: PostProcess[];
  69407. /**
  69408. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69409. */
  69410. blurVPostProcesses: PostProcess[];
  69411. /**
  69412. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69413. */
  69414. textureAdderPostProcess: Nullable<PostProcess>;
  69415. /**
  69416. * Post-process used to create volumetric lighting effect
  69417. */
  69418. volumetricLightPostProcess: Nullable<PostProcess>;
  69419. /**
  69420. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69421. */
  69422. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69423. /**
  69424. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69425. */
  69426. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69427. /**
  69428. * Post-process used to merge the volumetric light effect and the real scene color
  69429. */
  69430. volumetricLightMergePostProces: Nullable<PostProcess>;
  69431. /**
  69432. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69433. */
  69434. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69435. /**
  69436. * Base post-process used to calculate the average luminance of the final image for HDR
  69437. */
  69438. luminancePostProcess: Nullable<PostProcess>;
  69439. /**
  69440. * Post-processes used to create down sample post-processes in order to get
  69441. * the average luminance of the final image for HDR
  69442. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69443. */
  69444. luminanceDownSamplePostProcesses: PostProcess[];
  69445. /**
  69446. * Post-process used to create a HDR effect (light adaptation)
  69447. */
  69448. hdrPostProcess: Nullable<PostProcess>;
  69449. /**
  69450. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69451. */
  69452. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69453. /**
  69454. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69455. */
  69456. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69457. /**
  69458. * Post-process used to merge the final HDR post-process and the real scene color
  69459. */
  69460. hdrFinalPostProcess: Nullable<PostProcess>;
  69461. /**
  69462. * Post-process used to create a lens flare effect
  69463. */
  69464. lensFlarePostProcess: Nullable<PostProcess>;
  69465. /**
  69466. * Post-process that merges the result of the lens flare post-process and the real scene color
  69467. */
  69468. lensFlareComposePostProcess: Nullable<PostProcess>;
  69469. /**
  69470. * Post-process used to create a motion blur effect
  69471. */
  69472. motionBlurPostProcess: Nullable<PostProcess>;
  69473. /**
  69474. * Post-process used to create a depth of field effect
  69475. */
  69476. depthOfFieldPostProcess: Nullable<PostProcess>;
  69477. /**
  69478. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69479. */
  69480. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69481. /**
  69482. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69483. */
  69484. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69485. /**
  69486. * Represents the brightness threshold in order to configure the illuminated surfaces
  69487. */
  69488. brightThreshold: number;
  69489. /**
  69490. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69491. */
  69492. blurWidth: number;
  69493. /**
  69494. * Sets if the blur for highlighted surfaces must be only horizontal
  69495. */
  69496. horizontalBlur: boolean;
  69497. /**
  69498. * Gets the overall exposure used by the pipeline
  69499. */
  69500. get exposure(): number;
  69501. /**
  69502. * Sets the overall exposure used by the pipeline
  69503. */
  69504. set exposure(value: number);
  69505. /**
  69506. * Texture used typically to simulate "dirty" on camera lens
  69507. */
  69508. lensTexture: Nullable<Texture>;
  69509. /**
  69510. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69511. */
  69512. volumetricLightCoefficient: number;
  69513. /**
  69514. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69515. */
  69516. volumetricLightPower: number;
  69517. /**
  69518. * Used the set the blur intensity to smooth the volumetric lights
  69519. */
  69520. volumetricLightBlurScale: number;
  69521. /**
  69522. * Light (spot or directional) used to generate the volumetric lights rays
  69523. * The source light must have a shadow generate so the pipeline can get its
  69524. * depth map
  69525. */
  69526. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69527. /**
  69528. * For eye adaptation, represents the minimum luminance the eye can see
  69529. */
  69530. hdrMinimumLuminance: number;
  69531. /**
  69532. * For eye adaptation, represents the decrease luminance speed
  69533. */
  69534. hdrDecreaseRate: number;
  69535. /**
  69536. * For eye adaptation, represents the increase luminance speed
  69537. */
  69538. hdrIncreaseRate: number;
  69539. /**
  69540. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69541. */
  69542. get hdrAutoExposure(): boolean;
  69543. /**
  69544. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69545. */
  69546. set hdrAutoExposure(value: boolean);
  69547. /**
  69548. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69549. */
  69550. lensColorTexture: Nullable<Texture>;
  69551. /**
  69552. * The overall strengh for the lens flare effect
  69553. */
  69554. lensFlareStrength: number;
  69555. /**
  69556. * Dispersion coefficient for lens flare ghosts
  69557. */
  69558. lensFlareGhostDispersal: number;
  69559. /**
  69560. * Main lens flare halo width
  69561. */
  69562. lensFlareHaloWidth: number;
  69563. /**
  69564. * Based on the lens distortion effect, defines how much the lens flare result
  69565. * is distorted
  69566. */
  69567. lensFlareDistortionStrength: number;
  69568. /**
  69569. * Configures the blur intensity used for for lens flare (halo)
  69570. */
  69571. lensFlareBlurWidth: number;
  69572. /**
  69573. * Lens star texture must be used to simulate rays on the flares and is available
  69574. * in the documentation
  69575. */
  69576. lensStarTexture: Nullable<Texture>;
  69577. /**
  69578. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69579. * flare effect by taking account of the dirt texture
  69580. */
  69581. lensFlareDirtTexture: Nullable<Texture>;
  69582. /**
  69583. * Represents the focal length for the depth of field effect
  69584. */
  69585. depthOfFieldDistance: number;
  69586. /**
  69587. * Represents the blur intensity for the blurred part of the depth of field effect
  69588. */
  69589. depthOfFieldBlurWidth: number;
  69590. /**
  69591. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69592. */
  69593. get motionStrength(): number;
  69594. /**
  69595. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69596. */
  69597. set motionStrength(strength: number);
  69598. /**
  69599. * Gets wether or not the motion blur post-process is object based or screen based.
  69600. */
  69601. get objectBasedMotionBlur(): boolean;
  69602. /**
  69603. * Sets wether or not the motion blur post-process should be object based or screen based
  69604. */
  69605. set objectBasedMotionBlur(value: boolean);
  69606. /**
  69607. * List of animations for the pipeline (IAnimatable implementation)
  69608. */
  69609. animations: Animation[];
  69610. /**
  69611. * Private members
  69612. */
  69613. private _scene;
  69614. private _currentDepthOfFieldSource;
  69615. private _basePostProcess;
  69616. private _fixedExposure;
  69617. private _currentExposure;
  69618. private _hdrAutoExposure;
  69619. private _hdrCurrentLuminance;
  69620. private _motionStrength;
  69621. private _isObjectBasedMotionBlur;
  69622. private _floatTextureType;
  69623. private _camerasToBeAttached;
  69624. private _ratio;
  69625. private _bloomEnabled;
  69626. private _depthOfFieldEnabled;
  69627. private _vlsEnabled;
  69628. private _lensFlareEnabled;
  69629. private _hdrEnabled;
  69630. private _motionBlurEnabled;
  69631. private _fxaaEnabled;
  69632. private _screenSpaceReflectionsEnabled;
  69633. private _motionBlurSamples;
  69634. private _volumetricLightStepsCount;
  69635. private _samples;
  69636. /**
  69637. * @ignore
  69638. * Specifies if the bloom pipeline is enabled
  69639. */
  69640. get BloomEnabled(): boolean;
  69641. set BloomEnabled(enabled: boolean);
  69642. /**
  69643. * @ignore
  69644. * Specifies if the depth of field pipeline is enabed
  69645. */
  69646. get DepthOfFieldEnabled(): boolean;
  69647. set DepthOfFieldEnabled(enabled: boolean);
  69648. /**
  69649. * @ignore
  69650. * Specifies if the lens flare pipeline is enabed
  69651. */
  69652. get LensFlareEnabled(): boolean;
  69653. set LensFlareEnabled(enabled: boolean);
  69654. /**
  69655. * @ignore
  69656. * Specifies if the HDR pipeline is enabled
  69657. */
  69658. get HDREnabled(): boolean;
  69659. set HDREnabled(enabled: boolean);
  69660. /**
  69661. * @ignore
  69662. * Specifies if the volumetric lights scattering effect is enabled
  69663. */
  69664. get VLSEnabled(): boolean;
  69665. set VLSEnabled(enabled: boolean);
  69666. /**
  69667. * @ignore
  69668. * Specifies if the motion blur effect is enabled
  69669. */
  69670. get MotionBlurEnabled(): boolean;
  69671. set MotionBlurEnabled(enabled: boolean);
  69672. /**
  69673. * Specifies if anti-aliasing is enabled
  69674. */
  69675. get fxaaEnabled(): boolean;
  69676. set fxaaEnabled(enabled: boolean);
  69677. /**
  69678. * Specifies if screen space reflections are enabled.
  69679. */
  69680. get screenSpaceReflectionsEnabled(): boolean;
  69681. set screenSpaceReflectionsEnabled(enabled: boolean);
  69682. /**
  69683. * Specifies the number of steps used to calculate the volumetric lights
  69684. * Typically in interval [50, 200]
  69685. */
  69686. get volumetricLightStepsCount(): number;
  69687. set volumetricLightStepsCount(count: number);
  69688. /**
  69689. * Specifies the number of samples used for the motion blur effect
  69690. * Typically in interval [16, 64]
  69691. */
  69692. get motionBlurSamples(): number;
  69693. set motionBlurSamples(samples: number);
  69694. /**
  69695. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69696. */
  69697. get samples(): number;
  69698. set samples(sampleCount: number);
  69699. /**
  69700. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69701. * @constructor
  69702. * @param name The rendering pipeline name
  69703. * @param scene The scene linked to this pipeline
  69704. * @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)
  69705. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69706. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69707. */
  69708. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69709. private _buildPipeline;
  69710. private _createDownSampleX4PostProcess;
  69711. private _createBrightPassPostProcess;
  69712. private _createBlurPostProcesses;
  69713. private _createTextureAdderPostProcess;
  69714. private _createVolumetricLightPostProcess;
  69715. private _createLuminancePostProcesses;
  69716. private _createHdrPostProcess;
  69717. private _createLensFlarePostProcess;
  69718. private _createDepthOfFieldPostProcess;
  69719. private _createMotionBlurPostProcess;
  69720. private _getDepthTexture;
  69721. private _disposePostProcesses;
  69722. /**
  69723. * Dispose of the pipeline and stop all post processes
  69724. */
  69725. dispose(): void;
  69726. /**
  69727. * Serialize the rendering pipeline (Used when exporting)
  69728. * @returns the serialized object
  69729. */
  69730. serialize(): any;
  69731. /**
  69732. * Parse the serialized pipeline
  69733. * @param source Source pipeline.
  69734. * @param scene The scene to load the pipeline to.
  69735. * @param rootUrl The URL of the serialized pipeline.
  69736. * @returns An instantiated pipeline from the serialized object.
  69737. */
  69738. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69739. /**
  69740. * Luminance steps
  69741. */
  69742. static LuminanceSteps: number;
  69743. }
  69744. }
  69745. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69746. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69750. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69751. }
  69752. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69753. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69754. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69755. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69756. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69757. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69758. }
  69759. declare module "babylonjs/Shaders/tonemap.fragment" {
  69760. /** @hidden */
  69761. export var tonemapPixelShader: {
  69762. name: string;
  69763. shader: string;
  69764. };
  69765. }
  69766. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69767. import { Camera } from "babylonjs/Cameras/camera";
  69768. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69769. import "babylonjs/Shaders/tonemap.fragment";
  69770. import { Engine } from "babylonjs/Engines/engine";
  69771. /** Defines operator used for tonemapping */
  69772. export enum TonemappingOperator {
  69773. /** Hable */
  69774. Hable = 0,
  69775. /** Reinhard */
  69776. Reinhard = 1,
  69777. /** HejiDawson */
  69778. HejiDawson = 2,
  69779. /** Photographic */
  69780. Photographic = 3
  69781. }
  69782. /**
  69783. * Defines a post process to apply tone mapping
  69784. */
  69785. export class TonemapPostProcess extends PostProcess {
  69786. private _operator;
  69787. /** Defines the required exposure adjustement */
  69788. exposureAdjustment: number;
  69789. /**
  69790. * Creates a new TonemapPostProcess
  69791. * @param name defines the name of the postprocess
  69792. * @param _operator defines the operator to use
  69793. * @param exposureAdjustment defines the required exposure adjustement
  69794. * @param camera defines the camera to use (can be null)
  69795. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69796. * @param engine defines the hosting engine (can be ignore if camera is set)
  69797. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69798. */
  69799. constructor(name: string, _operator: TonemappingOperator,
  69800. /** Defines the required exposure adjustement */
  69801. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69802. }
  69803. }
  69804. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69805. /** @hidden */
  69806. export var volumetricLightScatteringPixelShader: {
  69807. name: string;
  69808. shader: string;
  69809. };
  69810. }
  69811. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69812. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69815. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69817. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69818. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69819. /** @hidden */
  69820. export var volumetricLightScatteringPassVertexShader: {
  69821. name: string;
  69822. shader: string;
  69823. };
  69824. }
  69825. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69826. /** @hidden */
  69827. export var volumetricLightScatteringPassPixelShader: {
  69828. name: string;
  69829. shader: string;
  69830. };
  69831. }
  69832. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69833. import { Vector3 } from "babylonjs/Maths/math.vector";
  69834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69835. import { Mesh } from "babylonjs/Meshes/mesh";
  69836. import { Camera } from "babylonjs/Cameras/camera";
  69837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69838. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69839. import { Scene } from "babylonjs/scene";
  69840. import "babylonjs/Meshes/Builders/planeBuilder";
  69841. import "babylonjs/Shaders/depth.vertex";
  69842. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69843. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69844. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69845. import { Engine } from "babylonjs/Engines/engine";
  69846. /**
  69847. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69848. */
  69849. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69850. private _volumetricLightScatteringPass;
  69851. private _volumetricLightScatteringRTT;
  69852. private _viewPort;
  69853. private _screenCoordinates;
  69854. private _cachedDefines;
  69855. /**
  69856. * If not undefined, the mesh position is computed from the attached node position
  69857. */
  69858. attachedNode: {
  69859. position: Vector3;
  69860. };
  69861. /**
  69862. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69863. */
  69864. customMeshPosition: Vector3;
  69865. /**
  69866. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69867. */
  69868. useCustomMeshPosition: boolean;
  69869. /**
  69870. * If the post-process should inverse the light scattering direction
  69871. */
  69872. invert: boolean;
  69873. /**
  69874. * The internal mesh used by the post-process
  69875. */
  69876. mesh: Mesh;
  69877. /**
  69878. * @hidden
  69879. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69880. */
  69881. get useDiffuseColor(): boolean;
  69882. set useDiffuseColor(useDiffuseColor: boolean);
  69883. /**
  69884. * Array containing the excluded meshes not rendered in the internal pass
  69885. */
  69886. excludedMeshes: AbstractMesh[];
  69887. /**
  69888. * Controls the overall intensity of the post-process
  69889. */
  69890. exposure: number;
  69891. /**
  69892. * Dissipates each sample's contribution in range [0, 1]
  69893. */
  69894. decay: number;
  69895. /**
  69896. * Controls the overall intensity of each sample
  69897. */
  69898. weight: number;
  69899. /**
  69900. * Controls the density of each sample
  69901. */
  69902. density: number;
  69903. /**
  69904. * @constructor
  69905. * @param name The post-process name
  69906. * @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)
  69907. * @param camera The camera that the post-process will be attached to
  69908. * @param mesh The mesh used to create the light scattering
  69909. * @param samples The post-process quality, default 100
  69910. * @param samplingModeThe post-process filtering mode
  69911. * @param engine The babylon engine
  69912. * @param reusable If the post-process is reusable
  69913. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69914. */
  69915. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69916. /**
  69917. * Returns the string "VolumetricLightScatteringPostProcess"
  69918. * @returns "VolumetricLightScatteringPostProcess"
  69919. */
  69920. getClassName(): string;
  69921. private _isReady;
  69922. /**
  69923. * Sets the new light position for light scattering effect
  69924. * @param position The new custom light position
  69925. */
  69926. setCustomMeshPosition(position: Vector3): void;
  69927. /**
  69928. * Returns the light position for light scattering effect
  69929. * @return Vector3 The custom light position
  69930. */
  69931. getCustomMeshPosition(): Vector3;
  69932. /**
  69933. * Disposes the internal assets and detaches the post-process from the camera
  69934. */
  69935. dispose(camera: Camera): void;
  69936. /**
  69937. * Returns the render target texture used by the post-process
  69938. * @return the render target texture used by the post-process
  69939. */
  69940. getPass(): RenderTargetTexture;
  69941. private _meshExcluded;
  69942. private _createPass;
  69943. private _updateMeshScreenCoordinates;
  69944. /**
  69945. * Creates a default mesh for the Volumeric Light Scattering post-process
  69946. * @param name The mesh name
  69947. * @param scene The scene where to create the mesh
  69948. * @return the default mesh
  69949. */
  69950. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69951. }
  69952. }
  69953. declare module "babylonjs/PostProcesses/index" {
  69954. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69955. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69956. export * from "babylonjs/PostProcesses/bloomEffect";
  69957. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69958. export * from "babylonjs/PostProcesses/blurPostProcess";
  69959. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69960. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69961. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69962. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69963. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69964. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69965. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69966. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69967. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69968. export * from "babylonjs/PostProcesses/filterPostProcess";
  69969. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69970. export * from "babylonjs/PostProcesses/grainPostProcess";
  69971. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69972. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69973. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69974. export * from "babylonjs/PostProcesses/passPostProcess";
  69975. export * from "babylonjs/PostProcesses/postProcess";
  69976. export * from "babylonjs/PostProcesses/postProcessManager";
  69977. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69978. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69979. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69980. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69981. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69982. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69983. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69984. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69985. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69986. }
  69987. declare module "babylonjs/Probes/index" {
  69988. export * from "babylonjs/Probes/reflectionProbe";
  69989. }
  69990. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69991. import { Scene } from "babylonjs/scene";
  69992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69993. import { SmartArray } from "babylonjs/Misc/smartArray";
  69994. import { ISceneComponent } from "babylonjs/sceneComponent";
  69995. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69996. import "babylonjs/Meshes/Builders/boxBuilder";
  69997. import "babylonjs/Shaders/color.fragment";
  69998. import "babylonjs/Shaders/color.vertex";
  69999. import { Color3 } from "babylonjs/Maths/math.color";
  70000. module "babylonjs/scene" {
  70001. interface Scene {
  70002. /** @hidden (Backing field) */
  70003. _boundingBoxRenderer: BoundingBoxRenderer;
  70004. /** @hidden (Backing field) */
  70005. _forceShowBoundingBoxes: boolean;
  70006. /**
  70007. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70008. */
  70009. forceShowBoundingBoxes: boolean;
  70010. /**
  70011. * Gets the bounding box renderer associated with the scene
  70012. * @returns a BoundingBoxRenderer
  70013. */
  70014. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70015. }
  70016. }
  70017. module "babylonjs/Meshes/abstractMesh" {
  70018. interface AbstractMesh {
  70019. /** @hidden (Backing field) */
  70020. _showBoundingBox: boolean;
  70021. /**
  70022. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70023. */
  70024. showBoundingBox: boolean;
  70025. }
  70026. }
  70027. /**
  70028. * Component responsible of rendering the bounding box of the meshes in a scene.
  70029. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70030. */
  70031. export class BoundingBoxRenderer implements ISceneComponent {
  70032. /**
  70033. * The component name helpfull to identify the component in the list of scene components.
  70034. */
  70035. readonly name: string;
  70036. /**
  70037. * The scene the component belongs to.
  70038. */
  70039. scene: Scene;
  70040. /**
  70041. * Color of the bounding box lines placed in front of an object
  70042. */
  70043. frontColor: Color3;
  70044. /**
  70045. * Color of the bounding box lines placed behind an object
  70046. */
  70047. backColor: Color3;
  70048. /**
  70049. * Defines if the renderer should show the back lines or not
  70050. */
  70051. showBackLines: boolean;
  70052. /**
  70053. * @hidden
  70054. */
  70055. renderList: SmartArray<BoundingBox>;
  70056. private _colorShader;
  70057. private _vertexBuffers;
  70058. private _indexBuffer;
  70059. private _fillIndexBuffer;
  70060. private _fillIndexData;
  70061. /**
  70062. * Instantiates a new bounding box renderer in a scene.
  70063. * @param scene the scene the renderer renders in
  70064. */
  70065. constructor(scene: Scene);
  70066. /**
  70067. * Registers the component in a given scene
  70068. */
  70069. register(): void;
  70070. private _evaluateSubMesh;
  70071. private _activeMesh;
  70072. private _prepareRessources;
  70073. private _createIndexBuffer;
  70074. /**
  70075. * Rebuilds the elements related to this component in case of
  70076. * context lost for instance.
  70077. */
  70078. rebuild(): void;
  70079. /**
  70080. * @hidden
  70081. */
  70082. reset(): void;
  70083. /**
  70084. * Render the bounding boxes of a specific rendering group
  70085. * @param renderingGroupId defines the rendering group to render
  70086. */
  70087. render(renderingGroupId: number): void;
  70088. /**
  70089. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70090. * @param mesh Define the mesh to render the occlusion bounding box for
  70091. */
  70092. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70093. /**
  70094. * Dispose and release the resources attached to this renderer.
  70095. */
  70096. dispose(): void;
  70097. }
  70098. }
  70099. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70100. import { Nullable } from "babylonjs/types";
  70101. import { Scene } from "babylonjs/scene";
  70102. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70103. import { Camera } from "babylonjs/Cameras/camera";
  70104. import { ISceneComponent } from "babylonjs/sceneComponent";
  70105. module "babylonjs/scene" {
  70106. interface Scene {
  70107. /** @hidden (Backing field) */
  70108. _depthRenderer: {
  70109. [id: string]: DepthRenderer;
  70110. };
  70111. /**
  70112. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70113. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70114. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70115. * @returns the created depth renderer
  70116. */
  70117. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70118. /**
  70119. * Disables a depth renderer for a given camera
  70120. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70121. */
  70122. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70123. }
  70124. }
  70125. /**
  70126. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70127. * in several rendering techniques.
  70128. */
  70129. export class DepthRendererSceneComponent implements ISceneComponent {
  70130. /**
  70131. * The component name helpfull to identify the component in the list of scene components.
  70132. */
  70133. readonly name: string;
  70134. /**
  70135. * The scene the component belongs to.
  70136. */
  70137. scene: Scene;
  70138. /**
  70139. * Creates a new instance of the component for the given scene
  70140. * @param scene Defines the scene to register the component in
  70141. */
  70142. constructor(scene: Scene);
  70143. /**
  70144. * Registers the component in a given scene
  70145. */
  70146. register(): void;
  70147. /**
  70148. * Rebuilds the elements related to this component in case of
  70149. * context lost for instance.
  70150. */
  70151. rebuild(): void;
  70152. /**
  70153. * Disposes the component and the associated ressources
  70154. */
  70155. dispose(): void;
  70156. private _gatherRenderTargets;
  70157. private _gatherActiveCameraRenderTargets;
  70158. }
  70159. }
  70160. declare module "babylonjs/Shaders/outline.fragment" {
  70161. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70162. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70163. /** @hidden */
  70164. export var outlinePixelShader: {
  70165. name: string;
  70166. shader: string;
  70167. };
  70168. }
  70169. declare module "babylonjs/Shaders/outline.vertex" {
  70170. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70173. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70174. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70175. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70176. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70177. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70178. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70179. /** @hidden */
  70180. export var outlineVertexShader: {
  70181. name: string;
  70182. shader: string;
  70183. };
  70184. }
  70185. declare module "babylonjs/Rendering/outlineRenderer" {
  70186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70187. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70188. import { Scene } from "babylonjs/scene";
  70189. import { ISceneComponent } from "babylonjs/sceneComponent";
  70190. import "babylonjs/Shaders/outline.fragment";
  70191. import "babylonjs/Shaders/outline.vertex";
  70192. module "babylonjs/scene" {
  70193. interface Scene {
  70194. /** @hidden */
  70195. _outlineRenderer: OutlineRenderer;
  70196. /**
  70197. * Gets the outline renderer associated with the scene
  70198. * @returns a OutlineRenderer
  70199. */
  70200. getOutlineRenderer(): OutlineRenderer;
  70201. }
  70202. }
  70203. module "babylonjs/Meshes/abstractMesh" {
  70204. interface AbstractMesh {
  70205. /** @hidden (Backing field) */
  70206. _renderOutline: boolean;
  70207. /**
  70208. * Gets or sets a boolean indicating if the outline must be rendered as well
  70209. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70210. */
  70211. renderOutline: boolean;
  70212. /** @hidden (Backing field) */
  70213. _renderOverlay: boolean;
  70214. /**
  70215. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70216. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70217. */
  70218. renderOverlay: boolean;
  70219. }
  70220. }
  70221. /**
  70222. * This class is responsible to draw bothe outline/overlay of meshes.
  70223. * It should not be used directly but through the available method on mesh.
  70224. */
  70225. export class OutlineRenderer implements ISceneComponent {
  70226. /**
  70227. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70228. */
  70229. private static _StencilReference;
  70230. /**
  70231. * The name of the component. Each component must have a unique name.
  70232. */
  70233. name: string;
  70234. /**
  70235. * The scene the component belongs to.
  70236. */
  70237. scene: Scene;
  70238. /**
  70239. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70240. */
  70241. zOffset: number;
  70242. private _engine;
  70243. private _effect;
  70244. private _cachedDefines;
  70245. private _savedDepthWrite;
  70246. /**
  70247. * Instantiates a new outline renderer. (There could be only one per scene).
  70248. * @param scene Defines the scene it belongs to
  70249. */
  70250. constructor(scene: Scene);
  70251. /**
  70252. * Register the component to one instance of a scene.
  70253. */
  70254. register(): void;
  70255. /**
  70256. * Rebuilds the elements related to this component in case of
  70257. * context lost for instance.
  70258. */
  70259. rebuild(): void;
  70260. /**
  70261. * Disposes the component and the associated ressources.
  70262. */
  70263. dispose(): void;
  70264. /**
  70265. * Renders the outline in the canvas.
  70266. * @param subMesh Defines the sumesh to render
  70267. * @param batch Defines the batch of meshes in case of instances
  70268. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70269. */
  70270. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70271. /**
  70272. * Returns whether or not the outline renderer is ready for a given submesh.
  70273. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70274. * @param subMesh Defines the submesh to check readyness for
  70275. * @param useInstances Defines wheter wee are trying to render instances or not
  70276. * @returns true if ready otherwise false
  70277. */
  70278. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70279. private _beforeRenderingMesh;
  70280. private _afterRenderingMesh;
  70281. }
  70282. }
  70283. declare module "babylonjs/Rendering/index" {
  70284. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70285. export * from "babylonjs/Rendering/depthRenderer";
  70286. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70287. export * from "babylonjs/Rendering/edgesRenderer";
  70288. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70289. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70290. export * from "babylonjs/Rendering/outlineRenderer";
  70291. export * from "babylonjs/Rendering/renderingGroup";
  70292. export * from "babylonjs/Rendering/renderingManager";
  70293. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70294. }
  70295. declare module "babylonjs/Sprites/ISprites" {
  70296. /**
  70297. * Defines the basic options interface of a Sprite Frame Source Size.
  70298. */
  70299. export interface ISpriteJSONSpriteSourceSize {
  70300. /**
  70301. * number of the original width of the Frame
  70302. */
  70303. w: number;
  70304. /**
  70305. * number of the original height of the Frame
  70306. */
  70307. h: number;
  70308. }
  70309. /**
  70310. * Defines the basic options interface of a Sprite Frame Data.
  70311. */
  70312. export interface ISpriteJSONSpriteFrameData {
  70313. /**
  70314. * number of the x offset of the Frame
  70315. */
  70316. x: number;
  70317. /**
  70318. * number of the y offset of the Frame
  70319. */
  70320. y: number;
  70321. /**
  70322. * number of the width of the Frame
  70323. */
  70324. w: number;
  70325. /**
  70326. * number of the height of the Frame
  70327. */
  70328. h: number;
  70329. }
  70330. /**
  70331. * Defines the basic options interface of a JSON Sprite.
  70332. */
  70333. export interface ISpriteJSONSprite {
  70334. /**
  70335. * string name of the Frame
  70336. */
  70337. filename: string;
  70338. /**
  70339. * ISpriteJSONSpriteFrame basic object of the frame data
  70340. */
  70341. frame: ISpriteJSONSpriteFrameData;
  70342. /**
  70343. * boolean to flag is the frame was rotated.
  70344. */
  70345. rotated: boolean;
  70346. /**
  70347. * boolean to flag is the frame was trimmed.
  70348. */
  70349. trimmed: boolean;
  70350. /**
  70351. * ISpriteJSONSpriteFrame basic object of the source data
  70352. */
  70353. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70354. /**
  70355. * ISpriteJSONSpriteFrame basic object of the source data
  70356. */
  70357. sourceSize: ISpriteJSONSpriteSourceSize;
  70358. }
  70359. /**
  70360. * Defines the basic options interface of a JSON atlas.
  70361. */
  70362. export interface ISpriteJSONAtlas {
  70363. /**
  70364. * Array of objects that contain the frame data.
  70365. */
  70366. frames: Array<ISpriteJSONSprite>;
  70367. /**
  70368. * object basic object containing the sprite meta data.
  70369. */
  70370. meta?: object;
  70371. }
  70372. }
  70373. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70374. /** @hidden */
  70375. export var spriteMapPixelShader: {
  70376. name: string;
  70377. shader: string;
  70378. };
  70379. }
  70380. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70381. /** @hidden */
  70382. export var spriteMapVertexShader: {
  70383. name: string;
  70384. shader: string;
  70385. };
  70386. }
  70387. declare module "babylonjs/Sprites/spriteMap" {
  70388. import { IDisposable, Scene } from "babylonjs/scene";
  70389. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70390. import { Texture } from "babylonjs/Materials/Textures/texture";
  70391. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70392. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70393. import "babylonjs/Meshes/Builders/planeBuilder";
  70394. import "babylonjs/Shaders/spriteMap.fragment";
  70395. import "babylonjs/Shaders/spriteMap.vertex";
  70396. /**
  70397. * Defines the basic options interface of a SpriteMap
  70398. */
  70399. export interface ISpriteMapOptions {
  70400. /**
  70401. * Vector2 of the number of cells in the grid.
  70402. */
  70403. stageSize?: Vector2;
  70404. /**
  70405. * Vector2 of the size of the output plane in World Units.
  70406. */
  70407. outputSize?: Vector2;
  70408. /**
  70409. * Vector3 of the position of the output plane in World Units.
  70410. */
  70411. outputPosition?: Vector3;
  70412. /**
  70413. * Vector3 of the rotation of the output plane.
  70414. */
  70415. outputRotation?: Vector3;
  70416. /**
  70417. * number of layers that the system will reserve in resources.
  70418. */
  70419. layerCount?: number;
  70420. /**
  70421. * number of max animation frames a single cell will reserve in resources.
  70422. */
  70423. maxAnimationFrames?: number;
  70424. /**
  70425. * number cell index of the base tile when the system compiles.
  70426. */
  70427. baseTile?: number;
  70428. /**
  70429. * boolean flip the sprite after its been repositioned by the framing data.
  70430. */
  70431. flipU?: boolean;
  70432. /**
  70433. * Vector3 scalar of the global RGB values of the SpriteMap.
  70434. */
  70435. colorMultiply?: Vector3;
  70436. }
  70437. /**
  70438. * Defines the IDisposable interface in order to be cleanable from resources.
  70439. */
  70440. export interface ISpriteMap extends IDisposable {
  70441. /**
  70442. * String name of the SpriteMap.
  70443. */
  70444. name: string;
  70445. /**
  70446. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70447. */
  70448. atlasJSON: ISpriteJSONAtlas;
  70449. /**
  70450. * Texture of the SpriteMap.
  70451. */
  70452. spriteSheet: Texture;
  70453. /**
  70454. * The parameters to initialize the SpriteMap with.
  70455. */
  70456. options: ISpriteMapOptions;
  70457. }
  70458. /**
  70459. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70460. */
  70461. export class SpriteMap implements ISpriteMap {
  70462. /** The Name of the spriteMap */
  70463. name: string;
  70464. /** The JSON file with the frame and meta data */
  70465. atlasJSON: ISpriteJSONAtlas;
  70466. /** The systems Sprite Sheet Texture */
  70467. spriteSheet: Texture;
  70468. /** Arguments passed with the Constructor */
  70469. options: ISpriteMapOptions;
  70470. /** Public Sprite Storage array, parsed from atlasJSON */
  70471. sprites: Array<ISpriteJSONSprite>;
  70472. /** Returns the Number of Sprites in the System */
  70473. get spriteCount(): number;
  70474. /** Returns the Position of Output Plane*/
  70475. get position(): Vector3;
  70476. /** Returns the Position of Output Plane*/
  70477. set position(v: Vector3);
  70478. /** Returns the Rotation of Output Plane*/
  70479. get rotation(): Vector3;
  70480. /** Returns the Rotation of Output Plane*/
  70481. set rotation(v: Vector3);
  70482. /** Sets the AnimationMap*/
  70483. get animationMap(): RawTexture;
  70484. /** Sets the AnimationMap*/
  70485. set animationMap(v: RawTexture);
  70486. /** Scene that the SpriteMap was created in */
  70487. private _scene;
  70488. /** Texture Buffer of Float32 that holds tile frame data*/
  70489. private _frameMap;
  70490. /** Texture Buffers of Float32 that holds tileMap data*/
  70491. private _tileMaps;
  70492. /** Texture Buffer of Float32 that holds Animation Data*/
  70493. private _animationMap;
  70494. /** Custom ShaderMaterial Central to the System*/
  70495. private _material;
  70496. /** Custom ShaderMaterial Central to the System*/
  70497. private _output;
  70498. /** Systems Time Ticker*/
  70499. private _time;
  70500. /**
  70501. * Creates a new SpriteMap
  70502. * @param name defines the SpriteMaps Name
  70503. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70504. * @param spriteSheet is the Texture that the Sprites are on.
  70505. * @param options a basic deployment configuration
  70506. * @param scene The Scene that the map is deployed on
  70507. */
  70508. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70509. /**
  70510. * Returns tileID location
  70511. * @returns Vector2 the cell position ID
  70512. */
  70513. getTileID(): Vector2;
  70514. /**
  70515. * Gets the UV location of the mouse over the SpriteMap.
  70516. * @returns Vector2 the UV position of the mouse interaction
  70517. */
  70518. getMousePosition(): Vector2;
  70519. /**
  70520. * Creates the "frame" texture Buffer
  70521. * -------------------------------------
  70522. * Structure of frames
  70523. * "filename": "Falling-Water-2.png",
  70524. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70525. * "rotated": true,
  70526. * "trimmed": true,
  70527. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70528. * "sourceSize": {"w":32,"h":32}
  70529. * @returns RawTexture of the frameMap
  70530. */
  70531. private _createFrameBuffer;
  70532. /**
  70533. * Creates the tileMap texture Buffer
  70534. * @param buffer normally and array of numbers, or a false to generate from scratch
  70535. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70536. * @returns RawTexture of the tileMap
  70537. */
  70538. private _createTileBuffer;
  70539. /**
  70540. * Modifies the data of the tileMaps
  70541. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70542. * @param pos is the iVector2 Coordinates of the Tile
  70543. * @param tile The SpriteIndex of the new Tile
  70544. */
  70545. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70546. /**
  70547. * Creates the animationMap texture Buffer
  70548. * @param buffer normally and array of numbers, or a false to generate from scratch
  70549. * @returns RawTexture of the animationMap
  70550. */
  70551. private _createTileAnimationBuffer;
  70552. /**
  70553. * Modifies the data of the animationMap
  70554. * @param cellID is the Index of the Sprite
  70555. * @param _frame is the target Animation frame
  70556. * @param toCell is the Target Index of the next frame of the animation
  70557. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70558. * @param speed is a global scalar of the time variable on the map.
  70559. */
  70560. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70561. /**
  70562. * Exports the .tilemaps file
  70563. */
  70564. saveTileMaps(): void;
  70565. /**
  70566. * Imports the .tilemaps file
  70567. * @param url of the .tilemaps file
  70568. */
  70569. loadTileMaps(url: string): void;
  70570. /**
  70571. * Release associated resources
  70572. */
  70573. dispose(): void;
  70574. }
  70575. }
  70576. declare module "babylonjs/Sprites/spritePackedManager" {
  70577. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70578. import { Scene } from "babylonjs/scene";
  70579. /**
  70580. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70581. * @see http://doc.babylonjs.com/babylon101/sprites
  70582. */
  70583. export class SpritePackedManager extends SpriteManager {
  70584. /** defines the packed manager's name */
  70585. name: string;
  70586. /**
  70587. * Creates a new sprite manager from a packed sprite sheet
  70588. * @param name defines the manager's name
  70589. * @param imgUrl defines the sprite sheet url
  70590. * @param capacity defines the maximum allowed number of sprites
  70591. * @param scene defines the hosting scene
  70592. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70593. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70594. * @param samplingMode defines the smapling mode to use with spritesheet
  70595. * @param fromPacked set to true; do not alter
  70596. */
  70597. constructor(
  70598. /** defines the packed manager's name */
  70599. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70600. }
  70601. }
  70602. declare module "babylonjs/Sprites/index" {
  70603. export * from "babylonjs/Sprites/sprite";
  70604. export * from "babylonjs/Sprites/ISprites";
  70605. export * from "babylonjs/Sprites/spriteManager";
  70606. export * from "babylonjs/Sprites/spriteMap";
  70607. export * from "babylonjs/Sprites/spritePackedManager";
  70608. export * from "babylonjs/Sprites/spriteSceneComponent";
  70609. }
  70610. declare module "babylonjs/States/index" {
  70611. export * from "babylonjs/States/alphaCullingState";
  70612. export * from "babylonjs/States/depthCullingState";
  70613. export * from "babylonjs/States/stencilState";
  70614. }
  70615. declare module "babylonjs/Misc/assetsManager" {
  70616. import { Scene } from "babylonjs/scene";
  70617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70618. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70619. import { Skeleton } from "babylonjs/Bones/skeleton";
  70620. import { Observable } from "babylonjs/Misc/observable";
  70621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70622. import { Texture } from "babylonjs/Materials/Textures/texture";
  70623. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70624. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70625. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70626. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70627. /**
  70628. * Defines the list of states available for a task inside a AssetsManager
  70629. */
  70630. export enum AssetTaskState {
  70631. /**
  70632. * Initialization
  70633. */
  70634. INIT = 0,
  70635. /**
  70636. * Running
  70637. */
  70638. RUNNING = 1,
  70639. /**
  70640. * Done
  70641. */
  70642. DONE = 2,
  70643. /**
  70644. * Error
  70645. */
  70646. ERROR = 3
  70647. }
  70648. /**
  70649. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70650. */
  70651. export abstract class AbstractAssetTask {
  70652. /**
  70653. * Task name
  70654. */ name: string;
  70655. /**
  70656. * Callback called when the task is successful
  70657. */
  70658. onSuccess: (task: any) => void;
  70659. /**
  70660. * Callback called when the task is not successful
  70661. */
  70662. onError: (task: any, message?: string, exception?: any) => void;
  70663. /**
  70664. * Creates a new AssetsManager
  70665. * @param name defines the name of the task
  70666. */
  70667. constructor(
  70668. /**
  70669. * Task name
  70670. */ name: string);
  70671. private _isCompleted;
  70672. private _taskState;
  70673. private _errorObject;
  70674. /**
  70675. * Get if the task is completed
  70676. */
  70677. get isCompleted(): boolean;
  70678. /**
  70679. * Gets the current state of the task
  70680. */
  70681. get taskState(): AssetTaskState;
  70682. /**
  70683. * Gets the current error object (if task is in error)
  70684. */
  70685. get errorObject(): {
  70686. message?: string;
  70687. exception?: any;
  70688. };
  70689. /**
  70690. * Internal only
  70691. * @hidden
  70692. */
  70693. _setErrorObject(message?: string, exception?: any): void;
  70694. /**
  70695. * Execute the current task
  70696. * @param scene defines the scene where you want your assets to be loaded
  70697. * @param onSuccess is a callback called when the task is successfully executed
  70698. * @param onError is a callback called if an error occurs
  70699. */
  70700. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70701. /**
  70702. * Execute the current task
  70703. * @param scene defines the scene where you want your assets to be loaded
  70704. * @param onSuccess is a callback called when the task is successfully executed
  70705. * @param onError is a callback called if an error occurs
  70706. */
  70707. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70708. /**
  70709. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70710. * This can be used with failed tasks that have the reason for failure fixed.
  70711. */
  70712. reset(): void;
  70713. private onErrorCallback;
  70714. private onDoneCallback;
  70715. }
  70716. /**
  70717. * Define the interface used by progress events raised during assets loading
  70718. */
  70719. export interface IAssetsProgressEvent {
  70720. /**
  70721. * Defines the number of remaining tasks to process
  70722. */
  70723. remainingCount: number;
  70724. /**
  70725. * Defines the total number of tasks
  70726. */
  70727. totalCount: number;
  70728. /**
  70729. * Defines the task that was just processed
  70730. */
  70731. task: AbstractAssetTask;
  70732. }
  70733. /**
  70734. * Class used to share progress information about assets loading
  70735. */
  70736. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70737. /**
  70738. * Defines the number of remaining tasks to process
  70739. */
  70740. remainingCount: number;
  70741. /**
  70742. * Defines the total number of tasks
  70743. */
  70744. totalCount: number;
  70745. /**
  70746. * Defines the task that was just processed
  70747. */
  70748. task: AbstractAssetTask;
  70749. /**
  70750. * Creates a AssetsProgressEvent
  70751. * @param remainingCount defines the number of remaining tasks to process
  70752. * @param totalCount defines the total number of tasks
  70753. * @param task defines the task that was just processed
  70754. */
  70755. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70756. }
  70757. /**
  70758. * Define a task used by AssetsManager to load meshes
  70759. */
  70760. export class MeshAssetTask extends AbstractAssetTask {
  70761. /**
  70762. * Defines the name of the task
  70763. */
  70764. name: string;
  70765. /**
  70766. * Defines the list of mesh's names you want to load
  70767. */
  70768. meshesNames: any;
  70769. /**
  70770. * Defines the root url to use as a base to load your meshes and associated resources
  70771. */
  70772. rootUrl: string;
  70773. /**
  70774. * Defines the filename of the scene to load from
  70775. */
  70776. sceneFilename: string;
  70777. /**
  70778. * Gets the list of loaded meshes
  70779. */
  70780. loadedMeshes: Array<AbstractMesh>;
  70781. /**
  70782. * Gets the list of loaded particle systems
  70783. */
  70784. loadedParticleSystems: Array<IParticleSystem>;
  70785. /**
  70786. * Gets the list of loaded skeletons
  70787. */
  70788. loadedSkeletons: Array<Skeleton>;
  70789. /**
  70790. * Gets the list of loaded animation groups
  70791. */
  70792. loadedAnimationGroups: Array<AnimationGroup>;
  70793. /**
  70794. * Callback called when the task is successful
  70795. */
  70796. onSuccess: (task: MeshAssetTask) => void;
  70797. /**
  70798. * Callback called when the task is successful
  70799. */
  70800. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70801. /**
  70802. * Creates a new MeshAssetTask
  70803. * @param name defines the name of the task
  70804. * @param meshesNames defines the list of mesh's names you want to load
  70805. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70806. * @param sceneFilename defines the filename of the scene to load from
  70807. */
  70808. constructor(
  70809. /**
  70810. * Defines the name of the task
  70811. */
  70812. name: string,
  70813. /**
  70814. * Defines the list of mesh's names you want to load
  70815. */
  70816. meshesNames: any,
  70817. /**
  70818. * Defines the root url to use as a base to load your meshes and associated resources
  70819. */
  70820. rootUrl: string,
  70821. /**
  70822. * Defines the filename of the scene to load from
  70823. */
  70824. sceneFilename: string);
  70825. /**
  70826. * Execute the current task
  70827. * @param scene defines the scene where you want your assets to be loaded
  70828. * @param onSuccess is a callback called when the task is successfully executed
  70829. * @param onError is a callback called if an error occurs
  70830. */
  70831. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70832. }
  70833. /**
  70834. * Define a task used by AssetsManager to load text content
  70835. */
  70836. export class TextFileAssetTask extends AbstractAssetTask {
  70837. /**
  70838. * Defines the name of the task
  70839. */
  70840. name: string;
  70841. /**
  70842. * Defines the location of the file to load
  70843. */
  70844. url: string;
  70845. /**
  70846. * Gets the loaded text string
  70847. */
  70848. text: string;
  70849. /**
  70850. * Callback called when the task is successful
  70851. */
  70852. onSuccess: (task: TextFileAssetTask) => void;
  70853. /**
  70854. * Callback called when the task is successful
  70855. */
  70856. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70857. /**
  70858. * Creates a new TextFileAssetTask object
  70859. * @param name defines the name of the task
  70860. * @param url defines the location of the file to load
  70861. */
  70862. constructor(
  70863. /**
  70864. * Defines the name of the task
  70865. */
  70866. name: string,
  70867. /**
  70868. * Defines the location of the file to load
  70869. */
  70870. url: string);
  70871. /**
  70872. * Execute the current task
  70873. * @param scene defines the scene where you want your assets to be loaded
  70874. * @param onSuccess is a callback called when the task is successfully executed
  70875. * @param onError is a callback called if an error occurs
  70876. */
  70877. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70878. }
  70879. /**
  70880. * Define a task used by AssetsManager to load binary data
  70881. */
  70882. export class BinaryFileAssetTask extends AbstractAssetTask {
  70883. /**
  70884. * Defines the name of the task
  70885. */
  70886. name: string;
  70887. /**
  70888. * Defines the location of the file to load
  70889. */
  70890. url: string;
  70891. /**
  70892. * Gets the lodaded data (as an array buffer)
  70893. */
  70894. data: ArrayBuffer;
  70895. /**
  70896. * Callback called when the task is successful
  70897. */
  70898. onSuccess: (task: BinaryFileAssetTask) => void;
  70899. /**
  70900. * Callback called when the task is successful
  70901. */
  70902. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70903. /**
  70904. * Creates a new BinaryFileAssetTask object
  70905. * @param name defines the name of the new task
  70906. * @param url defines the location of the file to load
  70907. */
  70908. constructor(
  70909. /**
  70910. * Defines the name of the task
  70911. */
  70912. name: string,
  70913. /**
  70914. * Defines the location of the file to load
  70915. */
  70916. url: string);
  70917. /**
  70918. * Execute the current task
  70919. * @param scene defines the scene where you want your assets to be loaded
  70920. * @param onSuccess is a callback called when the task is successfully executed
  70921. * @param onError is a callback called if an error occurs
  70922. */
  70923. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70924. }
  70925. /**
  70926. * Define a task used by AssetsManager to load images
  70927. */
  70928. export class ImageAssetTask extends AbstractAssetTask {
  70929. /**
  70930. * Defines the name of the task
  70931. */
  70932. name: string;
  70933. /**
  70934. * Defines the location of the image to load
  70935. */
  70936. url: string;
  70937. /**
  70938. * Gets the loaded images
  70939. */
  70940. image: HTMLImageElement;
  70941. /**
  70942. * Callback called when the task is successful
  70943. */
  70944. onSuccess: (task: ImageAssetTask) => void;
  70945. /**
  70946. * Callback called when the task is successful
  70947. */
  70948. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70949. /**
  70950. * Creates a new ImageAssetTask
  70951. * @param name defines the name of the task
  70952. * @param url defines the location of the image to load
  70953. */
  70954. constructor(
  70955. /**
  70956. * Defines the name of the task
  70957. */
  70958. name: string,
  70959. /**
  70960. * Defines the location of the image to load
  70961. */
  70962. url: string);
  70963. /**
  70964. * Execute the current task
  70965. * @param scene defines the scene where you want your assets to be loaded
  70966. * @param onSuccess is a callback called when the task is successfully executed
  70967. * @param onError is a callback called if an error occurs
  70968. */
  70969. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70970. }
  70971. /**
  70972. * Defines the interface used by texture loading tasks
  70973. */
  70974. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70975. /**
  70976. * Gets the loaded texture
  70977. */
  70978. texture: TEX;
  70979. }
  70980. /**
  70981. * Define a task used by AssetsManager to load 2D textures
  70982. */
  70983. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70984. /**
  70985. * Defines the name of the task
  70986. */
  70987. name: string;
  70988. /**
  70989. * Defines the location of the file to load
  70990. */
  70991. url: string;
  70992. /**
  70993. * Defines if mipmap should not be generated (default is false)
  70994. */
  70995. noMipmap?: boolean | undefined;
  70996. /**
  70997. * Defines if texture must be inverted on Y axis (default is false)
  70998. */
  70999. invertY?: boolean | undefined;
  71000. /**
  71001. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71002. */
  71003. samplingMode: number;
  71004. /**
  71005. * Gets the loaded texture
  71006. */
  71007. texture: Texture;
  71008. /**
  71009. * Callback called when the task is successful
  71010. */
  71011. onSuccess: (task: TextureAssetTask) => void;
  71012. /**
  71013. * Callback called when the task is successful
  71014. */
  71015. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71016. /**
  71017. * Creates a new TextureAssetTask object
  71018. * @param name defines the name of the task
  71019. * @param url defines the location of the file to load
  71020. * @param noMipmap defines if mipmap should not be generated (default is false)
  71021. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71022. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71023. */
  71024. constructor(
  71025. /**
  71026. * Defines the name of the task
  71027. */
  71028. name: string,
  71029. /**
  71030. * Defines the location of the file to load
  71031. */
  71032. url: string,
  71033. /**
  71034. * Defines if mipmap should not be generated (default is false)
  71035. */
  71036. noMipmap?: boolean | undefined,
  71037. /**
  71038. * Defines if texture must be inverted on Y axis (default is false)
  71039. */
  71040. invertY?: boolean | undefined,
  71041. /**
  71042. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71043. */
  71044. samplingMode?: number);
  71045. /**
  71046. * Execute the current task
  71047. * @param scene defines the scene where you want your assets to be loaded
  71048. * @param onSuccess is a callback called when the task is successfully executed
  71049. * @param onError is a callback called if an error occurs
  71050. */
  71051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71052. }
  71053. /**
  71054. * Define a task used by AssetsManager to load cube textures
  71055. */
  71056. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71057. /**
  71058. * Defines the name of the task
  71059. */
  71060. name: string;
  71061. /**
  71062. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71063. */
  71064. url: string;
  71065. /**
  71066. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71067. */
  71068. extensions?: string[] | undefined;
  71069. /**
  71070. * Defines if mipmaps should not be generated (default is false)
  71071. */
  71072. noMipmap?: boolean | undefined;
  71073. /**
  71074. * Defines the explicit list of files (undefined by default)
  71075. */
  71076. files?: string[] | undefined;
  71077. /**
  71078. * Gets the loaded texture
  71079. */
  71080. texture: CubeTexture;
  71081. /**
  71082. * Callback called when the task is successful
  71083. */
  71084. onSuccess: (task: CubeTextureAssetTask) => void;
  71085. /**
  71086. * Callback called when the task is successful
  71087. */
  71088. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71089. /**
  71090. * Creates a new CubeTextureAssetTask
  71091. * @param name defines the name of the task
  71092. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71093. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71094. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71095. * @param files defines the explicit list of files (undefined by default)
  71096. */
  71097. constructor(
  71098. /**
  71099. * Defines the name of the task
  71100. */
  71101. name: string,
  71102. /**
  71103. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71104. */
  71105. url: string,
  71106. /**
  71107. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71108. */
  71109. extensions?: string[] | undefined,
  71110. /**
  71111. * Defines if mipmaps should not be generated (default is false)
  71112. */
  71113. noMipmap?: boolean | undefined,
  71114. /**
  71115. * Defines the explicit list of files (undefined by default)
  71116. */
  71117. files?: string[] | undefined);
  71118. /**
  71119. * Execute the current task
  71120. * @param scene defines the scene where you want your assets to be loaded
  71121. * @param onSuccess is a callback called when the task is successfully executed
  71122. * @param onError is a callback called if an error occurs
  71123. */
  71124. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71125. }
  71126. /**
  71127. * Define a task used by AssetsManager to load HDR cube textures
  71128. */
  71129. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71130. /**
  71131. * Defines the name of the task
  71132. */
  71133. name: string;
  71134. /**
  71135. * Defines the location of the file to load
  71136. */
  71137. url: string;
  71138. /**
  71139. * Defines the desired size (the more it increases the longer the generation will be)
  71140. */
  71141. size: number;
  71142. /**
  71143. * Defines if mipmaps should not be generated (default is false)
  71144. */
  71145. noMipmap: boolean;
  71146. /**
  71147. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71148. */
  71149. generateHarmonics: boolean;
  71150. /**
  71151. * 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)
  71152. */
  71153. gammaSpace: boolean;
  71154. /**
  71155. * Internal Use Only
  71156. */
  71157. reserved: boolean;
  71158. /**
  71159. * Gets the loaded texture
  71160. */
  71161. texture: HDRCubeTexture;
  71162. /**
  71163. * Callback called when the task is successful
  71164. */
  71165. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71166. /**
  71167. * Callback called when the task is successful
  71168. */
  71169. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71170. /**
  71171. * Creates a new HDRCubeTextureAssetTask object
  71172. * @param name defines the name of the task
  71173. * @param url defines the location of the file to load
  71174. * @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.
  71175. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71176. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71177. * @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)
  71178. * @param reserved Internal use only
  71179. */
  71180. constructor(
  71181. /**
  71182. * Defines the name of the task
  71183. */
  71184. name: string,
  71185. /**
  71186. * Defines the location of the file to load
  71187. */
  71188. url: string,
  71189. /**
  71190. * Defines the desired size (the more it increases the longer the generation will be)
  71191. */
  71192. size: number,
  71193. /**
  71194. * Defines if mipmaps should not be generated (default is false)
  71195. */
  71196. noMipmap?: boolean,
  71197. /**
  71198. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71199. */
  71200. generateHarmonics?: boolean,
  71201. /**
  71202. * 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)
  71203. */
  71204. gammaSpace?: boolean,
  71205. /**
  71206. * Internal Use Only
  71207. */
  71208. reserved?: boolean);
  71209. /**
  71210. * Execute the current task
  71211. * @param scene defines the scene where you want your assets to be loaded
  71212. * @param onSuccess is a callback called when the task is successfully executed
  71213. * @param onError is a callback called if an error occurs
  71214. */
  71215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71216. }
  71217. /**
  71218. * Define a task used by AssetsManager to load Equirectangular cube textures
  71219. */
  71220. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71221. /**
  71222. * Defines the name of the task
  71223. */
  71224. name: string;
  71225. /**
  71226. * Defines the location of the file to load
  71227. */
  71228. url: string;
  71229. /**
  71230. * Defines the desired size (the more it increases the longer the generation will be)
  71231. */
  71232. size: number;
  71233. /**
  71234. * Defines if mipmaps should not be generated (default is false)
  71235. */
  71236. noMipmap: boolean;
  71237. /**
  71238. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71239. * but the standard material would require them in Gamma space) (default is true)
  71240. */
  71241. gammaSpace: boolean;
  71242. /**
  71243. * Gets the loaded texture
  71244. */
  71245. texture: EquiRectangularCubeTexture;
  71246. /**
  71247. * Callback called when the task is successful
  71248. */
  71249. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71250. /**
  71251. * Callback called when the task is successful
  71252. */
  71253. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71254. /**
  71255. * Creates a new EquiRectangularCubeTextureAssetTask object
  71256. * @param name defines the name of the task
  71257. * @param url defines the location of the file to load
  71258. * @param size defines the desired size (the more it increases the longer the generation will be)
  71259. * If the size is omitted this implies you are using a preprocessed cubemap.
  71260. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71261. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71262. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71263. * (default is true)
  71264. */
  71265. constructor(
  71266. /**
  71267. * Defines the name of the task
  71268. */
  71269. name: string,
  71270. /**
  71271. * Defines the location of the file to load
  71272. */
  71273. url: string,
  71274. /**
  71275. * Defines the desired size (the more it increases the longer the generation will be)
  71276. */
  71277. size: number,
  71278. /**
  71279. * Defines if mipmaps should not be generated (default is false)
  71280. */
  71281. noMipmap?: boolean,
  71282. /**
  71283. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71284. * but the standard material would require them in Gamma space) (default is true)
  71285. */
  71286. gammaSpace?: boolean);
  71287. /**
  71288. * Execute the current task
  71289. * @param scene defines the scene where you want your assets to be loaded
  71290. * @param onSuccess is a callback called when the task is successfully executed
  71291. * @param onError is a callback called if an error occurs
  71292. */
  71293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71294. }
  71295. /**
  71296. * This class can be used to easily import assets into a scene
  71297. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71298. */
  71299. export class AssetsManager {
  71300. private _scene;
  71301. private _isLoading;
  71302. protected _tasks: AbstractAssetTask[];
  71303. protected _waitingTasksCount: number;
  71304. protected _totalTasksCount: number;
  71305. /**
  71306. * Callback called when all tasks are processed
  71307. */
  71308. onFinish: (tasks: AbstractAssetTask[]) => void;
  71309. /**
  71310. * Callback called when a task is successful
  71311. */
  71312. onTaskSuccess: (task: AbstractAssetTask) => void;
  71313. /**
  71314. * Callback called when a task had an error
  71315. */
  71316. onTaskError: (task: AbstractAssetTask) => void;
  71317. /**
  71318. * Callback called when a task is done (whatever the result is)
  71319. */
  71320. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71321. /**
  71322. * Observable called when all tasks are processed
  71323. */
  71324. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71325. /**
  71326. * Observable called when a task had an error
  71327. */
  71328. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71329. /**
  71330. * Observable called when all tasks were executed
  71331. */
  71332. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71333. /**
  71334. * Observable called when a task is done (whatever the result is)
  71335. */
  71336. onProgressObservable: Observable<IAssetsProgressEvent>;
  71337. /**
  71338. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71340. */
  71341. useDefaultLoadingScreen: boolean;
  71342. /**
  71343. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71344. * when all assets have been downloaded.
  71345. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71346. */
  71347. autoHideLoadingUI: boolean;
  71348. /**
  71349. * Creates a new AssetsManager
  71350. * @param scene defines the scene to work on
  71351. */
  71352. constructor(scene: Scene);
  71353. /**
  71354. * Add a MeshAssetTask to the list of active tasks
  71355. * @param taskName defines the name of the new task
  71356. * @param meshesNames defines the name of meshes to load
  71357. * @param rootUrl defines the root url to use to locate files
  71358. * @param sceneFilename defines the filename of the scene file
  71359. * @returns a new MeshAssetTask object
  71360. */
  71361. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71362. /**
  71363. * Add a TextFileAssetTask to the list of active tasks
  71364. * @param taskName defines the name of the new task
  71365. * @param url defines the url of the file to load
  71366. * @returns a new TextFileAssetTask object
  71367. */
  71368. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71369. /**
  71370. * Add a BinaryFileAssetTask to the list of active tasks
  71371. * @param taskName defines the name of the new task
  71372. * @param url defines the url of the file to load
  71373. * @returns a new BinaryFileAssetTask object
  71374. */
  71375. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71376. /**
  71377. * Add a ImageAssetTask to the list of active tasks
  71378. * @param taskName defines the name of the new task
  71379. * @param url defines the url of the file to load
  71380. * @returns a new ImageAssetTask object
  71381. */
  71382. addImageTask(taskName: string, url: string): ImageAssetTask;
  71383. /**
  71384. * Add a TextureAssetTask to the list of active tasks
  71385. * @param taskName defines the name of the new task
  71386. * @param url defines the url of the file to load
  71387. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71388. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71389. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71390. * @returns a new TextureAssetTask object
  71391. */
  71392. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71393. /**
  71394. * Add a CubeTextureAssetTask to the list of active tasks
  71395. * @param taskName defines the name of the new task
  71396. * @param url defines the url of the file to load
  71397. * @param extensions defines the extension to use to load the cube map (can be null)
  71398. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71399. * @param files defines the list of files to load (can be null)
  71400. * @returns a new CubeTextureAssetTask object
  71401. */
  71402. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71403. /**
  71404. *
  71405. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71406. * @param taskName defines the name of the new task
  71407. * @param url defines the url of the file to load
  71408. * @param size defines the size you want for the cubemap (can be null)
  71409. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71410. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71411. * @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)
  71412. * @param reserved Internal use only
  71413. * @returns a new HDRCubeTextureAssetTask object
  71414. */
  71415. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71416. /**
  71417. *
  71418. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71419. * @param taskName defines the name of the new task
  71420. * @param url defines the url of the file to load
  71421. * @param size defines the size you want for the cubemap (can be null)
  71422. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71423. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71424. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71425. * @returns a new EquiRectangularCubeTextureAssetTask object
  71426. */
  71427. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71428. /**
  71429. * Remove a task from the assets manager.
  71430. * @param task the task to remove
  71431. */
  71432. removeTask(task: AbstractAssetTask): void;
  71433. private _decreaseWaitingTasksCount;
  71434. private _runTask;
  71435. /**
  71436. * Reset the AssetsManager and remove all tasks
  71437. * @return the current instance of the AssetsManager
  71438. */
  71439. reset(): AssetsManager;
  71440. /**
  71441. * Start the loading process
  71442. * @return the current instance of the AssetsManager
  71443. */
  71444. load(): AssetsManager;
  71445. /**
  71446. * Start the loading process as an async operation
  71447. * @return a promise returning the list of failed tasks
  71448. */
  71449. loadAsync(): Promise<void>;
  71450. }
  71451. }
  71452. declare module "babylonjs/Misc/deferred" {
  71453. /**
  71454. * Wrapper class for promise with external resolve and reject.
  71455. */
  71456. export class Deferred<T> {
  71457. /**
  71458. * The promise associated with this deferred object.
  71459. */
  71460. readonly promise: Promise<T>;
  71461. private _resolve;
  71462. private _reject;
  71463. /**
  71464. * The resolve method of the promise associated with this deferred object.
  71465. */
  71466. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71467. /**
  71468. * The reject method of the promise associated with this deferred object.
  71469. */
  71470. get reject(): (reason?: any) => void;
  71471. /**
  71472. * Constructor for this deferred object.
  71473. */
  71474. constructor();
  71475. }
  71476. }
  71477. declare module "babylonjs/Misc/meshExploder" {
  71478. import { Mesh } from "babylonjs/Meshes/mesh";
  71479. /**
  71480. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71481. */
  71482. export class MeshExploder {
  71483. private _centerMesh;
  71484. private _meshes;
  71485. private _meshesOrigins;
  71486. private _toCenterVectors;
  71487. private _scaledDirection;
  71488. private _newPosition;
  71489. private _centerPosition;
  71490. /**
  71491. * Explodes meshes from a center mesh.
  71492. * @param meshes The meshes to explode.
  71493. * @param centerMesh The mesh to be center of explosion.
  71494. */
  71495. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71496. private _setCenterMesh;
  71497. /**
  71498. * Get class name
  71499. * @returns "MeshExploder"
  71500. */
  71501. getClassName(): string;
  71502. /**
  71503. * "Exploded meshes"
  71504. * @returns Array of meshes with the centerMesh at index 0.
  71505. */
  71506. getMeshes(): Array<Mesh>;
  71507. /**
  71508. * Explodes meshes giving a specific direction
  71509. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71510. */
  71511. explode(direction?: number): void;
  71512. }
  71513. }
  71514. declare module "babylonjs/Misc/filesInput" {
  71515. import { Engine } from "babylonjs/Engines/engine";
  71516. import { Scene } from "babylonjs/scene";
  71517. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71518. /**
  71519. * Class used to help managing file picking and drag'n'drop
  71520. */
  71521. export class FilesInput {
  71522. /**
  71523. * List of files ready to be loaded
  71524. */
  71525. static get FilesToLoad(): {
  71526. [key: string]: File;
  71527. };
  71528. /**
  71529. * Callback called when a file is processed
  71530. */
  71531. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71532. private _engine;
  71533. private _currentScene;
  71534. private _sceneLoadedCallback;
  71535. private _progressCallback;
  71536. private _additionalRenderLoopLogicCallback;
  71537. private _textureLoadingCallback;
  71538. private _startingProcessingFilesCallback;
  71539. private _onReloadCallback;
  71540. private _errorCallback;
  71541. private _elementToMonitor;
  71542. private _sceneFileToLoad;
  71543. private _filesToLoad;
  71544. /**
  71545. * Creates a new FilesInput
  71546. * @param engine defines the rendering engine
  71547. * @param scene defines the hosting scene
  71548. * @param sceneLoadedCallback callback called when scene is loaded
  71549. * @param progressCallback callback called to track progress
  71550. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71551. * @param textureLoadingCallback callback called when a texture is loading
  71552. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71553. * @param onReloadCallback callback called when a reload is requested
  71554. * @param errorCallback callback call if an error occurs
  71555. */
  71556. 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);
  71557. private _dragEnterHandler;
  71558. private _dragOverHandler;
  71559. private _dropHandler;
  71560. /**
  71561. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71562. * @param elementToMonitor defines the DOM element to track
  71563. */
  71564. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71565. /**
  71566. * Release all associated resources
  71567. */
  71568. dispose(): void;
  71569. private renderFunction;
  71570. private drag;
  71571. private drop;
  71572. private _traverseFolder;
  71573. private _processFiles;
  71574. /**
  71575. * Load files from a drop event
  71576. * @param event defines the drop event to use as source
  71577. */
  71578. loadFiles(event: any): void;
  71579. private _processReload;
  71580. /**
  71581. * Reload the current scene from the loaded files
  71582. */
  71583. reload(): void;
  71584. }
  71585. }
  71586. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71587. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71588. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71589. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71590. }
  71591. declare module "babylonjs/Misc/sceneOptimizer" {
  71592. import { Scene, IDisposable } from "babylonjs/scene";
  71593. import { Observable } from "babylonjs/Misc/observable";
  71594. /**
  71595. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71597. */
  71598. export class SceneOptimization {
  71599. /**
  71600. * Defines the priority of this optimization (0 by default which means first in the list)
  71601. */
  71602. priority: number;
  71603. /**
  71604. * Gets a string describing the action executed by the current optimization
  71605. * @returns description string
  71606. */
  71607. getDescription(): string;
  71608. /**
  71609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71610. * @param scene defines the current scene where to apply this optimization
  71611. * @param optimizer defines the current optimizer
  71612. * @returns true if everything that can be done was applied
  71613. */
  71614. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71615. /**
  71616. * Creates the SceneOptimization object
  71617. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71618. * @param desc defines the description associated with the optimization
  71619. */
  71620. constructor(
  71621. /**
  71622. * Defines the priority of this optimization (0 by default which means first in the list)
  71623. */
  71624. priority?: number);
  71625. }
  71626. /**
  71627. * Defines an optimization used to reduce the size of render target textures
  71628. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71629. */
  71630. export class TextureOptimization extends SceneOptimization {
  71631. /**
  71632. * Defines the priority of this optimization (0 by default which means first in the list)
  71633. */
  71634. priority: number;
  71635. /**
  71636. * 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
  71637. */
  71638. maximumSize: number;
  71639. /**
  71640. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71641. */
  71642. step: number;
  71643. /**
  71644. * Gets a string describing the action executed by the current optimization
  71645. * @returns description string
  71646. */
  71647. getDescription(): string;
  71648. /**
  71649. * Creates the TextureOptimization object
  71650. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71651. * @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
  71652. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71653. */
  71654. constructor(
  71655. /**
  71656. * Defines the priority of this optimization (0 by default which means first in the list)
  71657. */
  71658. priority?: number,
  71659. /**
  71660. * 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
  71661. */
  71662. maximumSize?: number,
  71663. /**
  71664. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71665. */
  71666. step?: number);
  71667. /**
  71668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71669. * @param scene defines the current scene where to apply this optimization
  71670. * @param optimizer defines the current optimizer
  71671. * @returns true if everything that can be done was applied
  71672. */
  71673. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71674. }
  71675. /**
  71676. * Defines an optimization used to increase or decrease the rendering resolution
  71677. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71678. */
  71679. export class HardwareScalingOptimization extends SceneOptimization {
  71680. /**
  71681. * Defines the priority of this optimization (0 by default which means first in the list)
  71682. */
  71683. priority: number;
  71684. /**
  71685. * Defines the maximum scale to use (2 by default)
  71686. */
  71687. maximumScale: number;
  71688. /**
  71689. * Defines the step to use between two passes (0.5 by default)
  71690. */
  71691. step: number;
  71692. private _currentScale;
  71693. private _directionOffset;
  71694. /**
  71695. * Gets a string describing the action executed by the current optimization
  71696. * @return description string
  71697. */
  71698. getDescription(): string;
  71699. /**
  71700. * Creates the HardwareScalingOptimization object
  71701. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71702. * @param maximumScale defines the maximum scale to use (2 by default)
  71703. * @param step defines the step to use between two passes (0.5 by default)
  71704. */
  71705. constructor(
  71706. /**
  71707. * Defines the priority of this optimization (0 by default which means first in the list)
  71708. */
  71709. priority?: number,
  71710. /**
  71711. * Defines the maximum scale to use (2 by default)
  71712. */
  71713. maximumScale?: number,
  71714. /**
  71715. * Defines the step to use between two passes (0.5 by default)
  71716. */
  71717. step?: number);
  71718. /**
  71719. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71720. * @param scene defines the current scene where to apply this optimization
  71721. * @param optimizer defines the current optimizer
  71722. * @returns true if everything that can be done was applied
  71723. */
  71724. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71725. }
  71726. /**
  71727. * Defines an optimization used to remove shadows
  71728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71729. */
  71730. export class ShadowsOptimization extends SceneOptimization {
  71731. /**
  71732. * Gets a string describing the action executed by the current optimization
  71733. * @return description string
  71734. */
  71735. getDescription(): string;
  71736. /**
  71737. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71738. * @param scene defines the current scene where to apply this optimization
  71739. * @param optimizer defines the current optimizer
  71740. * @returns true if everything that can be done was applied
  71741. */
  71742. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71743. }
  71744. /**
  71745. * Defines an optimization used to turn post-processes off
  71746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71747. */
  71748. export class PostProcessesOptimization extends SceneOptimization {
  71749. /**
  71750. * Gets a string describing the action executed by the current optimization
  71751. * @return description string
  71752. */
  71753. getDescription(): string;
  71754. /**
  71755. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71756. * @param scene defines the current scene where to apply this optimization
  71757. * @param optimizer defines the current optimizer
  71758. * @returns true if everything that can be done was applied
  71759. */
  71760. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71761. }
  71762. /**
  71763. * Defines an optimization used to turn lens flares off
  71764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71765. */
  71766. export class LensFlaresOptimization extends SceneOptimization {
  71767. /**
  71768. * Gets a string describing the action executed by the current optimization
  71769. * @return description string
  71770. */
  71771. getDescription(): string;
  71772. /**
  71773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71774. * @param scene defines the current scene where to apply this optimization
  71775. * @param optimizer defines the current optimizer
  71776. * @returns true if everything that can be done was applied
  71777. */
  71778. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71779. }
  71780. /**
  71781. * Defines an optimization based on user defined callback.
  71782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71783. */
  71784. export class CustomOptimization extends SceneOptimization {
  71785. /**
  71786. * Callback called to apply the custom optimization.
  71787. */
  71788. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71789. /**
  71790. * Callback called to get custom description
  71791. */
  71792. onGetDescription: () => string;
  71793. /**
  71794. * Gets a string describing the action executed by the current optimization
  71795. * @returns description string
  71796. */
  71797. getDescription(): string;
  71798. /**
  71799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71800. * @param scene defines the current scene where to apply this optimization
  71801. * @param optimizer defines the current optimizer
  71802. * @returns true if everything that can be done was applied
  71803. */
  71804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71805. }
  71806. /**
  71807. * Defines an optimization used to turn particles off
  71808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71809. */
  71810. export class ParticlesOptimization extends SceneOptimization {
  71811. /**
  71812. * Gets a string describing the action executed by the current optimization
  71813. * @return description string
  71814. */
  71815. getDescription(): string;
  71816. /**
  71817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71818. * @param scene defines the current scene where to apply this optimization
  71819. * @param optimizer defines the current optimizer
  71820. * @returns true if everything that can be done was applied
  71821. */
  71822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71823. }
  71824. /**
  71825. * Defines an optimization used to turn render targets off
  71826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71827. */
  71828. export class RenderTargetsOptimization extends SceneOptimization {
  71829. /**
  71830. * Gets a string describing the action executed by the current optimization
  71831. * @return description string
  71832. */
  71833. getDescription(): string;
  71834. /**
  71835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71836. * @param scene defines the current scene where to apply this optimization
  71837. * @param optimizer defines the current optimizer
  71838. * @returns true if everything that can be done was applied
  71839. */
  71840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71841. }
  71842. /**
  71843. * Defines an optimization used to merge meshes with compatible materials
  71844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71845. */
  71846. export class MergeMeshesOptimization extends SceneOptimization {
  71847. private static _UpdateSelectionTree;
  71848. /**
  71849. * Gets or sets a boolean which defines if optimization octree has to be updated
  71850. */
  71851. static get UpdateSelectionTree(): boolean;
  71852. /**
  71853. * Gets or sets a boolean which defines if optimization octree has to be updated
  71854. */
  71855. static set UpdateSelectionTree(value: boolean);
  71856. /**
  71857. * Gets a string describing the action executed by the current optimization
  71858. * @return description string
  71859. */
  71860. getDescription(): string;
  71861. private _canBeMerged;
  71862. /**
  71863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71864. * @param scene defines the current scene where to apply this optimization
  71865. * @param optimizer defines the current optimizer
  71866. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71867. * @returns true if everything that can be done was applied
  71868. */
  71869. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71870. }
  71871. /**
  71872. * Defines a list of options used by SceneOptimizer
  71873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71874. */
  71875. export class SceneOptimizerOptions {
  71876. /**
  71877. * Defines the target frame rate to reach (60 by default)
  71878. */
  71879. targetFrameRate: number;
  71880. /**
  71881. * Defines the interval between two checkes (2000ms by default)
  71882. */
  71883. trackerDuration: number;
  71884. /**
  71885. * Gets the list of optimizations to apply
  71886. */
  71887. optimizations: SceneOptimization[];
  71888. /**
  71889. * Creates a new list of options used by SceneOptimizer
  71890. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71891. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71892. */
  71893. constructor(
  71894. /**
  71895. * Defines the target frame rate to reach (60 by default)
  71896. */
  71897. targetFrameRate?: number,
  71898. /**
  71899. * Defines the interval between two checkes (2000ms by default)
  71900. */
  71901. trackerDuration?: number);
  71902. /**
  71903. * Add a new optimization
  71904. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71905. * @returns the current SceneOptimizerOptions
  71906. */
  71907. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71908. /**
  71909. * Add a new custom optimization
  71910. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71911. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71912. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71913. * @returns the current SceneOptimizerOptions
  71914. */
  71915. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71916. /**
  71917. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71918. * @param targetFrameRate defines the target frame rate (60 by default)
  71919. * @returns a SceneOptimizerOptions object
  71920. */
  71921. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71922. /**
  71923. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71924. * @param targetFrameRate defines the target frame rate (60 by default)
  71925. * @returns a SceneOptimizerOptions object
  71926. */
  71927. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71928. /**
  71929. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71930. * @param targetFrameRate defines the target frame rate (60 by default)
  71931. * @returns a SceneOptimizerOptions object
  71932. */
  71933. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71934. }
  71935. /**
  71936. * Class used to run optimizations in order to reach a target frame rate
  71937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71938. */
  71939. export class SceneOptimizer implements IDisposable {
  71940. private _isRunning;
  71941. private _options;
  71942. private _scene;
  71943. private _currentPriorityLevel;
  71944. private _targetFrameRate;
  71945. private _trackerDuration;
  71946. private _currentFrameRate;
  71947. private _sceneDisposeObserver;
  71948. private _improvementMode;
  71949. /**
  71950. * Defines an observable called when the optimizer reaches the target frame rate
  71951. */
  71952. onSuccessObservable: Observable<SceneOptimizer>;
  71953. /**
  71954. * Defines an observable called when the optimizer enables an optimization
  71955. */
  71956. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71957. /**
  71958. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71959. */
  71960. onFailureObservable: Observable<SceneOptimizer>;
  71961. /**
  71962. * Gets a boolean indicating if the optimizer is in improvement mode
  71963. */
  71964. get isInImprovementMode(): boolean;
  71965. /**
  71966. * Gets the current priority level (0 at start)
  71967. */
  71968. get currentPriorityLevel(): number;
  71969. /**
  71970. * Gets the current frame rate checked by the SceneOptimizer
  71971. */
  71972. get currentFrameRate(): number;
  71973. /**
  71974. * Gets or sets the current target frame rate (60 by default)
  71975. */
  71976. get targetFrameRate(): number;
  71977. /**
  71978. * Gets or sets the current target frame rate (60 by default)
  71979. */
  71980. set targetFrameRate(value: number);
  71981. /**
  71982. * Gets or sets the current interval between two checks (every 2000ms by default)
  71983. */
  71984. get trackerDuration(): number;
  71985. /**
  71986. * Gets or sets the current interval between two checks (every 2000ms by default)
  71987. */
  71988. set trackerDuration(value: number);
  71989. /**
  71990. * Gets the list of active optimizations
  71991. */
  71992. get optimizations(): SceneOptimization[];
  71993. /**
  71994. * Creates a new SceneOptimizer
  71995. * @param scene defines the scene to work on
  71996. * @param options defines the options to use with the SceneOptimizer
  71997. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71998. * @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)
  71999. */
  72000. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72001. /**
  72002. * Stops the current optimizer
  72003. */
  72004. stop(): void;
  72005. /**
  72006. * Reset the optimizer to initial step (current priority level = 0)
  72007. */
  72008. reset(): void;
  72009. /**
  72010. * Start the optimizer. By default it will try to reach a specific framerate
  72011. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72012. */
  72013. start(): void;
  72014. private _checkCurrentState;
  72015. /**
  72016. * Release all resources
  72017. */
  72018. dispose(): void;
  72019. /**
  72020. * Helper function to create a SceneOptimizer with one single line of code
  72021. * @param scene defines the scene to work on
  72022. * @param options defines the options to use with the SceneOptimizer
  72023. * @param onSuccess defines a callback to call on success
  72024. * @param onFailure defines a callback to call on failure
  72025. * @returns the new SceneOptimizer object
  72026. */
  72027. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72028. }
  72029. }
  72030. declare module "babylonjs/Misc/sceneSerializer" {
  72031. import { Scene } from "babylonjs/scene";
  72032. /**
  72033. * Class used to serialize a scene into a string
  72034. */
  72035. export class SceneSerializer {
  72036. /**
  72037. * Clear cache used by a previous serialization
  72038. */
  72039. static ClearCache(): void;
  72040. /**
  72041. * Serialize a scene into a JSON compatible object
  72042. * @param scene defines the scene to serialize
  72043. * @returns a JSON compatible object
  72044. */
  72045. static Serialize(scene: Scene): any;
  72046. /**
  72047. * Serialize a mesh into a JSON compatible object
  72048. * @param toSerialize defines the mesh to serialize
  72049. * @param withParents defines if parents must be serialized as well
  72050. * @param withChildren defines if children must be serialized as well
  72051. * @returns a JSON compatible object
  72052. */
  72053. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72054. }
  72055. }
  72056. declare module "babylonjs/Misc/textureTools" {
  72057. import { Texture } from "babylonjs/Materials/Textures/texture";
  72058. /**
  72059. * Class used to host texture specific utilities
  72060. */
  72061. export class TextureTools {
  72062. /**
  72063. * Uses the GPU to create a copy texture rescaled at a given size
  72064. * @param texture Texture to copy from
  72065. * @param width defines the desired width
  72066. * @param height defines the desired height
  72067. * @param useBilinearMode defines if bilinear mode has to be used
  72068. * @return the generated texture
  72069. */
  72070. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72071. }
  72072. }
  72073. declare module "babylonjs/Misc/videoRecorder" {
  72074. import { Nullable } from "babylonjs/types";
  72075. import { Engine } from "babylonjs/Engines/engine";
  72076. /**
  72077. * This represents the different options available for the video capture.
  72078. */
  72079. export interface VideoRecorderOptions {
  72080. /** Defines the mime type of the video. */
  72081. mimeType: string;
  72082. /** Defines the FPS the video should be recorded at. */
  72083. fps: number;
  72084. /** Defines the chunk size for the recording data. */
  72085. recordChunckSize: number;
  72086. /** The audio tracks to attach to the recording. */
  72087. audioTracks?: MediaStreamTrack[];
  72088. }
  72089. /**
  72090. * This can help with recording videos from BabylonJS.
  72091. * This is based on the available WebRTC functionalities of the browser.
  72092. *
  72093. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72094. */
  72095. export class VideoRecorder {
  72096. private static readonly _defaultOptions;
  72097. /**
  72098. * Returns whether or not the VideoRecorder is available in your browser.
  72099. * @param engine Defines the Babylon Engine.
  72100. * @returns true if supported otherwise false.
  72101. */
  72102. static IsSupported(engine: Engine): boolean;
  72103. private readonly _options;
  72104. private _canvas;
  72105. private _mediaRecorder;
  72106. private _recordedChunks;
  72107. private _fileName;
  72108. private _resolve;
  72109. private _reject;
  72110. /**
  72111. * True when a recording is already in progress.
  72112. */
  72113. get isRecording(): boolean;
  72114. /**
  72115. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72116. * @param engine Defines the BabylonJS Engine you wish to record.
  72117. * @param options Defines options that can be used to customize the capture.
  72118. */
  72119. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72120. /**
  72121. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72122. */
  72123. stopRecording(): void;
  72124. /**
  72125. * Starts recording the canvas for a max duration specified in parameters.
  72126. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72127. * If null no automatic download will start and you can rely on the promise to get the data back.
  72128. * @param maxDuration Defines the maximum recording time in seconds.
  72129. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72130. * @return A promise callback at the end of the recording with the video data in Blob.
  72131. */
  72132. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72133. /**
  72134. * Releases internal resources used during the recording.
  72135. */
  72136. dispose(): void;
  72137. private _handleDataAvailable;
  72138. private _handleError;
  72139. private _handleStop;
  72140. }
  72141. }
  72142. declare module "babylonjs/Misc/screenshotTools" {
  72143. import { Camera } from "babylonjs/Cameras/camera";
  72144. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72145. import { Engine } from "babylonjs/Engines/engine";
  72146. /**
  72147. * Class containing a set of static utilities functions for screenshots
  72148. */
  72149. export class ScreenshotTools {
  72150. /**
  72151. * Captures a screenshot of the current rendering
  72152. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72153. * @param engine defines the rendering engine
  72154. * @param camera defines the source camera
  72155. * @param size This parameter can be set to a single number or to an object with the
  72156. * following (optional) properties: precision, width, height. If a single number is passed,
  72157. * it will be used for both width and height. If an object is passed, the screenshot size
  72158. * will be derived from the parameters. The precision property is a multiplier allowing
  72159. * rendering at a higher or lower resolution
  72160. * @param successCallback defines the callback receives a single parameter which contains the
  72161. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72162. * src parameter of an <img> to display it
  72163. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72164. * Check your browser for supported MIME types
  72165. */
  72166. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72167. /**
  72168. * Captures a screenshot of the current rendering
  72169. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72170. * @param engine defines the rendering engine
  72171. * @param camera defines the source camera
  72172. * @param size This parameter can be set to a single number or to an object with the
  72173. * following (optional) properties: precision, width, height. If a single number is passed,
  72174. * it will be used for both width and height. If an object is passed, the screenshot size
  72175. * will be derived from the parameters. The precision property is a multiplier allowing
  72176. * rendering at a higher or lower resolution
  72177. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72178. * Check your browser for supported MIME types
  72179. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72180. * to the src parameter of an <img> to display it
  72181. */
  72182. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72183. /**
  72184. * Generates an image screenshot from the specified camera.
  72185. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72186. * @param engine The engine to use for rendering
  72187. * @param camera The camera to use for rendering
  72188. * @param size This parameter can be set to a single number or to an object with the
  72189. * following (optional) properties: precision, width, height. If a single number is passed,
  72190. * it will be used for both width and height. If an object is passed, the screenshot size
  72191. * will be derived from the parameters. The precision property is a multiplier allowing
  72192. * rendering at a higher or lower resolution
  72193. * @param successCallback The callback receives a single parameter which contains the
  72194. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72195. * src parameter of an <img> to display it
  72196. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72197. * Check your browser for supported MIME types
  72198. * @param samples Texture samples (default: 1)
  72199. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72200. * @param fileName A name for for the downloaded file.
  72201. */
  72202. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72203. /**
  72204. * Generates an image screenshot from the specified camera.
  72205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72206. * @param engine The engine to use for rendering
  72207. * @param camera The camera to use for rendering
  72208. * @param size This parameter can be set to a single number or to an object with the
  72209. * following (optional) properties: precision, width, height. If a single number is passed,
  72210. * it will be used for both width and height. If an object is passed, the screenshot size
  72211. * will be derived from the parameters. The precision property is a multiplier allowing
  72212. * rendering at a higher or lower resolution
  72213. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72214. * Check your browser for supported MIME types
  72215. * @param samples Texture samples (default: 1)
  72216. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72217. * @param fileName A name for for the downloaded file.
  72218. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72219. * to the src parameter of an <img> to display it
  72220. */
  72221. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72222. /**
  72223. * Gets height and width for screenshot size
  72224. * @private
  72225. */
  72226. private static _getScreenshotSize;
  72227. }
  72228. }
  72229. declare module "babylonjs/Misc/dataReader" {
  72230. /**
  72231. * Interface for a data buffer
  72232. */
  72233. export interface IDataBuffer {
  72234. /**
  72235. * Reads bytes from the data buffer.
  72236. * @param byteOffset The byte offset to read
  72237. * @param byteLength The byte length to read
  72238. * @returns A promise that resolves when the bytes are read
  72239. */
  72240. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72241. /**
  72242. * The byte length of the buffer.
  72243. */
  72244. readonly byteLength: number;
  72245. }
  72246. /**
  72247. * Utility class for reading from a data buffer
  72248. */
  72249. export class DataReader {
  72250. /**
  72251. * The data buffer associated with this data reader.
  72252. */
  72253. readonly buffer: IDataBuffer;
  72254. /**
  72255. * The current byte offset from the beginning of the data buffer.
  72256. */
  72257. byteOffset: number;
  72258. private _dataView;
  72259. private _dataByteOffset;
  72260. /**
  72261. * Constructor
  72262. * @param buffer The buffer to read
  72263. */
  72264. constructor(buffer: IDataBuffer);
  72265. /**
  72266. * Loads the given byte length.
  72267. * @param byteLength The byte length to load
  72268. * @returns A promise that resolves when the load is complete
  72269. */
  72270. loadAsync(byteLength: number): Promise<void>;
  72271. /**
  72272. * Read a unsigned 32-bit integer from the currently loaded data range.
  72273. * @returns The 32-bit integer read
  72274. */
  72275. readUint32(): number;
  72276. /**
  72277. * Read a byte array from the currently loaded data range.
  72278. * @param byteLength The byte length to read
  72279. * @returns The byte array read
  72280. */
  72281. readUint8Array(byteLength: number): Uint8Array;
  72282. /**
  72283. * Read a string from the currently loaded data range.
  72284. * @param byteLength The byte length to read
  72285. * @returns The string read
  72286. */
  72287. readString(byteLength: number): string;
  72288. /**
  72289. * Skips the given byte length the currently loaded data range.
  72290. * @param byteLength The byte length to skip
  72291. */
  72292. skipBytes(byteLength: number): void;
  72293. }
  72294. }
  72295. declare module "babylonjs/Misc/index" {
  72296. export * from "babylonjs/Misc/andOrNotEvaluator";
  72297. export * from "babylonjs/Misc/assetsManager";
  72298. export * from "babylonjs/Misc/basis";
  72299. export * from "babylonjs/Misc/dds";
  72300. export * from "babylonjs/Misc/decorators";
  72301. export * from "babylonjs/Misc/deferred";
  72302. export * from "babylonjs/Misc/environmentTextureTools";
  72303. export * from "babylonjs/Misc/meshExploder";
  72304. export * from "babylonjs/Misc/filesInput";
  72305. export * from "babylonjs/Misc/HighDynamicRange/index";
  72306. export * from "babylonjs/Misc/khronosTextureContainer";
  72307. export * from "babylonjs/Misc/observable";
  72308. export * from "babylonjs/Misc/performanceMonitor";
  72309. export * from "babylonjs/Misc/promise";
  72310. export * from "babylonjs/Misc/sceneOptimizer";
  72311. export * from "babylonjs/Misc/sceneSerializer";
  72312. export * from "babylonjs/Misc/smartArray";
  72313. export * from "babylonjs/Misc/stringDictionary";
  72314. export * from "babylonjs/Misc/tags";
  72315. export * from "babylonjs/Misc/textureTools";
  72316. export * from "babylonjs/Misc/tga";
  72317. export * from "babylonjs/Misc/tools";
  72318. export * from "babylonjs/Misc/videoRecorder";
  72319. export * from "babylonjs/Misc/virtualJoystick";
  72320. export * from "babylonjs/Misc/workerPool";
  72321. export * from "babylonjs/Misc/logger";
  72322. export * from "babylonjs/Misc/typeStore";
  72323. export * from "babylonjs/Misc/filesInputStore";
  72324. export * from "babylonjs/Misc/deepCopier";
  72325. export * from "babylonjs/Misc/pivotTools";
  72326. export * from "babylonjs/Misc/precisionDate";
  72327. export * from "babylonjs/Misc/screenshotTools";
  72328. export * from "babylonjs/Misc/typeStore";
  72329. export * from "babylonjs/Misc/webRequest";
  72330. export * from "babylonjs/Misc/iInspectable";
  72331. export * from "babylonjs/Misc/brdfTextureTools";
  72332. export * from "babylonjs/Misc/rgbdTextureTools";
  72333. export * from "babylonjs/Misc/gradients";
  72334. export * from "babylonjs/Misc/perfCounter";
  72335. export * from "babylonjs/Misc/fileRequest";
  72336. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72337. export * from "babylonjs/Misc/retryStrategy";
  72338. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72339. export * from "babylonjs/Misc/canvasGenerator";
  72340. export * from "babylonjs/Misc/fileTools";
  72341. export * from "babylonjs/Misc/stringTools";
  72342. export * from "babylonjs/Misc/dataReader";
  72343. export * from "babylonjs/Misc/minMaxReducer";
  72344. export * from "babylonjs/Misc/depthReducer";
  72345. }
  72346. declare module "babylonjs/index" {
  72347. export * from "babylonjs/abstractScene";
  72348. export * from "babylonjs/Actions/index";
  72349. export * from "babylonjs/Animations/index";
  72350. export * from "babylonjs/assetContainer";
  72351. export * from "babylonjs/Audio/index";
  72352. export * from "babylonjs/Behaviors/index";
  72353. export * from "babylonjs/Bones/index";
  72354. export * from "babylonjs/Cameras/index";
  72355. export * from "babylonjs/Collisions/index";
  72356. export * from "babylonjs/Culling/index";
  72357. export * from "babylonjs/Debug/index";
  72358. export * from "babylonjs/Engines/index";
  72359. export * from "babylonjs/Events/index";
  72360. export * from "babylonjs/Gamepads/index";
  72361. export * from "babylonjs/Gizmos/index";
  72362. export * from "babylonjs/Helpers/index";
  72363. export * from "babylonjs/Instrumentation/index";
  72364. export * from "babylonjs/Layers/index";
  72365. export * from "babylonjs/LensFlares/index";
  72366. export * from "babylonjs/Lights/index";
  72367. export * from "babylonjs/Loading/index";
  72368. export * from "babylonjs/Materials/index";
  72369. export * from "babylonjs/Maths/index";
  72370. export * from "babylonjs/Meshes/index";
  72371. export * from "babylonjs/Morph/index";
  72372. export * from "babylonjs/Navigation/index";
  72373. export * from "babylonjs/node";
  72374. export * from "babylonjs/Offline/index";
  72375. export * from "babylonjs/Particles/index";
  72376. export * from "babylonjs/Physics/index";
  72377. export * from "babylonjs/PostProcesses/index";
  72378. export * from "babylonjs/Probes/index";
  72379. export * from "babylonjs/Rendering/index";
  72380. export * from "babylonjs/scene";
  72381. export * from "babylonjs/sceneComponent";
  72382. export * from "babylonjs/Sprites/index";
  72383. export * from "babylonjs/States/index";
  72384. export * from "babylonjs/Misc/index";
  72385. export * from "babylonjs/types";
  72386. }
  72387. declare module "babylonjs/Animations/pathCursor" {
  72388. import { Vector3 } from "babylonjs/Maths/math.vector";
  72389. import { Path2 } from "babylonjs/Maths/math.path";
  72390. /**
  72391. * A cursor which tracks a point on a path
  72392. */
  72393. export class PathCursor {
  72394. private path;
  72395. /**
  72396. * Stores path cursor callbacks for when an onchange event is triggered
  72397. */
  72398. private _onchange;
  72399. /**
  72400. * The value of the path cursor
  72401. */
  72402. value: number;
  72403. /**
  72404. * The animation array of the path cursor
  72405. */
  72406. animations: Animation[];
  72407. /**
  72408. * Initializes the path cursor
  72409. * @param path The path to track
  72410. */
  72411. constructor(path: Path2);
  72412. /**
  72413. * Gets the cursor point on the path
  72414. * @returns A point on the path cursor at the cursor location
  72415. */
  72416. getPoint(): Vector3;
  72417. /**
  72418. * Moves the cursor ahead by the step amount
  72419. * @param step The amount to move the cursor forward
  72420. * @returns This path cursor
  72421. */
  72422. moveAhead(step?: number): PathCursor;
  72423. /**
  72424. * Moves the cursor behind by the step amount
  72425. * @param step The amount to move the cursor back
  72426. * @returns This path cursor
  72427. */
  72428. moveBack(step?: number): PathCursor;
  72429. /**
  72430. * Moves the cursor by the step amount
  72431. * If the step amount is greater than one, an exception is thrown
  72432. * @param step The amount to move the cursor
  72433. * @returns This path cursor
  72434. */
  72435. move(step: number): PathCursor;
  72436. /**
  72437. * Ensures that the value is limited between zero and one
  72438. * @returns This path cursor
  72439. */
  72440. private ensureLimits;
  72441. /**
  72442. * Runs onchange callbacks on change (used by the animation engine)
  72443. * @returns This path cursor
  72444. */
  72445. private raiseOnChange;
  72446. /**
  72447. * Executes a function on change
  72448. * @param f A path cursor onchange callback
  72449. * @returns This path cursor
  72450. */
  72451. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72452. }
  72453. }
  72454. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  72455. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  72456. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  72457. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  72458. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  72459. }
  72460. declare module "babylonjs/Engines/Processors/Expressions/index" {
  72461. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  72462. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  72463. }
  72464. declare module "babylonjs/Engines/Processors/index" {
  72465. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  72466. export * from "babylonjs/Engines/Processors/Expressions/index";
  72467. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  72468. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  72469. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  72470. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  72471. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  72472. export * from "babylonjs/Engines/Processors/shaderProcessor";
  72473. }
  72474. declare module "babylonjs/Legacy/legacy" {
  72475. import * as Babylon from "babylonjs/index";
  72476. export * from "babylonjs/index";
  72477. }
  72478. declare module "babylonjs/Shaders/blur.fragment" {
  72479. /** @hidden */
  72480. export var blurPixelShader: {
  72481. name: string;
  72482. shader: string;
  72483. };
  72484. }
  72485. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  72486. /** @hidden */
  72487. export var pointCloudVertexDeclaration: {
  72488. name: string;
  72489. shader: string;
  72490. };
  72491. }
  72492. declare module "babylonjs" {
  72493. export * from "babylonjs/Legacy/legacy";
  72494. }
  72495. declare module BABYLON {
  72496. /** Alias type for value that can be null */
  72497. export type Nullable<T> = T | null;
  72498. /**
  72499. * Alias type for number that are floats
  72500. * @ignorenaming
  72501. */
  72502. export type float = number;
  72503. /**
  72504. * Alias type for number that are doubles.
  72505. * @ignorenaming
  72506. */
  72507. export type double = number;
  72508. /**
  72509. * Alias type for number that are integer
  72510. * @ignorenaming
  72511. */
  72512. export type int = number;
  72513. /** Alias type for number array or Float32Array */
  72514. export type FloatArray = number[] | Float32Array;
  72515. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  72516. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  72517. /**
  72518. * Alias for types that can be used by a Buffer or VertexBuffer.
  72519. */
  72520. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  72521. /**
  72522. * Alias type for primitive types
  72523. * @ignorenaming
  72524. */
  72525. type Primitive = undefined | null | boolean | string | number | Function;
  72526. /**
  72527. * Type modifier to make all the properties of an object Readonly
  72528. */
  72529. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  72530. /**
  72531. * Type modifier to make all the properties of an object Readonly recursively
  72532. */
  72533. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  72534. /**
  72535. * Type modifier to make object properties readonly.
  72536. */
  72537. export type DeepImmutableObject<T> = {
  72538. readonly [K in keyof T]: DeepImmutable<T[K]>;
  72539. };
  72540. /** @hidden */
  72541. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  72542. }
  72543. }
  72544. declare module BABYLON {
  72545. /**
  72546. * A class serves as a medium between the observable and its observers
  72547. */
  72548. export class EventState {
  72549. /**
  72550. * Create a new EventState
  72551. * @param mask defines the mask associated with this state
  72552. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72553. * @param target defines the original target of the state
  72554. * @param currentTarget defines the current target of the state
  72555. */
  72556. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  72557. /**
  72558. * Initialize the current event state
  72559. * @param mask defines the mask associated with this state
  72560. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72561. * @param target defines the original target of the state
  72562. * @param currentTarget defines the current target of the state
  72563. * @returns the current event state
  72564. */
  72565. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72566. /**
  72567. * An Observer can set this property to true to prevent subsequent observers of being notified
  72568. */
  72569. skipNextObservers: boolean;
  72570. /**
  72571. * Get the mask value that were used to trigger the event corresponding to this EventState object
  72572. */
  72573. mask: number;
  72574. /**
  72575. * The object that originally notified the event
  72576. */
  72577. target?: any;
  72578. /**
  72579. * The current object in the bubbling phase
  72580. */
  72581. currentTarget?: any;
  72582. /**
  72583. * This will be populated with the return value of the last function that was executed.
  72584. * If it is the first function in the callback chain it will be the event data.
  72585. */
  72586. lastReturnValue?: any;
  72587. }
  72588. /**
  72589. * Represent an Observer registered to a given Observable object.
  72590. */
  72591. export class Observer<T> {
  72592. /**
  72593. * Defines the callback to call when the observer is notified
  72594. */
  72595. callback: (eventData: T, eventState: EventState) => void;
  72596. /**
  72597. * Defines the mask of the observer (used to filter notifications)
  72598. */
  72599. mask: number;
  72600. /**
  72601. * Defines the current scope used to restore the JS context
  72602. */
  72603. scope: any;
  72604. /** @hidden */
  72605. _willBeUnregistered: boolean;
  72606. /**
  72607. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  72608. */
  72609. unregisterOnNextCall: boolean;
  72610. /**
  72611. * Creates a new observer
  72612. * @param callback defines the callback to call when the observer is notified
  72613. * @param mask defines the mask of the observer (used to filter notifications)
  72614. * @param scope defines the current scope used to restore the JS context
  72615. */
  72616. constructor(
  72617. /**
  72618. * Defines the callback to call when the observer is notified
  72619. */
  72620. callback: (eventData: T, eventState: EventState) => void,
  72621. /**
  72622. * Defines the mask of the observer (used to filter notifications)
  72623. */
  72624. mask: number,
  72625. /**
  72626. * Defines the current scope used to restore the JS context
  72627. */
  72628. scope?: any);
  72629. }
  72630. /**
  72631. * Represent a list of observers registered to multiple Observables object.
  72632. */
  72633. export class MultiObserver<T> {
  72634. private _observers;
  72635. private _observables;
  72636. /**
  72637. * Release associated resources
  72638. */
  72639. dispose(): void;
  72640. /**
  72641. * Raise a callback when one of the observable will notify
  72642. * @param observables defines a list of observables to watch
  72643. * @param callback defines the callback to call on notification
  72644. * @param mask defines the mask used to filter notifications
  72645. * @param scope defines the current scope used to restore the JS context
  72646. * @returns the new MultiObserver
  72647. */
  72648. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  72649. }
  72650. /**
  72651. * The Observable class is a simple implementation of the Observable pattern.
  72652. *
  72653. * 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.
  72654. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  72655. * 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).
  72656. * 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.
  72657. */
  72658. export class Observable<T> {
  72659. private _observers;
  72660. private _eventState;
  72661. private _onObserverAdded;
  72662. /**
  72663. * Gets the list of observers
  72664. */
  72665. get observers(): Array<Observer<T>>;
  72666. /**
  72667. * Creates a new observable
  72668. * @param onObserverAdded defines a callback to call when a new observer is added
  72669. */
  72670. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  72671. /**
  72672. * Create a new Observer with the specified callback
  72673. * @param callback the callback that will be executed for that Observer
  72674. * @param mask the mask used to filter observers
  72675. * @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.
  72676. * @param scope optional scope for the callback to be called from
  72677. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  72678. * @returns the new observer created for the callback
  72679. */
  72680. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  72681. /**
  72682. * Create a new Observer with the specified callback and unregisters after the next notification
  72683. * @param callback the callback that will be executed for that Observer
  72684. * @returns the new observer created for the callback
  72685. */
  72686. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  72687. /**
  72688. * Remove an Observer from the Observable object
  72689. * @param observer the instance of the Observer to remove
  72690. * @returns false if it doesn't belong to this Observable
  72691. */
  72692. remove(observer: Nullable<Observer<T>>): boolean;
  72693. /**
  72694. * Remove a callback from the Observable object
  72695. * @param callback the callback to remove
  72696. * @param scope optional scope. If used only the callbacks with this scope will be removed
  72697. * @returns false if it doesn't belong to this Observable
  72698. */
  72699. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  72700. private _deferUnregister;
  72701. private _remove;
  72702. /**
  72703. * Moves the observable to the top of the observer list making it get called first when notified
  72704. * @param observer the observer to move
  72705. */
  72706. makeObserverTopPriority(observer: Observer<T>): void;
  72707. /**
  72708. * Moves the observable to the bottom of the observer list making it get called last when notified
  72709. * @param observer the observer to move
  72710. */
  72711. makeObserverBottomPriority(observer: Observer<T>): void;
  72712. /**
  72713. * Notify all Observers by calling their respective callback with the given data
  72714. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  72715. * @param eventData defines the data to send to all observers
  72716. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  72717. * @param target defines the original target of the state
  72718. * @param currentTarget defines the current target of the state
  72719. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  72720. */
  72721. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  72722. /**
  72723. * Calling this will execute each callback, expecting it to be a promise or return a value.
  72724. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  72725. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  72726. * and it is crucial that all callbacks will be executed.
  72727. * The order of the callbacks is kept, callbacks are not executed parallel.
  72728. *
  72729. * @param eventData The data to be sent to each callback
  72730. * @param mask is used to filter observers defaults to -1
  72731. * @param target defines the callback target (see EventState)
  72732. * @param currentTarget defines he current object in the bubbling phase
  72733. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  72734. */
  72735. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  72736. /**
  72737. * Notify a specific observer
  72738. * @param observer defines the observer to notify
  72739. * @param eventData defines the data to be sent to each callback
  72740. * @param mask is used to filter observers defaults to -1
  72741. */
  72742. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  72743. /**
  72744. * Gets a boolean indicating if the observable has at least one observer
  72745. * @returns true is the Observable has at least one Observer registered
  72746. */
  72747. hasObservers(): boolean;
  72748. /**
  72749. * Clear the list of observers
  72750. */
  72751. clear(): void;
  72752. /**
  72753. * Clone the current observable
  72754. * @returns a new observable
  72755. */
  72756. clone(): Observable<T>;
  72757. /**
  72758. * Does this observable handles observer registered with a given mask
  72759. * @param mask defines the mask to be tested
  72760. * @return whether or not one observer registered with the given mask is handeled
  72761. **/
  72762. hasSpecificMask(mask?: number): boolean;
  72763. }
  72764. }
  72765. declare module BABYLON {
  72766. /**
  72767. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  72768. * Babylon.js
  72769. */
  72770. export class DomManagement {
  72771. /**
  72772. * Checks if the window object exists
  72773. * @returns true if the window object exists
  72774. */
  72775. static IsWindowObjectExist(): boolean;
  72776. /**
  72777. * Checks if the navigator object exists
  72778. * @returns true if the navigator object exists
  72779. */
  72780. static IsNavigatorAvailable(): boolean;
  72781. /**
  72782. * Extracts text content from a DOM element hierarchy
  72783. * @param element defines the root element
  72784. * @returns a string
  72785. */
  72786. static GetDOMTextContent(element: HTMLElement): string;
  72787. }
  72788. }
  72789. declare module BABYLON {
  72790. /**
  72791. * Logger used througouht the application to allow configuration of
  72792. * the log level required for the messages.
  72793. */
  72794. export class Logger {
  72795. /**
  72796. * No log
  72797. */
  72798. static readonly NoneLogLevel: number;
  72799. /**
  72800. * Only message logs
  72801. */
  72802. static readonly MessageLogLevel: number;
  72803. /**
  72804. * Only warning logs
  72805. */
  72806. static readonly WarningLogLevel: number;
  72807. /**
  72808. * Only error logs
  72809. */
  72810. static readonly ErrorLogLevel: number;
  72811. /**
  72812. * All logs
  72813. */
  72814. static readonly AllLogLevel: number;
  72815. private static _LogCache;
  72816. /**
  72817. * Gets a value indicating the number of loading errors
  72818. * @ignorenaming
  72819. */
  72820. static errorsCount: number;
  72821. /**
  72822. * Callback called when a new log is added
  72823. */
  72824. static OnNewCacheEntry: (entry: string) => void;
  72825. private static _AddLogEntry;
  72826. private static _FormatMessage;
  72827. private static _LogDisabled;
  72828. private static _LogEnabled;
  72829. private static _WarnDisabled;
  72830. private static _WarnEnabled;
  72831. private static _ErrorDisabled;
  72832. private static _ErrorEnabled;
  72833. /**
  72834. * Log a message to the console
  72835. */
  72836. static Log: (message: string) => void;
  72837. /**
  72838. * Write a warning message to the console
  72839. */
  72840. static Warn: (message: string) => void;
  72841. /**
  72842. * Write an error message to the console
  72843. */
  72844. static Error: (message: string) => void;
  72845. /**
  72846. * Gets current log cache (list of logs)
  72847. */
  72848. static get LogCache(): string;
  72849. /**
  72850. * Clears the log cache
  72851. */
  72852. static ClearLogCache(): void;
  72853. /**
  72854. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  72855. */
  72856. static set LogLevels(level: number);
  72857. }
  72858. }
  72859. declare module BABYLON {
  72860. /** @hidden */
  72861. export class _TypeStore {
  72862. /** @hidden */
  72863. static RegisteredTypes: {
  72864. [key: string]: Object;
  72865. };
  72866. /** @hidden */
  72867. static GetClass(fqdn: string): any;
  72868. }
  72869. }
  72870. declare module BABYLON {
  72871. /**
  72872. * Helper to manipulate strings
  72873. */
  72874. export class StringTools {
  72875. /**
  72876. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  72877. * @param str Source string
  72878. * @param suffix Suffix to search for in the source string
  72879. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  72880. */
  72881. static EndsWith(str: string, suffix: string): boolean;
  72882. /**
  72883. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  72884. * @param str Source string
  72885. * @param suffix Suffix to search for in the source string
  72886. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  72887. */
  72888. static StartsWith(str: string, suffix: string): boolean;
  72889. /**
  72890. * Decodes a buffer into a string
  72891. * @param buffer The buffer to decode
  72892. * @returns The decoded string
  72893. */
  72894. static Decode(buffer: Uint8Array | Uint16Array): string;
  72895. /**
  72896. * Encode a buffer to a base64 string
  72897. * @param buffer defines the buffer to encode
  72898. * @returns the encoded string
  72899. */
  72900. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  72901. }
  72902. }
  72903. declare module BABYLON {
  72904. /**
  72905. * Class containing a set of static utilities functions for deep copy.
  72906. */
  72907. export class DeepCopier {
  72908. /**
  72909. * Tries to copy an object by duplicating every property
  72910. * @param source defines the source object
  72911. * @param destination defines the target object
  72912. * @param doNotCopyList defines a list of properties to avoid
  72913. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  72914. */
  72915. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  72916. }
  72917. }
  72918. declare module BABYLON {
  72919. /**
  72920. * Class containing a set of static utilities functions for precision date
  72921. */
  72922. export class PrecisionDate {
  72923. /**
  72924. * Gets either window.performance.now() if supported or Date.now() else
  72925. */
  72926. static get Now(): number;
  72927. }
  72928. }
  72929. declare module BABYLON {
  72930. /** @hidden */
  72931. export class _DevTools {
  72932. static WarnImport(name: string): string;
  72933. }
  72934. }
  72935. declare module BABYLON {
  72936. /**
  72937. * Interface used to define the mechanism to get data from the network
  72938. */
  72939. export interface IWebRequest {
  72940. /**
  72941. * Returns client's response url
  72942. */
  72943. responseURL: string;
  72944. /**
  72945. * Returns client's status
  72946. */
  72947. status: number;
  72948. /**
  72949. * Returns client's status as a text
  72950. */
  72951. statusText: string;
  72952. }
  72953. }
  72954. declare module BABYLON {
  72955. /**
  72956. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  72957. */
  72958. export class WebRequest implements IWebRequest {
  72959. private _xhr;
  72960. /**
  72961. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  72962. * i.e. when loading files, where the server/service expects an Authorization header
  72963. */
  72964. static CustomRequestHeaders: {
  72965. [key: string]: string;
  72966. };
  72967. /**
  72968. * Add callback functions in this array to update all the requests before they get sent to the network
  72969. */
  72970. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  72971. private _injectCustomRequestHeaders;
  72972. /**
  72973. * Gets or sets a function to be called when loading progress changes
  72974. */
  72975. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  72976. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  72977. /**
  72978. * Returns client's state
  72979. */
  72980. get readyState(): number;
  72981. /**
  72982. * Returns client's status
  72983. */
  72984. get status(): number;
  72985. /**
  72986. * Returns client's status as a text
  72987. */
  72988. get statusText(): string;
  72989. /**
  72990. * Returns client's response
  72991. */
  72992. get response(): any;
  72993. /**
  72994. * Returns client's response url
  72995. */
  72996. get responseURL(): string;
  72997. /**
  72998. * Returns client's response as text
  72999. */
  73000. get responseText(): string;
  73001. /**
  73002. * Gets or sets the expected response type
  73003. */
  73004. get responseType(): XMLHttpRequestResponseType;
  73005. set responseType(value: XMLHttpRequestResponseType);
  73006. /** @hidden */
  73007. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73008. /** @hidden */
  73009. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73010. /**
  73011. * Cancels any network activity
  73012. */
  73013. abort(): void;
  73014. /**
  73015. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73016. * @param body defines an optional request body
  73017. */
  73018. send(body?: Document | BodyInit | null): void;
  73019. /**
  73020. * Sets the request method, request URL
  73021. * @param method defines the method to use (GET, POST, etc..)
  73022. * @param url defines the url to connect with
  73023. */
  73024. open(method: string, url: string): void;
  73025. /**
  73026. * Sets the value of a request header.
  73027. * @param name The name of the header whose value is to be set
  73028. * @param value The value to set as the body of the header
  73029. */
  73030. setRequestHeader(name: string, value: string): void;
  73031. /**
  73032. * Get the string containing the text of a particular header's value.
  73033. * @param name The name of the header
  73034. * @returns The string containing the text of the given header name
  73035. */
  73036. getResponseHeader(name: string): Nullable<string>;
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /**
  73041. * File request interface
  73042. */
  73043. export interface IFileRequest {
  73044. /**
  73045. * Raised when the request is complete (success or error).
  73046. */
  73047. onCompleteObservable: Observable<IFileRequest>;
  73048. /**
  73049. * Aborts the request for a file.
  73050. */
  73051. abort: () => void;
  73052. }
  73053. }
  73054. declare module BABYLON {
  73055. /**
  73056. * Define options used to create a render target texture
  73057. */
  73058. export class RenderTargetCreationOptions {
  73059. /**
  73060. * Specifies is mipmaps must be generated
  73061. */
  73062. generateMipMaps?: boolean;
  73063. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73064. generateDepthBuffer?: boolean;
  73065. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73066. generateStencilBuffer?: boolean;
  73067. /** Defines texture type (int by default) */
  73068. type?: number;
  73069. /** Defines sampling mode (trilinear by default) */
  73070. samplingMode?: number;
  73071. /** Defines format (RGBA by default) */
  73072. format?: number;
  73073. }
  73074. }
  73075. declare module BABYLON {
  73076. /**
  73077. * @hidden
  73078. **/
  73079. export class _TimeToken {
  73080. _startTimeQuery: Nullable<WebGLQuery>;
  73081. _endTimeQuery: Nullable<WebGLQuery>;
  73082. _timeElapsedQuery: Nullable<WebGLQuery>;
  73083. _timeElapsedQueryEnded: boolean;
  73084. }
  73085. }
  73086. declare module BABYLON {
  73087. /** Defines the cross module used constants to avoid circular dependncies */
  73088. export class Constants {
  73089. /** Defines that alpha blending is disabled */
  73090. static readonly ALPHA_DISABLE: number;
  73091. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73092. static readonly ALPHA_ADD: number;
  73093. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73094. static readonly ALPHA_COMBINE: number;
  73095. /** Defines that alpha blending is DEST - SRC * DEST */
  73096. static readonly ALPHA_SUBTRACT: number;
  73097. /** Defines that alpha blending is SRC * DEST */
  73098. static readonly ALPHA_MULTIPLY: number;
  73099. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73100. static readonly ALPHA_MAXIMIZED: number;
  73101. /** Defines that alpha blending is SRC + DEST */
  73102. static readonly ALPHA_ONEONE: number;
  73103. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73104. static readonly ALPHA_PREMULTIPLIED: number;
  73105. /**
  73106. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73107. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73108. */
  73109. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73110. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73111. static readonly ALPHA_INTERPOLATE: number;
  73112. /**
  73113. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73114. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73115. */
  73116. static readonly ALPHA_SCREENMODE: number;
  73117. /**
  73118. * Defines that alpha blending is SRC + DST
  73119. * Alpha will be set to SRC ALPHA + DST ALPHA
  73120. */
  73121. static readonly ALPHA_ONEONE_ONEONE: number;
  73122. /**
  73123. * Defines that alpha blending is SRC * DST ALPHA + DST
  73124. * Alpha will be set to 0
  73125. */
  73126. static readonly ALPHA_ALPHATOCOLOR: number;
  73127. /**
  73128. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73129. */
  73130. static readonly ALPHA_REVERSEONEMINUS: number;
  73131. /**
  73132. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73133. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73134. */
  73135. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73136. /**
  73137. * Defines that alpha blending is SRC + DST
  73138. * Alpha will be set to SRC ALPHA
  73139. */
  73140. static readonly ALPHA_ONEONE_ONEZERO: number;
  73141. /**
  73142. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73143. * Alpha will be set to DST ALPHA
  73144. */
  73145. static readonly ALPHA_EXCLUSION: number;
  73146. /** Defines that alpha blending equation a SUM */
  73147. static readonly ALPHA_EQUATION_ADD: number;
  73148. /** Defines that alpha blending equation a SUBSTRACTION */
  73149. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73150. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73151. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73152. /** Defines that alpha blending equation a MAX operation */
  73153. static readonly ALPHA_EQUATION_MAX: number;
  73154. /** Defines that alpha blending equation a MIN operation */
  73155. static readonly ALPHA_EQUATION_MIN: number;
  73156. /**
  73157. * Defines that alpha blending equation a DARKEN operation:
  73158. * It takes the min of the src and sums the alpha channels.
  73159. */
  73160. static readonly ALPHA_EQUATION_DARKEN: number;
  73161. /** Defines that the ressource is not delayed*/
  73162. static readonly DELAYLOADSTATE_NONE: number;
  73163. /** Defines that the ressource was successfully delay loaded */
  73164. static readonly DELAYLOADSTATE_LOADED: number;
  73165. /** Defines that the ressource is currently delay loading */
  73166. static readonly DELAYLOADSTATE_LOADING: number;
  73167. /** Defines that the ressource is delayed and has not started loading */
  73168. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73169. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73170. static readonly NEVER: number;
  73171. /** 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 */
  73172. static readonly ALWAYS: number;
  73173. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73174. static readonly LESS: number;
  73175. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73176. static readonly EQUAL: number;
  73177. /** 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 */
  73178. static readonly LEQUAL: number;
  73179. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73180. static readonly GREATER: number;
  73181. /** 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 */
  73182. static readonly GEQUAL: number;
  73183. /** 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 */
  73184. static readonly NOTEQUAL: number;
  73185. /** Passed to stencilOperation to specify that stencil value must be kept */
  73186. static readonly KEEP: number;
  73187. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73188. static readonly REPLACE: number;
  73189. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73190. static readonly INCR: number;
  73191. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73192. static readonly DECR: number;
  73193. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73194. static readonly INVERT: number;
  73195. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73196. static readonly INCR_WRAP: number;
  73197. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73198. static readonly DECR_WRAP: number;
  73199. /** Texture is not repeating outside of 0..1 UVs */
  73200. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73201. /** Texture is repeating outside of 0..1 UVs */
  73202. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73203. /** Texture is repeating and mirrored */
  73204. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73205. /** ALPHA */
  73206. static readonly TEXTUREFORMAT_ALPHA: number;
  73207. /** LUMINANCE */
  73208. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73209. /** LUMINANCE_ALPHA */
  73210. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73211. /** RGB */
  73212. static readonly TEXTUREFORMAT_RGB: number;
  73213. /** RGBA */
  73214. static readonly TEXTUREFORMAT_RGBA: number;
  73215. /** RED */
  73216. static readonly TEXTUREFORMAT_RED: number;
  73217. /** RED (2nd reference) */
  73218. static readonly TEXTUREFORMAT_R: number;
  73219. /** RG */
  73220. static readonly TEXTUREFORMAT_RG: number;
  73221. /** RED_INTEGER */
  73222. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73223. /** RED_INTEGER (2nd reference) */
  73224. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73225. /** RG_INTEGER */
  73226. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73227. /** RGB_INTEGER */
  73228. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73229. /** RGBA_INTEGER */
  73230. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73231. /** UNSIGNED_BYTE */
  73232. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73233. /** UNSIGNED_BYTE (2nd reference) */
  73234. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73235. /** FLOAT */
  73236. static readonly TEXTURETYPE_FLOAT: number;
  73237. /** HALF_FLOAT */
  73238. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73239. /** BYTE */
  73240. static readonly TEXTURETYPE_BYTE: number;
  73241. /** SHORT */
  73242. static readonly TEXTURETYPE_SHORT: number;
  73243. /** UNSIGNED_SHORT */
  73244. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73245. /** INT */
  73246. static readonly TEXTURETYPE_INT: number;
  73247. /** UNSIGNED_INT */
  73248. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73249. /** UNSIGNED_SHORT_4_4_4_4 */
  73250. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73251. /** UNSIGNED_SHORT_5_5_5_1 */
  73252. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73253. /** UNSIGNED_SHORT_5_6_5 */
  73254. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73255. /** UNSIGNED_INT_2_10_10_10_REV */
  73256. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73257. /** UNSIGNED_INT_24_8 */
  73258. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73259. /** UNSIGNED_INT_10F_11F_11F_REV */
  73260. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73261. /** UNSIGNED_INT_5_9_9_9_REV */
  73262. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73263. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73264. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73265. /** nearest is mag = nearest and min = nearest and no mip */
  73266. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73267. /** mag = nearest and min = nearest and mip = none */
  73268. static readonly TEXTURE_NEAREST_NEAREST: number;
  73269. /** Bilinear is mag = linear and min = linear and no mip */
  73270. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73271. /** mag = linear and min = linear and mip = none */
  73272. static readonly TEXTURE_LINEAR_LINEAR: number;
  73273. /** Trilinear is mag = linear and min = linear and mip = linear */
  73274. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73275. /** Trilinear is mag = linear and min = linear and mip = linear */
  73276. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73277. /** mag = nearest and min = nearest and mip = nearest */
  73278. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73279. /** mag = nearest and min = linear and mip = nearest */
  73280. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73281. /** mag = nearest and min = linear and mip = linear */
  73282. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  73283. /** mag = nearest and min = linear and mip = none */
  73284. static readonly TEXTURE_NEAREST_LINEAR: number;
  73285. /** nearest is mag = nearest and min = nearest and mip = linear */
  73286. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  73287. /** mag = linear and min = nearest and mip = nearest */
  73288. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  73289. /** mag = linear and min = nearest and mip = linear */
  73290. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  73291. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73292. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  73293. /** mag = linear and min = nearest and mip = none */
  73294. static readonly TEXTURE_LINEAR_NEAREST: number;
  73295. /** Explicit coordinates mode */
  73296. static readonly TEXTURE_EXPLICIT_MODE: number;
  73297. /** Spherical coordinates mode */
  73298. static readonly TEXTURE_SPHERICAL_MODE: number;
  73299. /** Planar coordinates mode */
  73300. static readonly TEXTURE_PLANAR_MODE: number;
  73301. /** Cubic coordinates mode */
  73302. static readonly TEXTURE_CUBIC_MODE: number;
  73303. /** Projection coordinates mode */
  73304. static readonly TEXTURE_PROJECTION_MODE: number;
  73305. /** Skybox coordinates mode */
  73306. static readonly TEXTURE_SKYBOX_MODE: number;
  73307. /** Inverse Cubic coordinates mode */
  73308. static readonly TEXTURE_INVCUBIC_MODE: number;
  73309. /** Equirectangular coordinates mode */
  73310. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  73311. /** Equirectangular Fixed coordinates mode */
  73312. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  73313. /** Equirectangular Fixed Mirrored coordinates mode */
  73314. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73315. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  73316. static readonly SCALEMODE_FLOOR: number;
  73317. /** Defines that texture rescaling will look for the nearest power of 2 size */
  73318. static readonly SCALEMODE_NEAREST: number;
  73319. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  73320. static readonly SCALEMODE_CEILING: number;
  73321. /**
  73322. * The dirty texture flag value
  73323. */
  73324. static readonly MATERIAL_TextureDirtyFlag: number;
  73325. /**
  73326. * The dirty light flag value
  73327. */
  73328. static readonly MATERIAL_LightDirtyFlag: number;
  73329. /**
  73330. * The dirty fresnel flag value
  73331. */
  73332. static readonly MATERIAL_FresnelDirtyFlag: number;
  73333. /**
  73334. * The dirty attribute flag value
  73335. */
  73336. static readonly MATERIAL_AttributesDirtyFlag: number;
  73337. /**
  73338. * The dirty misc flag value
  73339. */
  73340. static readonly MATERIAL_MiscDirtyFlag: number;
  73341. /**
  73342. * The all dirty flag value
  73343. */
  73344. static readonly MATERIAL_AllDirtyFlag: number;
  73345. /**
  73346. * Returns the triangle fill mode
  73347. */
  73348. static readonly MATERIAL_TriangleFillMode: number;
  73349. /**
  73350. * Returns the wireframe mode
  73351. */
  73352. static readonly MATERIAL_WireFrameFillMode: number;
  73353. /**
  73354. * Returns the point fill mode
  73355. */
  73356. static readonly MATERIAL_PointFillMode: number;
  73357. /**
  73358. * Returns the point list draw mode
  73359. */
  73360. static readonly MATERIAL_PointListDrawMode: number;
  73361. /**
  73362. * Returns the line list draw mode
  73363. */
  73364. static readonly MATERIAL_LineListDrawMode: number;
  73365. /**
  73366. * Returns the line loop draw mode
  73367. */
  73368. static readonly MATERIAL_LineLoopDrawMode: number;
  73369. /**
  73370. * Returns the line strip draw mode
  73371. */
  73372. static readonly MATERIAL_LineStripDrawMode: number;
  73373. /**
  73374. * Returns the triangle strip draw mode
  73375. */
  73376. static readonly MATERIAL_TriangleStripDrawMode: number;
  73377. /**
  73378. * Returns the triangle fan draw mode
  73379. */
  73380. static readonly MATERIAL_TriangleFanDrawMode: number;
  73381. /**
  73382. * Stores the clock-wise side orientation
  73383. */
  73384. static readonly MATERIAL_ClockWiseSideOrientation: number;
  73385. /**
  73386. * Stores the counter clock-wise side orientation
  73387. */
  73388. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  73389. /**
  73390. * Nothing
  73391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73392. */
  73393. static readonly ACTION_NothingTrigger: number;
  73394. /**
  73395. * On pick
  73396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73397. */
  73398. static readonly ACTION_OnPickTrigger: number;
  73399. /**
  73400. * On left pick
  73401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73402. */
  73403. static readonly ACTION_OnLeftPickTrigger: number;
  73404. /**
  73405. * On right pick
  73406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73407. */
  73408. static readonly ACTION_OnRightPickTrigger: number;
  73409. /**
  73410. * On center pick
  73411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73412. */
  73413. static readonly ACTION_OnCenterPickTrigger: number;
  73414. /**
  73415. * On pick down
  73416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73417. */
  73418. static readonly ACTION_OnPickDownTrigger: number;
  73419. /**
  73420. * On double pick
  73421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73422. */
  73423. static readonly ACTION_OnDoublePickTrigger: number;
  73424. /**
  73425. * On pick up
  73426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73427. */
  73428. static readonly ACTION_OnPickUpTrigger: number;
  73429. /**
  73430. * On pick out.
  73431. * This trigger will only be raised if you also declared a OnPickDown
  73432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73433. */
  73434. static readonly ACTION_OnPickOutTrigger: number;
  73435. /**
  73436. * On long press
  73437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73438. */
  73439. static readonly ACTION_OnLongPressTrigger: number;
  73440. /**
  73441. * On pointer over
  73442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73443. */
  73444. static readonly ACTION_OnPointerOverTrigger: number;
  73445. /**
  73446. * On pointer out
  73447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73448. */
  73449. static readonly ACTION_OnPointerOutTrigger: number;
  73450. /**
  73451. * On every frame
  73452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73453. */
  73454. static readonly ACTION_OnEveryFrameTrigger: number;
  73455. /**
  73456. * On intersection enter
  73457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73458. */
  73459. static readonly ACTION_OnIntersectionEnterTrigger: number;
  73460. /**
  73461. * On intersection exit
  73462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73463. */
  73464. static readonly ACTION_OnIntersectionExitTrigger: number;
  73465. /**
  73466. * On key down
  73467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73468. */
  73469. static readonly ACTION_OnKeyDownTrigger: number;
  73470. /**
  73471. * On key up
  73472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73473. */
  73474. static readonly ACTION_OnKeyUpTrigger: number;
  73475. /**
  73476. * Billboard mode will only apply to Y axis
  73477. */
  73478. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  73479. /**
  73480. * Billboard mode will apply to all axes
  73481. */
  73482. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  73483. /**
  73484. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73485. */
  73486. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  73487. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  73488. * Test order :
  73489. * Is the bounding sphere outside the frustum ?
  73490. * If not, are the bounding box vertices outside the frustum ?
  73491. * It not, then the cullable object is in the frustum.
  73492. */
  73493. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  73494. /** Culling strategy : Bounding Sphere Only.
  73495. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  73496. * It's also less accurate than the standard because some not visible objects can still be selected.
  73497. * Test : is the bounding sphere outside the frustum ?
  73498. * If not, then the cullable object is in the frustum.
  73499. */
  73500. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  73501. /** Culling strategy : Optimistic Inclusion.
  73502. * This in an inclusion test first, then the standard exclusion test.
  73503. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  73504. * 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.
  73505. * Anyway, it's as accurate as the standard strategy.
  73506. * Test :
  73507. * Is the cullable object bounding sphere center in the frustum ?
  73508. * If not, apply the default culling strategy.
  73509. */
  73510. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  73511. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  73512. * This in an inclusion test first, then the bounding sphere only exclusion test.
  73513. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  73514. * 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.
  73515. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  73516. * Test :
  73517. * Is the cullable object bounding sphere center in the frustum ?
  73518. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  73519. */
  73520. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  73521. /**
  73522. * No logging while loading
  73523. */
  73524. static readonly SCENELOADER_NO_LOGGING: number;
  73525. /**
  73526. * Minimal logging while loading
  73527. */
  73528. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  73529. /**
  73530. * Summary logging while loading
  73531. */
  73532. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  73533. /**
  73534. * Detailled logging while loading
  73535. */
  73536. static readonly SCENELOADER_DETAILED_LOGGING: number;
  73537. }
  73538. }
  73539. declare module BABYLON {
  73540. /**
  73541. * This represents the required contract to create a new type of texture loader.
  73542. */
  73543. export interface IInternalTextureLoader {
  73544. /**
  73545. * Defines wether the loader supports cascade loading the different faces.
  73546. */
  73547. supportCascades: boolean;
  73548. /**
  73549. * This returns if the loader support the current file information.
  73550. * @param extension defines the file extension of the file being loaded
  73551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73552. * @param fallback defines the fallback internal texture if any
  73553. * @param isBase64 defines whether the texture is encoded as a base64
  73554. * @param isBuffer defines whether the texture data are stored as a buffer
  73555. * @returns true if the loader can load the specified file
  73556. */
  73557. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73558. /**
  73559. * Transform the url before loading if required.
  73560. * @param rootUrl the url of the texture
  73561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73562. * @returns the transformed texture
  73563. */
  73564. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73565. /**
  73566. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73567. * @param rootUrl the url of the texture
  73568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73569. * @returns the fallback texture
  73570. */
  73571. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73572. /**
  73573. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73574. * @param data contains the texture data
  73575. * @param texture defines the BabylonJS internal texture
  73576. * @param createPolynomials will be true if polynomials have been requested
  73577. * @param onLoad defines the callback to trigger once the texture is ready
  73578. * @param onError defines the callback to trigger in case of error
  73579. */
  73580. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73581. /**
  73582. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73583. * @param data contains the texture data
  73584. * @param texture defines the BabylonJS internal texture
  73585. * @param callback defines the method to call once ready to upload
  73586. */
  73587. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73588. }
  73589. }
  73590. declare module BABYLON {
  73591. /**
  73592. * Class used to store and describe the pipeline context associated with an effect
  73593. */
  73594. export interface IPipelineContext {
  73595. /**
  73596. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  73597. */
  73598. isAsync: boolean;
  73599. /**
  73600. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  73601. */
  73602. isReady: boolean;
  73603. /** @hidden */
  73604. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  73605. }
  73606. }
  73607. declare module BABYLON {
  73608. /**
  73609. * Class used to store gfx data (like WebGLBuffer)
  73610. */
  73611. export class DataBuffer {
  73612. /**
  73613. * Gets or sets the number of objects referencing this buffer
  73614. */
  73615. references: number;
  73616. /** Gets or sets the size of the underlying buffer */
  73617. capacity: number;
  73618. /**
  73619. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  73620. */
  73621. is32Bits: boolean;
  73622. /**
  73623. * Gets the underlying buffer
  73624. */
  73625. get underlyingResource(): any;
  73626. }
  73627. }
  73628. declare module BABYLON {
  73629. /** @hidden */
  73630. export interface IShaderProcessor {
  73631. attributeProcessor?: (attribute: string) => string;
  73632. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  73633. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  73634. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  73635. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  73636. lineProcessor?: (line: string, isFragment: boolean) => string;
  73637. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73638. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73639. }
  73640. }
  73641. declare module BABYLON {
  73642. /** @hidden */
  73643. export interface ProcessingOptions {
  73644. defines: string[];
  73645. indexParameters: any;
  73646. isFragment: boolean;
  73647. shouldUseHighPrecisionShader: boolean;
  73648. supportsUniformBuffers: boolean;
  73649. shadersRepository: string;
  73650. includesShadersStore: {
  73651. [key: string]: string;
  73652. };
  73653. processor?: IShaderProcessor;
  73654. version: string;
  73655. platformName: string;
  73656. lookForClosingBracketForUniformBuffer?: boolean;
  73657. }
  73658. }
  73659. declare module BABYLON {
  73660. /** @hidden */
  73661. export class ShaderCodeNode {
  73662. line: string;
  73663. children: ShaderCodeNode[];
  73664. additionalDefineKey?: string;
  73665. additionalDefineValue?: string;
  73666. isValid(preprocessors: {
  73667. [key: string]: string;
  73668. }): boolean;
  73669. process(preprocessors: {
  73670. [key: string]: string;
  73671. }, options: ProcessingOptions): string;
  73672. }
  73673. }
  73674. declare module BABYLON {
  73675. /** @hidden */
  73676. export class ShaderCodeCursor {
  73677. private _lines;
  73678. lineIndex: number;
  73679. get currentLine(): string;
  73680. get canRead(): boolean;
  73681. set lines(value: string[]);
  73682. }
  73683. }
  73684. declare module BABYLON {
  73685. /** @hidden */
  73686. export class ShaderCodeConditionNode extends ShaderCodeNode {
  73687. process(preprocessors: {
  73688. [key: string]: string;
  73689. }, options: ProcessingOptions): string;
  73690. }
  73691. }
  73692. declare module BABYLON {
  73693. /** @hidden */
  73694. export class ShaderDefineExpression {
  73695. isTrue(preprocessors: {
  73696. [key: string]: string;
  73697. }): boolean;
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /** @hidden */
  73702. export class ShaderCodeTestNode extends ShaderCodeNode {
  73703. testExpression: ShaderDefineExpression;
  73704. isValid(preprocessors: {
  73705. [key: string]: string;
  73706. }): boolean;
  73707. }
  73708. }
  73709. declare module BABYLON {
  73710. /** @hidden */
  73711. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  73712. define: string;
  73713. not: boolean;
  73714. constructor(define: string, not?: boolean);
  73715. isTrue(preprocessors: {
  73716. [key: string]: string;
  73717. }): boolean;
  73718. }
  73719. }
  73720. declare module BABYLON {
  73721. /** @hidden */
  73722. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  73723. leftOperand: ShaderDefineExpression;
  73724. rightOperand: ShaderDefineExpression;
  73725. isTrue(preprocessors: {
  73726. [key: string]: string;
  73727. }): boolean;
  73728. }
  73729. }
  73730. declare module BABYLON {
  73731. /** @hidden */
  73732. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  73733. leftOperand: ShaderDefineExpression;
  73734. rightOperand: ShaderDefineExpression;
  73735. isTrue(preprocessors: {
  73736. [key: string]: string;
  73737. }): boolean;
  73738. }
  73739. }
  73740. declare module BABYLON {
  73741. /** @hidden */
  73742. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  73743. define: string;
  73744. operand: string;
  73745. testValue: string;
  73746. constructor(define: string, operand: string, testValue: string);
  73747. isTrue(preprocessors: {
  73748. [key: string]: string;
  73749. }): boolean;
  73750. }
  73751. }
  73752. declare module BABYLON {
  73753. /**
  73754. * Class used to enable access to offline support
  73755. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  73756. */
  73757. export interface IOfflineProvider {
  73758. /**
  73759. * Gets a boolean indicating if scene must be saved in the database
  73760. */
  73761. enableSceneOffline: boolean;
  73762. /**
  73763. * Gets a boolean indicating if textures must be saved in the database
  73764. */
  73765. enableTexturesOffline: boolean;
  73766. /**
  73767. * Open the offline support and make it available
  73768. * @param successCallback defines the callback to call on success
  73769. * @param errorCallback defines the callback to call on error
  73770. */
  73771. open(successCallback: () => void, errorCallback: () => void): void;
  73772. /**
  73773. * Loads an image from the offline support
  73774. * @param url defines the url to load from
  73775. * @param image defines the target DOM image
  73776. */
  73777. loadImage(url: string, image: HTMLImageElement): void;
  73778. /**
  73779. * Loads a file from offline support
  73780. * @param url defines the URL to load from
  73781. * @param sceneLoaded defines a callback to call on success
  73782. * @param progressCallBack defines a callback to call when progress changed
  73783. * @param errorCallback defines a callback to call on error
  73784. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  73785. */
  73786. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Class used to help managing file picking and drag'n'drop
  73792. * File Storage
  73793. */
  73794. export class FilesInputStore {
  73795. /**
  73796. * List of files ready to be loaded
  73797. */
  73798. static FilesToLoad: {
  73799. [key: string]: File;
  73800. };
  73801. }
  73802. }
  73803. declare module BABYLON {
  73804. /**
  73805. * Class used to define a retry strategy when error happens while loading assets
  73806. */
  73807. export class RetryStrategy {
  73808. /**
  73809. * Function used to defines an exponential back off strategy
  73810. * @param maxRetries defines the maximum number of retries (3 by default)
  73811. * @param baseInterval defines the interval between retries
  73812. * @returns the strategy function to use
  73813. */
  73814. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  73815. }
  73816. }
  73817. declare module BABYLON {
  73818. /**
  73819. * @ignore
  73820. * Application error to support additional information when loading a file
  73821. */
  73822. export abstract class BaseError extends Error {
  73823. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  73824. }
  73825. }
  73826. declare module BABYLON {
  73827. /** @ignore */
  73828. export class LoadFileError extends BaseError {
  73829. request?: WebRequest;
  73830. file?: File;
  73831. /**
  73832. * Creates a new LoadFileError
  73833. * @param message defines the message of the error
  73834. * @param request defines the optional web request
  73835. * @param file defines the optional file
  73836. */
  73837. constructor(message: string, object?: WebRequest | File);
  73838. }
  73839. /** @ignore */
  73840. export class RequestFileError extends BaseError {
  73841. request: WebRequest;
  73842. /**
  73843. * Creates a new LoadFileError
  73844. * @param message defines the message of the error
  73845. * @param request defines the optional web request
  73846. */
  73847. constructor(message: string, request: WebRequest);
  73848. }
  73849. /** @ignore */
  73850. export class ReadFileError extends BaseError {
  73851. file: File;
  73852. /**
  73853. * Creates a new ReadFileError
  73854. * @param message defines the message of the error
  73855. * @param file defines the optional file
  73856. */
  73857. constructor(message: string, file: File);
  73858. }
  73859. /**
  73860. * @hidden
  73861. */
  73862. export class FileTools {
  73863. /**
  73864. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  73865. */
  73866. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  73867. /**
  73868. * Gets or sets the base URL to use to load assets
  73869. */
  73870. static BaseUrl: string;
  73871. /**
  73872. * Default behaviour for cors in the application.
  73873. * It can be a string if the expected behavior is identical in the entire app.
  73874. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  73875. */
  73876. static CorsBehavior: string | ((url: string | string[]) => string);
  73877. /**
  73878. * Gets or sets a function used to pre-process url before using them to load assets
  73879. */
  73880. static PreprocessUrl: (url: string) => string;
  73881. /**
  73882. * Removes unwanted characters from an url
  73883. * @param url defines the url to clean
  73884. * @returns the cleaned url
  73885. */
  73886. private static _CleanUrl;
  73887. /**
  73888. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  73889. * @param url define the url we are trying
  73890. * @param element define the dom element where to configure the cors policy
  73891. */
  73892. static SetCorsBehavior(url: string | string[], element: {
  73893. crossOrigin: string | null;
  73894. }): void;
  73895. /**
  73896. * Loads an image as an HTMLImageElement.
  73897. * @param input url string, ArrayBuffer, or Blob to load
  73898. * @param onLoad callback called when the image successfully loads
  73899. * @param onError callback called when the image fails to load
  73900. * @param offlineProvider offline provider for caching
  73901. * @param mimeType optional mime type
  73902. * @returns the HTMLImageElement of the loaded image
  73903. */
  73904. 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>;
  73905. /**
  73906. * Reads a file from a File object
  73907. * @param file defines the file to load
  73908. * @param onSuccess defines the callback to call when data is loaded
  73909. * @param onProgress defines the callback to call during loading process
  73910. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  73911. * @param onError defines the callback to call when an error occurs
  73912. * @returns a file request object
  73913. */
  73914. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  73915. /**
  73916. * Loads a file from a url
  73917. * @param url url to load
  73918. * @param onSuccess callback called when the file successfully loads
  73919. * @param onProgress callback called while file is loading (if the server supports this mode)
  73920. * @param offlineProvider defines the offline provider for caching
  73921. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73922. * @param onError callback called when the file fails to load
  73923. * @returns a file request object
  73924. */
  73925. 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;
  73926. /**
  73927. * Loads a file
  73928. * @param url url to load
  73929. * @param onSuccess callback called when the file successfully loads
  73930. * @param onProgress callback called while file is loading (if the server supports this mode)
  73931. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73932. * @param onError callback called when the file fails to load
  73933. * @param onOpened callback called when the web request is opened
  73934. * @returns a file request object
  73935. */
  73936. 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;
  73937. /**
  73938. * Checks if the loaded document was accessed via `file:`-Protocol.
  73939. * @returns boolean
  73940. */
  73941. static IsFileURL(): boolean;
  73942. }
  73943. }
  73944. declare module BABYLON {
  73945. /** @hidden */
  73946. export class ShaderProcessor {
  73947. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  73948. private static _ProcessPrecision;
  73949. private static _ExtractOperation;
  73950. private static _BuildSubExpression;
  73951. private static _BuildExpression;
  73952. private static _MoveCursorWithinIf;
  73953. private static _MoveCursor;
  73954. private static _EvaluatePreProcessors;
  73955. private static _PreparePreProcessors;
  73956. private static _ProcessShaderConversion;
  73957. private static _ProcessIncludes;
  73958. /**
  73959. * Loads a file from a url
  73960. * @param url url to load
  73961. * @param onSuccess callback called when the file successfully loads
  73962. * @param onProgress callback called while file is loading (if the server supports this mode)
  73963. * @param offlineProvider defines the offline provider for caching
  73964. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73965. * @param onError callback called when the file fails to load
  73966. * @returns a file request object
  73967. * @hidden
  73968. */
  73969. 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;
  73970. }
  73971. }
  73972. declare module BABYLON {
  73973. /**
  73974. * @hidden
  73975. */
  73976. export interface IColor4Like {
  73977. r: float;
  73978. g: float;
  73979. b: float;
  73980. a: float;
  73981. }
  73982. /**
  73983. * @hidden
  73984. */
  73985. export interface IColor3Like {
  73986. r: float;
  73987. g: float;
  73988. b: float;
  73989. }
  73990. /**
  73991. * @hidden
  73992. */
  73993. export interface IVector4Like {
  73994. x: float;
  73995. y: float;
  73996. z: float;
  73997. w: float;
  73998. }
  73999. /**
  74000. * @hidden
  74001. */
  74002. export interface IVector3Like {
  74003. x: float;
  74004. y: float;
  74005. z: float;
  74006. }
  74007. /**
  74008. * @hidden
  74009. */
  74010. export interface IVector2Like {
  74011. x: float;
  74012. y: float;
  74013. }
  74014. /**
  74015. * @hidden
  74016. */
  74017. export interface IMatrixLike {
  74018. toArray(): DeepImmutable<Float32Array>;
  74019. updateFlag: int;
  74020. }
  74021. /**
  74022. * @hidden
  74023. */
  74024. export interface IViewportLike {
  74025. x: float;
  74026. y: float;
  74027. width: float;
  74028. height: float;
  74029. }
  74030. /**
  74031. * @hidden
  74032. */
  74033. export interface IPlaneLike {
  74034. normal: IVector3Like;
  74035. d: float;
  74036. normalize(): void;
  74037. }
  74038. }
  74039. declare module BABYLON {
  74040. /**
  74041. * Interface used to define common properties for effect fallbacks
  74042. */
  74043. export interface IEffectFallbacks {
  74044. /**
  74045. * Removes the defines that should be removed when falling back.
  74046. * @param currentDefines defines the current define statements for the shader.
  74047. * @param effect defines the current effect we try to compile
  74048. * @returns The resulting defines with defines of the current rank removed.
  74049. */
  74050. reduce(currentDefines: string, effect: Effect): string;
  74051. /**
  74052. * Removes the fallback from the bound mesh.
  74053. */
  74054. unBindMesh(): void;
  74055. /**
  74056. * Checks to see if more fallbacks are still availible.
  74057. */
  74058. hasMoreFallbacks: boolean;
  74059. }
  74060. }
  74061. declare module BABYLON {
  74062. /**
  74063. * Class used to evalaute queries containing `and` and `or` operators
  74064. */
  74065. export class AndOrNotEvaluator {
  74066. /**
  74067. * Evaluate a query
  74068. * @param query defines the query to evaluate
  74069. * @param evaluateCallback defines the callback used to filter result
  74070. * @returns true if the query matches
  74071. */
  74072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74073. private static _HandleParenthesisContent;
  74074. private static _SimplifyNegation;
  74075. }
  74076. }
  74077. declare module BABYLON {
  74078. /**
  74079. * Class used to store custom tags
  74080. */
  74081. export class Tags {
  74082. /**
  74083. * Adds support for tags on the given object
  74084. * @param obj defines the object to use
  74085. */
  74086. static EnableFor(obj: any): void;
  74087. /**
  74088. * Removes tags support
  74089. * @param obj defines the object to use
  74090. */
  74091. static DisableFor(obj: any): void;
  74092. /**
  74093. * Gets a boolean indicating if the given object has tags
  74094. * @param obj defines the object to use
  74095. * @returns a boolean
  74096. */
  74097. static HasTags(obj: any): boolean;
  74098. /**
  74099. * Gets the tags available on a given object
  74100. * @param obj defines the object to use
  74101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74102. * @returns the tags
  74103. */
  74104. static GetTags(obj: any, asString?: boolean): any;
  74105. /**
  74106. * Adds tags to an object
  74107. * @param obj defines the object to use
  74108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74110. */
  74111. static AddTagsTo(obj: any, tagsString: string): void;
  74112. /**
  74113. * @hidden
  74114. */
  74115. static _AddTagTo(obj: any, tag: string): void;
  74116. /**
  74117. * Removes specific tags from a specific object
  74118. * @param obj defines the object to use
  74119. * @param tagsString defines the tags to remove
  74120. */
  74121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74122. /**
  74123. * @hidden
  74124. */
  74125. static _RemoveTagFrom(obj: any, tag: string): void;
  74126. /**
  74127. * Defines if tags hosted on an object match a given query
  74128. * @param obj defines the object to use
  74129. * @param tagsQuery defines the tag query
  74130. * @returns a boolean
  74131. */
  74132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74133. }
  74134. }
  74135. declare module BABYLON {
  74136. /**
  74137. * Scalar computation library
  74138. */
  74139. export class Scalar {
  74140. /**
  74141. * Two pi constants convenient for computation.
  74142. */
  74143. static TwoPi: number;
  74144. /**
  74145. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74146. * @param a number
  74147. * @param b number
  74148. * @param epsilon (default = 1.401298E-45)
  74149. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74150. */
  74151. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74152. /**
  74153. * Returns a string : the upper case translation of the number i to hexadecimal.
  74154. * @param i number
  74155. * @returns the upper case translation of the number i to hexadecimal.
  74156. */
  74157. static ToHex(i: number): string;
  74158. /**
  74159. * Returns -1 if value is negative and +1 is value is positive.
  74160. * @param value the value
  74161. * @returns the value itself if it's equal to zero.
  74162. */
  74163. static Sign(value: number): number;
  74164. /**
  74165. * Returns the value itself if it's between min and max.
  74166. * Returns min if the value is lower than min.
  74167. * Returns max if the value is greater than max.
  74168. * @param value the value to clmap
  74169. * @param min the min value to clamp to (default: 0)
  74170. * @param max the max value to clamp to (default: 1)
  74171. * @returns the clamped value
  74172. */
  74173. static Clamp(value: number, min?: number, max?: number): number;
  74174. /**
  74175. * the log2 of value.
  74176. * @param value the value to compute log2 of
  74177. * @returns the log2 of value.
  74178. */
  74179. static Log2(value: number): number;
  74180. /**
  74181. * Loops the value, so that it is never larger than length and never smaller than 0.
  74182. *
  74183. * This is similar to the modulo operator but it works with floating point numbers.
  74184. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74185. * With t = 5 and length = 2.5, the result would be 0.0.
  74186. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74187. * @param value the value
  74188. * @param length the length
  74189. * @returns the looped value
  74190. */
  74191. static Repeat(value: number, length: number): number;
  74192. /**
  74193. * Normalize the value between 0.0 and 1.0 using min and max values
  74194. * @param value value to normalize
  74195. * @param min max to normalize between
  74196. * @param max min to normalize between
  74197. * @returns the normalized value
  74198. */
  74199. static Normalize(value: number, min: number, max: number): number;
  74200. /**
  74201. * Denormalize the value from 0.0 and 1.0 using min and max values
  74202. * @param normalized value to denormalize
  74203. * @param min max to denormalize between
  74204. * @param max min to denormalize between
  74205. * @returns the denormalized value
  74206. */
  74207. static Denormalize(normalized: number, min: number, max: number): number;
  74208. /**
  74209. * Calculates the shortest difference between two given angles given in degrees.
  74210. * @param current current angle in degrees
  74211. * @param target target angle in degrees
  74212. * @returns the delta
  74213. */
  74214. static DeltaAngle(current: number, target: number): number;
  74215. /**
  74216. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74217. * @param tx value
  74218. * @param length length
  74219. * @returns The returned value will move back and forth between 0 and length
  74220. */
  74221. static PingPong(tx: number, length: number): number;
  74222. /**
  74223. * Interpolates between min and max with smoothing at the limits.
  74224. *
  74225. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74226. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74227. * @param from from
  74228. * @param to to
  74229. * @param tx value
  74230. * @returns the smooth stepped value
  74231. */
  74232. static SmoothStep(from: number, to: number, tx: number): number;
  74233. /**
  74234. * Moves a value current towards target.
  74235. *
  74236. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74237. * Negative values of maxDelta pushes the value away from target.
  74238. * @param current current value
  74239. * @param target target value
  74240. * @param maxDelta max distance to move
  74241. * @returns resulting value
  74242. */
  74243. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74244. /**
  74245. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74246. *
  74247. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74248. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74249. * @param current current value
  74250. * @param target target value
  74251. * @param maxDelta max distance to move
  74252. * @returns resulting angle
  74253. */
  74254. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74255. /**
  74256. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74257. * @param start start value
  74258. * @param end target value
  74259. * @param amount amount to lerp between
  74260. * @returns the lerped value
  74261. */
  74262. static Lerp(start: number, end: number, amount: number): number;
  74263. /**
  74264. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74265. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74266. * @param start start value
  74267. * @param end target value
  74268. * @param amount amount to lerp between
  74269. * @returns the lerped value
  74270. */
  74271. static LerpAngle(start: number, end: number, amount: number): number;
  74272. /**
  74273. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74274. * @param a start value
  74275. * @param b target value
  74276. * @param value value between a and b
  74277. * @returns the inverseLerp value
  74278. */
  74279. static InverseLerp(a: number, b: number, value: number): number;
  74280. /**
  74281. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74282. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74283. * @param value1 spline value
  74284. * @param tangent1 spline value
  74285. * @param value2 spline value
  74286. * @param tangent2 spline value
  74287. * @param amount input value
  74288. * @returns hermite result
  74289. */
  74290. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74291. /**
  74292. * Returns a random float number between and min and max values
  74293. * @param min min value of random
  74294. * @param max max value of random
  74295. * @returns random value
  74296. */
  74297. static RandomRange(min: number, max: number): number;
  74298. /**
  74299. * This function returns percentage of a number in a given range.
  74300. *
  74301. * RangeToPercent(40,20,60) will return 0.5 (50%)
  74302. * RangeToPercent(34,0,100) will return 0.34 (34%)
  74303. * @param number to convert to percentage
  74304. * @param min min range
  74305. * @param max max range
  74306. * @returns the percentage
  74307. */
  74308. static RangeToPercent(number: number, min: number, max: number): number;
  74309. /**
  74310. * This function returns number that corresponds to the percentage in a given range.
  74311. *
  74312. * PercentToRange(0.34,0,100) will return 34.
  74313. * @param percent to convert to number
  74314. * @param min min range
  74315. * @param max max range
  74316. * @returns the number
  74317. */
  74318. static PercentToRange(percent: number, min: number, max: number): number;
  74319. /**
  74320. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  74321. * @param angle The angle to normalize in radian.
  74322. * @return The converted angle.
  74323. */
  74324. static NormalizeRadians(angle: number): number;
  74325. }
  74326. }
  74327. declare module BABYLON {
  74328. /**
  74329. * Constant used to convert a value to gamma space
  74330. * @ignorenaming
  74331. */
  74332. export const ToGammaSpace: number;
  74333. /**
  74334. * Constant used to convert a value to linear space
  74335. * @ignorenaming
  74336. */
  74337. export const ToLinearSpace = 2.2;
  74338. /**
  74339. * Constant used to define the minimal number value in Babylon.js
  74340. * @ignorenaming
  74341. */
  74342. let Epsilon: number;
  74343. }
  74344. declare module BABYLON {
  74345. /**
  74346. * Class used to represent a viewport on screen
  74347. */
  74348. export class Viewport {
  74349. /** viewport left coordinate */
  74350. x: number;
  74351. /** viewport top coordinate */
  74352. y: number;
  74353. /**viewport width */
  74354. width: number;
  74355. /** viewport height */
  74356. height: number;
  74357. /**
  74358. * Creates a Viewport object located at (x, y) and sized (width, height)
  74359. * @param x defines viewport left coordinate
  74360. * @param y defines viewport top coordinate
  74361. * @param width defines the viewport width
  74362. * @param height defines the viewport height
  74363. */
  74364. constructor(
  74365. /** viewport left coordinate */
  74366. x: number,
  74367. /** viewport top coordinate */
  74368. y: number,
  74369. /**viewport width */
  74370. width: number,
  74371. /** viewport height */
  74372. height: number);
  74373. /**
  74374. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74375. * @param renderWidth defines the rendering width
  74376. * @param renderHeight defines the rendering height
  74377. * @returns a new Viewport
  74378. */
  74379. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  74380. /**
  74381. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74382. * @param renderWidth defines the rendering width
  74383. * @param renderHeight defines the rendering height
  74384. * @param ref defines the target viewport
  74385. * @returns the current viewport
  74386. */
  74387. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  74388. /**
  74389. * Returns a new Viewport copied from the current one
  74390. * @returns a new Viewport
  74391. */
  74392. clone(): Viewport;
  74393. }
  74394. }
  74395. declare module BABYLON {
  74396. /**
  74397. * Class containing a set of static utilities functions for arrays.
  74398. */
  74399. export class ArrayTools {
  74400. /**
  74401. * Returns an array of the given size filled with element built from the given constructor and the paramters
  74402. * @param size the number of element to construct and put in the array
  74403. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  74404. * @returns a new array filled with new objects
  74405. */
  74406. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  74407. }
  74408. }
  74409. declare module BABYLON {
  74410. /**
  74411. * Class representing a vector containing 2 coordinates
  74412. */
  74413. export class Vector2 {
  74414. /** defines the first coordinate */
  74415. x: number;
  74416. /** defines the second coordinate */
  74417. y: number;
  74418. /**
  74419. * Creates a new Vector2 from the given x and y coordinates
  74420. * @param x defines the first coordinate
  74421. * @param y defines the second coordinate
  74422. */
  74423. constructor(
  74424. /** defines the first coordinate */
  74425. x?: number,
  74426. /** defines the second coordinate */
  74427. y?: number);
  74428. /**
  74429. * Gets a string with the Vector2 coordinates
  74430. * @returns a string with the Vector2 coordinates
  74431. */
  74432. toString(): string;
  74433. /**
  74434. * Gets class name
  74435. * @returns the string "Vector2"
  74436. */
  74437. getClassName(): string;
  74438. /**
  74439. * Gets current vector hash code
  74440. * @returns the Vector2 hash code as a number
  74441. */
  74442. getHashCode(): number;
  74443. /**
  74444. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  74445. * @param array defines the source array
  74446. * @param index defines the offset in source array
  74447. * @returns the current Vector2
  74448. */
  74449. toArray(array: FloatArray, index?: number): Vector2;
  74450. /**
  74451. * Copy the current vector to an array
  74452. * @returns a new array with 2 elements: the Vector2 coordinates.
  74453. */
  74454. asArray(): number[];
  74455. /**
  74456. * Sets the Vector2 coordinates with the given Vector2 coordinates
  74457. * @param source defines the source Vector2
  74458. * @returns the current updated Vector2
  74459. */
  74460. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  74461. /**
  74462. * Sets the Vector2 coordinates with the given floats
  74463. * @param x defines the first coordinate
  74464. * @param y defines the second coordinate
  74465. * @returns the current updated Vector2
  74466. */
  74467. copyFromFloats(x: number, y: number): Vector2;
  74468. /**
  74469. * Sets the Vector2 coordinates with the given floats
  74470. * @param x defines the first coordinate
  74471. * @param y defines the second coordinate
  74472. * @returns the current updated Vector2
  74473. */
  74474. set(x: number, y: number): Vector2;
  74475. /**
  74476. * Add another vector with the current one
  74477. * @param otherVector defines the other vector
  74478. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  74479. */
  74480. add(otherVector: DeepImmutable<Vector2>): Vector2;
  74481. /**
  74482. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  74483. * @param otherVector defines the other vector
  74484. * @param result defines the target vector
  74485. * @returns the unmodified current Vector2
  74486. */
  74487. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74488. /**
  74489. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  74490. * @param otherVector defines the other vector
  74491. * @returns the current updated Vector2
  74492. */
  74493. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74494. /**
  74495. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  74496. * @param otherVector defines the other vector
  74497. * @returns a new Vector2
  74498. */
  74499. addVector3(otherVector: Vector3): Vector2;
  74500. /**
  74501. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  74502. * @param otherVector defines the other vector
  74503. * @returns a new Vector2
  74504. */
  74505. subtract(otherVector: Vector2): Vector2;
  74506. /**
  74507. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  74508. * @param otherVector defines the other vector
  74509. * @param result defines the target vector
  74510. * @returns the unmodified current Vector2
  74511. */
  74512. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74513. /**
  74514. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  74515. * @param otherVector defines the other vector
  74516. * @returns the current updated Vector2
  74517. */
  74518. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74519. /**
  74520. * Multiplies in place the current Vector2 coordinates by the given ones
  74521. * @param otherVector defines the other vector
  74522. * @returns the current updated Vector2
  74523. */
  74524. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74525. /**
  74526. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  74527. * @param otherVector defines the other vector
  74528. * @returns a new Vector2
  74529. */
  74530. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  74531. /**
  74532. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  74533. * @param otherVector defines the other vector
  74534. * @param result defines the target vector
  74535. * @returns the unmodified current Vector2
  74536. */
  74537. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74538. /**
  74539. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  74540. * @param x defines the first coordinate
  74541. * @param y defines the second coordinate
  74542. * @returns a new Vector2
  74543. */
  74544. multiplyByFloats(x: number, y: number): Vector2;
  74545. /**
  74546. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  74547. * @param otherVector defines the other vector
  74548. * @returns a new Vector2
  74549. */
  74550. divide(otherVector: Vector2): Vector2;
  74551. /**
  74552. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  74553. * @param otherVector defines the other vector
  74554. * @param result defines the target vector
  74555. * @returns the unmodified current Vector2
  74556. */
  74557. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74558. /**
  74559. * Divides the current Vector2 coordinates by the given ones
  74560. * @param otherVector defines the other vector
  74561. * @returns the current updated Vector2
  74562. */
  74563. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74564. /**
  74565. * Gets a new Vector2 with current Vector2 negated coordinates
  74566. * @returns a new Vector2
  74567. */
  74568. negate(): Vector2;
  74569. /**
  74570. * Multiply the Vector2 coordinates by scale
  74571. * @param scale defines the scaling factor
  74572. * @returns the current updated Vector2
  74573. */
  74574. scaleInPlace(scale: number): Vector2;
  74575. /**
  74576. * Returns a new Vector2 scaled by "scale" from the current Vector2
  74577. * @param scale defines the scaling factor
  74578. * @returns a new Vector2
  74579. */
  74580. scale(scale: number): Vector2;
  74581. /**
  74582. * Scale the current Vector2 values by a factor to a given Vector2
  74583. * @param scale defines the scale factor
  74584. * @param result defines the Vector2 object where to store the result
  74585. * @returns the unmodified current Vector2
  74586. */
  74587. scaleToRef(scale: number, result: Vector2): Vector2;
  74588. /**
  74589. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  74590. * @param scale defines the scale factor
  74591. * @param result defines the Vector2 object where to store the result
  74592. * @returns the unmodified current Vector2
  74593. */
  74594. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  74595. /**
  74596. * Gets a boolean if two vectors are equals
  74597. * @param otherVector defines the other vector
  74598. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  74599. */
  74600. equals(otherVector: DeepImmutable<Vector2>): boolean;
  74601. /**
  74602. * Gets a boolean if two vectors are equals (using an epsilon value)
  74603. * @param otherVector defines the other vector
  74604. * @param epsilon defines the minimal distance to consider equality
  74605. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  74606. */
  74607. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  74608. /**
  74609. * Gets a new Vector2 from current Vector2 floored values
  74610. * @returns a new Vector2
  74611. */
  74612. floor(): Vector2;
  74613. /**
  74614. * Gets a new Vector2 from current Vector2 floored values
  74615. * @returns a new Vector2
  74616. */
  74617. fract(): Vector2;
  74618. /**
  74619. * Gets the length of the vector
  74620. * @returns the vector length (float)
  74621. */
  74622. length(): number;
  74623. /**
  74624. * Gets the vector squared length
  74625. * @returns the vector squared length (float)
  74626. */
  74627. lengthSquared(): number;
  74628. /**
  74629. * Normalize the vector
  74630. * @returns the current updated Vector2
  74631. */
  74632. normalize(): Vector2;
  74633. /**
  74634. * Gets a new Vector2 copied from the Vector2
  74635. * @returns a new Vector2
  74636. */
  74637. clone(): Vector2;
  74638. /**
  74639. * Gets a new Vector2(0, 0)
  74640. * @returns a new Vector2
  74641. */
  74642. static Zero(): Vector2;
  74643. /**
  74644. * Gets a new Vector2(1, 1)
  74645. * @returns a new Vector2
  74646. */
  74647. static One(): Vector2;
  74648. /**
  74649. * Gets a new Vector2 set from the given index element of the given array
  74650. * @param array defines the data source
  74651. * @param offset defines the offset in the data source
  74652. * @returns a new Vector2
  74653. */
  74654. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  74655. /**
  74656. * Sets "result" from the given index element of the given array
  74657. * @param array defines the data source
  74658. * @param offset defines the offset in the data source
  74659. * @param result defines the target vector
  74660. */
  74661. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  74662. /**
  74663. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  74664. * @param value1 defines 1st point of control
  74665. * @param value2 defines 2nd point of control
  74666. * @param value3 defines 3rd point of control
  74667. * @param value4 defines 4th point of control
  74668. * @param amount defines the interpolation factor
  74669. * @returns a new Vector2
  74670. */
  74671. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  74672. /**
  74673. * 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".
  74674. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  74675. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  74676. * @param value defines the value to clamp
  74677. * @param min defines the lower limit
  74678. * @param max defines the upper limit
  74679. * @returns a new Vector2
  74680. */
  74681. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  74682. /**
  74683. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  74684. * @param value1 defines the 1st control point
  74685. * @param tangent1 defines the outgoing tangent
  74686. * @param value2 defines the 2nd control point
  74687. * @param tangent2 defines the incoming tangent
  74688. * @param amount defines the interpolation factor
  74689. * @returns a new Vector2
  74690. */
  74691. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  74692. /**
  74693. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  74694. * @param start defines the start vector
  74695. * @param end defines the end vector
  74696. * @param amount defines the interpolation factor
  74697. * @returns a new Vector2
  74698. */
  74699. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  74700. /**
  74701. * Gets the dot product of the vector "left" and the vector "right"
  74702. * @param left defines first vector
  74703. * @param right defines second vector
  74704. * @returns the dot product (float)
  74705. */
  74706. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  74707. /**
  74708. * Returns a new Vector2 equal to the normalized given vector
  74709. * @param vector defines the vector to normalize
  74710. * @returns a new Vector2
  74711. */
  74712. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  74713. /**
  74714. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  74715. * @param left defines 1st vector
  74716. * @param right defines 2nd vector
  74717. * @returns a new Vector2
  74718. */
  74719. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74720. /**
  74721. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  74722. * @param left defines 1st vector
  74723. * @param right defines 2nd vector
  74724. * @returns a new Vector2
  74725. */
  74726. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74727. /**
  74728. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  74729. * @param vector defines the vector to transform
  74730. * @param transformation defines the matrix to apply
  74731. * @returns a new Vector2
  74732. */
  74733. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  74734. /**
  74735. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  74736. * @param vector defines the vector to transform
  74737. * @param transformation defines the matrix to apply
  74738. * @param result defines the target vector
  74739. */
  74740. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  74741. /**
  74742. * Determines if a given vector is included in a triangle
  74743. * @param p defines the vector to test
  74744. * @param p0 defines 1st triangle point
  74745. * @param p1 defines 2nd triangle point
  74746. * @param p2 defines 3rd triangle point
  74747. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  74748. */
  74749. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  74750. /**
  74751. * Gets the distance between the vectors "value1" and "value2"
  74752. * @param value1 defines first vector
  74753. * @param value2 defines second vector
  74754. * @returns the distance between vectors
  74755. */
  74756. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74757. /**
  74758. * Returns the squared distance between the vectors "value1" and "value2"
  74759. * @param value1 defines first vector
  74760. * @param value2 defines second vector
  74761. * @returns the squared distance between vectors
  74762. */
  74763. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74764. /**
  74765. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  74766. * @param value1 defines first vector
  74767. * @param value2 defines second vector
  74768. * @returns a new Vector2
  74769. */
  74770. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  74771. /**
  74772. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  74773. * @param p defines the middle point
  74774. * @param segA defines one point of the segment
  74775. * @param segB defines the other point of the segment
  74776. * @returns the shortest distance
  74777. */
  74778. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  74779. }
  74780. /**
  74781. * Class used to store (x,y,z) vector representation
  74782. * A Vector3 is the main object used in 3D geometry
  74783. * It can represent etiher the coordinates of a point the space, either a direction
  74784. * Reminder: js uses a left handed forward facing system
  74785. */
  74786. export class Vector3 {
  74787. /**
  74788. * Defines the first coordinates (on X axis)
  74789. */
  74790. x: number;
  74791. /**
  74792. * Defines the second coordinates (on Y axis)
  74793. */
  74794. y: number;
  74795. /**
  74796. * Defines the third coordinates (on Z axis)
  74797. */
  74798. z: number;
  74799. private static _UpReadOnly;
  74800. private static _ZeroReadOnly;
  74801. /**
  74802. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  74803. * @param x defines the first coordinates (on X axis)
  74804. * @param y defines the second coordinates (on Y axis)
  74805. * @param z defines the third coordinates (on Z axis)
  74806. */
  74807. constructor(
  74808. /**
  74809. * Defines the first coordinates (on X axis)
  74810. */
  74811. x?: number,
  74812. /**
  74813. * Defines the second coordinates (on Y axis)
  74814. */
  74815. y?: number,
  74816. /**
  74817. * Defines the third coordinates (on Z axis)
  74818. */
  74819. z?: number);
  74820. /**
  74821. * Creates a string representation of the Vector3
  74822. * @returns a string with the Vector3 coordinates.
  74823. */
  74824. toString(): string;
  74825. /**
  74826. * Gets the class name
  74827. * @returns the string "Vector3"
  74828. */
  74829. getClassName(): string;
  74830. /**
  74831. * Creates the Vector3 hash code
  74832. * @returns a number which tends to be unique between Vector3 instances
  74833. */
  74834. getHashCode(): number;
  74835. /**
  74836. * Creates an array containing three elements : the coordinates of the Vector3
  74837. * @returns a new array of numbers
  74838. */
  74839. asArray(): number[];
  74840. /**
  74841. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  74842. * @param array defines the destination array
  74843. * @param index defines the offset in the destination array
  74844. * @returns the current Vector3
  74845. */
  74846. toArray(array: FloatArray, index?: number): Vector3;
  74847. /**
  74848. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  74849. * @returns a new Quaternion object, computed from the Vector3 coordinates
  74850. */
  74851. toQuaternion(): Quaternion;
  74852. /**
  74853. * Adds the given vector to the current Vector3
  74854. * @param otherVector defines the second operand
  74855. * @returns the current updated Vector3
  74856. */
  74857. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74858. /**
  74859. * Adds the given coordinates to the current Vector3
  74860. * @param x defines the x coordinate of the operand
  74861. * @param y defines the y coordinate of the operand
  74862. * @param z defines the z coordinate of the operand
  74863. * @returns the current updated Vector3
  74864. */
  74865. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  74866. /**
  74867. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  74868. * @param otherVector defines the second operand
  74869. * @returns the resulting Vector3
  74870. */
  74871. add(otherVector: DeepImmutable<Vector3>): Vector3;
  74872. /**
  74873. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  74874. * @param otherVector defines the second operand
  74875. * @param result defines the Vector3 object where to store the result
  74876. * @returns the current Vector3
  74877. */
  74878. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74879. /**
  74880. * Subtract the given vector from the current Vector3
  74881. * @param otherVector defines the second operand
  74882. * @returns the current updated Vector3
  74883. */
  74884. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74885. /**
  74886. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  74887. * @param otherVector defines the second operand
  74888. * @returns the resulting Vector3
  74889. */
  74890. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  74891. /**
  74892. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  74893. * @param otherVector defines the second operand
  74894. * @param result defines the Vector3 object where to store the result
  74895. * @returns the current Vector3
  74896. */
  74897. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74898. /**
  74899. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  74900. * @param x defines the x coordinate of the operand
  74901. * @param y defines the y coordinate of the operand
  74902. * @param z defines the z coordinate of the operand
  74903. * @returns the resulting Vector3
  74904. */
  74905. subtractFromFloats(x: number, y: number, z: number): Vector3;
  74906. /**
  74907. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  74908. * @param x defines the x coordinate of the operand
  74909. * @param y defines the y coordinate of the operand
  74910. * @param z defines the z coordinate of the operand
  74911. * @param result defines the Vector3 object where to store the result
  74912. * @returns the current Vector3
  74913. */
  74914. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  74915. /**
  74916. * Gets a new Vector3 set with the current Vector3 negated coordinates
  74917. * @returns a new Vector3
  74918. */
  74919. negate(): Vector3;
  74920. /**
  74921. * Negate this vector in place
  74922. * @returns this
  74923. */
  74924. negateInPlace(): Vector3;
  74925. /**
  74926. * Multiplies the Vector3 coordinates by the float "scale"
  74927. * @param scale defines the multiplier factor
  74928. * @returns the current updated Vector3
  74929. */
  74930. scaleInPlace(scale: number): Vector3;
  74931. /**
  74932. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  74933. * @param scale defines the multiplier factor
  74934. * @returns a new Vector3
  74935. */
  74936. scale(scale: number): Vector3;
  74937. /**
  74938. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  74939. * @param scale defines the multiplier factor
  74940. * @param result defines the Vector3 object where to store the result
  74941. * @returns the current Vector3
  74942. */
  74943. scaleToRef(scale: number, result: Vector3): Vector3;
  74944. /**
  74945. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  74946. * @param scale defines the scale factor
  74947. * @param result defines the Vector3 object where to store the result
  74948. * @returns the unmodified current Vector3
  74949. */
  74950. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  74951. /**
  74952. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  74953. * @param otherVector defines the second operand
  74954. * @returns true if both vectors are equals
  74955. */
  74956. equals(otherVector: DeepImmutable<Vector3>): boolean;
  74957. /**
  74958. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  74959. * @param otherVector defines the second operand
  74960. * @param epsilon defines the minimal distance to define values as equals
  74961. * @returns true if both vectors are distant less than epsilon
  74962. */
  74963. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  74964. /**
  74965. * Returns true if the current Vector3 coordinates equals the given floats
  74966. * @param x defines the x coordinate of the operand
  74967. * @param y defines the y coordinate of the operand
  74968. * @param z defines the z coordinate of the operand
  74969. * @returns true if both vectors are equals
  74970. */
  74971. equalsToFloats(x: number, y: number, z: number): boolean;
  74972. /**
  74973. * Multiplies the current Vector3 coordinates by the given ones
  74974. * @param otherVector defines the second operand
  74975. * @returns the current updated Vector3
  74976. */
  74977. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74978. /**
  74979. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  74980. * @param otherVector defines the second operand
  74981. * @returns the new Vector3
  74982. */
  74983. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  74984. /**
  74985. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  74986. * @param otherVector defines the second operand
  74987. * @param result defines the Vector3 object where to store the result
  74988. * @returns the current Vector3
  74989. */
  74990. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74991. /**
  74992. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  74993. * @param x defines the x coordinate of the operand
  74994. * @param y defines the y coordinate of the operand
  74995. * @param z defines the z coordinate of the operand
  74996. * @returns the new Vector3
  74997. */
  74998. multiplyByFloats(x: number, y: number, z: number): Vector3;
  74999. /**
  75000. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75001. * @param otherVector defines the second operand
  75002. * @returns the new Vector3
  75003. */
  75004. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75005. /**
  75006. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75007. * @param otherVector defines the second operand
  75008. * @param result defines the Vector3 object where to store the result
  75009. * @returns the current Vector3
  75010. */
  75011. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75012. /**
  75013. * Divides the current Vector3 coordinates by the given ones.
  75014. * @param otherVector defines the second operand
  75015. * @returns the current updated Vector3
  75016. */
  75017. divideInPlace(otherVector: Vector3): Vector3;
  75018. /**
  75019. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75020. * @param other defines the second operand
  75021. * @returns the current updated Vector3
  75022. */
  75023. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75024. /**
  75025. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75026. * @param other defines the second operand
  75027. * @returns the current updated Vector3
  75028. */
  75029. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75030. /**
  75031. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75032. * @param x defines the x coordinate of the operand
  75033. * @param y defines the y coordinate of the operand
  75034. * @param z defines the z coordinate of the operand
  75035. * @returns the current updated Vector3
  75036. */
  75037. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75038. /**
  75039. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75040. * @param x defines the x coordinate of the operand
  75041. * @param y defines the y coordinate of the operand
  75042. * @param z defines the z coordinate of the operand
  75043. * @returns the current updated Vector3
  75044. */
  75045. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75046. /**
  75047. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75048. * Check if is non uniform within a certain amount of decimal places to account for this
  75049. * @param epsilon the amount the values can differ
  75050. * @returns if the the vector is non uniform to a certain number of decimal places
  75051. */
  75052. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75053. /**
  75054. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75055. */
  75056. get isNonUniform(): boolean;
  75057. /**
  75058. * Gets a new Vector3 from current Vector3 floored values
  75059. * @returns a new Vector3
  75060. */
  75061. floor(): Vector3;
  75062. /**
  75063. * Gets a new Vector3 from current Vector3 floored values
  75064. * @returns a new Vector3
  75065. */
  75066. fract(): Vector3;
  75067. /**
  75068. * Gets the length of the Vector3
  75069. * @returns the length of the Vector3
  75070. */
  75071. length(): number;
  75072. /**
  75073. * Gets the squared length of the Vector3
  75074. * @returns squared length of the Vector3
  75075. */
  75076. lengthSquared(): number;
  75077. /**
  75078. * Normalize the current Vector3.
  75079. * Please note that this is an in place operation.
  75080. * @returns the current updated Vector3
  75081. */
  75082. normalize(): Vector3;
  75083. /**
  75084. * Reorders the x y z properties of the vector in place
  75085. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75086. * @returns the current updated vector
  75087. */
  75088. reorderInPlace(order: string): this;
  75089. /**
  75090. * Rotates the vector around 0,0,0 by a quaternion
  75091. * @param quaternion the rotation quaternion
  75092. * @param result vector to store the result
  75093. * @returns the resulting vector
  75094. */
  75095. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75096. /**
  75097. * Rotates a vector around a given point
  75098. * @param quaternion the rotation quaternion
  75099. * @param point the point to rotate around
  75100. * @param result vector to store the result
  75101. * @returns the resulting vector
  75102. */
  75103. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75104. /**
  75105. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75106. * The cross product is then orthogonal to both current and "other"
  75107. * @param other defines the right operand
  75108. * @returns the cross product
  75109. */
  75110. cross(other: Vector3): Vector3;
  75111. /**
  75112. * Normalize the current Vector3 with the given input length.
  75113. * Please note that this is an in place operation.
  75114. * @param len the length of the vector
  75115. * @returns the current updated Vector3
  75116. */
  75117. normalizeFromLength(len: number): Vector3;
  75118. /**
  75119. * Normalize the current Vector3 to a new vector
  75120. * @returns the new Vector3
  75121. */
  75122. normalizeToNew(): Vector3;
  75123. /**
  75124. * Normalize the current Vector3 to the reference
  75125. * @param reference define the Vector3 to update
  75126. * @returns the updated Vector3
  75127. */
  75128. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75129. /**
  75130. * Creates a new Vector3 copied from the current Vector3
  75131. * @returns the new Vector3
  75132. */
  75133. clone(): Vector3;
  75134. /**
  75135. * Copies the given vector coordinates to the current Vector3 ones
  75136. * @param source defines the source Vector3
  75137. * @returns the current updated Vector3
  75138. */
  75139. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75140. /**
  75141. * Copies the given floats to the current Vector3 coordinates
  75142. * @param x defines the x coordinate of the operand
  75143. * @param y defines the y coordinate of the operand
  75144. * @param z defines the z coordinate of the operand
  75145. * @returns the current updated Vector3
  75146. */
  75147. copyFromFloats(x: number, y: number, z: number): Vector3;
  75148. /**
  75149. * Copies the given floats to the current Vector3 coordinates
  75150. * @param x defines the x coordinate of the operand
  75151. * @param y defines the y coordinate of the operand
  75152. * @param z defines the z coordinate of the operand
  75153. * @returns the current updated Vector3
  75154. */
  75155. set(x: number, y: number, z: number): Vector3;
  75156. /**
  75157. * Copies the given float to the current Vector3 coordinates
  75158. * @param v defines the x, y and z coordinates of the operand
  75159. * @returns the current updated Vector3
  75160. */
  75161. setAll(v: number): Vector3;
  75162. /**
  75163. * Get the clip factor between two vectors
  75164. * @param vector0 defines the first operand
  75165. * @param vector1 defines the second operand
  75166. * @param axis defines the axis to use
  75167. * @param size defines the size along the axis
  75168. * @returns the clip factor
  75169. */
  75170. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75171. /**
  75172. * Get angle between two vectors
  75173. * @param vector0 angle between vector0 and vector1
  75174. * @param vector1 angle between vector0 and vector1
  75175. * @param normal direction of the normal
  75176. * @return the angle between vector0 and vector1
  75177. */
  75178. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75179. /**
  75180. * Returns a new Vector3 set from the index "offset" of the given array
  75181. * @param array defines the source array
  75182. * @param offset defines the offset in the source array
  75183. * @returns the new Vector3
  75184. */
  75185. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75186. /**
  75187. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75188. * @param array defines the source array
  75189. * @param offset defines the offset in the source array
  75190. * @returns the new Vector3
  75191. * @deprecated Please use FromArray instead.
  75192. */
  75193. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75194. /**
  75195. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75196. * @param array defines the source array
  75197. * @param offset defines the offset in the source array
  75198. * @param result defines the Vector3 where to store the result
  75199. */
  75200. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75201. /**
  75202. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75203. * @param array defines the source array
  75204. * @param offset defines the offset in the source array
  75205. * @param result defines the Vector3 where to store the result
  75206. * @deprecated Please use FromArrayToRef instead.
  75207. */
  75208. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75209. /**
  75210. * Sets the given vector "result" with the given floats.
  75211. * @param x defines the x coordinate of the source
  75212. * @param y defines the y coordinate of the source
  75213. * @param z defines the z coordinate of the source
  75214. * @param result defines the Vector3 where to store the result
  75215. */
  75216. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75217. /**
  75218. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75219. * @returns a new empty Vector3
  75220. */
  75221. static Zero(): Vector3;
  75222. /**
  75223. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75224. * @returns a new unit Vector3
  75225. */
  75226. static One(): Vector3;
  75227. /**
  75228. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75229. * @returns a new up Vector3
  75230. */
  75231. static Up(): Vector3;
  75232. /**
  75233. * Gets a up Vector3 that must not be updated
  75234. */
  75235. static get UpReadOnly(): DeepImmutable<Vector3>;
  75236. /**
  75237. * Gets a zero Vector3 that must not be updated
  75238. */
  75239. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75240. /**
  75241. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75242. * @returns a new down Vector3
  75243. */
  75244. static Down(): Vector3;
  75245. /**
  75246. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75247. * @returns a new forward Vector3
  75248. */
  75249. static Forward(): Vector3;
  75250. /**
  75251. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75252. * @returns a new forward Vector3
  75253. */
  75254. static Backward(): Vector3;
  75255. /**
  75256. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75257. * @returns a new right Vector3
  75258. */
  75259. static Right(): Vector3;
  75260. /**
  75261. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75262. * @returns a new left Vector3
  75263. */
  75264. static Left(): Vector3;
  75265. /**
  75266. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75267. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75268. * @param vector defines the Vector3 to transform
  75269. * @param transformation defines the transformation matrix
  75270. * @returns the transformed Vector3
  75271. */
  75272. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75273. /**
  75274. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75275. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75276. * @param vector defines the Vector3 to transform
  75277. * @param transformation defines the transformation matrix
  75278. * @param result defines the Vector3 where to store the result
  75279. */
  75280. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75281. /**
  75282. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  75283. * This method computes tranformed coordinates only, not transformed direction vectors
  75284. * @param x define the x coordinate of the source vector
  75285. * @param y define the y coordinate of the source vector
  75286. * @param z define the z coordinate of the source vector
  75287. * @param transformation defines the transformation matrix
  75288. * @param result defines the Vector3 where to store the result
  75289. */
  75290. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75291. /**
  75292. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  75293. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75294. * @param vector defines the Vector3 to transform
  75295. * @param transformation defines the transformation matrix
  75296. * @returns the new Vector3
  75297. */
  75298. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75299. /**
  75300. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  75301. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75302. * @param vector defines the Vector3 to transform
  75303. * @param transformation defines the transformation matrix
  75304. * @param result defines the Vector3 where to store the result
  75305. */
  75306. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75307. /**
  75308. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  75309. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75310. * @param x define the x coordinate of the source vector
  75311. * @param y define the y coordinate of the source vector
  75312. * @param z define the z coordinate of the source vector
  75313. * @param transformation defines the transformation matrix
  75314. * @param result defines the Vector3 where to store the result
  75315. */
  75316. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75317. /**
  75318. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  75319. * @param value1 defines the first control point
  75320. * @param value2 defines the second control point
  75321. * @param value3 defines the third control point
  75322. * @param value4 defines the fourth control point
  75323. * @param amount defines the amount on the spline to use
  75324. * @returns the new Vector3
  75325. */
  75326. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  75327. /**
  75328. * 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"
  75329. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75330. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75331. * @param value defines the current value
  75332. * @param min defines the lower range value
  75333. * @param max defines the upper range value
  75334. * @returns the new Vector3
  75335. */
  75336. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  75337. /**
  75338. * 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"
  75339. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75340. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75341. * @param value defines the current value
  75342. * @param min defines the lower range value
  75343. * @param max defines the upper range value
  75344. * @param result defines the Vector3 where to store the result
  75345. */
  75346. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  75347. /**
  75348. * Checks if a given vector is inside a specific range
  75349. * @param v defines the vector to test
  75350. * @param min defines the minimum range
  75351. * @param max defines the maximum range
  75352. */
  75353. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  75354. /**
  75355. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  75356. * @param value1 defines the first control point
  75357. * @param tangent1 defines the first tangent vector
  75358. * @param value2 defines the second control point
  75359. * @param tangent2 defines the second tangent vector
  75360. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  75361. * @returns the new Vector3
  75362. */
  75363. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  75364. /**
  75365. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75366. * @param start defines the start value
  75367. * @param end defines the end value
  75368. * @param amount max defines amount between both (between 0 and 1)
  75369. * @returns the new Vector3
  75370. */
  75371. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  75372. /**
  75373. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75374. * @param start defines the start value
  75375. * @param end defines the end value
  75376. * @param amount max defines amount between both (between 0 and 1)
  75377. * @param result defines the Vector3 where to store the result
  75378. */
  75379. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  75380. /**
  75381. * Returns the dot product (float) between the vectors "left" and "right"
  75382. * @param left defines the left operand
  75383. * @param right defines the right operand
  75384. * @returns the dot product
  75385. */
  75386. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  75387. /**
  75388. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75389. * The cross product is then orthogonal to both "left" and "right"
  75390. * @param left defines the left operand
  75391. * @param right defines the right operand
  75392. * @returns the cross product
  75393. */
  75394. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75395. /**
  75396. * Sets the given vector "result" with the cross product of "left" and "right"
  75397. * The cross product is then orthogonal to both "left" and "right"
  75398. * @param left defines the left operand
  75399. * @param right defines the right operand
  75400. * @param result defines the Vector3 where to store the result
  75401. */
  75402. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  75403. /**
  75404. * Returns a new Vector3 as the normalization of the given vector
  75405. * @param vector defines the Vector3 to normalize
  75406. * @returns the new Vector3
  75407. */
  75408. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  75409. /**
  75410. * Sets the given vector "result" with the normalization of the given first vector
  75411. * @param vector defines the Vector3 to normalize
  75412. * @param result defines the Vector3 where to store the result
  75413. */
  75414. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  75415. /**
  75416. * Project a Vector3 onto screen space
  75417. * @param vector defines the Vector3 to project
  75418. * @param world defines the world matrix to use
  75419. * @param transform defines the transform (view x projection) matrix to use
  75420. * @param viewport defines the screen viewport to use
  75421. * @returns the new Vector3
  75422. */
  75423. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  75424. /** @hidden */
  75425. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  75426. /**
  75427. * Unproject from screen space to object space
  75428. * @param source defines the screen space Vector3 to use
  75429. * @param viewportWidth defines the current width of the viewport
  75430. * @param viewportHeight defines the current height of the viewport
  75431. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75432. * @param transform defines the transform (view x projection) matrix to use
  75433. * @returns the new Vector3
  75434. */
  75435. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  75436. /**
  75437. * Unproject from screen space to object space
  75438. * @param source defines the screen space Vector3 to use
  75439. * @param viewportWidth defines the current width of the viewport
  75440. * @param viewportHeight defines the current height of the viewport
  75441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75442. * @param view defines the view matrix to use
  75443. * @param projection defines the projection matrix to use
  75444. * @returns the new Vector3
  75445. */
  75446. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  75447. /**
  75448. * Unproject from screen space to object space
  75449. * @param source defines the screen space Vector3 to use
  75450. * @param viewportWidth defines the current width of the viewport
  75451. * @param viewportHeight defines the current height of the viewport
  75452. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75453. * @param view defines the view matrix to use
  75454. * @param projection defines the projection matrix to use
  75455. * @param result defines the Vector3 where to store the result
  75456. */
  75457. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75458. /**
  75459. * Unproject from screen space to object space
  75460. * @param sourceX defines the screen space x coordinate to use
  75461. * @param sourceY defines the screen space y coordinate to use
  75462. * @param sourceZ defines the screen space z coordinate to use
  75463. * @param viewportWidth defines the current width of the viewport
  75464. * @param viewportHeight defines the current height of the viewport
  75465. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75466. * @param view defines the view matrix to use
  75467. * @param projection defines the projection matrix to use
  75468. * @param result defines the Vector3 where to store the result
  75469. */
  75470. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75471. /**
  75472. * Gets the minimal coordinate values between two Vector3
  75473. * @param left defines the first operand
  75474. * @param right defines the second operand
  75475. * @returns the new Vector3
  75476. */
  75477. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75478. /**
  75479. * Gets the maximal coordinate values between two Vector3
  75480. * @param left defines the first operand
  75481. * @param right defines the second operand
  75482. * @returns the new Vector3
  75483. */
  75484. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75485. /**
  75486. * Returns the distance between the vectors "value1" and "value2"
  75487. * @param value1 defines the first operand
  75488. * @param value2 defines the second operand
  75489. * @returns the distance
  75490. */
  75491. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75492. /**
  75493. * Returns the squared distance between the vectors "value1" and "value2"
  75494. * @param value1 defines the first operand
  75495. * @param value2 defines the second operand
  75496. * @returns the squared distance
  75497. */
  75498. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75499. /**
  75500. * Returns a new Vector3 located at the center between "value1" and "value2"
  75501. * @param value1 defines the first operand
  75502. * @param value2 defines the second operand
  75503. * @returns the new Vector3
  75504. */
  75505. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  75506. /**
  75507. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75508. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75509. * to something in order to rotate it from its local system to the given target system
  75510. * Note: axis1, axis2 and axis3 are normalized during this operation
  75511. * @param axis1 defines the first axis
  75512. * @param axis2 defines the second axis
  75513. * @param axis3 defines the third axis
  75514. * @returns a new Vector3
  75515. */
  75516. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  75517. /**
  75518. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75519. * @param axis1 defines the first axis
  75520. * @param axis2 defines the second axis
  75521. * @param axis3 defines the third axis
  75522. * @param ref defines the Vector3 where to store the result
  75523. */
  75524. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  75525. }
  75526. /**
  75527. * Vector4 class created for EulerAngle class conversion to Quaternion
  75528. */
  75529. export class Vector4 {
  75530. /** x value of the vector */
  75531. x: number;
  75532. /** y value of the vector */
  75533. y: number;
  75534. /** z value of the vector */
  75535. z: number;
  75536. /** w value of the vector */
  75537. w: number;
  75538. /**
  75539. * Creates a Vector4 object from the given floats.
  75540. * @param x x value of the vector
  75541. * @param y y value of the vector
  75542. * @param z z value of the vector
  75543. * @param w w value of the vector
  75544. */
  75545. constructor(
  75546. /** x value of the vector */
  75547. x: number,
  75548. /** y value of the vector */
  75549. y: number,
  75550. /** z value of the vector */
  75551. z: number,
  75552. /** w value of the vector */
  75553. w: number);
  75554. /**
  75555. * Returns the string with the Vector4 coordinates.
  75556. * @returns a string containing all the vector values
  75557. */
  75558. toString(): string;
  75559. /**
  75560. * Returns the string "Vector4".
  75561. * @returns "Vector4"
  75562. */
  75563. getClassName(): string;
  75564. /**
  75565. * Returns the Vector4 hash code.
  75566. * @returns a unique hash code
  75567. */
  75568. getHashCode(): number;
  75569. /**
  75570. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75571. * @returns the resulting array
  75572. */
  75573. asArray(): number[];
  75574. /**
  75575. * Populates the given array from the given index with the Vector4 coordinates.
  75576. * @param array array to populate
  75577. * @param index index of the array to start at (default: 0)
  75578. * @returns the Vector4.
  75579. */
  75580. toArray(array: FloatArray, index?: number): Vector4;
  75581. /**
  75582. * Adds the given vector to the current Vector4.
  75583. * @param otherVector the vector to add
  75584. * @returns the updated Vector4.
  75585. */
  75586. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75587. /**
  75588. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75589. * @param otherVector the vector to add
  75590. * @returns the resulting vector
  75591. */
  75592. add(otherVector: DeepImmutable<Vector4>): Vector4;
  75593. /**
  75594. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75595. * @param otherVector the vector to add
  75596. * @param result the vector to store the result
  75597. * @returns the current Vector4.
  75598. */
  75599. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75600. /**
  75601. * Subtract in place the given vector from the current Vector4.
  75602. * @param otherVector the vector to subtract
  75603. * @returns the updated Vector4.
  75604. */
  75605. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75606. /**
  75607. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75608. * @param otherVector the vector to add
  75609. * @returns the new vector with the result
  75610. */
  75611. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  75612. /**
  75613. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75614. * @param otherVector the vector to subtract
  75615. * @param result the vector to store the result
  75616. * @returns the current Vector4.
  75617. */
  75618. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75619. /**
  75620. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75621. */
  75622. /**
  75623. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75624. * @param x value to subtract
  75625. * @param y value to subtract
  75626. * @param z value to subtract
  75627. * @param w value to subtract
  75628. * @returns new vector containing the result
  75629. */
  75630. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75631. /**
  75632. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75633. * @param x value to subtract
  75634. * @param y value to subtract
  75635. * @param z value to subtract
  75636. * @param w value to subtract
  75637. * @param result the vector to store the result in
  75638. * @returns the current Vector4.
  75639. */
  75640. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  75641. /**
  75642. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  75643. * @returns a new vector with the negated values
  75644. */
  75645. negate(): Vector4;
  75646. /**
  75647. * Multiplies the current Vector4 coordinates by scale (float).
  75648. * @param scale the number to scale with
  75649. * @returns the updated Vector4.
  75650. */
  75651. scaleInPlace(scale: number): Vector4;
  75652. /**
  75653. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  75654. * @param scale the number to scale with
  75655. * @returns a new vector with the result
  75656. */
  75657. scale(scale: number): Vector4;
  75658. /**
  75659. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  75660. * @param scale the number to scale with
  75661. * @param result a vector to store the result in
  75662. * @returns the current Vector4.
  75663. */
  75664. scaleToRef(scale: number, result: Vector4): Vector4;
  75665. /**
  75666. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  75667. * @param scale defines the scale factor
  75668. * @param result defines the Vector4 object where to store the result
  75669. * @returns the unmodified current Vector4
  75670. */
  75671. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  75672. /**
  75673. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  75674. * @param otherVector the vector to compare against
  75675. * @returns true if they are equal
  75676. */
  75677. equals(otherVector: DeepImmutable<Vector4>): boolean;
  75678. /**
  75679. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  75680. * @param otherVector vector to compare against
  75681. * @param epsilon (Default: very small number)
  75682. * @returns true if they are equal
  75683. */
  75684. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  75685. /**
  75686. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  75687. * @param x x value to compare against
  75688. * @param y y value to compare against
  75689. * @param z z value to compare against
  75690. * @param w w value to compare against
  75691. * @returns true if equal
  75692. */
  75693. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  75694. /**
  75695. * Multiplies in place the current Vector4 by the given one.
  75696. * @param otherVector vector to multiple with
  75697. * @returns the updated Vector4.
  75698. */
  75699. multiplyInPlace(otherVector: Vector4): Vector4;
  75700. /**
  75701. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  75702. * @param otherVector vector to multiple with
  75703. * @returns resulting new vector
  75704. */
  75705. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  75706. /**
  75707. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  75708. * @param otherVector vector to multiple with
  75709. * @param result vector to store the result
  75710. * @returns the current Vector4.
  75711. */
  75712. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75713. /**
  75714. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  75715. * @param x x value multiply with
  75716. * @param y y value multiply with
  75717. * @param z z value multiply with
  75718. * @param w w value multiply with
  75719. * @returns resulting new vector
  75720. */
  75721. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  75722. /**
  75723. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  75724. * @param otherVector vector to devide with
  75725. * @returns resulting new vector
  75726. */
  75727. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  75728. /**
  75729. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  75730. * @param otherVector vector to devide with
  75731. * @param result vector to store the result
  75732. * @returns the current Vector4.
  75733. */
  75734. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75735. /**
  75736. * Divides the current Vector3 coordinates by the given ones.
  75737. * @param otherVector vector to devide with
  75738. * @returns the updated Vector3.
  75739. */
  75740. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75741. /**
  75742. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  75743. * @param other defines the second operand
  75744. * @returns the current updated Vector4
  75745. */
  75746. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75747. /**
  75748. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  75749. * @param other defines the second operand
  75750. * @returns the current updated Vector4
  75751. */
  75752. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75753. /**
  75754. * Gets a new Vector4 from current Vector4 floored values
  75755. * @returns a new Vector4
  75756. */
  75757. floor(): Vector4;
  75758. /**
  75759. * Gets a new Vector4 from current Vector3 floored values
  75760. * @returns a new Vector4
  75761. */
  75762. fract(): Vector4;
  75763. /**
  75764. * Returns the Vector4 length (float).
  75765. * @returns the length
  75766. */
  75767. length(): number;
  75768. /**
  75769. * Returns the Vector4 squared length (float).
  75770. * @returns the length squared
  75771. */
  75772. lengthSquared(): number;
  75773. /**
  75774. * Normalizes in place the Vector4.
  75775. * @returns the updated Vector4.
  75776. */
  75777. normalize(): Vector4;
  75778. /**
  75779. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  75780. * @returns this converted to a new vector3
  75781. */
  75782. toVector3(): Vector3;
  75783. /**
  75784. * Returns a new Vector4 copied from the current one.
  75785. * @returns the new cloned vector
  75786. */
  75787. clone(): Vector4;
  75788. /**
  75789. * Updates the current Vector4 with the given one coordinates.
  75790. * @param source the source vector to copy from
  75791. * @returns the updated Vector4.
  75792. */
  75793. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  75794. /**
  75795. * Updates the current Vector4 coordinates with the given floats.
  75796. * @param x float to copy from
  75797. * @param y float to copy from
  75798. * @param z float to copy from
  75799. * @param w float to copy from
  75800. * @returns the updated Vector4.
  75801. */
  75802. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75803. /**
  75804. * Updates the current Vector4 coordinates with the given floats.
  75805. * @param x float to set from
  75806. * @param y float to set from
  75807. * @param z float to set from
  75808. * @param w float to set from
  75809. * @returns the updated Vector4.
  75810. */
  75811. set(x: number, y: number, z: number, w: number): Vector4;
  75812. /**
  75813. * Copies the given float to the current Vector3 coordinates
  75814. * @param v defines the x, y, z and w coordinates of the operand
  75815. * @returns the current updated Vector3
  75816. */
  75817. setAll(v: number): Vector4;
  75818. /**
  75819. * Returns a new Vector4 set from the starting index of the given array.
  75820. * @param array the array to pull values from
  75821. * @param offset the offset into the array to start at
  75822. * @returns the new vector
  75823. */
  75824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  75825. /**
  75826. * Updates the given vector "result" from the starting index of the given array.
  75827. * @param array the array to pull values from
  75828. * @param offset the offset into the array to start at
  75829. * @param result the vector to store the result in
  75830. */
  75831. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  75832. /**
  75833. * Updates the given vector "result" from the starting index of the given Float32Array.
  75834. * @param array the array to pull values from
  75835. * @param offset the offset into the array to start at
  75836. * @param result the vector to store the result in
  75837. */
  75838. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  75839. /**
  75840. * Updates the given vector "result" coordinates from the given floats.
  75841. * @param x float to set from
  75842. * @param y float to set from
  75843. * @param z float to set from
  75844. * @param w float to set from
  75845. * @param result the vector to the floats in
  75846. */
  75847. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  75848. /**
  75849. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  75850. * @returns the new vector
  75851. */
  75852. static Zero(): Vector4;
  75853. /**
  75854. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  75855. * @returns the new vector
  75856. */
  75857. static One(): Vector4;
  75858. /**
  75859. * Returns a new normalized Vector4 from the given one.
  75860. * @param vector the vector to normalize
  75861. * @returns the vector
  75862. */
  75863. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  75864. /**
  75865. * Updates the given vector "result" from the normalization of the given one.
  75866. * @param vector the vector to normalize
  75867. * @param result the vector to store the result in
  75868. */
  75869. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  75870. /**
  75871. * Returns a vector with the minimum values from the left and right vectors
  75872. * @param left left vector to minimize
  75873. * @param right right vector to minimize
  75874. * @returns a new vector with the minimum of the left and right vector values
  75875. */
  75876. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  75877. /**
  75878. * Returns a vector with the maximum values from the left and right vectors
  75879. * @param left left vector to maximize
  75880. * @param right right vector to maximize
  75881. * @returns a new vector with the maximum of the left and right vector values
  75882. */
  75883. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  75884. /**
  75885. * Returns the distance (float) between the vectors "value1" and "value2".
  75886. * @param value1 value to calulate the distance between
  75887. * @param value2 value to calulate the distance between
  75888. * @return the distance between the two vectors
  75889. */
  75890. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  75891. /**
  75892. * Returns the squared distance (float) between the vectors "value1" and "value2".
  75893. * @param value1 value to calulate the distance between
  75894. * @param value2 value to calulate the distance between
  75895. * @return the distance between the two vectors squared
  75896. */
  75897. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  75898. /**
  75899. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  75900. * @param value1 value to calulate the center between
  75901. * @param value2 value to calulate the center between
  75902. * @return the center between the two vectors
  75903. */
  75904. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  75905. /**
  75906. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  75907. * This methods computes transformed normalized direction vectors only.
  75908. * @param vector the vector to transform
  75909. * @param transformation the transformation matrix to apply
  75910. * @returns the new vector
  75911. */
  75912. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  75913. /**
  75914. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  75915. * This methods computes transformed normalized direction vectors only.
  75916. * @param vector the vector to transform
  75917. * @param transformation the transformation matrix to apply
  75918. * @param result the vector to store the result in
  75919. */
  75920. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  75921. /**
  75922. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  75923. * This methods computes transformed normalized direction vectors only.
  75924. * @param x value to transform
  75925. * @param y value to transform
  75926. * @param z value to transform
  75927. * @param w value to transform
  75928. * @param transformation the transformation matrix to apply
  75929. * @param result the vector to store the results in
  75930. */
  75931. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  75932. /**
  75933. * Creates a new Vector4 from a Vector3
  75934. * @param source defines the source data
  75935. * @param w defines the 4th component (default is 0)
  75936. * @returns a new Vector4
  75937. */
  75938. static FromVector3(source: Vector3, w?: number): Vector4;
  75939. }
  75940. /**
  75941. * Class used to store quaternion data
  75942. * @see https://en.wikipedia.org/wiki/Quaternion
  75943. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  75944. */
  75945. export class Quaternion {
  75946. /** defines the first component (0 by default) */
  75947. x: number;
  75948. /** defines the second component (0 by default) */
  75949. y: number;
  75950. /** defines the third component (0 by default) */
  75951. z: number;
  75952. /** defines the fourth component (1.0 by default) */
  75953. w: number;
  75954. /**
  75955. * Creates a new Quaternion from the given floats
  75956. * @param x defines the first component (0 by default)
  75957. * @param y defines the second component (0 by default)
  75958. * @param z defines the third component (0 by default)
  75959. * @param w defines the fourth component (1.0 by default)
  75960. */
  75961. constructor(
  75962. /** defines the first component (0 by default) */
  75963. x?: number,
  75964. /** defines the second component (0 by default) */
  75965. y?: number,
  75966. /** defines the third component (0 by default) */
  75967. z?: number,
  75968. /** defines the fourth component (1.0 by default) */
  75969. w?: number);
  75970. /**
  75971. * Gets a string representation for the current quaternion
  75972. * @returns a string with the Quaternion coordinates
  75973. */
  75974. toString(): string;
  75975. /**
  75976. * Gets the class name of the quaternion
  75977. * @returns the string "Quaternion"
  75978. */
  75979. getClassName(): string;
  75980. /**
  75981. * Gets a hash code for this quaternion
  75982. * @returns the quaternion hash code
  75983. */
  75984. getHashCode(): number;
  75985. /**
  75986. * Copy the quaternion to an array
  75987. * @returns a new array populated with 4 elements from the quaternion coordinates
  75988. */
  75989. asArray(): number[];
  75990. /**
  75991. * Check if two quaternions are equals
  75992. * @param otherQuaternion defines the second operand
  75993. * @return true if the current quaternion and the given one coordinates are strictly equals
  75994. */
  75995. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  75996. /**
  75997. * Gets a boolean if two quaternions are equals (using an epsilon value)
  75998. * @param otherQuaternion defines the other quaternion
  75999. * @param epsilon defines the minimal distance to consider equality
  76000. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76001. */
  76002. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76003. /**
  76004. * Clone the current quaternion
  76005. * @returns a new quaternion copied from the current one
  76006. */
  76007. clone(): Quaternion;
  76008. /**
  76009. * Copy a quaternion to the current one
  76010. * @param other defines the other quaternion
  76011. * @returns the updated current quaternion
  76012. */
  76013. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76014. /**
  76015. * Updates the current quaternion with the given float coordinates
  76016. * @param x defines the x coordinate
  76017. * @param y defines the y coordinate
  76018. * @param z defines the z coordinate
  76019. * @param w defines the w coordinate
  76020. * @returns the updated current quaternion
  76021. */
  76022. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76023. /**
  76024. * Updates the current quaternion from the given float coordinates
  76025. * @param x defines the x coordinate
  76026. * @param y defines the y coordinate
  76027. * @param z defines the z coordinate
  76028. * @param w defines the w coordinate
  76029. * @returns the updated current quaternion
  76030. */
  76031. set(x: number, y: number, z: number, w: number): Quaternion;
  76032. /**
  76033. * Adds two quaternions
  76034. * @param other defines the second operand
  76035. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76036. */
  76037. add(other: DeepImmutable<Quaternion>): Quaternion;
  76038. /**
  76039. * Add a quaternion to the current one
  76040. * @param other defines the quaternion to add
  76041. * @returns the current quaternion
  76042. */
  76043. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76044. /**
  76045. * Subtract two quaternions
  76046. * @param other defines the second operand
  76047. * @returns a new quaternion as the subtraction result of the given one from the current one
  76048. */
  76049. subtract(other: Quaternion): Quaternion;
  76050. /**
  76051. * Multiplies the current quaternion by a scale factor
  76052. * @param value defines the scale factor
  76053. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76054. */
  76055. scale(value: number): Quaternion;
  76056. /**
  76057. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76058. * @param scale defines the scale factor
  76059. * @param result defines the Quaternion object where to store the result
  76060. * @returns the unmodified current quaternion
  76061. */
  76062. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76063. /**
  76064. * Multiplies in place the current quaternion by a scale factor
  76065. * @param value defines the scale factor
  76066. * @returns the current modified quaternion
  76067. */
  76068. scaleInPlace(value: number): Quaternion;
  76069. /**
  76070. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76071. * @param scale defines the scale factor
  76072. * @param result defines the Quaternion object where to store the result
  76073. * @returns the unmodified current quaternion
  76074. */
  76075. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76076. /**
  76077. * Multiplies two quaternions
  76078. * @param q1 defines the second operand
  76079. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76080. */
  76081. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76082. /**
  76083. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76084. * @param q1 defines the second operand
  76085. * @param result defines the target quaternion
  76086. * @returns the current quaternion
  76087. */
  76088. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76089. /**
  76090. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76091. * @param q1 defines the second operand
  76092. * @returns the currentupdated quaternion
  76093. */
  76094. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76095. /**
  76096. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76097. * @param ref defines the target quaternion
  76098. * @returns the current quaternion
  76099. */
  76100. conjugateToRef(ref: Quaternion): Quaternion;
  76101. /**
  76102. * Conjugates in place (1-q) the current quaternion
  76103. * @returns the current updated quaternion
  76104. */
  76105. conjugateInPlace(): Quaternion;
  76106. /**
  76107. * Conjugates in place (1-q) the current quaternion
  76108. * @returns a new quaternion
  76109. */
  76110. conjugate(): Quaternion;
  76111. /**
  76112. * Gets length of current quaternion
  76113. * @returns the quaternion length (float)
  76114. */
  76115. length(): number;
  76116. /**
  76117. * Normalize in place the current quaternion
  76118. * @returns the current updated quaternion
  76119. */
  76120. normalize(): Quaternion;
  76121. /**
  76122. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76123. * @param order is a reserved parameter and is ignore for now
  76124. * @returns a new Vector3 containing the Euler angles
  76125. */
  76126. toEulerAngles(order?: string): Vector3;
  76127. /**
  76128. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76129. * @param result defines the vector which will be filled with the Euler angles
  76130. * @param order is a reserved parameter and is ignore for now
  76131. * @returns the current unchanged quaternion
  76132. */
  76133. toEulerAnglesToRef(result: Vector3): Quaternion;
  76134. /**
  76135. * Updates the given rotation matrix with the current quaternion values
  76136. * @param result defines the target matrix
  76137. * @returns the current unchanged quaternion
  76138. */
  76139. toRotationMatrix(result: Matrix): Quaternion;
  76140. /**
  76141. * Updates the current quaternion from the given rotation matrix values
  76142. * @param matrix defines the source matrix
  76143. * @returns the current updated quaternion
  76144. */
  76145. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76146. /**
  76147. * Creates a new quaternion from a rotation matrix
  76148. * @param matrix defines the source matrix
  76149. * @returns a new quaternion created from the given rotation matrix values
  76150. */
  76151. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76152. /**
  76153. * Updates the given quaternion with the given rotation matrix values
  76154. * @param matrix defines the source matrix
  76155. * @param result defines the target quaternion
  76156. */
  76157. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76158. /**
  76159. * Returns the dot product (float) between the quaternions "left" and "right"
  76160. * @param left defines the left operand
  76161. * @param right defines the right operand
  76162. * @returns the dot product
  76163. */
  76164. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76165. /**
  76166. * Checks if the two quaternions are close to each other
  76167. * @param quat0 defines the first quaternion to check
  76168. * @param quat1 defines the second quaternion to check
  76169. * @returns true if the two quaternions are close to each other
  76170. */
  76171. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76172. /**
  76173. * Creates an empty quaternion
  76174. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76175. */
  76176. static Zero(): Quaternion;
  76177. /**
  76178. * Inverse a given quaternion
  76179. * @param q defines the source quaternion
  76180. * @returns a new quaternion as the inverted current quaternion
  76181. */
  76182. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76183. /**
  76184. * Inverse a given quaternion
  76185. * @param q defines the source quaternion
  76186. * @param result the quaternion the result will be stored in
  76187. * @returns the result quaternion
  76188. */
  76189. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76190. /**
  76191. * Creates an identity quaternion
  76192. * @returns the identity quaternion
  76193. */
  76194. static Identity(): Quaternion;
  76195. /**
  76196. * Gets a boolean indicating if the given quaternion is identity
  76197. * @param quaternion defines the quaternion to check
  76198. * @returns true if the quaternion is identity
  76199. */
  76200. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76201. /**
  76202. * Creates a quaternion from a rotation around an axis
  76203. * @param axis defines the axis to use
  76204. * @param angle defines the angle to use
  76205. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76206. */
  76207. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76208. /**
  76209. * Creates a rotation around an axis and stores it into the given quaternion
  76210. * @param axis defines the axis to use
  76211. * @param angle defines the angle to use
  76212. * @param result defines the target quaternion
  76213. * @returns the target quaternion
  76214. */
  76215. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76216. /**
  76217. * Creates a new quaternion from data stored into an array
  76218. * @param array defines the data source
  76219. * @param offset defines the offset in the source array where the data starts
  76220. * @returns a new quaternion
  76221. */
  76222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76223. /**
  76224. * Create a quaternion from Euler rotation angles
  76225. * @param x Pitch
  76226. * @param y Yaw
  76227. * @param z Roll
  76228. * @returns the new Quaternion
  76229. */
  76230. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76231. /**
  76232. * Updates a quaternion from Euler rotation angles
  76233. * @param x Pitch
  76234. * @param y Yaw
  76235. * @param z Roll
  76236. * @param result the quaternion to store the result
  76237. * @returns the updated quaternion
  76238. */
  76239. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76240. /**
  76241. * Create a quaternion from Euler rotation vector
  76242. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76243. * @returns the new Quaternion
  76244. */
  76245. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76246. /**
  76247. * Updates a quaternion from Euler rotation vector
  76248. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76249. * @param result the quaternion to store the result
  76250. * @returns the updated quaternion
  76251. */
  76252. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76253. /**
  76254. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76255. * @param yaw defines the rotation around Y axis
  76256. * @param pitch defines the rotation around X axis
  76257. * @param roll defines the rotation around Z axis
  76258. * @returns the new quaternion
  76259. */
  76260. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76261. /**
  76262. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76263. * @param yaw defines the rotation around Y axis
  76264. * @param pitch defines the rotation around X axis
  76265. * @param roll defines the rotation around Z axis
  76266. * @param result defines the target quaternion
  76267. */
  76268. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76269. /**
  76270. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76271. * @param alpha defines the rotation around first axis
  76272. * @param beta defines the rotation around second axis
  76273. * @param gamma defines the rotation around third axis
  76274. * @returns the new quaternion
  76275. */
  76276. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  76277. /**
  76278. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76279. * @param alpha defines the rotation around first axis
  76280. * @param beta defines the rotation around second axis
  76281. * @param gamma defines the rotation around third axis
  76282. * @param result defines the target quaternion
  76283. */
  76284. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  76285. /**
  76286. * 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)
  76287. * @param axis1 defines the first axis
  76288. * @param axis2 defines the second axis
  76289. * @param axis3 defines the third axis
  76290. * @returns the new quaternion
  76291. */
  76292. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  76293. /**
  76294. * 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
  76295. * @param axis1 defines the first axis
  76296. * @param axis2 defines the second axis
  76297. * @param axis3 defines the third axis
  76298. * @param ref defines the target quaternion
  76299. */
  76300. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  76301. /**
  76302. * Interpolates between two quaternions
  76303. * @param left defines first quaternion
  76304. * @param right defines second quaternion
  76305. * @param amount defines the gradient to use
  76306. * @returns the new interpolated quaternion
  76307. */
  76308. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76309. /**
  76310. * Interpolates between two quaternions and stores it into a target quaternion
  76311. * @param left defines first quaternion
  76312. * @param right defines second quaternion
  76313. * @param amount defines the gradient to use
  76314. * @param result defines the target quaternion
  76315. */
  76316. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  76317. /**
  76318. * Interpolate between two quaternions using Hermite interpolation
  76319. * @param value1 defines first quaternion
  76320. * @param tangent1 defines the incoming tangent
  76321. * @param value2 defines second quaternion
  76322. * @param tangent2 defines the outgoing tangent
  76323. * @param amount defines the target quaternion
  76324. * @returns the new interpolated quaternion
  76325. */
  76326. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76327. }
  76328. /**
  76329. * Class used to store matrix data (4x4)
  76330. */
  76331. export class Matrix {
  76332. private static _updateFlagSeed;
  76333. private static _identityReadOnly;
  76334. private _isIdentity;
  76335. private _isIdentityDirty;
  76336. private _isIdentity3x2;
  76337. private _isIdentity3x2Dirty;
  76338. /**
  76339. * Gets the update flag of the matrix which is an unique number for the matrix.
  76340. * It will be incremented every time the matrix data change.
  76341. * You can use it to speed the comparison between two versions of the same matrix.
  76342. */
  76343. updateFlag: number;
  76344. private readonly _m;
  76345. /**
  76346. * Gets the internal data of the matrix
  76347. */
  76348. get m(): DeepImmutable<Float32Array>;
  76349. /** @hidden */
  76350. _markAsUpdated(): void;
  76351. /** @hidden */
  76352. private _updateIdentityStatus;
  76353. /**
  76354. * Creates an empty matrix (filled with zeros)
  76355. */
  76356. constructor();
  76357. /**
  76358. * Check if the current matrix is identity
  76359. * @returns true is the matrix is the identity matrix
  76360. */
  76361. isIdentity(): boolean;
  76362. /**
  76363. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76364. * @returns true is the matrix is the identity matrix
  76365. */
  76366. isIdentityAs3x2(): boolean;
  76367. /**
  76368. * Gets the determinant of the matrix
  76369. * @returns the matrix determinant
  76370. */
  76371. determinant(): number;
  76372. /**
  76373. * Returns the matrix as a Float32Array
  76374. * @returns the matrix underlying array
  76375. */
  76376. toArray(): DeepImmutable<Float32Array>;
  76377. /**
  76378. * Returns the matrix as a Float32Array
  76379. * @returns the matrix underlying array.
  76380. */
  76381. asArray(): DeepImmutable<Float32Array>;
  76382. /**
  76383. * Inverts the current matrix in place
  76384. * @returns the current inverted matrix
  76385. */
  76386. invert(): Matrix;
  76387. /**
  76388. * Sets all the matrix elements to zero
  76389. * @returns the current matrix
  76390. */
  76391. reset(): Matrix;
  76392. /**
  76393. * Adds the current matrix with a second one
  76394. * @param other defines the matrix to add
  76395. * @returns a new matrix as the addition of the current matrix and the given one
  76396. */
  76397. add(other: DeepImmutable<Matrix>): Matrix;
  76398. /**
  76399. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76400. * @param other defines the matrix to add
  76401. * @param result defines the target matrix
  76402. * @returns the current matrix
  76403. */
  76404. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76405. /**
  76406. * Adds in place the given matrix to the current matrix
  76407. * @param other defines the second operand
  76408. * @returns the current updated matrix
  76409. */
  76410. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  76411. /**
  76412. * Sets the given matrix to the current inverted Matrix
  76413. * @param other defines the target matrix
  76414. * @returns the unmodified current matrix
  76415. */
  76416. invertToRef(other: Matrix): Matrix;
  76417. /**
  76418. * add a value at the specified position in the current Matrix
  76419. * @param index the index of the value within the matrix. between 0 and 15.
  76420. * @param value the value to be added
  76421. * @returns the current updated matrix
  76422. */
  76423. addAtIndex(index: number, value: number): Matrix;
  76424. /**
  76425. * mutiply the specified position in the current Matrix by a value
  76426. * @param index the index of the value within the matrix. between 0 and 15.
  76427. * @param value the value to be added
  76428. * @returns the current updated matrix
  76429. */
  76430. multiplyAtIndex(index: number, value: number): Matrix;
  76431. /**
  76432. * Inserts the translation vector (using 3 floats) in the current matrix
  76433. * @param x defines the 1st component of the translation
  76434. * @param y defines the 2nd component of the translation
  76435. * @param z defines the 3rd component of the translation
  76436. * @returns the current updated matrix
  76437. */
  76438. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76439. /**
  76440. * Adds the translation vector (using 3 floats) in the current matrix
  76441. * @param x defines the 1st component of the translation
  76442. * @param y defines the 2nd component of the translation
  76443. * @param z defines the 3rd component of the translation
  76444. * @returns the current updated matrix
  76445. */
  76446. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76447. /**
  76448. * Inserts the translation vector in the current matrix
  76449. * @param vector3 defines the translation to insert
  76450. * @returns the current updated matrix
  76451. */
  76452. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  76453. /**
  76454. * Gets the translation value of the current matrix
  76455. * @returns a new Vector3 as the extracted translation from the matrix
  76456. */
  76457. getTranslation(): Vector3;
  76458. /**
  76459. * Fill a Vector3 with the extracted translation from the matrix
  76460. * @param result defines the Vector3 where to store the translation
  76461. * @returns the current matrix
  76462. */
  76463. getTranslationToRef(result: Vector3): Matrix;
  76464. /**
  76465. * Remove rotation and scaling part from the matrix
  76466. * @returns the updated matrix
  76467. */
  76468. removeRotationAndScaling(): Matrix;
  76469. /**
  76470. * Multiply two matrices
  76471. * @param other defines the second operand
  76472. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  76473. */
  76474. multiply(other: DeepImmutable<Matrix>): Matrix;
  76475. /**
  76476. * Copy the current matrix from the given one
  76477. * @param other defines the source matrix
  76478. * @returns the current updated matrix
  76479. */
  76480. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  76481. /**
  76482. * Populates the given array from the starting index with the current matrix values
  76483. * @param array defines the target array
  76484. * @param offset defines the offset in the target array where to start storing values
  76485. * @returns the current matrix
  76486. */
  76487. copyToArray(array: Float32Array, offset?: number): Matrix;
  76488. /**
  76489. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  76490. * @param other defines the second operand
  76491. * @param result defines the matrix where to store the multiplication
  76492. * @returns the current matrix
  76493. */
  76494. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76495. /**
  76496. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  76497. * @param other defines the second operand
  76498. * @param result defines the array where to store the multiplication
  76499. * @param offset defines the offset in the target array where to start storing values
  76500. * @returns the current matrix
  76501. */
  76502. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  76503. /**
  76504. * Check equality between this matrix and a second one
  76505. * @param value defines the second matrix to compare
  76506. * @returns true is the current matrix and the given one values are strictly equal
  76507. */
  76508. equals(value: DeepImmutable<Matrix>): boolean;
  76509. /**
  76510. * Clone the current matrix
  76511. * @returns a new matrix from the current matrix
  76512. */
  76513. clone(): Matrix;
  76514. /**
  76515. * Returns the name of the current matrix class
  76516. * @returns the string "Matrix"
  76517. */
  76518. getClassName(): string;
  76519. /**
  76520. * Gets the hash code of the current matrix
  76521. * @returns the hash code
  76522. */
  76523. getHashCode(): number;
  76524. /**
  76525. * Decomposes the current Matrix into a translation, rotation and scaling components
  76526. * @param scale defines the scale vector3 given as a reference to update
  76527. * @param rotation defines the rotation quaternion given as a reference to update
  76528. * @param translation defines the translation vector3 given as a reference to update
  76529. * @returns true if operation was successful
  76530. */
  76531. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  76532. /**
  76533. * Gets specific row of the matrix
  76534. * @param index defines the number of the row to get
  76535. * @returns the index-th row of the current matrix as a new Vector4
  76536. */
  76537. getRow(index: number): Nullable<Vector4>;
  76538. /**
  76539. * Sets the index-th row of the current matrix to the vector4 values
  76540. * @param index defines the number of the row to set
  76541. * @param row defines the target vector4
  76542. * @returns the updated current matrix
  76543. */
  76544. setRow(index: number, row: Vector4): Matrix;
  76545. /**
  76546. * Compute the transpose of the matrix
  76547. * @returns the new transposed matrix
  76548. */
  76549. transpose(): Matrix;
  76550. /**
  76551. * Compute the transpose of the matrix and store it in a given matrix
  76552. * @param result defines the target matrix
  76553. * @returns the current matrix
  76554. */
  76555. transposeToRef(result: Matrix): Matrix;
  76556. /**
  76557. * Sets the index-th row of the current matrix with the given 4 x float values
  76558. * @param index defines the row index
  76559. * @param x defines the x component to set
  76560. * @param y defines the y component to set
  76561. * @param z defines the z component to set
  76562. * @param w defines the w component to set
  76563. * @returns the updated current matrix
  76564. */
  76565. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  76566. /**
  76567. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  76568. * @param scale defines the scale factor
  76569. * @returns a new matrix
  76570. */
  76571. scale(scale: number): Matrix;
  76572. /**
  76573. * Scale the current matrix values by a factor to a given result matrix
  76574. * @param scale defines the scale factor
  76575. * @param result defines the matrix to store the result
  76576. * @returns the current matrix
  76577. */
  76578. scaleToRef(scale: number, result: Matrix): Matrix;
  76579. /**
  76580. * Scale the current matrix values by a factor and add the result to a given matrix
  76581. * @param scale defines the scale factor
  76582. * @param result defines the Matrix to store the result
  76583. * @returns the current matrix
  76584. */
  76585. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  76586. /**
  76587. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76588. * @param ref matrix to store the result
  76589. */
  76590. toNormalMatrix(ref: Matrix): void;
  76591. /**
  76592. * Gets only rotation part of the current matrix
  76593. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76594. */
  76595. getRotationMatrix(): Matrix;
  76596. /**
  76597. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76598. * @param result defines the target matrix to store data to
  76599. * @returns the current matrix
  76600. */
  76601. getRotationMatrixToRef(result: Matrix): Matrix;
  76602. /**
  76603. * Toggles model matrix from being right handed to left handed in place and vice versa
  76604. */
  76605. toggleModelMatrixHandInPlace(): void;
  76606. /**
  76607. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76608. */
  76609. toggleProjectionMatrixHandInPlace(): void;
  76610. /**
  76611. * Creates a matrix from an array
  76612. * @param array defines the source array
  76613. * @param offset defines an offset in the source array
  76614. * @returns a new Matrix set from the starting index of the given array
  76615. */
  76616. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  76617. /**
  76618. * Copy the content of an array into a given matrix
  76619. * @param array defines the source array
  76620. * @param offset defines an offset in the source array
  76621. * @param result defines the target matrix
  76622. */
  76623. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  76624. /**
  76625. * Stores an array into a matrix after having multiplied each component by a given factor
  76626. * @param array defines the source array
  76627. * @param offset defines the offset in the source array
  76628. * @param scale defines the scaling factor
  76629. * @param result defines the target matrix
  76630. */
  76631. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  76632. /**
  76633. * Gets an identity matrix that must not be updated
  76634. */
  76635. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  76636. /**
  76637. * Stores a list of values (16) inside a given matrix
  76638. * @param initialM11 defines 1st value of 1st row
  76639. * @param initialM12 defines 2nd value of 1st row
  76640. * @param initialM13 defines 3rd value of 1st row
  76641. * @param initialM14 defines 4th value of 1st row
  76642. * @param initialM21 defines 1st value of 2nd row
  76643. * @param initialM22 defines 2nd value of 2nd row
  76644. * @param initialM23 defines 3rd value of 2nd row
  76645. * @param initialM24 defines 4th value of 2nd row
  76646. * @param initialM31 defines 1st value of 3rd row
  76647. * @param initialM32 defines 2nd value of 3rd row
  76648. * @param initialM33 defines 3rd value of 3rd row
  76649. * @param initialM34 defines 4th value of 3rd row
  76650. * @param initialM41 defines 1st value of 4th row
  76651. * @param initialM42 defines 2nd value of 4th row
  76652. * @param initialM43 defines 3rd value of 4th row
  76653. * @param initialM44 defines 4th value of 4th row
  76654. * @param result defines the target matrix
  76655. */
  76656. 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;
  76657. /**
  76658. * Creates new matrix from a list of values (16)
  76659. * @param initialM11 defines 1st value of 1st row
  76660. * @param initialM12 defines 2nd value of 1st row
  76661. * @param initialM13 defines 3rd value of 1st row
  76662. * @param initialM14 defines 4th value of 1st row
  76663. * @param initialM21 defines 1st value of 2nd row
  76664. * @param initialM22 defines 2nd value of 2nd row
  76665. * @param initialM23 defines 3rd value of 2nd row
  76666. * @param initialM24 defines 4th value of 2nd row
  76667. * @param initialM31 defines 1st value of 3rd row
  76668. * @param initialM32 defines 2nd value of 3rd row
  76669. * @param initialM33 defines 3rd value of 3rd row
  76670. * @param initialM34 defines 4th value of 3rd row
  76671. * @param initialM41 defines 1st value of 4th row
  76672. * @param initialM42 defines 2nd value of 4th row
  76673. * @param initialM43 defines 3rd value of 4th row
  76674. * @param initialM44 defines 4th value of 4th row
  76675. * @returns the new matrix
  76676. */
  76677. 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;
  76678. /**
  76679. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76680. * @param scale defines the scale vector3
  76681. * @param rotation defines the rotation quaternion
  76682. * @param translation defines the translation vector3
  76683. * @returns a new matrix
  76684. */
  76685. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  76686. /**
  76687. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76688. * @param scale defines the scale vector3
  76689. * @param rotation defines the rotation quaternion
  76690. * @param translation defines the translation vector3
  76691. * @param result defines the target matrix
  76692. */
  76693. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  76694. /**
  76695. * Creates a new identity matrix
  76696. * @returns a new identity matrix
  76697. */
  76698. static Identity(): Matrix;
  76699. /**
  76700. * Creates a new identity matrix and stores the result in a given matrix
  76701. * @param result defines the target matrix
  76702. */
  76703. static IdentityToRef(result: Matrix): void;
  76704. /**
  76705. * Creates a new zero matrix
  76706. * @returns a new zero matrix
  76707. */
  76708. static Zero(): Matrix;
  76709. /**
  76710. * Creates a new rotation matrix for "angle" radians around the X axis
  76711. * @param angle defines the angle (in radians) to use
  76712. * @return the new matrix
  76713. */
  76714. static RotationX(angle: number): Matrix;
  76715. /**
  76716. * Creates a new matrix as the invert of a given matrix
  76717. * @param source defines the source matrix
  76718. * @returns the new matrix
  76719. */
  76720. static Invert(source: DeepImmutable<Matrix>): Matrix;
  76721. /**
  76722. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  76723. * @param angle defines the angle (in radians) to use
  76724. * @param result defines the target matrix
  76725. */
  76726. static RotationXToRef(angle: number, result: Matrix): void;
  76727. /**
  76728. * Creates a new rotation matrix for "angle" radians around the Y axis
  76729. * @param angle defines the angle (in radians) to use
  76730. * @return the new matrix
  76731. */
  76732. static RotationY(angle: number): Matrix;
  76733. /**
  76734. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76735. * @param angle defines the angle (in radians) to use
  76736. * @param result defines the target matrix
  76737. */
  76738. static RotationYToRef(angle: number, result: Matrix): void;
  76739. /**
  76740. * Creates a new rotation matrix for "angle" radians around the Z axis
  76741. * @param angle defines the angle (in radians) to use
  76742. * @return the new matrix
  76743. */
  76744. static RotationZ(angle: number): Matrix;
  76745. /**
  76746. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76747. * @param angle defines the angle (in radians) to use
  76748. * @param result defines the target matrix
  76749. */
  76750. static RotationZToRef(angle: number, result: Matrix): void;
  76751. /**
  76752. * Creates a new rotation matrix for "angle" radians around the given axis
  76753. * @param axis defines the axis to use
  76754. * @param angle defines the angle (in radians) to use
  76755. * @return the new matrix
  76756. */
  76757. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  76758. /**
  76759. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76760. * @param axis defines the axis to use
  76761. * @param angle defines the angle (in radians) to use
  76762. * @param result defines the target matrix
  76763. */
  76764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  76765. /**
  76766. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76767. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76768. * @param from defines the vector to align
  76769. * @param to defines the vector to align to
  76770. * @param result defines the target matrix
  76771. */
  76772. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  76773. /**
  76774. * Creates a rotation matrix
  76775. * @param yaw defines the yaw angle in radians (Y axis)
  76776. * @param pitch defines the pitch angle in radians (X axis)
  76777. * @param roll defines the roll angle in radians (X axis)
  76778. * @returns the new rotation matrix
  76779. */
  76780. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  76781. /**
  76782. * Creates a rotation matrix and stores it in a given matrix
  76783. * @param yaw defines the yaw angle in radians (Y axis)
  76784. * @param pitch defines the pitch angle in radians (X axis)
  76785. * @param roll defines the roll angle in radians (X axis)
  76786. * @param result defines the target matrix
  76787. */
  76788. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  76789. /**
  76790. * Creates a scaling matrix
  76791. * @param x defines the scale factor on X axis
  76792. * @param y defines the scale factor on Y axis
  76793. * @param z defines the scale factor on Z axis
  76794. * @returns the new matrix
  76795. */
  76796. static Scaling(x: number, y: number, z: number): Matrix;
  76797. /**
  76798. * Creates a scaling matrix and stores it in a given matrix
  76799. * @param x defines the scale factor on X axis
  76800. * @param y defines the scale factor on Y axis
  76801. * @param z defines the scale factor on Z axis
  76802. * @param result defines the target matrix
  76803. */
  76804. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  76805. /**
  76806. * Creates a translation matrix
  76807. * @param x defines the translation on X axis
  76808. * @param y defines the translation on Y axis
  76809. * @param z defines the translationon Z axis
  76810. * @returns the new matrix
  76811. */
  76812. static Translation(x: number, y: number, z: number): Matrix;
  76813. /**
  76814. * Creates a translation matrix and stores it in a given matrix
  76815. * @param x defines the translation on X axis
  76816. * @param y defines the translation on Y axis
  76817. * @param z defines the translationon Z axis
  76818. * @param result defines the target matrix
  76819. */
  76820. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  76821. /**
  76822. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76823. * @param startValue defines the start value
  76824. * @param endValue defines the end value
  76825. * @param gradient defines the gradient factor
  76826. * @returns the new matrix
  76827. */
  76828. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  76829. /**
  76830. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76831. * @param startValue defines the start value
  76832. * @param endValue defines the end value
  76833. * @param gradient defines the gradient factor
  76834. * @param result defines the Matrix object where to store data
  76835. */
  76836. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  76837. /**
  76838. * Builds a new matrix whose values are computed by:
  76839. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76840. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76841. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76842. * @param startValue defines the first matrix
  76843. * @param endValue defines the second matrix
  76844. * @param gradient defines the gradient between the two matrices
  76845. * @returns the new matrix
  76846. */
  76847. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  76848. /**
  76849. * Update a matrix to values which are computed by:
  76850. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76851. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76852. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76853. * @param startValue defines the first matrix
  76854. * @param endValue defines the second matrix
  76855. * @param gradient defines the gradient between the two matrices
  76856. * @param result defines the target matrix
  76857. */
  76858. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  76859. /**
  76860. * 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"
  76861. * This function works in left handed mode
  76862. * @param eye defines the final position of the entity
  76863. * @param target defines where the entity should look at
  76864. * @param up defines the up vector for the entity
  76865. * @returns the new matrix
  76866. */
  76867. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  76868. /**
  76869. * 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".
  76870. * This function works in left handed mode
  76871. * @param eye defines the final position of the entity
  76872. * @param target defines where the entity should look at
  76873. * @param up defines the up vector for the entity
  76874. * @param result defines the target matrix
  76875. */
  76876. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  76877. /**
  76878. * 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"
  76879. * This function works in right handed mode
  76880. * @param eye defines the final position of the entity
  76881. * @param target defines where the entity should look at
  76882. * @param up defines the up vector for the entity
  76883. * @returns the new matrix
  76884. */
  76885. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  76886. /**
  76887. * 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".
  76888. * This function works in right handed mode
  76889. * @param eye defines the final position of the entity
  76890. * @param target defines where the entity should look at
  76891. * @param up defines the up vector for the entity
  76892. * @param result defines the target matrix
  76893. */
  76894. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  76895. /**
  76896. * Create a left-handed orthographic projection matrix
  76897. * @param width defines the viewport width
  76898. * @param height defines the viewport height
  76899. * @param znear defines the near clip plane
  76900. * @param zfar defines the far clip plane
  76901. * @returns a new matrix as a left-handed orthographic projection matrix
  76902. */
  76903. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  76904. /**
  76905. * Store a left-handed orthographic projection to a given matrix
  76906. * @param width defines the viewport width
  76907. * @param height defines the viewport height
  76908. * @param znear defines the near clip plane
  76909. * @param zfar defines the far clip plane
  76910. * @param result defines the target matrix
  76911. */
  76912. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  76913. /**
  76914. * Create a left-handed orthographic projection matrix
  76915. * @param left defines the viewport left coordinate
  76916. * @param right defines the viewport right coordinate
  76917. * @param bottom defines the viewport bottom coordinate
  76918. * @param top defines the viewport top coordinate
  76919. * @param znear defines the near clip plane
  76920. * @param zfar defines the far clip plane
  76921. * @returns a new matrix as a left-handed orthographic projection matrix
  76922. */
  76923. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  76924. /**
  76925. * Stores a left-handed orthographic projection into a given matrix
  76926. * @param left defines the viewport left coordinate
  76927. * @param right defines the viewport right coordinate
  76928. * @param bottom defines the viewport bottom coordinate
  76929. * @param top defines the viewport top coordinate
  76930. * @param znear defines the near clip plane
  76931. * @param zfar defines the far clip plane
  76932. * @param result defines the target matrix
  76933. */
  76934. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  76935. /**
  76936. * Creates a right-handed orthographic projection matrix
  76937. * @param left defines the viewport left coordinate
  76938. * @param right defines the viewport right coordinate
  76939. * @param bottom defines the viewport bottom coordinate
  76940. * @param top defines the viewport top coordinate
  76941. * @param znear defines the near clip plane
  76942. * @param zfar defines the far clip plane
  76943. * @returns a new matrix as a right-handed orthographic projection matrix
  76944. */
  76945. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  76946. /**
  76947. * Stores a right-handed orthographic projection into a given matrix
  76948. * @param left defines the viewport left coordinate
  76949. * @param right defines the viewport right coordinate
  76950. * @param bottom defines the viewport bottom coordinate
  76951. * @param top defines the viewport top coordinate
  76952. * @param znear defines the near clip plane
  76953. * @param zfar defines the far clip plane
  76954. * @param result defines the target matrix
  76955. */
  76956. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  76957. /**
  76958. * Creates a left-handed perspective projection matrix
  76959. * @param width defines the viewport width
  76960. * @param height defines the viewport height
  76961. * @param znear defines the near clip plane
  76962. * @param zfar defines the far clip plane
  76963. * @returns a new matrix as a left-handed perspective projection matrix
  76964. */
  76965. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  76966. /**
  76967. * Creates a left-handed perspective projection matrix
  76968. * @param fov defines the horizontal field of view
  76969. * @param aspect defines the aspect ratio
  76970. * @param znear defines the near clip plane
  76971. * @param zfar defines the far clip plane
  76972. * @returns a new matrix as a left-handed perspective projection matrix
  76973. */
  76974. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  76975. /**
  76976. * Stores a left-handed perspective projection into a given matrix
  76977. * @param fov defines the horizontal field of view
  76978. * @param aspect defines the aspect ratio
  76979. * @param znear defines the near clip plane
  76980. * @param zfar defines the far clip plane
  76981. * @param result defines the target matrix
  76982. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76983. */
  76984. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76985. /**
  76986. * Stores a left-handed perspective projection into a given matrix with depth reversed
  76987. * @param fov defines the horizontal field of view
  76988. * @param aspect defines the aspect ratio
  76989. * @param znear defines the near clip plane
  76990. * @param zfar not used as infinity is used as far clip
  76991. * @param result defines the target matrix
  76992. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76993. */
  76994. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76995. /**
  76996. * Creates a right-handed perspective projection matrix
  76997. * @param fov defines the horizontal field of view
  76998. * @param aspect defines the aspect ratio
  76999. * @param znear defines the near clip plane
  77000. * @param zfar defines the far clip plane
  77001. * @returns a new matrix as a right-handed perspective projection matrix
  77002. */
  77003. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77004. /**
  77005. * Stores a right-handed perspective projection into a given matrix
  77006. * @param fov defines the horizontal field of view
  77007. * @param aspect defines the aspect ratio
  77008. * @param znear defines the near clip plane
  77009. * @param zfar defines the far clip plane
  77010. * @param result defines the target matrix
  77011. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77012. */
  77013. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77014. /**
  77015. * Stores a right-handed perspective projection into a given matrix
  77016. * @param fov defines the horizontal field of view
  77017. * @param aspect defines the aspect ratio
  77018. * @param znear defines the near clip plane
  77019. * @param zfar not used as infinity is used as far clip
  77020. * @param result defines the target matrix
  77021. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77022. */
  77023. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77024. /**
  77025. * Stores a perspective projection for WebVR info a given matrix
  77026. * @param fov defines the field of view
  77027. * @param znear defines the near clip plane
  77028. * @param zfar defines the far clip plane
  77029. * @param result defines the target matrix
  77030. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77031. */
  77032. static PerspectiveFovWebVRToRef(fov: {
  77033. upDegrees: number;
  77034. downDegrees: number;
  77035. leftDegrees: number;
  77036. rightDegrees: number;
  77037. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77038. /**
  77039. * Computes a complete transformation matrix
  77040. * @param viewport defines the viewport to use
  77041. * @param world defines the world matrix
  77042. * @param view defines the view matrix
  77043. * @param projection defines the projection matrix
  77044. * @param zmin defines the near clip plane
  77045. * @param zmax defines the far clip plane
  77046. * @returns the transformation matrix
  77047. */
  77048. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77049. /**
  77050. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77051. * @param matrix defines the matrix to use
  77052. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77053. */
  77054. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77055. /**
  77056. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77057. * @param matrix defines the matrix to use
  77058. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77059. */
  77060. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77061. /**
  77062. * Compute the transpose of a given matrix
  77063. * @param matrix defines the matrix to transpose
  77064. * @returns the new matrix
  77065. */
  77066. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77067. /**
  77068. * Compute the transpose of a matrix and store it in a target matrix
  77069. * @param matrix defines the matrix to transpose
  77070. * @param result defines the target matrix
  77071. */
  77072. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77073. /**
  77074. * Computes a reflection matrix from a plane
  77075. * @param plane defines the reflection plane
  77076. * @returns a new matrix
  77077. */
  77078. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77079. /**
  77080. * Computes a reflection matrix from a plane
  77081. * @param plane defines the reflection plane
  77082. * @param result defines the target matrix
  77083. */
  77084. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77085. /**
  77086. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77087. * @param xaxis defines the value of the 1st axis
  77088. * @param yaxis defines the value of the 2nd axis
  77089. * @param zaxis defines the value of the 3rd axis
  77090. * @param result defines the target matrix
  77091. */
  77092. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77093. /**
  77094. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77095. * @param quat defines the quaternion to use
  77096. * @param result defines the target matrix
  77097. */
  77098. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77099. }
  77100. /**
  77101. * @hidden
  77102. */
  77103. export class TmpVectors {
  77104. static Vector2: Vector2[];
  77105. static Vector3: Vector3[];
  77106. static Vector4: Vector4[];
  77107. static Quaternion: Quaternion[];
  77108. static Matrix: Matrix[];
  77109. }
  77110. }
  77111. declare module BABYLON {
  77112. /**
  77113. * Defines potential orientation for back face culling
  77114. */
  77115. export enum Orientation {
  77116. /**
  77117. * Clockwise
  77118. */
  77119. CW = 0,
  77120. /** Counter clockwise */
  77121. CCW = 1
  77122. }
  77123. /** Class used to represent a Bezier curve */
  77124. export class BezierCurve {
  77125. /**
  77126. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77127. * @param t defines the time
  77128. * @param x1 defines the left coordinate on X axis
  77129. * @param y1 defines the left coordinate on Y axis
  77130. * @param x2 defines the right coordinate on X axis
  77131. * @param y2 defines the right coordinate on Y axis
  77132. * @returns the interpolated value
  77133. */
  77134. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77135. }
  77136. /**
  77137. * Defines angle representation
  77138. */
  77139. export class Angle {
  77140. private _radians;
  77141. /**
  77142. * Creates an Angle object of "radians" radians (float).
  77143. * @param radians the angle in radians
  77144. */
  77145. constructor(radians: number);
  77146. /**
  77147. * Get value in degrees
  77148. * @returns the Angle value in degrees (float)
  77149. */
  77150. degrees(): number;
  77151. /**
  77152. * Get value in radians
  77153. * @returns the Angle value in radians (float)
  77154. */
  77155. radians(): number;
  77156. /**
  77157. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77158. * @param a defines first vector
  77159. * @param b defines second vector
  77160. * @returns a new Angle
  77161. */
  77162. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77163. /**
  77164. * Gets a new Angle object from the given float in radians
  77165. * @param radians defines the angle value in radians
  77166. * @returns a new Angle
  77167. */
  77168. static FromRadians(radians: number): Angle;
  77169. /**
  77170. * Gets a new Angle object from the given float in degrees
  77171. * @param degrees defines the angle value in degrees
  77172. * @returns a new Angle
  77173. */
  77174. static FromDegrees(degrees: number): Angle;
  77175. }
  77176. /**
  77177. * This represents an arc in a 2d space.
  77178. */
  77179. export class Arc2 {
  77180. /** Defines the start point of the arc */
  77181. startPoint: Vector2;
  77182. /** Defines the mid point of the arc */
  77183. midPoint: Vector2;
  77184. /** Defines the end point of the arc */
  77185. endPoint: Vector2;
  77186. /**
  77187. * Defines the center point of the arc.
  77188. */
  77189. centerPoint: Vector2;
  77190. /**
  77191. * Defines the radius of the arc.
  77192. */
  77193. radius: number;
  77194. /**
  77195. * Defines the angle of the arc (from mid point to end point).
  77196. */
  77197. angle: Angle;
  77198. /**
  77199. * Defines the start angle of the arc (from start point to middle point).
  77200. */
  77201. startAngle: Angle;
  77202. /**
  77203. * Defines the orientation of the arc (clock wise/counter clock wise).
  77204. */
  77205. orientation: Orientation;
  77206. /**
  77207. * Creates an Arc object from the three given points : start, middle and end.
  77208. * @param startPoint Defines the start point of the arc
  77209. * @param midPoint Defines the midlle point of the arc
  77210. * @param endPoint Defines the end point of the arc
  77211. */
  77212. constructor(
  77213. /** Defines the start point of the arc */
  77214. startPoint: Vector2,
  77215. /** Defines the mid point of the arc */
  77216. midPoint: Vector2,
  77217. /** Defines the end point of the arc */
  77218. endPoint: Vector2);
  77219. }
  77220. /**
  77221. * Represents a 2D path made up of multiple 2D points
  77222. */
  77223. export class Path2 {
  77224. private _points;
  77225. private _length;
  77226. /**
  77227. * If the path start and end point are the same
  77228. */
  77229. closed: boolean;
  77230. /**
  77231. * Creates a Path2 object from the starting 2D coordinates x and y.
  77232. * @param x the starting points x value
  77233. * @param y the starting points y value
  77234. */
  77235. constructor(x: number, y: number);
  77236. /**
  77237. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77238. * @param x the added points x value
  77239. * @param y the added points y value
  77240. * @returns the updated Path2.
  77241. */
  77242. addLineTo(x: number, y: number): Path2;
  77243. /**
  77244. * 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.
  77245. * @param midX middle point x value
  77246. * @param midY middle point y value
  77247. * @param endX end point x value
  77248. * @param endY end point y value
  77249. * @param numberOfSegments (default: 36)
  77250. * @returns the updated Path2.
  77251. */
  77252. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77253. /**
  77254. * Closes the Path2.
  77255. * @returns the Path2.
  77256. */
  77257. close(): Path2;
  77258. /**
  77259. * Gets the sum of the distance between each sequential point in the path
  77260. * @returns the Path2 total length (float).
  77261. */
  77262. length(): number;
  77263. /**
  77264. * Gets the points which construct the path
  77265. * @returns the Path2 internal array of points.
  77266. */
  77267. getPoints(): Vector2[];
  77268. /**
  77269. * Retreives the point at the distance aways from the starting point
  77270. * @param normalizedLengthPosition the length along the path to retreive the point from
  77271. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77272. */
  77273. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  77274. /**
  77275. * Creates a new path starting from an x and y position
  77276. * @param x starting x value
  77277. * @param y starting y value
  77278. * @returns a new Path2 starting at the coordinates (x, y).
  77279. */
  77280. static StartingAt(x: number, y: number): Path2;
  77281. }
  77282. /**
  77283. * Represents a 3D path made up of multiple 3D points
  77284. */
  77285. export class Path3D {
  77286. /**
  77287. * an array of Vector3, the curve axis of the Path3D
  77288. */
  77289. path: Vector3[];
  77290. private _curve;
  77291. private _distances;
  77292. private _tangents;
  77293. private _normals;
  77294. private _binormals;
  77295. private _raw;
  77296. private _alignTangentsWithPath;
  77297. private readonly _pointAtData;
  77298. /**
  77299. * new Path3D(path, normal, raw)
  77300. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77301. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77302. * @param path an array of Vector3, the curve axis of the Path3D
  77303. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77304. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77305. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  77306. */
  77307. constructor(
  77308. /**
  77309. * an array of Vector3, the curve axis of the Path3D
  77310. */
  77311. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  77312. /**
  77313. * Returns the Path3D array of successive Vector3 designing its curve.
  77314. * @returns the Path3D array of successive Vector3 designing its curve.
  77315. */
  77316. getCurve(): Vector3[];
  77317. /**
  77318. * Returns the Path3D array of successive Vector3 designing its curve.
  77319. * @returns the Path3D array of successive Vector3 designing its curve.
  77320. */
  77321. getPoints(): Vector3[];
  77322. /**
  77323. * @returns the computed length (float) of the path.
  77324. */
  77325. length(): number;
  77326. /**
  77327. * Returns an array populated with tangent vectors on each Path3D curve point.
  77328. * @returns an array populated with tangent vectors on each Path3D curve point.
  77329. */
  77330. getTangents(): Vector3[];
  77331. /**
  77332. * Returns an array populated with normal vectors on each Path3D curve point.
  77333. * @returns an array populated with normal vectors on each Path3D curve point.
  77334. */
  77335. getNormals(): Vector3[];
  77336. /**
  77337. * Returns an array populated with binormal vectors on each Path3D curve point.
  77338. * @returns an array populated with binormal vectors on each Path3D curve point.
  77339. */
  77340. getBinormals(): Vector3[];
  77341. /**
  77342. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77343. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77344. */
  77345. getDistances(): number[];
  77346. /**
  77347. * Returns an interpolated point along this path
  77348. * @param position the position of the point along this path, from 0.0 to 1.0
  77349. * @returns a new Vector3 as the point
  77350. */
  77351. getPointAt(position: number): Vector3;
  77352. /**
  77353. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77354. * @param position the position of the point along this path, from 0.0 to 1.0
  77355. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  77356. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  77357. */
  77358. getTangentAt(position: number, interpolated?: boolean): Vector3;
  77359. /**
  77360. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77361. * @param position the position of the point along this path, from 0.0 to 1.0
  77362. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  77363. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  77364. */
  77365. getNormalAt(position: number, interpolated?: boolean): Vector3;
  77366. /**
  77367. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  77368. * @param position the position of the point along this path, from 0.0 to 1.0
  77369. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  77370. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  77371. */
  77372. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  77373. /**
  77374. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  77375. * @param position the position of the point along this path, from 0.0 to 1.0
  77376. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  77377. */
  77378. getDistanceAt(position: number): number;
  77379. /**
  77380. * Returns the array index of the previous point of an interpolated point along this path
  77381. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77382. * @returns the array index
  77383. */
  77384. getPreviousPointIndexAt(position: number): number;
  77385. /**
  77386. * 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)
  77387. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77388. * @returns the sub position
  77389. */
  77390. getSubPositionAt(position: number): number;
  77391. /**
  77392. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  77393. * @param target the vector of which to get the closest position to
  77394. * @returns the position of the closest virtual point on this path to the target vector
  77395. */
  77396. getClosestPositionTo(target: Vector3): number;
  77397. /**
  77398. * Returns a sub path (slice) of this path
  77399. * @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
  77400. * @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
  77401. * @returns a sub path (slice) of this path
  77402. */
  77403. slice(start?: number, end?: number): Path3D;
  77404. /**
  77405. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77406. * @param path path which all values are copied into the curves points
  77407. * @param firstNormal which should be projected onto the curve
  77408. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  77409. * @returns the same object updated.
  77410. */
  77411. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  77412. private _compute;
  77413. private _getFirstNonNullVector;
  77414. private _getLastNonNullVector;
  77415. private _normalVector;
  77416. /**
  77417. * Updates the point at data for an interpolated point along this curve
  77418. * @param position the position of the point along this curve, from 0.0 to 1.0
  77419. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  77420. * @returns the (updated) point at data
  77421. */
  77422. private _updatePointAtData;
  77423. /**
  77424. * Updates the point at data from the specified parameters
  77425. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  77426. * @param point the interpolated point
  77427. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  77428. */
  77429. private _setPointAtData;
  77430. /**
  77431. * Updates the point at interpolation matrix for the tangents, normals and binormals
  77432. */
  77433. private _updateInterpolationMatrix;
  77434. }
  77435. /**
  77436. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77437. * A Curve3 is designed from a series of successive Vector3.
  77438. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77439. */
  77440. export class Curve3 {
  77441. private _points;
  77442. private _length;
  77443. /**
  77444. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77445. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77446. * @param v1 (Vector3) the control point
  77447. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77448. * @param nbPoints (integer) the wanted number of points in the curve
  77449. * @returns the created Curve3
  77450. */
  77451. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77452. /**
  77453. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77454. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77455. * @param v1 (Vector3) the first control point
  77456. * @param v2 (Vector3) the second control point
  77457. * @param v3 (Vector3) the end point of the Cubic Bezier
  77458. * @param nbPoints (integer) the wanted number of points in the curve
  77459. * @returns the created Curve3
  77460. */
  77461. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77462. /**
  77463. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77464. * @param p1 (Vector3) the origin point of the Hermite Spline
  77465. * @param t1 (Vector3) the tangent vector at the origin point
  77466. * @param p2 (Vector3) the end point of the Hermite Spline
  77467. * @param t2 (Vector3) the tangent vector at the end point
  77468. * @param nbPoints (integer) the wanted number of points in the curve
  77469. * @returns the created Curve3
  77470. */
  77471. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77472. /**
  77473. * Returns a Curve3 object along a CatmullRom Spline curve :
  77474. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77475. * @param nbPoints (integer) the wanted number of points between each curve control points
  77476. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77477. * @returns the created Curve3
  77478. */
  77479. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  77480. /**
  77481. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77482. * A Curve3 is designed from a series of successive Vector3.
  77483. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77484. * @param points points which make up the curve
  77485. */
  77486. constructor(points: Vector3[]);
  77487. /**
  77488. * @returns the Curve3 stored array of successive Vector3
  77489. */
  77490. getPoints(): Vector3[];
  77491. /**
  77492. * @returns the computed length (float) of the curve.
  77493. */
  77494. length(): number;
  77495. /**
  77496. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77497. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77498. * curveA and curveB keep unchanged.
  77499. * @param curve the curve to continue from this curve
  77500. * @returns the newly constructed curve
  77501. */
  77502. continue(curve: DeepImmutable<Curve3>): Curve3;
  77503. private _computeLength;
  77504. }
  77505. }
  77506. declare module BABYLON {
  77507. /**
  77508. * This represents the main contract an easing function should follow.
  77509. * Easing functions are used throughout the animation system.
  77510. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77511. */
  77512. export interface IEasingFunction {
  77513. /**
  77514. * Given an input gradient between 0 and 1, this returns the corrseponding value
  77515. * of the easing function.
  77516. * The link below provides some of the most common examples of easing functions.
  77517. * @see https://easings.net/
  77518. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77519. * @returns the corresponding value on the curve defined by the easing function
  77520. */
  77521. ease(gradient: number): number;
  77522. }
  77523. /**
  77524. * Base class used for every default easing function.
  77525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77526. */
  77527. export class EasingFunction implements IEasingFunction {
  77528. /**
  77529. * Interpolation follows the mathematical formula associated with the easing function.
  77530. */
  77531. static readonly EASINGMODE_EASEIN: number;
  77532. /**
  77533. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  77534. */
  77535. static readonly EASINGMODE_EASEOUT: number;
  77536. /**
  77537. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  77538. */
  77539. static readonly EASINGMODE_EASEINOUT: number;
  77540. private _easingMode;
  77541. /**
  77542. * Sets the easing mode of the current function.
  77543. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  77544. */
  77545. setEasingMode(easingMode: number): void;
  77546. /**
  77547. * Gets the current easing mode.
  77548. * @returns the easing mode
  77549. */
  77550. getEasingMode(): number;
  77551. /**
  77552. * @hidden
  77553. */
  77554. easeInCore(gradient: number): number;
  77555. /**
  77556. * Given an input gradient between 0 and 1, this returns the corresponding value
  77557. * of the easing function.
  77558. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77559. * @returns the corresponding value on the curve defined by the easing function
  77560. */
  77561. ease(gradient: number): number;
  77562. }
  77563. /**
  77564. * Easing function with a circle shape (see link below).
  77565. * @see https://easings.net/#easeInCirc
  77566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77567. */
  77568. export class CircleEase extends EasingFunction implements IEasingFunction {
  77569. /** @hidden */
  77570. easeInCore(gradient: number): number;
  77571. }
  77572. /**
  77573. * Easing function with a ease back shape (see link below).
  77574. * @see https://easings.net/#easeInBack
  77575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77576. */
  77577. export class BackEase extends EasingFunction implements IEasingFunction {
  77578. /** Defines the amplitude of the function */
  77579. amplitude: number;
  77580. /**
  77581. * Instantiates a back ease easing
  77582. * @see https://easings.net/#easeInBack
  77583. * @param amplitude Defines the amplitude of the function
  77584. */
  77585. constructor(
  77586. /** Defines the amplitude of the function */
  77587. amplitude?: number);
  77588. /** @hidden */
  77589. easeInCore(gradient: number): number;
  77590. }
  77591. /**
  77592. * Easing function with a bouncing shape (see link below).
  77593. * @see https://easings.net/#easeInBounce
  77594. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77595. */
  77596. export class BounceEase extends EasingFunction implements IEasingFunction {
  77597. /** Defines the number of bounces */
  77598. bounces: number;
  77599. /** Defines the amplitude of the bounce */
  77600. bounciness: number;
  77601. /**
  77602. * Instantiates a bounce easing
  77603. * @see https://easings.net/#easeInBounce
  77604. * @param bounces Defines the number of bounces
  77605. * @param bounciness Defines the amplitude of the bounce
  77606. */
  77607. constructor(
  77608. /** Defines the number of bounces */
  77609. bounces?: number,
  77610. /** Defines the amplitude of the bounce */
  77611. bounciness?: number);
  77612. /** @hidden */
  77613. easeInCore(gradient: number): number;
  77614. }
  77615. /**
  77616. * Easing function with a power of 3 shape (see link below).
  77617. * @see https://easings.net/#easeInCubic
  77618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77619. */
  77620. export class CubicEase extends EasingFunction implements IEasingFunction {
  77621. /** @hidden */
  77622. easeInCore(gradient: number): number;
  77623. }
  77624. /**
  77625. * Easing function with an elastic shape (see link below).
  77626. * @see https://easings.net/#easeInElastic
  77627. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77628. */
  77629. export class ElasticEase extends EasingFunction implements IEasingFunction {
  77630. /** Defines the number of oscillations*/
  77631. oscillations: number;
  77632. /** Defines the amplitude of the oscillations*/
  77633. springiness: number;
  77634. /**
  77635. * Instantiates an elastic easing function
  77636. * @see https://easings.net/#easeInElastic
  77637. * @param oscillations Defines the number of oscillations
  77638. * @param springiness Defines the amplitude of the oscillations
  77639. */
  77640. constructor(
  77641. /** Defines the number of oscillations*/
  77642. oscillations?: number,
  77643. /** Defines the amplitude of the oscillations*/
  77644. springiness?: number);
  77645. /** @hidden */
  77646. easeInCore(gradient: number): number;
  77647. }
  77648. /**
  77649. * Easing function with an exponential shape (see link below).
  77650. * @see https://easings.net/#easeInExpo
  77651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77652. */
  77653. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  77654. /** Defines the exponent of the function */
  77655. exponent: number;
  77656. /**
  77657. * Instantiates an exponential easing function
  77658. * @see https://easings.net/#easeInExpo
  77659. * @param exponent Defines the exponent of the function
  77660. */
  77661. constructor(
  77662. /** Defines the exponent of the function */
  77663. exponent?: number);
  77664. /** @hidden */
  77665. easeInCore(gradient: number): number;
  77666. }
  77667. /**
  77668. * Easing function with a power shape (see link below).
  77669. * @see https://easings.net/#easeInQuad
  77670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77671. */
  77672. export class PowerEase extends EasingFunction implements IEasingFunction {
  77673. /** Defines the power of the function */
  77674. power: number;
  77675. /**
  77676. * Instantiates an power base easing function
  77677. * @see https://easings.net/#easeInQuad
  77678. * @param power Defines the power of the function
  77679. */
  77680. constructor(
  77681. /** Defines the power of the function */
  77682. power?: number);
  77683. /** @hidden */
  77684. easeInCore(gradient: number): number;
  77685. }
  77686. /**
  77687. * Easing function with a power of 2 shape (see link below).
  77688. * @see https://easings.net/#easeInQuad
  77689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77690. */
  77691. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  77692. /** @hidden */
  77693. easeInCore(gradient: number): number;
  77694. }
  77695. /**
  77696. * Easing function with a power of 4 shape (see link below).
  77697. * @see https://easings.net/#easeInQuart
  77698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77699. */
  77700. export class QuarticEase extends EasingFunction implements IEasingFunction {
  77701. /** @hidden */
  77702. easeInCore(gradient: number): number;
  77703. }
  77704. /**
  77705. * Easing function with a power of 5 shape (see link below).
  77706. * @see https://easings.net/#easeInQuint
  77707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77708. */
  77709. export class QuinticEase extends EasingFunction implements IEasingFunction {
  77710. /** @hidden */
  77711. easeInCore(gradient: number): number;
  77712. }
  77713. /**
  77714. * Easing function with a sin shape (see link below).
  77715. * @see https://easings.net/#easeInSine
  77716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77717. */
  77718. export class SineEase extends EasingFunction implements IEasingFunction {
  77719. /** @hidden */
  77720. easeInCore(gradient: number): number;
  77721. }
  77722. /**
  77723. * Easing function with a bezier shape (see link below).
  77724. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77725. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77726. */
  77727. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  77728. /** Defines the x component of the start tangent in the bezier curve */
  77729. x1: number;
  77730. /** Defines the y component of the start tangent in the bezier curve */
  77731. y1: number;
  77732. /** Defines the x component of the end tangent in the bezier curve */
  77733. x2: number;
  77734. /** Defines the y component of the end tangent in the bezier curve */
  77735. y2: number;
  77736. /**
  77737. * Instantiates a bezier function
  77738. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77739. * @param x1 Defines the x component of the start tangent in the bezier curve
  77740. * @param y1 Defines the y component of the start tangent in the bezier curve
  77741. * @param x2 Defines the x component of the end tangent in the bezier curve
  77742. * @param y2 Defines the y component of the end tangent in the bezier curve
  77743. */
  77744. constructor(
  77745. /** Defines the x component of the start tangent in the bezier curve */
  77746. x1?: number,
  77747. /** Defines the y component of the start tangent in the bezier curve */
  77748. y1?: number,
  77749. /** Defines the x component of the end tangent in the bezier curve */
  77750. x2?: number,
  77751. /** Defines the y component of the end tangent in the bezier curve */
  77752. y2?: number);
  77753. /** @hidden */
  77754. easeInCore(gradient: number): number;
  77755. }
  77756. }
  77757. declare module BABYLON {
  77758. /**
  77759. * Class used to hold a RBG color
  77760. */
  77761. export class Color3 {
  77762. /**
  77763. * Defines the red component (between 0 and 1, default is 0)
  77764. */
  77765. r: number;
  77766. /**
  77767. * Defines the green component (between 0 and 1, default is 0)
  77768. */
  77769. g: number;
  77770. /**
  77771. * Defines the blue component (between 0 and 1, default is 0)
  77772. */
  77773. b: number;
  77774. /**
  77775. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  77776. * @param r defines the red component (between 0 and 1, default is 0)
  77777. * @param g defines the green component (between 0 and 1, default is 0)
  77778. * @param b defines the blue component (between 0 and 1, default is 0)
  77779. */
  77780. constructor(
  77781. /**
  77782. * Defines the red component (between 0 and 1, default is 0)
  77783. */
  77784. r?: number,
  77785. /**
  77786. * Defines the green component (between 0 and 1, default is 0)
  77787. */
  77788. g?: number,
  77789. /**
  77790. * Defines the blue component (between 0 and 1, default is 0)
  77791. */
  77792. b?: number);
  77793. /**
  77794. * Creates a string with the Color3 current values
  77795. * @returns the string representation of the Color3 object
  77796. */
  77797. toString(): string;
  77798. /**
  77799. * Returns the string "Color3"
  77800. * @returns "Color3"
  77801. */
  77802. getClassName(): string;
  77803. /**
  77804. * Compute the Color3 hash code
  77805. * @returns an unique number that can be used to hash Color3 objects
  77806. */
  77807. getHashCode(): number;
  77808. /**
  77809. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  77810. * @param array defines the array where to store the r,g,b components
  77811. * @param index defines an optional index in the target array to define where to start storing values
  77812. * @returns the current Color3 object
  77813. */
  77814. toArray(array: FloatArray, index?: number): Color3;
  77815. /**
  77816. * Returns a new Color4 object from the current Color3 and the given alpha
  77817. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  77818. * @returns a new Color4 object
  77819. */
  77820. toColor4(alpha?: number): Color4;
  77821. /**
  77822. * Returns a new array populated with 3 numeric elements : red, green and blue values
  77823. * @returns the new array
  77824. */
  77825. asArray(): number[];
  77826. /**
  77827. * Returns the luminance value
  77828. * @returns a float value
  77829. */
  77830. toLuminance(): number;
  77831. /**
  77832. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  77833. * @param otherColor defines the second operand
  77834. * @returns the new Color3 object
  77835. */
  77836. multiply(otherColor: DeepImmutable<Color3>): Color3;
  77837. /**
  77838. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  77839. * @param otherColor defines the second operand
  77840. * @param result defines the Color3 object where to store the result
  77841. * @returns the current Color3
  77842. */
  77843. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77844. /**
  77845. * Determines equality between Color3 objects
  77846. * @param otherColor defines the second operand
  77847. * @returns true if the rgb values are equal to the given ones
  77848. */
  77849. equals(otherColor: DeepImmutable<Color3>): boolean;
  77850. /**
  77851. * Determines equality between the current Color3 object and a set of r,b,g values
  77852. * @param r defines the red component to check
  77853. * @param g defines the green component to check
  77854. * @param b defines the blue component to check
  77855. * @returns true if the rgb values are equal to the given ones
  77856. */
  77857. equalsFloats(r: number, g: number, b: number): boolean;
  77858. /**
  77859. * Multiplies in place each rgb value by scale
  77860. * @param scale defines the scaling factor
  77861. * @returns the updated Color3
  77862. */
  77863. scale(scale: number): Color3;
  77864. /**
  77865. * Multiplies the rgb values by scale and stores the result into "result"
  77866. * @param scale defines the scaling factor
  77867. * @param result defines the Color3 object where to store the result
  77868. * @returns the unmodified current Color3
  77869. */
  77870. scaleToRef(scale: number, result: Color3): Color3;
  77871. /**
  77872. * Scale the current Color3 values by a factor and add the result to a given Color3
  77873. * @param scale defines the scale factor
  77874. * @param result defines color to store the result into
  77875. * @returns the unmodified current Color3
  77876. */
  77877. scaleAndAddToRef(scale: number, result: Color3): Color3;
  77878. /**
  77879. * Clamps the rgb values by the min and max values and stores the result into "result"
  77880. * @param min defines minimum clamping value (default is 0)
  77881. * @param max defines maximum clamping value (default is 1)
  77882. * @param result defines color to store the result into
  77883. * @returns the original Color3
  77884. */
  77885. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  77886. /**
  77887. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  77888. * @param otherColor defines the second operand
  77889. * @returns the new Color3
  77890. */
  77891. add(otherColor: DeepImmutable<Color3>): Color3;
  77892. /**
  77893. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  77894. * @param otherColor defines the second operand
  77895. * @param result defines Color3 object to store the result into
  77896. * @returns the unmodified current Color3
  77897. */
  77898. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77899. /**
  77900. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  77901. * @param otherColor defines the second operand
  77902. * @returns the new Color3
  77903. */
  77904. subtract(otherColor: DeepImmutable<Color3>): Color3;
  77905. /**
  77906. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  77907. * @param otherColor defines the second operand
  77908. * @param result defines Color3 object to store the result into
  77909. * @returns the unmodified current Color3
  77910. */
  77911. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77912. /**
  77913. * Copy the current object
  77914. * @returns a new Color3 copied the current one
  77915. */
  77916. clone(): Color3;
  77917. /**
  77918. * Copies the rgb values from the source in the current Color3
  77919. * @param source defines the source Color3 object
  77920. * @returns the updated Color3 object
  77921. */
  77922. copyFrom(source: DeepImmutable<Color3>): Color3;
  77923. /**
  77924. * Updates the Color3 rgb values from the given floats
  77925. * @param r defines the red component to read from
  77926. * @param g defines the green component to read from
  77927. * @param b defines the blue component to read from
  77928. * @returns the current Color3 object
  77929. */
  77930. copyFromFloats(r: number, g: number, b: number): Color3;
  77931. /**
  77932. * Updates the Color3 rgb values from the given floats
  77933. * @param r defines the red component to read from
  77934. * @param g defines the green component to read from
  77935. * @param b defines the blue component to read from
  77936. * @returns the current Color3 object
  77937. */
  77938. set(r: number, g: number, b: number): Color3;
  77939. /**
  77940. * Compute the Color3 hexadecimal code as a string
  77941. * @returns a string containing the hexadecimal representation of the Color3 object
  77942. */
  77943. toHexString(): string;
  77944. /**
  77945. * Computes a new Color3 converted from the current one to linear space
  77946. * @returns a new Color3 object
  77947. */
  77948. toLinearSpace(): Color3;
  77949. /**
  77950. * Converts current color in rgb space to HSV values
  77951. * @returns a new color3 representing the HSV values
  77952. */
  77953. toHSV(): Color3;
  77954. /**
  77955. * Converts current color in rgb space to HSV values
  77956. * @param result defines the Color3 where to store the HSV values
  77957. */
  77958. toHSVToRef(result: Color3): void;
  77959. /**
  77960. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  77961. * @param convertedColor defines the Color3 object where to store the linear space version
  77962. * @returns the unmodified Color3
  77963. */
  77964. toLinearSpaceToRef(convertedColor: Color3): Color3;
  77965. /**
  77966. * Computes a new Color3 converted from the current one to gamma space
  77967. * @returns a new Color3 object
  77968. */
  77969. toGammaSpace(): Color3;
  77970. /**
  77971. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  77972. * @param convertedColor defines the Color3 object where to store the gamma space version
  77973. * @returns the unmodified Color3
  77974. */
  77975. toGammaSpaceToRef(convertedColor: Color3): Color3;
  77976. private static _BlackReadOnly;
  77977. /**
  77978. * Convert Hue, saturation and value to a Color3 (RGB)
  77979. * @param hue defines the hue
  77980. * @param saturation defines the saturation
  77981. * @param value defines the value
  77982. * @param result defines the Color3 where to store the RGB values
  77983. */
  77984. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  77985. /**
  77986. * Creates a new Color3 from the string containing valid hexadecimal values
  77987. * @param hex defines a string containing valid hexadecimal values
  77988. * @returns a new Color3 object
  77989. */
  77990. static FromHexString(hex: string): Color3;
  77991. /**
  77992. * Creates a new Color3 from the starting index of the given array
  77993. * @param array defines the source array
  77994. * @param offset defines an offset in the source array
  77995. * @returns a new Color3 object
  77996. */
  77997. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  77998. /**
  77999. * Creates a new Color3 from integer values (< 256)
  78000. * @param r defines the red component to read from (value between 0 and 255)
  78001. * @param g defines the green component to read from (value between 0 and 255)
  78002. * @param b defines the blue component to read from (value between 0 and 255)
  78003. * @returns a new Color3 object
  78004. */
  78005. static FromInts(r: number, g: number, b: number): Color3;
  78006. /**
  78007. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78008. * @param start defines the start Color3 value
  78009. * @param end defines the end Color3 value
  78010. * @param amount defines the gradient value between start and end
  78011. * @returns a new Color3 object
  78012. */
  78013. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78014. /**
  78015. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78016. * @param left defines the start value
  78017. * @param right defines the end value
  78018. * @param amount defines the gradient factor
  78019. * @param result defines the Color3 object where to store the result
  78020. */
  78021. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78022. /**
  78023. * Returns a Color3 value containing a red color
  78024. * @returns a new Color3 object
  78025. */
  78026. static Red(): Color3;
  78027. /**
  78028. * Returns a Color3 value containing a green color
  78029. * @returns a new Color3 object
  78030. */
  78031. static Green(): Color3;
  78032. /**
  78033. * Returns a Color3 value containing a blue color
  78034. * @returns a new Color3 object
  78035. */
  78036. static Blue(): Color3;
  78037. /**
  78038. * Returns a Color3 value containing a black color
  78039. * @returns a new Color3 object
  78040. */
  78041. static Black(): Color3;
  78042. /**
  78043. * Gets a Color3 value containing a black color that must not be updated
  78044. */
  78045. static get BlackReadOnly(): DeepImmutable<Color3>;
  78046. /**
  78047. * Returns a Color3 value containing a white color
  78048. * @returns a new Color3 object
  78049. */
  78050. static White(): Color3;
  78051. /**
  78052. * Returns a Color3 value containing a purple color
  78053. * @returns a new Color3 object
  78054. */
  78055. static Purple(): Color3;
  78056. /**
  78057. * Returns a Color3 value containing a magenta color
  78058. * @returns a new Color3 object
  78059. */
  78060. static Magenta(): Color3;
  78061. /**
  78062. * Returns a Color3 value containing a yellow color
  78063. * @returns a new Color3 object
  78064. */
  78065. static Yellow(): Color3;
  78066. /**
  78067. * Returns a Color3 value containing a gray color
  78068. * @returns a new Color3 object
  78069. */
  78070. static Gray(): Color3;
  78071. /**
  78072. * Returns a Color3 value containing a teal color
  78073. * @returns a new Color3 object
  78074. */
  78075. static Teal(): Color3;
  78076. /**
  78077. * Returns a Color3 value containing a random color
  78078. * @returns a new Color3 object
  78079. */
  78080. static Random(): Color3;
  78081. }
  78082. /**
  78083. * Class used to hold a RBGA color
  78084. */
  78085. export class Color4 {
  78086. /**
  78087. * Defines the red component (between 0 and 1, default is 0)
  78088. */
  78089. r: number;
  78090. /**
  78091. * Defines the green component (between 0 and 1, default is 0)
  78092. */
  78093. g: number;
  78094. /**
  78095. * Defines the blue component (between 0 and 1, default is 0)
  78096. */
  78097. b: number;
  78098. /**
  78099. * Defines the alpha component (between 0 and 1, default is 1)
  78100. */
  78101. a: number;
  78102. /**
  78103. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78104. * @param r defines the red component (between 0 and 1, default is 0)
  78105. * @param g defines the green component (between 0 and 1, default is 0)
  78106. * @param b defines the blue component (between 0 and 1, default is 0)
  78107. * @param a defines the alpha component (between 0 and 1, default is 1)
  78108. */
  78109. constructor(
  78110. /**
  78111. * Defines the red component (between 0 and 1, default is 0)
  78112. */
  78113. r?: number,
  78114. /**
  78115. * Defines the green component (between 0 and 1, default is 0)
  78116. */
  78117. g?: number,
  78118. /**
  78119. * Defines the blue component (between 0 and 1, default is 0)
  78120. */
  78121. b?: number,
  78122. /**
  78123. * Defines the alpha component (between 0 and 1, default is 1)
  78124. */
  78125. a?: number);
  78126. /**
  78127. * Adds in place the given Color4 values to the current Color4 object
  78128. * @param right defines the second operand
  78129. * @returns the current updated Color4 object
  78130. */
  78131. addInPlace(right: DeepImmutable<Color4>): Color4;
  78132. /**
  78133. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78134. * @returns the new array
  78135. */
  78136. asArray(): number[];
  78137. /**
  78138. * Stores from the starting index in the given array the Color4 successive values
  78139. * @param array defines the array where to store the r,g,b components
  78140. * @param index defines an optional index in the target array to define where to start storing values
  78141. * @returns the current Color4 object
  78142. */
  78143. toArray(array: number[], index?: number): Color4;
  78144. /**
  78145. * Determines equality between Color4 objects
  78146. * @param otherColor defines the second operand
  78147. * @returns true if the rgba values are equal to the given ones
  78148. */
  78149. equals(otherColor: DeepImmutable<Color4>): boolean;
  78150. /**
  78151. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78152. * @param right defines the second operand
  78153. * @returns a new Color4 object
  78154. */
  78155. add(right: DeepImmutable<Color4>): Color4;
  78156. /**
  78157. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78158. * @param right defines the second operand
  78159. * @returns a new Color4 object
  78160. */
  78161. subtract(right: DeepImmutable<Color4>): Color4;
  78162. /**
  78163. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78164. * @param right defines the second operand
  78165. * @param result defines the Color4 object where to store the result
  78166. * @returns the current Color4 object
  78167. */
  78168. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78169. /**
  78170. * Creates a new Color4 with the current Color4 values multiplied by scale
  78171. * @param scale defines the scaling factor to apply
  78172. * @returns a new Color4 object
  78173. */
  78174. scale(scale: number): Color4;
  78175. /**
  78176. * Multiplies the current Color4 values by scale and stores the result in "result"
  78177. * @param scale defines the scaling factor to apply
  78178. * @param result defines the Color4 object where to store the result
  78179. * @returns the current unmodified Color4
  78180. */
  78181. scaleToRef(scale: number, result: Color4): Color4;
  78182. /**
  78183. * Scale the current Color4 values by a factor and add the result to a given Color4
  78184. * @param scale defines the scale factor
  78185. * @param result defines the Color4 object where to store the result
  78186. * @returns the unmodified current Color4
  78187. */
  78188. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78189. /**
  78190. * Clamps the rgb values by the min and max values and stores the result into "result"
  78191. * @param min defines minimum clamping value (default is 0)
  78192. * @param max defines maximum clamping value (default is 1)
  78193. * @param result defines color to store the result into.
  78194. * @returns the cuurent Color4
  78195. */
  78196. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78197. /**
  78198. * Multipy an Color4 value by another and return a new Color4 object
  78199. * @param color defines the Color4 value to multiply by
  78200. * @returns a new Color4 object
  78201. */
  78202. multiply(color: Color4): Color4;
  78203. /**
  78204. * Multipy a Color4 value by another and push the result in a reference value
  78205. * @param color defines the Color4 value to multiply by
  78206. * @param result defines the Color4 to fill the result in
  78207. * @returns the result Color4
  78208. */
  78209. multiplyToRef(color: Color4, result: Color4): Color4;
  78210. /**
  78211. * Creates a string with the Color4 current values
  78212. * @returns the string representation of the Color4 object
  78213. */
  78214. toString(): string;
  78215. /**
  78216. * Returns the string "Color4"
  78217. * @returns "Color4"
  78218. */
  78219. getClassName(): string;
  78220. /**
  78221. * Compute the Color4 hash code
  78222. * @returns an unique number that can be used to hash Color4 objects
  78223. */
  78224. getHashCode(): number;
  78225. /**
  78226. * Creates a new Color4 copied from the current one
  78227. * @returns a new Color4 object
  78228. */
  78229. clone(): Color4;
  78230. /**
  78231. * Copies the given Color4 values into the current one
  78232. * @param source defines the source Color4 object
  78233. * @returns the current updated Color4 object
  78234. */
  78235. copyFrom(source: Color4): Color4;
  78236. /**
  78237. * Copies the given float values into the current one
  78238. * @param r defines the red component to read from
  78239. * @param g defines the green component to read from
  78240. * @param b defines the blue component to read from
  78241. * @param a defines the alpha component to read from
  78242. * @returns the current updated Color4 object
  78243. */
  78244. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78245. /**
  78246. * Copies the given float values into the current one
  78247. * @param r defines the red component to read from
  78248. * @param g defines the green component to read from
  78249. * @param b defines the blue component to read from
  78250. * @param a defines the alpha component to read from
  78251. * @returns the current updated Color4 object
  78252. */
  78253. set(r: number, g: number, b: number, a: number): Color4;
  78254. /**
  78255. * Compute the Color4 hexadecimal code as a string
  78256. * @returns a string containing the hexadecimal representation of the Color4 object
  78257. */
  78258. toHexString(): string;
  78259. /**
  78260. * Computes a new Color4 converted from the current one to linear space
  78261. * @returns a new Color4 object
  78262. */
  78263. toLinearSpace(): Color4;
  78264. /**
  78265. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78266. * @param convertedColor defines the Color4 object where to store the linear space version
  78267. * @returns the unmodified Color4
  78268. */
  78269. toLinearSpaceToRef(convertedColor: Color4): Color4;
  78270. /**
  78271. * Computes a new Color4 converted from the current one to gamma space
  78272. * @returns a new Color4 object
  78273. */
  78274. toGammaSpace(): Color4;
  78275. /**
  78276. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  78277. * @param convertedColor defines the Color4 object where to store the gamma space version
  78278. * @returns the unmodified Color4
  78279. */
  78280. toGammaSpaceToRef(convertedColor: Color4): Color4;
  78281. /**
  78282. * Creates a new Color4 from the string containing valid hexadecimal values
  78283. * @param hex defines a string containing valid hexadecimal values
  78284. * @returns a new Color4 object
  78285. */
  78286. static FromHexString(hex: string): Color4;
  78287. /**
  78288. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78289. * @param left defines the start value
  78290. * @param right defines the end value
  78291. * @param amount defines the gradient factor
  78292. * @returns a new Color4 object
  78293. */
  78294. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  78295. /**
  78296. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78297. * @param left defines the start value
  78298. * @param right defines the end value
  78299. * @param amount defines the gradient factor
  78300. * @param result defines the Color4 object where to store data
  78301. */
  78302. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  78303. /**
  78304. * Creates a new Color4 from a Color3 and an alpha value
  78305. * @param color3 defines the source Color3 to read from
  78306. * @param alpha defines the alpha component (1.0 by default)
  78307. * @returns a new Color4 object
  78308. */
  78309. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  78310. /**
  78311. * Creates a new Color4 from the starting index element of the given array
  78312. * @param array defines the source array to read from
  78313. * @param offset defines the offset in the source array
  78314. * @returns a new Color4 object
  78315. */
  78316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  78317. /**
  78318. * Creates a new Color3 from integer values (< 256)
  78319. * @param r defines the red component to read from (value between 0 and 255)
  78320. * @param g defines the green component to read from (value between 0 and 255)
  78321. * @param b defines the blue component to read from (value between 0 and 255)
  78322. * @param a defines the alpha component to read from (value between 0 and 255)
  78323. * @returns a new Color3 object
  78324. */
  78325. static FromInts(r: number, g: number, b: number, a: number): Color4;
  78326. /**
  78327. * Check the content of a given array and convert it to an array containing RGBA data
  78328. * If the original array was already containing count * 4 values then it is returned directly
  78329. * @param colors defines the array to check
  78330. * @param count defines the number of RGBA data to expect
  78331. * @returns an array containing count * 4 values (RGBA)
  78332. */
  78333. static CheckColors4(colors: number[], count: number): number[];
  78334. }
  78335. /**
  78336. * @hidden
  78337. */
  78338. export class TmpColors {
  78339. static Color3: Color3[];
  78340. static Color4: Color4[];
  78341. }
  78342. }
  78343. declare module BABYLON {
  78344. /**
  78345. * Defines an interface which represents an animation key frame
  78346. */
  78347. export interface IAnimationKey {
  78348. /**
  78349. * Frame of the key frame
  78350. */
  78351. frame: number;
  78352. /**
  78353. * Value at the specifies key frame
  78354. */
  78355. value: any;
  78356. /**
  78357. * The input tangent for the cubic hermite spline
  78358. */
  78359. inTangent?: any;
  78360. /**
  78361. * The output tangent for the cubic hermite spline
  78362. */
  78363. outTangent?: any;
  78364. /**
  78365. * The animation interpolation type
  78366. */
  78367. interpolation?: AnimationKeyInterpolation;
  78368. }
  78369. /**
  78370. * Enum for the animation key frame interpolation type
  78371. */
  78372. export enum AnimationKeyInterpolation {
  78373. /**
  78374. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  78375. */
  78376. STEP = 1
  78377. }
  78378. }
  78379. declare module BABYLON {
  78380. /**
  78381. * Represents the range of an animation
  78382. */
  78383. export class AnimationRange {
  78384. /**The name of the animation range**/
  78385. name: string;
  78386. /**The starting frame of the animation */
  78387. from: number;
  78388. /**The ending frame of the animation*/
  78389. to: number;
  78390. /**
  78391. * Initializes the range of an animation
  78392. * @param name The name of the animation range
  78393. * @param from The starting frame of the animation
  78394. * @param to The ending frame of the animation
  78395. */
  78396. constructor(
  78397. /**The name of the animation range**/
  78398. name: string,
  78399. /**The starting frame of the animation */
  78400. from: number,
  78401. /**The ending frame of the animation*/
  78402. to: number);
  78403. /**
  78404. * Makes a copy of the animation range
  78405. * @returns A copy of the animation range
  78406. */
  78407. clone(): AnimationRange;
  78408. }
  78409. }
  78410. declare module BABYLON {
  78411. /**
  78412. * Composed of a frame, and an action function
  78413. */
  78414. export class AnimationEvent {
  78415. /** The frame for which the event is triggered **/
  78416. frame: number;
  78417. /** The event to perform when triggered **/
  78418. action: (currentFrame: number) => void;
  78419. /** Specifies if the event should be triggered only once**/
  78420. onlyOnce?: boolean | undefined;
  78421. /**
  78422. * Specifies if the animation event is done
  78423. */
  78424. isDone: boolean;
  78425. /**
  78426. * Initializes the animation event
  78427. * @param frame The frame for which the event is triggered
  78428. * @param action The event to perform when triggered
  78429. * @param onlyOnce Specifies if the event should be triggered only once
  78430. */
  78431. constructor(
  78432. /** The frame for which the event is triggered **/
  78433. frame: number,
  78434. /** The event to perform when triggered **/
  78435. action: (currentFrame: number) => void,
  78436. /** Specifies if the event should be triggered only once**/
  78437. onlyOnce?: boolean | undefined);
  78438. /** @hidden */
  78439. _clone(): AnimationEvent;
  78440. }
  78441. }
  78442. declare module BABYLON {
  78443. /**
  78444. * Interface used to define a behavior
  78445. */
  78446. export interface Behavior<T> {
  78447. /** gets or sets behavior's name */
  78448. name: string;
  78449. /**
  78450. * Function called when the behavior needs to be initialized (after attaching it to a target)
  78451. */
  78452. init(): void;
  78453. /**
  78454. * Called when the behavior is attached to a target
  78455. * @param target defines the target where the behavior is attached to
  78456. */
  78457. attach(target: T): void;
  78458. /**
  78459. * Called when the behavior is detached from its target
  78460. */
  78461. detach(): void;
  78462. }
  78463. /**
  78464. * Interface implemented by classes supporting behaviors
  78465. */
  78466. export interface IBehaviorAware<T> {
  78467. /**
  78468. * Attach a behavior
  78469. * @param behavior defines the behavior to attach
  78470. * @returns the current host
  78471. */
  78472. addBehavior(behavior: Behavior<T>): T;
  78473. /**
  78474. * Remove a behavior from the current object
  78475. * @param behavior defines the behavior to detach
  78476. * @returns the current host
  78477. */
  78478. removeBehavior(behavior: Behavior<T>): T;
  78479. /**
  78480. * Gets a behavior using its name to search
  78481. * @param name defines the name to search
  78482. * @returns the behavior or null if not found
  78483. */
  78484. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  78485. }
  78486. }
  78487. declare module BABYLON {
  78488. /**
  78489. * Defines an array and its length.
  78490. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  78491. */
  78492. export interface ISmartArrayLike<T> {
  78493. /**
  78494. * The data of the array.
  78495. */
  78496. data: Array<T>;
  78497. /**
  78498. * The active length of the array.
  78499. */
  78500. length: number;
  78501. }
  78502. /**
  78503. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78504. */
  78505. export class SmartArray<T> implements ISmartArrayLike<T> {
  78506. /**
  78507. * The full set of data from the array.
  78508. */
  78509. data: Array<T>;
  78510. /**
  78511. * The active length of the array.
  78512. */
  78513. length: number;
  78514. protected _id: number;
  78515. /**
  78516. * Instantiates a Smart Array.
  78517. * @param capacity defines the default capacity of the array.
  78518. */
  78519. constructor(capacity: number);
  78520. /**
  78521. * Pushes a value at the end of the active data.
  78522. * @param value defines the object to push in the array.
  78523. */
  78524. push(value: T): void;
  78525. /**
  78526. * Iterates over the active data and apply the lambda to them.
  78527. * @param func defines the action to apply on each value.
  78528. */
  78529. forEach(func: (content: T) => void): void;
  78530. /**
  78531. * Sorts the full sets of data.
  78532. * @param compareFn defines the comparison function to apply.
  78533. */
  78534. sort(compareFn: (a: T, b: T) => number): void;
  78535. /**
  78536. * Resets the active data to an empty array.
  78537. */
  78538. reset(): void;
  78539. /**
  78540. * Releases all the data from the array as well as the array.
  78541. */
  78542. dispose(): void;
  78543. /**
  78544. * Concats the active data with a given array.
  78545. * @param array defines the data to concatenate with.
  78546. */
  78547. concat(array: any): void;
  78548. /**
  78549. * Returns the position of a value in the active data.
  78550. * @param value defines the value to find the index for
  78551. * @returns the index if found in the active data otherwise -1
  78552. */
  78553. indexOf(value: T): number;
  78554. /**
  78555. * Returns whether an element is part of the active data.
  78556. * @param value defines the value to look for
  78557. * @returns true if found in the active data otherwise false
  78558. */
  78559. contains(value: T): boolean;
  78560. private static _GlobalId;
  78561. }
  78562. /**
  78563. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78564. * The data in this array can only be present once
  78565. */
  78566. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  78567. private _duplicateId;
  78568. /**
  78569. * Pushes a value at the end of the active data.
  78570. * THIS DOES NOT PREVENT DUPPLICATE DATA
  78571. * @param value defines the object to push in the array.
  78572. */
  78573. push(value: T): void;
  78574. /**
  78575. * Pushes a value at the end of the active data.
  78576. * If the data is already present, it won t be added again
  78577. * @param value defines the object to push in the array.
  78578. * @returns true if added false if it was already present
  78579. */
  78580. pushNoDuplicate(value: T): boolean;
  78581. /**
  78582. * Resets the active data to an empty array.
  78583. */
  78584. reset(): void;
  78585. /**
  78586. * Concats the active data with a given array.
  78587. * This ensures no dupplicate will be present in the result.
  78588. * @param array defines the data to concatenate with.
  78589. */
  78590. concatWithNoDuplicate(array: any): void;
  78591. }
  78592. }
  78593. declare module BABYLON {
  78594. /**
  78595. * @ignore
  78596. * This is a list of all the different input types that are available in the application.
  78597. * Fo instance: ArcRotateCameraGamepadInput...
  78598. */
  78599. export var CameraInputTypes: {};
  78600. /**
  78601. * This is the contract to implement in order to create a new input class.
  78602. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  78603. */
  78604. export interface ICameraInput<TCamera extends Camera> {
  78605. /**
  78606. * Defines the camera the input is attached to.
  78607. */
  78608. camera: Nullable<TCamera>;
  78609. /**
  78610. * Gets the class name of the current intput.
  78611. * @returns the class name
  78612. */
  78613. getClassName(): string;
  78614. /**
  78615. * Get the friendly name associated with the input class.
  78616. * @returns the input friendly name
  78617. */
  78618. getSimpleName(): string;
  78619. /**
  78620. * Attach the input controls to a specific dom element to get the input from.
  78621. * @param element Defines the element the controls should be listened from
  78622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78623. */
  78624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78625. /**
  78626. * Detach the current controls from the specified dom element.
  78627. * @param element Defines the element to stop listening the inputs from
  78628. */
  78629. detachControl(element: Nullable<HTMLElement>): void;
  78630. /**
  78631. * Update the current camera state depending on the inputs that have been used this frame.
  78632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78633. */
  78634. checkInputs?: () => void;
  78635. }
  78636. /**
  78637. * Represents a map of input types to input instance or input index to input instance.
  78638. */
  78639. export interface CameraInputsMap<TCamera extends Camera> {
  78640. /**
  78641. * Accessor to the input by input type.
  78642. */
  78643. [name: string]: ICameraInput<TCamera>;
  78644. /**
  78645. * Accessor to the input by input index.
  78646. */
  78647. [idx: number]: ICameraInput<TCamera>;
  78648. }
  78649. /**
  78650. * This represents the input manager used within a camera.
  78651. * It helps dealing with all the different kind of input attached to a camera.
  78652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78653. */
  78654. export class CameraInputsManager<TCamera extends Camera> {
  78655. /**
  78656. * Defines the list of inputs attahed to the camera.
  78657. */
  78658. attached: CameraInputsMap<TCamera>;
  78659. /**
  78660. * Defines the dom element the camera is collecting inputs from.
  78661. * This is null if the controls have not been attached.
  78662. */
  78663. attachedElement: Nullable<HTMLElement>;
  78664. /**
  78665. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78666. */
  78667. noPreventDefault: boolean;
  78668. /**
  78669. * Defined the camera the input manager belongs to.
  78670. */
  78671. camera: TCamera;
  78672. /**
  78673. * Update the current camera state depending on the inputs that have been used this frame.
  78674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78675. */
  78676. checkInputs: () => void;
  78677. /**
  78678. * Instantiate a new Camera Input Manager.
  78679. * @param camera Defines the camera the input manager blongs to
  78680. */
  78681. constructor(camera: TCamera);
  78682. /**
  78683. * Add an input method to a camera
  78684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78685. * @param input camera input method
  78686. */
  78687. add(input: ICameraInput<TCamera>): void;
  78688. /**
  78689. * Remove a specific input method from a camera
  78690. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  78691. * @param inputToRemove camera input method
  78692. */
  78693. remove(inputToRemove: ICameraInput<TCamera>): void;
  78694. /**
  78695. * Remove a specific input type from a camera
  78696. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  78697. * @param inputType the type of the input to remove
  78698. */
  78699. removeByType(inputType: string): void;
  78700. private _addCheckInputs;
  78701. /**
  78702. * Attach the input controls to the currently attached dom element to listen the events from.
  78703. * @param input Defines the input to attach
  78704. */
  78705. attachInput(input: ICameraInput<TCamera>): void;
  78706. /**
  78707. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  78708. * @param element Defines the dom element to collect the events from
  78709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78710. */
  78711. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  78712. /**
  78713. * Detach the current manager inputs controls from a specific dom element.
  78714. * @param element Defines the dom element to collect the events from
  78715. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  78716. */
  78717. detachElement(element: HTMLElement, disconnect?: boolean): void;
  78718. /**
  78719. * Rebuild the dynamic inputCheck function from the current list of
  78720. * defined inputs in the manager.
  78721. */
  78722. rebuildInputCheck(): void;
  78723. /**
  78724. * Remove all attached input methods from a camera
  78725. */
  78726. clear(): void;
  78727. /**
  78728. * Serialize the current input manager attached to a camera.
  78729. * This ensures than once parsed,
  78730. * the input associated to the camera will be identical to the current ones
  78731. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  78732. */
  78733. serialize(serializedCamera: any): void;
  78734. /**
  78735. * Parses an input manager serialized JSON to restore the previous list of inputs
  78736. * and states associated to a camera.
  78737. * @param parsedCamera Defines the JSON to parse
  78738. */
  78739. parse(parsedCamera: any): void;
  78740. }
  78741. }
  78742. declare module BABYLON {
  78743. /**
  78744. * Class used to store data that will be store in GPU memory
  78745. */
  78746. export class Buffer {
  78747. private _engine;
  78748. private _buffer;
  78749. /** @hidden */
  78750. _data: Nullable<DataArray>;
  78751. private _updatable;
  78752. private _instanced;
  78753. private _divisor;
  78754. /**
  78755. * Gets the byte stride.
  78756. */
  78757. readonly byteStride: number;
  78758. /**
  78759. * Constructor
  78760. * @param engine the engine
  78761. * @param data the data to use for this buffer
  78762. * @param updatable whether the data is updatable
  78763. * @param stride the stride (optional)
  78764. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78765. * @param instanced whether the buffer is instanced (optional)
  78766. * @param useBytes set to true if the stride in in bytes (optional)
  78767. * @param divisor sets an optional divisor for instances (1 by default)
  78768. */
  78769. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  78770. /**
  78771. * Create a new VertexBuffer based on the current buffer
  78772. * @param kind defines the vertex buffer kind (position, normal, etc.)
  78773. * @param offset defines offset in the buffer (0 by default)
  78774. * @param size defines the size in floats of attributes (position is 3 for instance)
  78775. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  78776. * @param instanced defines if the vertex buffer contains indexed data
  78777. * @param useBytes defines if the offset and stride are in bytes *
  78778. * @param divisor sets an optional divisor for instances (1 by default)
  78779. * @returns the new vertex buffer
  78780. */
  78781. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  78782. /**
  78783. * Gets a boolean indicating if the Buffer is updatable?
  78784. * @returns true if the buffer is updatable
  78785. */
  78786. isUpdatable(): boolean;
  78787. /**
  78788. * Gets current buffer's data
  78789. * @returns a DataArray or null
  78790. */
  78791. getData(): Nullable<DataArray>;
  78792. /**
  78793. * Gets underlying native buffer
  78794. * @returns underlying native buffer
  78795. */
  78796. getBuffer(): Nullable<DataBuffer>;
  78797. /**
  78798. * Gets the stride in float32 units (i.e. byte stride / 4).
  78799. * May not be an integer if the byte stride is not divisible by 4.
  78800. * @returns the stride in float32 units
  78801. * @deprecated Please use byteStride instead.
  78802. */
  78803. getStrideSize(): number;
  78804. /**
  78805. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78806. * @param data defines the data to store
  78807. */
  78808. create(data?: Nullable<DataArray>): void;
  78809. /** @hidden */
  78810. _rebuild(): void;
  78811. /**
  78812. * Update current buffer data
  78813. * @param data defines the data to store
  78814. */
  78815. update(data: DataArray): void;
  78816. /**
  78817. * Updates the data directly.
  78818. * @param data the new data
  78819. * @param offset the new offset
  78820. * @param vertexCount the vertex count (optional)
  78821. * @param useBytes set to true if the offset is in bytes
  78822. */
  78823. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  78824. /**
  78825. * Release all resources
  78826. */
  78827. dispose(): void;
  78828. }
  78829. /**
  78830. * Specialized buffer used to store vertex data
  78831. */
  78832. export class VertexBuffer {
  78833. /** @hidden */
  78834. _buffer: Buffer;
  78835. private _kind;
  78836. private _size;
  78837. private _ownsBuffer;
  78838. private _instanced;
  78839. private _instanceDivisor;
  78840. /**
  78841. * The byte type.
  78842. */
  78843. static readonly BYTE: number;
  78844. /**
  78845. * The unsigned byte type.
  78846. */
  78847. static readonly UNSIGNED_BYTE: number;
  78848. /**
  78849. * The short type.
  78850. */
  78851. static readonly SHORT: number;
  78852. /**
  78853. * The unsigned short type.
  78854. */
  78855. static readonly UNSIGNED_SHORT: number;
  78856. /**
  78857. * The integer type.
  78858. */
  78859. static readonly INT: number;
  78860. /**
  78861. * The unsigned integer type.
  78862. */
  78863. static readonly UNSIGNED_INT: number;
  78864. /**
  78865. * The float type.
  78866. */
  78867. static readonly FLOAT: number;
  78868. /**
  78869. * Gets or sets the instance divisor when in instanced mode
  78870. */
  78871. get instanceDivisor(): number;
  78872. set instanceDivisor(value: number);
  78873. /**
  78874. * Gets the byte stride.
  78875. */
  78876. readonly byteStride: number;
  78877. /**
  78878. * Gets the byte offset.
  78879. */
  78880. readonly byteOffset: number;
  78881. /**
  78882. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  78883. */
  78884. readonly normalized: boolean;
  78885. /**
  78886. * Gets the data type of each component in the array.
  78887. */
  78888. readonly type: number;
  78889. /**
  78890. * Constructor
  78891. * @param engine the engine
  78892. * @param data the data to use for this vertex buffer
  78893. * @param kind the vertex buffer kind
  78894. * @param updatable whether the data is updatable
  78895. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78896. * @param stride the stride (optional)
  78897. * @param instanced whether the buffer is instanced (optional)
  78898. * @param offset the offset of the data (optional)
  78899. * @param size the number of components (optional)
  78900. * @param type the type of the component (optional)
  78901. * @param normalized whether the data contains normalized data (optional)
  78902. * @param useBytes set to true if stride and offset are in bytes (optional)
  78903. * @param divisor defines the instance divisor to use (1 by default)
  78904. */
  78905. 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);
  78906. /** @hidden */
  78907. _rebuild(): void;
  78908. /**
  78909. * Returns the kind of the VertexBuffer (string)
  78910. * @returns a string
  78911. */
  78912. getKind(): string;
  78913. /**
  78914. * Gets a boolean indicating if the VertexBuffer is updatable?
  78915. * @returns true if the buffer is updatable
  78916. */
  78917. isUpdatable(): boolean;
  78918. /**
  78919. * Gets current buffer's data
  78920. * @returns a DataArray or null
  78921. */
  78922. getData(): Nullable<DataArray>;
  78923. /**
  78924. * Gets underlying native buffer
  78925. * @returns underlying native buffer
  78926. */
  78927. getBuffer(): Nullable<DataBuffer>;
  78928. /**
  78929. * Gets the stride in float32 units (i.e. byte stride / 4).
  78930. * May not be an integer if the byte stride is not divisible by 4.
  78931. * @returns the stride in float32 units
  78932. * @deprecated Please use byteStride instead.
  78933. */
  78934. getStrideSize(): number;
  78935. /**
  78936. * Returns the offset as a multiple of the type byte length.
  78937. * @returns the offset in bytes
  78938. * @deprecated Please use byteOffset instead.
  78939. */
  78940. getOffset(): number;
  78941. /**
  78942. * Returns the number of components per vertex attribute (integer)
  78943. * @returns the size in float
  78944. */
  78945. getSize(): number;
  78946. /**
  78947. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  78948. * @returns true if this buffer is instanced
  78949. */
  78950. getIsInstanced(): boolean;
  78951. /**
  78952. * Returns the instancing divisor, zero for non-instanced (integer).
  78953. * @returns a number
  78954. */
  78955. getInstanceDivisor(): number;
  78956. /**
  78957. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78958. * @param data defines the data to store
  78959. */
  78960. create(data?: DataArray): void;
  78961. /**
  78962. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  78963. * This function will create a new buffer if the current one is not updatable
  78964. * @param data defines the data to store
  78965. */
  78966. update(data: DataArray): void;
  78967. /**
  78968. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  78969. * Returns the directly updated WebGLBuffer.
  78970. * @param data the new data
  78971. * @param offset the new offset
  78972. * @param useBytes set to true if the offset is in bytes
  78973. */
  78974. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  78975. /**
  78976. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  78977. */
  78978. dispose(): void;
  78979. /**
  78980. * Enumerates each value of this vertex buffer as numbers.
  78981. * @param count the number of values to enumerate
  78982. * @param callback the callback function called for each value
  78983. */
  78984. forEach(count: number, callback: (value: number, index: number) => void): void;
  78985. /**
  78986. * Positions
  78987. */
  78988. static readonly PositionKind: string;
  78989. /**
  78990. * Normals
  78991. */
  78992. static readonly NormalKind: string;
  78993. /**
  78994. * Tangents
  78995. */
  78996. static readonly TangentKind: string;
  78997. /**
  78998. * Texture coordinates
  78999. */
  79000. static readonly UVKind: string;
  79001. /**
  79002. * Texture coordinates 2
  79003. */
  79004. static readonly UV2Kind: string;
  79005. /**
  79006. * Texture coordinates 3
  79007. */
  79008. static readonly UV3Kind: string;
  79009. /**
  79010. * Texture coordinates 4
  79011. */
  79012. static readonly UV4Kind: string;
  79013. /**
  79014. * Texture coordinates 5
  79015. */
  79016. static readonly UV5Kind: string;
  79017. /**
  79018. * Texture coordinates 6
  79019. */
  79020. static readonly UV6Kind: string;
  79021. /**
  79022. * Colors
  79023. */
  79024. static readonly ColorKind: string;
  79025. /**
  79026. * Matrix indices (for bones)
  79027. */
  79028. static readonly MatricesIndicesKind: string;
  79029. /**
  79030. * Matrix weights (for bones)
  79031. */
  79032. static readonly MatricesWeightsKind: string;
  79033. /**
  79034. * Additional matrix indices (for bones)
  79035. */
  79036. static readonly MatricesIndicesExtraKind: string;
  79037. /**
  79038. * Additional matrix weights (for bones)
  79039. */
  79040. static readonly MatricesWeightsExtraKind: string;
  79041. /**
  79042. * Deduces the stride given a kind.
  79043. * @param kind The kind string to deduce
  79044. * @returns The deduced stride
  79045. */
  79046. static DeduceStride(kind: string): number;
  79047. /**
  79048. * Gets the byte length of the given type.
  79049. * @param type the type
  79050. * @returns the number of bytes
  79051. */
  79052. static GetTypeByteLength(type: number): number;
  79053. /**
  79054. * Enumerates each value of the given parameters as numbers.
  79055. * @param data the data to enumerate
  79056. * @param byteOffset the byte offset of the data
  79057. * @param byteStride the byte stride of the data
  79058. * @param componentCount the number of components per element
  79059. * @param componentType the type of the component
  79060. * @param count the number of values to enumerate
  79061. * @param normalized whether the data is normalized
  79062. * @param callback the callback function called for each value
  79063. */
  79064. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79065. private static _GetFloatValue;
  79066. }
  79067. }
  79068. declare module BABYLON {
  79069. /**
  79070. * @hidden
  79071. */
  79072. export class IntersectionInfo {
  79073. bu: Nullable<number>;
  79074. bv: Nullable<number>;
  79075. distance: number;
  79076. faceId: number;
  79077. subMeshId: number;
  79078. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79079. }
  79080. }
  79081. declare module BABYLON {
  79082. /**
  79083. * Represens a plane by the equation ax + by + cz + d = 0
  79084. */
  79085. export class Plane {
  79086. private static _TmpMatrix;
  79087. /**
  79088. * Normal of the plane (a,b,c)
  79089. */
  79090. normal: Vector3;
  79091. /**
  79092. * d component of the plane
  79093. */
  79094. d: number;
  79095. /**
  79096. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79097. * @param a a component of the plane
  79098. * @param b b component of the plane
  79099. * @param c c component of the plane
  79100. * @param d d component of the plane
  79101. */
  79102. constructor(a: number, b: number, c: number, d: number);
  79103. /**
  79104. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79105. */
  79106. asArray(): number[];
  79107. /**
  79108. * @returns a new plane copied from the current Plane.
  79109. */
  79110. clone(): Plane;
  79111. /**
  79112. * @returns the string "Plane".
  79113. */
  79114. getClassName(): string;
  79115. /**
  79116. * @returns the Plane hash code.
  79117. */
  79118. getHashCode(): number;
  79119. /**
  79120. * Normalize the current Plane in place.
  79121. * @returns the updated Plane.
  79122. */
  79123. normalize(): Plane;
  79124. /**
  79125. * Applies a transformation the plane and returns the result
  79126. * @param transformation the transformation matrix to be applied to the plane
  79127. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79128. */
  79129. transform(transformation: DeepImmutable<Matrix>): Plane;
  79130. /**
  79131. * Calcualtte the dot product between the point and the plane normal
  79132. * @param point point to calculate the dot product with
  79133. * @returns the dot product (float) of the point coordinates and the plane normal.
  79134. */
  79135. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79136. /**
  79137. * Updates the current Plane from the plane defined by the three given points.
  79138. * @param point1 one of the points used to contruct the plane
  79139. * @param point2 one of the points used to contruct the plane
  79140. * @param point3 one of the points used to contruct the plane
  79141. * @returns the updated Plane.
  79142. */
  79143. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79144. /**
  79145. * Checks if the plane is facing a given direction
  79146. * @param direction the direction to check if the plane is facing
  79147. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79148. * @returns True is the vector "direction" is the same side than the plane normal.
  79149. */
  79150. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79151. /**
  79152. * Calculates the distance to a point
  79153. * @param point point to calculate distance to
  79154. * @returns the signed distance (float) from the given point to the Plane.
  79155. */
  79156. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79157. /**
  79158. * Creates a plane from an array
  79159. * @param array the array to create a plane from
  79160. * @returns a new Plane from the given array.
  79161. */
  79162. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79163. /**
  79164. * Creates a plane from three points
  79165. * @param point1 point used to create the plane
  79166. * @param point2 point used to create the plane
  79167. * @param point3 point used to create the plane
  79168. * @returns a new Plane defined by the three given points.
  79169. */
  79170. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79171. /**
  79172. * Creates a plane from an origin point and a normal
  79173. * @param origin origin of the plane to be constructed
  79174. * @param normal normal of the plane to be constructed
  79175. * @returns a new Plane the normal vector to this plane at the given origin point.
  79176. * Note : the vector "normal" is updated because normalized.
  79177. */
  79178. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79179. /**
  79180. * Calculates the distance from a plane and a point
  79181. * @param origin origin of the plane to be constructed
  79182. * @param normal normal of the plane to be constructed
  79183. * @param point point to calculate distance to
  79184. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79185. */
  79186. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79187. }
  79188. }
  79189. declare module BABYLON {
  79190. /**
  79191. * Class used to store bounding sphere information
  79192. */
  79193. export class BoundingSphere {
  79194. /**
  79195. * Gets the center of the bounding sphere in local space
  79196. */
  79197. readonly center: Vector3;
  79198. /**
  79199. * Radius of the bounding sphere in local space
  79200. */
  79201. radius: number;
  79202. /**
  79203. * Gets the center of the bounding sphere in world space
  79204. */
  79205. readonly centerWorld: Vector3;
  79206. /**
  79207. * Radius of the bounding sphere in world space
  79208. */
  79209. radiusWorld: number;
  79210. /**
  79211. * Gets the minimum vector in local space
  79212. */
  79213. readonly minimum: Vector3;
  79214. /**
  79215. * Gets the maximum vector in local space
  79216. */
  79217. readonly maximum: Vector3;
  79218. private _worldMatrix;
  79219. private static readonly TmpVector3;
  79220. /**
  79221. * Creates a new bounding sphere
  79222. * @param min defines the minimum vector (in local space)
  79223. * @param max defines the maximum vector (in local space)
  79224. * @param worldMatrix defines the new world matrix
  79225. */
  79226. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79227. /**
  79228. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79229. * @param min defines the new minimum vector (in local space)
  79230. * @param max defines the new maximum vector (in local space)
  79231. * @param worldMatrix defines the new world matrix
  79232. */
  79233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79234. /**
  79235. * Scale the current bounding sphere by applying a scale factor
  79236. * @param factor defines the scale factor to apply
  79237. * @returns the current bounding box
  79238. */
  79239. scale(factor: number): BoundingSphere;
  79240. /**
  79241. * Gets the world matrix of the bounding box
  79242. * @returns a matrix
  79243. */
  79244. getWorldMatrix(): DeepImmutable<Matrix>;
  79245. /** @hidden */
  79246. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79247. /**
  79248. * Tests if the bounding sphere is intersecting the frustum planes
  79249. * @param frustumPlanes defines the frustum planes to test
  79250. * @returns true if there is an intersection
  79251. */
  79252. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79253. /**
  79254. * Tests if the bounding sphere center is in between the frustum planes.
  79255. * Used for optimistic fast inclusion.
  79256. * @param frustumPlanes defines the frustum planes to test
  79257. * @returns true if the sphere center is in between the frustum planes
  79258. */
  79259. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79260. /**
  79261. * Tests if a point is inside the bounding sphere
  79262. * @param point defines the point to test
  79263. * @returns true if the point is inside the bounding sphere
  79264. */
  79265. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79266. /**
  79267. * Checks if two sphere intersct
  79268. * @param sphere0 sphere 0
  79269. * @param sphere1 sphere 1
  79270. * @returns true if the speres intersect
  79271. */
  79272. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  79273. }
  79274. }
  79275. declare module BABYLON {
  79276. /**
  79277. * Class used to store bounding box information
  79278. */
  79279. export class BoundingBox implements ICullable {
  79280. /**
  79281. * Gets the 8 vectors representing the bounding box in local space
  79282. */
  79283. readonly vectors: Vector3[];
  79284. /**
  79285. * Gets the center of the bounding box in local space
  79286. */
  79287. readonly center: Vector3;
  79288. /**
  79289. * Gets the center of the bounding box in world space
  79290. */
  79291. readonly centerWorld: Vector3;
  79292. /**
  79293. * Gets the extend size in local space
  79294. */
  79295. readonly extendSize: Vector3;
  79296. /**
  79297. * Gets the extend size in world space
  79298. */
  79299. readonly extendSizeWorld: Vector3;
  79300. /**
  79301. * Gets the OBB (object bounding box) directions
  79302. */
  79303. readonly directions: Vector3[];
  79304. /**
  79305. * Gets the 8 vectors representing the bounding box in world space
  79306. */
  79307. readonly vectorsWorld: Vector3[];
  79308. /**
  79309. * Gets the minimum vector in world space
  79310. */
  79311. readonly minimumWorld: Vector3;
  79312. /**
  79313. * Gets the maximum vector in world space
  79314. */
  79315. readonly maximumWorld: Vector3;
  79316. /**
  79317. * Gets the minimum vector in local space
  79318. */
  79319. readonly minimum: Vector3;
  79320. /**
  79321. * Gets the maximum vector in local space
  79322. */
  79323. readonly maximum: Vector3;
  79324. private _worldMatrix;
  79325. private static readonly TmpVector3;
  79326. /**
  79327. * @hidden
  79328. */
  79329. _tag: number;
  79330. /**
  79331. * Creates a new bounding box
  79332. * @param min defines the minimum vector (in local space)
  79333. * @param max defines the maximum vector (in local space)
  79334. * @param worldMatrix defines the new world matrix
  79335. */
  79336. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79337. /**
  79338. * Recreates the entire bounding box from scratch as if we call the constructor in place
  79339. * @param min defines the new minimum vector (in local space)
  79340. * @param max defines the new maximum vector (in local space)
  79341. * @param worldMatrix defines the new world matrix
  79342. */
  79343. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79344. /**
  79345. * Scale the current bounding box by applying a scale factor
  79346. * @param factor defines the scale factor to apply
  79347. * @returns the current bounding box
  79348. */
  79349. scale(factor: number): BoundingBox;
  79350. /**
  79351. * Gets the world matrix of the bounding box
  79352. * @returns a matrix
  79353. */
  79354. getWorldMatrix(): DeepImmutable<Matrix>;
  79355. /** @hidden */
  79356. _update(world: DeepImmutable<Matrix>): void;
  79357. /**
  79358. * Tests if the bounding box is intersecting the frustum planes
  79359. * @param frustumPlanes defines the frustum planes to test
  79360. * @returns true if there is an intersection
  79361. */
  79362. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79363. /**
  79364. * Tests if the bounding box is entirely inside the frustum planes
  79365. * @param frustumPlanes defines the frustum planes to test
  79366. * @returns true if there is an inclusion
  79367. */
  79368. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79369. /**
  79370. * Tests if a point is inside the bounding box
  79371. * @param point defines the point to test
  79372. * @returns true if the point is inside the bounding box
  79373. */
  79374. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79375. /**
  79376. * Tests if the bounding box intersects with a bounding sphere
  79377. * @param sphere defines the sphere to test
  79378. * @returns true if there is an intersection
  79379. */
  79380. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  79381. /**
  79382. * Tests if the bounding box intersects with a box defined by a min and max vectors
  79383. * @param min defines the min vector to use
  79384. * @param max defines the max vector to use
  79385. * @returns true if there is an intersection
  79386. */
  79387. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  79388. /**
  79389. * Tests if two bounding boxes are intersections
  79390. * @param box0 defines the first box to test
  79391. * @param box1 defines the second box to test
  79392. * @returns true if there is an intersection
  79393. */
  79394. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  79395. /**
  79396. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  79397. * @param minPoint defines the minimum vector of the bounding box
  79398. * @param maxPoint defines the maximum vector of the bounding box
  79399. * @param sphereCenter defines the sphere center
  79400. * @param sphereRadius defines the sphere radius
  79401. * @returns true if there is an intersection
  79402. */
  79403. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  79404. /**
  79405. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  79406. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79407. * @param frustumPlanes defines the frustum planes to test
  79408. * @return true if there is an inclusion
  79409. */
  79410. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79411. /**
  79412. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  79413. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79414. * @param frustumPlanes defines the frustum planes to test
  79415. * @return true if there is an intersection
  79416. */
  79417. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79418. }
  79419. }
  79420. declare module BABYLON {
  79421. /** @hidden */
  79422. export class Collider {
  79423. /** Define if a collision was found */
  79424. collisionFound: boolean;
  79425. /**
  79426. * Define last intersection point in local space
  79427. */
  79428. intersectionPoint: Vector3;
  79429. /**
  79430. * Define last collided mesh
  79431. */
  79432. collidedMesh: Nullable<AbstractMesh>;
  79433. private _collisionPoint;
  79434. private _planeIntersectionPoint;
  79435. private _tempVector;
  79436. private _tempVector2;
  79437. private _tempVector3;
  79438. private _tempVector4;
  79439. private _edge;
  79440. private _baseToVertex;
  79441. private _destinationPoint;
  79442. private _slidePlaneNormal;
  79443. private _displacementVector;
  79444. /** @hidden */
  79445. _radius: Vector3;
  79446. /** @hidden */
  79447. _retry: number;
  79448. private _velocity;
  79449. private _basePoint;
  79450. private _epsilon;
  79451. /** @hidden */
  79452. _velocityWorldLength: number;
  79453. /** @hidden */
  79454. _basePointWorld: Vector3;
  79455. private _velocityWorld;
  79456. private _normalizedVelocity;
  79457. /** @hidden */
  79458. _initialVelocity: Vector3;
  79459. /** @hidden */
  79460. _initialPosition: Vector3;
  79461. private _nearestDistance;
  79462. private _collisionMask;
  79463. get collisionMask(): number;
  79464. set collisionMask(mask: number);
  79465. /**
  79466. * Gets the plane normal used to compute the sliding response (in local space)
  79467. */
  79468. get slidePlaneNormal(): Vector3;
  79469. /** @hidden */
  79470. _initialize(source: Vector3, dir: Vector3, e: number): void;
  79471. /** @hidden */
  79472. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  79473. /** @hidden */
  79474. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  79475. /** @hidden */
  79476. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79477. /** @hidden */
  79478. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79479. /** @hidden */
  79480. _getResponse(pos: Vector3, vel: Vector3): void;
  79481. }
  79482. }
  79483. declare module BABYLON {
  79484. /**
  79485. * Interface for cullable objects
  79486. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  79487. */
  79488. export interface ICullable {
  79489. /**
  79490. * Checks if the object or part of the object is in the frustum
  79491. * @param frustumPlanes Camera near/planes
  79492. * @returns true if the object is in frustum otherwise false
  79493. */
  79494. isInFrustum(frustumPlanes: Plane[]): boolean;
  79495. /**
  79496. * Checks if a cullable object (mesh...) is in the camera frustum
  79497. * Unlike isInFrustum this cheks the full bounding box
  79498. * @param frustumPlanes Camera near/planes
  79499. * @returns true if the object is in frustum otherwise false
  79500. */
  79501. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79502. }
  79503. /**
  79504. * Info for a bounding data of a mesh
  79505. */
  79506. export class BoundingInfo implements ICullable {
  79507. /**
  79508. * Bounding box for the mesh
  79509. */
  79510. readonly boundingBox: BoundingBox;
  79511. /**
  79512. * Bounding sphere for the mesh
  79513. */
  79514. readonly boundingSphere: BoundingSphere;
  79515. private _isLocked;
  79516. private static readonly TmpVector3;
  79517. /**
  79518. * Constructs bounding info
  79519. * @param minimum min vector of the bounding box/sphere
  79520. * @param maximum max vector of the bounding box/sphere
  79521. * @param worldMatrix defines the new world matrix
  79522. */
  79523. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79524. /**
  79525. * Recreates the entire bounding info from scratch as if we call the constructor in place
  79526. * @param min defines the new minimum vector (in local space)
  79527. * @param max defines the new maximum vector (in local space)
  79528. * @param worldMatrix defines the new world matrix
  79529. */
  79530. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79531. /**
  79532. * min vector of the bounding box/sphere
  79533. */
  79534. get minimum(): Vector3;
  79535. /**
  79536. * max vector of the bounding box/sphere
  79537. */
  79538. get maximum(): Vector3;
  79539. /**
  79540. * If the info is locked and won't be updated to avoid perf overhead
  79541. */
  79542. get isLocked(): boolean;
  79543. set isLocked(value: boolean);
  79544. /**
  79545. * Updates the bounding sphere and box
  79546. * @param world world matrix to be used to update
  79547. */
  79548. update(world: DeepImmutable<Matrix>): void;
  79549. /**
  79550. * Recreate the bounding info to be centered around a specific point given a specific extend.
  79551. * @param center New center of the bounding info
  79552. * @param extend New extend of the bounding info
  79553. * @returns the current bounding info
  79554. */
  79555. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  79556. /**
  79557. * Scale the current bounding info by applying a scale factor
  79558. * @param factor defines the scale factor to apply
  79559. * @returns the current bounding info
  79560. */
  79561. scale(factor: number): BoundingInfo;
  79562. /**
  79563. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  79564. * @param frustumPlanes defines the frustum to test
  79565. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  79566. * @returns true if the bounding info is in the frustum planes
  79567. */
  79568. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  79569. /**
  79570. * Gets the world distance between the min and max points of the bounding box
  79571. */
  79572. get diagonalLength(): number;
  79573. /**
  79574. * Checks if a cullable object (mesh...) is in the camera frustum
  79575. * Unlike isInFrustum this cheks the full bounding box
  79576. * @param frustumPlanes Camera near/planes
  79577. * @returns true if the object is in frustum otherwise false
  79578. */
  79579. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79580. /** @hidden */
  79581. _checkCollision(collider: Collider): boolean;
  79582. /**
  79583. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  79584. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79585. * @param point the point to check intersection with
  79586. * @returns if the point intersects
  79587. */
  79588. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79589. /**
  79590. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  79591. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79592. * @param boundingInfo the bounding info to check intersection with
  79593. * @param precise if the intersection should be done using OBB
  79594. * @returns if the bounding info intersects
  79595. */
  79596. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  79597. }
  79598. }
  79599. declare module BABYLON {
  79600. /**
  79601. * Extracts minimum and maximum values from a list of indexed positions
  79602. * @param positions defines the positions to use
  79603. * @param indices defines the indices to the positions
  79604. * @param indexStart defines the start index
  79605. * @param indexCount defines the end index
  79606. * @param bias defines bias value to add to the result
  79607. * @return minimum and maximum values
  79608. */
  79609. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  79610. minimum: Vector3;
  79611. maximum: Vector3;
  79612. };
  79613. /**
  79614. * Extracts minimum and maximum values from a list of positions
  79615. * @param positions defines the positions to use
  79616. * @param start defines the start index in the positions array
  79617. * @param count defines the number of positions to handle
  79618. * @param bias defines bias value to add to the result
  79619. * @param stride defines the stride size to use (distance between two positions in the positions array)
  79620. * @return minimum and maximum values
  79621. */
  79622. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  79623. minimum: Vector3;
  79624. maximum: Vector3;
  79625. };
  79626. }
  79627. declare module BABYLON {
  79628. /** @hidden */
  79629. export class WebGLDataBuffer extends DataBuffer {
  79630. private _buffer;
  79631. constructor(resource: WebGLBuffer);
  79632. get underlyingResource(): any;
  79633. }
  79634. }
  79635. declare module BABYLON {
  79636. /** @hidden */
  79637. export class WebGLPipelineContext implements IPipelineContext {
  79638. engine: ThinEngine;
  79639. program: Nullable<WebGLProgram>;
  79640. context?: WebGLRenderingContext;
  79641. vertexShader?: WebGLShader;
  79642. fragmentShader?: WebGLShader;
  79643. isParallelCompiled: boolean;
  79644. onCompiled?: () => void;
  79645. transformFeedback?: WebGLTransformFeedback | null;
  79646. vertexCompilationError: Nullable<string>;
  79647. fragmentCompilationError: Nullable<string>;
  79648. programLinkError: Nullable<string>;
  79649. programValidationError: Nullable<string>;
  79650. get isAsync(): boolean;
  79651. get isReady(): boolean;
  79652. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  79653. }
  79654. }
  79655. declare module BABYLON {
  79656. interface ThinEngine {
  79657. /**
  79658. * Create an uniform buffer
  79659. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79660. * @param elements defines the content of the uniform buffer
  79661. * @returns the webGL uniform buffer
  79662. */
  79663. createUniformBuffer(elements: FloatArray): DataBuffer;
  79664. /**
  79665. * Create a dynamic uniform buffer
  79666. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79667. * @param elements defines the content of the uniform buffer
  79668. * @returns the webGL uniform buffer
  79669. */
  79670. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  79671. /**
  79672. * Update an existing uniform buffer
  79673. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79674. * @param uniformBuffer defines the target uniform buffer
  79675. * @param elements defines the content to update
  79676. * @param offset defines the offset in the uniform buffer where update should start
  79677. * @param count defines the size of the data to update
  79678. */
  79679. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  79680. /**
  79681. * Bind an uniform buffer to the current webGL context
  79682. * @param buffer defines the buffer to bind
  79683. */
  79684. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  79685. /**
  79686. * Bind a buffer to the current webGL context at a given location
  79687. * @param buffer defines the buffer to bind
  79688. * @param location defines the index where to bind the buffer
  79689. */
  79690. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  79691. /**
  79692. * Bind a specific block at a given index in a specific shader program
  79693. * @param pipelineContext defines the pipeline context to use
  79694. * @param blockName defines the block name
  79695. * @param index defines the index where to bind the block
  79696. */
  79697. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  79698. }
  79699. }
  79700. declare module BABYLON {
  79701. /**
  79702. * Uniform buffer objects.
  79703. *
  79704. * Handles blocks of uniform on the GPU.
  79705. *
  79706. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79707. *
  79708. * For more information, please refer to :
  79709. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79710. */
  79711. export class UniformBuffer {
  79712. private _engine;
  79713. private _buffer;
  79714. private _data;
  79715. private _bufferData;
  79716. private _dynamic?;
  79717. private _uniformLocations;
  79718. private _uniformSizes;
  79719. private _uniformLocationPointer;
  79720. private _needSync;
  79721. private _noUBO;
  79722. private _currentEffect;
  79723. /** @hidden */
  79724. _alreadyBound: boolean;
  79725. private static _MAX_UNIFORM_SIZE;
  79726. private static _tempBuffer;
  79727. /**
  79728. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  79729. * This is dynamic to allow compat with webgl 1 and 2.
  79730. * You will need to pass the name of the uniform as well as the value.
  79731. */
  79732. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  79733. /**
  79734. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  79735. * This is dynamic to allow compat with webgl 1 and 2.
  79736. * You will need to pass the name of the uniform as well as the value.
  79737. */
  79738. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  79739. /**
  79740. * Lambda to Update a single float in a uniform buffer.
  79741. * This is dynamic to allow compat with webgl 1 and 2.
  79742. * You will need to pass the name of the uniform as well as the value.
  79743. */
  79744. updateFloat: (name: string, x: number) => void;
  79745. /**
  79746. * Lambda to Update a vec2 of float in a uniform buffer.
  79747. * This is dynamic to allow compat with webgl 1 and 2.
  79748. * You will need to pass the name of the uniform as well as the value.
  79749. */
  79750. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  79751. /**
  79752. * Lambda to Update a vec3 of float in a uniform buffer.
  79753. * This is dynamic to allow compat with webgl 1 and 2.
  79754. * You will need to pass the name of the uniform as well as the value.
  79755. */
  79756. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  79757. /**
  79758. * Lambda to Update a vec4 of float in a uniform buffer.
  79759. * This is dynamic to allow compat with webgl 1 and 2.
  79760. * You will need to pass the name of the uniform as well as the value.
  79761. */
  79762. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  79763. /**
  79764. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  79765. * This is dynamic to allow compat with webgl 1 and 2.
  79766. * You will need to pass the name of the uniform as well as the value.
  79767. */
  79768. updateMatrix: (name: string, mat: Matrix) => void;
  79769. /**
  79770. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  79771. * This is dynamic to allow compat with webgl 1 and 2.
  79772. * You will need to pass the name of the uniform as well as the value.
  79773. */
  79774. updateVector3: (name: string, vector: Vector3) => void;
  79775. /**
  79776. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  79777. * This is dynamic to allow compat with webgl 1 and 2.
  79778. * You will need to pass the name of the uniform as well as the value.
  79779. */
  79780. updateVector4: (name: string, vector: Vector4) => void;
  79781. /**
  79782. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  79783. * This is dynamic to allow compat with webgl 1 and 2.
  79784. * You will need to pass the name of the uniform as well as the value.
  79785. */
  79786. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  79787. /**
  79788. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  79789. * This is dynamic to allow compat with webgl 1 and 2.
  79790. * You will need to pass the name of the uniform as well as the value.
  79791. */
  79792. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  79793. /**
  79794. * Instantiates a new Uniform buffer objects.
  79795. *
  79796. * Handles blocks of uniform on the GPU.
  79797. *
  79798. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79799. *
  79800. * For more information, please refer to :
  79801. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79802. * @param engine Define the engine the buffer is associated with
  79803. * @param data Define the data contained in the buffer
  79804. * @param dynamic Define if the buffer is updatable
  79805. */
  79806. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  79807. /**
  79808. * Indicates if the buffer is using the WebGL2 UBO implementation,
  79809. * or just falling back on setUniformXXX calls.
  79810. */
  79811. get useUbo(): boolean;
  79812. /**
  79813. * Indicates if the WebGL underlying uniform buffer is in sync
  79814. * with the javascript cache data.
  79815. */
  79816. get isSync(): boolean;
  79817. /**
  79818. * Indicates if the WebGL underlying uniform buffer is dynamic.
  79819. * Also, a dynamic UniformBuffer will disable cache verification and always
  79820. * update the underlying WebGL uniform buffer to the GPU.
  79821. * @returns if Dynamic, otherwise false
  79822. */
  79823. isDynamic(): boolean;
  79824. /**
  79825. * The data cache on JS side.
  79826. * @returns the underlying data as a float array
  79827. */
  79828. getData(): Float32Array;
  79829. /**
  79830. * The underlying WebGL Uniform buffer.
  79831. * @returns the webgl buffer
  79832. */
  79833. getBuffer(): Nullable<DataBuffer>;
  79834. /**
  79835. * std140 layout specifies how to align data within an UBO structure.
  79836. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  79837. * for specs.
  79838. */
  79839. private _fillAlignment;
  79840. /**
  79841. * Adds an uniform in the buffer.
  79842. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  79843. * for the layout to be correct !
  79844. * @param name Name of the uniform, as used in the uniform block in the shader.
  79845. * @param size Data size, or data directly.
  79846. */
  79847. addUniform(name: string, size: number | number[]): void;
  79848. /**
  79849. * Adds a Matrix 4x4 to the uniform buffer.
  79850. * @param name Name of the uniform, as used in the uniform block in the shader.
  79851. * @param mat A 4x4 matrix.
  79852. */
  79853. addMatrix(name: string, mat: Matrix): void;
  79854. /**
  79855. * Adds a vec2 to the uniform buffer.
  79856. * @param name Name of the uniform, as used in the uniform block in the shader.
  79857. * @param x Define the x component value of the vec2
  79858. * @param y Define the y component value of the vec2
  79859. */
  79860. addFloat2(name: string, x: number, y: number): void;
  79861. /**
  79862. * Adds a vec3 to the uniform buffer.
  79863. * @param name Name of the uniform, as used in the uniform block in the shader.
  79864. * @param x Define the x component value of the vec3
  79865. * @param y Define the y component value of the vec3
  79866. * @param z Define the z component value of the vec3
  79867. */
  79868. addFloat3(name: string, x: number, y: number, z: number): void;
  79869. /**
  79870. * Adds a vec3 to the uniform buffer.
  79871. * @param name Name of the uniform, as used in the uniform block in the shader.
  79872. * @param color Define the vec3 from a Color
  79873. */
  79874. addColor3(name: string, color: Color3): void;
  79875. /**
  79876. * Adds a vec4 to the uniform buffer.
  79877. * @param name Name of the uniform, as used in the uniform block in the shader.
  79878. * @param color Define the rgb components from a Color
  79879. * @param alpha Define the a component of the vec4
  79880. */
  79881. addColor4(name: string, color: Color3, alpha: number): void;
  79882. /**
  79883. * Adds a vec3 to the uniform buffer.
  79884. * @param name Name of the uniform, as used in the uniform block in the shader.
  79885. * @param vector Define the vec3 components from a Vector
  79886. */
  79887. addVector3(name: string, vector: Vector3): void;
  79888. /**
  79889. * Adds a Matrix 3x3 to the uniform buffer.
  79890. * @param name Name of the uniform, as used in the uniform block in the shader.
  79891. */
  79892. addMatrix3x3(name: string): void;
  79893. /**
  79894. * Adds a Matrix 2x2 to the uniform buffer.
  79895. * @param name Name of the uniform, as used in the uniform block in the shader.
  79896. */
  79897. addMatrix2x2(name: string): void;
  79898. /**
  79899. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  79900. */
  79901. create(): void;
  79902. /** @hidden */
  79903. _rebuild(): void;
  79904. /**
  79905. * Updates the WebGL Uniform Buffer on the GPU.
  79906. * If the `dynamic` flag is set to true, no cache comparison is done.
  79907. * Otherwise, the buffer will be updated only if the cache differs.
  79908. */
  79909. update(): void;
  79910. /**
  79911. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  79912. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  79913. * @param data Define the flattened data
  79914. * @param size Define the size of the data.
  79915. */
  79916. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  79917. private _valueCache;
  79918. private _cacheMatrix;
  79919. private _updateMatrix3x3ForUniform;
  79920. private _updateMatrix3x3ForEffect;
  79921. private _updateMatrix2x2ForEffect;
  79922. private _updateMatrix2x2ForUniform;
  79923. private _updateFloatForEffect;
  79924. private _updateFloatForUniform;
  79925. private _updateFloat2ForEffect;
  79926. private _updateFloat2ForUniform;
  79927. private _updateFloat3ForEffect;
  79928. private _updateFloat3ForUniform;
  79929. private _updateFloat4ForEffect;
  79930. private _updateFloat4ForUniform;
  79931. private _updateMatrixForEffect;
  79932. private _updateMatrixForUniform;
  79933. private _updateVector3ForEffect;
  79934. private _updateVector3ForUniform;
  79935. private _updateVector4ForEffect;
  79936. private _updateVector4ForUniform;
  79937. private _updateColor3ForEffect;
  79938. private _updateColor3ForUniform;
  79939. private _updateColor4ForEffect;
  79940. private _updateColor4ForUniform;
  79941. /**
  79942. * Sets a sampler uniform on the effect.
  79943. * @param name Define the name of the sampler.
  79944. * @param texture Define the texture to set in the sampler
  79945. */
  79946. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  79947. /**
  79948. * Directly updates the value of the uniform in the cache AND on the GPU.
  79949. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  79950. * @param data Define the flattened data
  79951. */
  79952. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  79953. /**
  79954. * Binds this uniform buffer to an effect.
  79955. * @param effect Define the effect to bind the buffer to
  79956. * @param name Name of the uniform block in the shader.
  79957. */
  79958. bindToEffect(effect: Effect, name: string): void;
  79959. /**
  79960. * Disposes the uniform buffer.
  79961. */
  79962. dispose(): void;
  79963. }
  79964. }
  79965. declare module BABYLON {
  79966. /**
  79967. * Enum that determines the text-wrapping mode to use.
  79968. */
  79969. export enum InspectableType {
  79970. /**
  79971. * Checkbox for booleans
  79972. */
  79973. Checkbox = 0,
  79974. /**
  79975. * Sliders for numbers
  79976. */
  79977. Slider = 1,
  79978. /**
  79979. * Vector3
  79980. */
  79981. Vector3 = 2,
  79982. /**
  79983. * Quaternions
  79984. */
  79985. Quaternion = 3,
  79986. /**
  79987. * Color3
  79988. */
  79989. Color3 = 4,
  79990. /**
  79991. * String
  79992. */
  79993. String = 5
  79994. }
  79995. /**
  79996. * Interface used to define custom inspectable properties.
  79997. * This interface is used by the inspector to display custom property grids
  79998. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79999. */
  80000. export interface IInspectable {
  80001. /**
  80002. * Gets the label to display
  80003. */
  80004. label: string;
  80005. /**
  80006. * Gets the name of the property to edit
  80007. */
  80008. propertyName: string;
  80009. /**
  80010. * Gets the type of the editor to use
  80011. */
  80012. type: InspectableType;
  80013. /**
  80014. * Gets the minimum value of the property when using in "slider" mode
  80015. */
  80016. min?: number;
  80017. /**
  80018. * Gets the maximum value of the property when using in "slider" mode
  80019. */
  80020. max?: number;
  80021. /**
  80022. * Gets the setp to use when using in "slider" mode
  80023. */
  80024. step?: number;
  80025. }
  80026. }
  80027. declare module BABYLON {
  80028. /**
  80029. * Class used to provide helper for timing
  80030. */
  80031. export class TimingTools {
  80032. /**
  80033. * Polyfill for setImmediate
  80034. * @param action defines the action to execute after the current execution block
  80035. */
  80036. static SetImmediate(action: () => void): void;
  80037. }
  80038. }
  80039. declare module BABYLON {
  80040. /**
  80041. * Class used to enable instatition of objects by class name
  80042. */
  80043. export class InstantiationTools {
  80044. /**
  80045. * Use this object to register external classes like custom textures or material
  80046. * to allow the laoders to instantiate them
  80047. */
  80048. static RegisteredExternalClasses: {
  80049. [key: string]: Object;
  80050. };
  80051. /**
  80052. * Tries to instantiate a new object from a given class name
  80053. * @param className defines the class name to instantiate
  80054. * @returns the new object or null if the system was not able to do the instantiation
  80055. */
  80056. static Instantiate(className: string): any;
  80057. }
  80058. }
  80059. declare module BABYLON {
  80060. /**
  80061. * Define options used to create a depth texture
  80062. */
  80063. export class DepthTextureCreationOptions {
  80064. /** Specifies whether or not a stencil should be allocated in the texture */
  80065. generateStencil?: boolean;
  80066. /** Specifies whether or not bilinear filtering is enable on the texture */
  80067. bilinearFiltering?: boolean;
  80068. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80069. comparisonFunction?: number;
  80070. /** Specifies if the created texture is a cube texture */
  80071. isCube?: boolean;
  80072. }
  80073. }
  80074. declare module BABYLON {
  80075. interface ThinEngine {
  80076. /**
  80077. * Creates a depth stencil cube texture.
  80078. * This is only available in WebGL 2.
  80079. * @param size The size of face edge in the cube texture.
  80080. * @param options The options defining the cube texture.
  80081. * @returns The cube texture
  80082. */
  80083. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80084. /**
  80085. * Creates a cube texture
  80086. * @param rootUrl defines the url where the files to load is located
  80087. * @param scene defines the current scene
  80088. * @param files defines the list of files to load (1 per face)
  80089. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80090. * @param onLoad defines an optional callback raised when the texture is loaded
  80091. * @param onError defines an optional callback raised if there is an issue to load the texture
  80092. * @param format defines the format of the data
  80093. * @param forcedExtension defines the extension to use to pick the right loader
  80094. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80095. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80096. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80097. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80098. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80099. * @returns the cube texture as an InternalTexture
  80100. */
  80101. 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;
  80102. /**
  80103. * Creates a cube texture
  80104. * @param rootUrl defines the url where the files to load is located
  80105. * @param scene defines the current scene
  80106. * @param files defines the list of files to load (1 per face)
  80107. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80108. * @param onLoad defines an optional callback raised when the texture is loaded
  80109. * @param onError defines an optional callback raised if there is an issue to load the texture
  80110. * @param format defines the format of the data
  80111. * @param forcedExtension defines the extension to use to pick the right loader
  80112. * @returns the cube texture as an InternalTexture
  80113. */
  80114. 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;
  80115. /**
  80116. * Creates a cube texture
  80117. * @param rootUrl defines the url where the files to load is located
  80118. * @param scene defines the current scene
  80119. * @param files defines the list of files to load (1 per face)
  80120. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80121. * @param onLoad defines an optional callback raised when the texture is loaded
  80122. * @param onError defines an optional callback raised if there is an issue to load the texture
  80123. * @param format defines the format of the data
  80124. * @param forcedExtension defines the extension to use to pick the right loader
  80125. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80126. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80127. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80128. * @returns the cube texture as an InternalTexture
  80129. */
  80130. 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;
  80131. /** @hidden */
  80132. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80133. /** @hidden */
  80134. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80135. /** @hidden */
  80136. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80137. /** @hidden */
  80138. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80139. /**
  80140. * @hidden
  80141. */
  80142. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80143. }
  80144. }
  80145. declare module BABYLON {
  80146. /**
  80147. * Class for creating a cube texture
  80148. */
  80149. export class CubeTexture extends BaseTexture {
  80150. private _delayedOnLoad;
  80151. /**
  80152. * The url of the texture
  80153. */
  80154. url: string;
  80155. /**
  80156. * Gets or sets the center of the bounding box associated with the cube texture.
  80157. * It must define where the camera used to render the texture was set
  80158. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80159. */
  80160. boundingBoxPosition: Vector3;
  80161. private _boundingBoxSize;
  80162. /**
  80163. * Gets or sets the size of the bounding box associated with the cube texture
  80164. * When defined, the cubemap will switch to local mode
  80165. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80166. * @example https://www.babylonjs-playground.com/#RNASML
  80167. */
  80168. set boundingBoxSize(value: Vector3);
  80169. /**
  80170. * Returns the bounding box size
  80171. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80172. */
  80173. get boundingBoxSize(): Vector3;
  80174. protected _rotationY: number;
  80175. /**
  80176. * Sets texture matrix rotation angle around Y axis in radians.
  80177. */
  80178. set rotationY(value: number);
  80179. /**
  80180. * Gets texture matrix rotation angle around Y axis radians.
  80181. */
  80182. get rotationY(): number;
  80183. /**
  80184. * Are mip maps generated for this texture or not.
  80185. */
  80186. get noMipmap(): boolean;
  80187. private _noMipmap;
  80188. private _files;
  80189. protected _forcedExtension: Nullable<string>;
  80190. private _extensions;
  80191. private _textureMatrix;
  80192. private _format;
  80193. private _createPolynomials;
  80194. /** @hidden */
  80195. _prefiltered: boolean;
  80196. /**
  80197. * Creates a cube texture from an array of image urls
  80198. * @param files defines an array of image urls
  80199. * @param scene defines the hosting scene
  80200. * @param noMipmap specifies if mip maps are not used
  80201. * @returns a cube texture
  80202. */
  80203. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80204. /**
  80205. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80206. * @param url defines the url of the prefiltered texture
  80207. * @param scene defines the scene the texture is attached to
  80208. * @param forcedExtension defines the extension of the file if different from the url
  80209. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80210. * @return the prefiltered texture
  80211. */
  80212. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80213. /**
  80214. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80215. * as prefiltered data.
  80216. * @param rootUrl defines the url of the texture or the root name of the six images
  80217. * @param scene defines the scene the texture is attached to
  80218. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80219. * @param noMipmap defines if mipmaps should be created or not
  80220. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80221. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80222. * @param onError defines a callback triggered in case of error during load
  80223. * @param format defines the internal format to use for the texture once loaded
  80224. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80225. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80226. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80227. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80228. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80229. * @return the cube texture
  80230. */
  80231. 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);
  80232. /**
  80233. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80234. */
  80235. get isPrefiltered(): boolean;
  80236. /**
  80237. * Get the current class name of the texture useful for serialization or dynamic coding.
  80238. * @returns "CubeTexture"
  80239. */
  80240. getClassName(): string;
  80241. /**
  80242. * Update the url (and optional buffer) of this texture if url was null during construction.
  80243. * @param url the url of the texture
  80244. * @param forcedExtension defines the extension to use
  80245. * @param onLoad callback called when the texture is loaded (defaults to null)
  80246. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80247. */
  80248. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80249. /**
  80250. * Delays loading of the cube texture
  80251. * @param forcedExtension defines the extension to use
  80252. */
  80253. delayLoad(forcedExtension?: string): void;
  80254. /**
  80255. * Returns the reflection texture matrix
  80256. * @returns the reflection texture matrix
  80257. */
  80258. getReflectionTextureMatrix(): Matrix;
  80259. /**
  80260. * Sets the reflection texture matrix
  80261. * @param value Reflection texture matrix
  80262. */
  80263. setReflectionTextureMatrix(value: Matrix): void;
  80264. /**
  80265. * Parses text to create a cube texture
  80266. * @param parsedTexture define the serialized text to read from
  80267. * @param scene defines the hosting scene
  80268. * @param rootUrl defines the root url of the cube texture
  80269. * @returns a cube texture
  80270. */
  80271. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  80272. /**
  80273. * Makes a clone, or deep copy, of the cube texture
  80274. * @returns a new cube texture
  80275. */
  80276. clone(): CubeTexture;
  80277. }
  80278. }
  80279. declare module BABYLON {
  80280. /**
  80281. * Manages the defines for the Material
  80282. */
  80283. export class MaterialDefines {
  80284. /** @hidden */
  80285. protected _keys: string[];
  80286. private _isDirty;
  80287. /** @hidden */
  80288. _renderId: number;
  80289. /** @hidden */
  80290. _areLightsDirty: boolean;
  80291. /** @hidden */
  80292. _areLightsDisposed: boolean;
  80293. /** @hidden */
  80294. _areAttributesDirty: boolean;
  80295. /** @hidden */
  80296. _areTexturesDirty: boolean;
  80297. /** @hidden */
  80298. _areFresnelDirty: boolean;
  80299. /** @hidden */
  80300. _areMiscDirty: boolean;
  80301. /** @hidden */
  80302. _areImageProcessingDirty: boolean;
  80303. /** @hidden */
  80304. _normals: boolean;
  80305. /** @hidden */
  80306. _uvs: boolean;
  80307. /** @hidden */
  80308. _needNormals: boolean;
  80309. /** @hidden */
  80310. _needUVs: boolean;
  80311. [id: string]: any;
  80312. /**
  80313. * Specifies if the material needs to be re-calculated
  80314. */
  80315. get isDirty(): boolean;
  80316. /**
  80317. * Marks the material to indicate that it has been re-calculated
  80318. */
  80319. markAsProcessed(): void;
  80320. /**
  80321. * Marks the material to indicate that it needs to be re-calculated
  80322. */
  80323. markAsUnprocessed(): void;
  80324. /**
  80325. * Marks the material to indicate all of its defines need to be re-calculated
  80326. */
  80327. markAllAsDirty(): void;
  80328. /**
  80329. * Marks the material to indicate that image processing needs to be re-calculated
  80330. */
  80331. markAsImageProcessingDirty(): void;
  80332. /**
  80333. * Marks the material to indicate the lights need to be re-calculated
  80334. * @param disposed Defines whether the light is dirty due to dispose or not
  80335. */
  80336. markAsLightDirty(disposed?: boolean): void;
  80337. /**
  80338. * Marks the attribute state as changed
  80339. */
  80340. markAsAttributesDirty(): void;
  80341. /**
  80342. * Marks the texture state as changed
  80343. */
  80344. markAsTexturesDirty(): void;
  80345. /**
  80346. * Marks the fresnel state as changed
  80347. */
  80348. markAsFresnelDirty(): void;
  80349. /**
  80350. * Marks the misc state as changed
  80351. */
  80352. markAsMiscDirty(): void;
  80353. /**
  80354. * Rebuilds the material defines
  80355. */
  80356. rebuild(): void;
  80357. /**
  80358. * Specifies if two material defines are equal
  80359. * @param other - A material define instance to compare to
  80360. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  80361. */
  80362. isEqual(other: MaterialDefines): boolean;
  80363. /**
  80364. * Clones this instance's defines to another instance
  80365. * @param other - material defines to clone values to
  80366. */
  80367. cloneTo(other: MaterialDefines): void;
  80368. /**
  80369. * Resets the material define values
  80370. */
  80371. reset(): void;
  80372. /**
  80373. * Converts the material define values to a string
  80374. * @returns - String of material define information
  80375. */
  80376. toString(): string;
  80377. }
  80378. }
  80379. declare module BABYLON {
  80380. /**
  80381. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  80382. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  80383. * 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;
  80384. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  80385. */
  80386. export class ColorCurves {
  80387. private _dirty;
  80388. private _tempColor;
  80389. private _globalCurve;
  80390. private _highlightsCurve;
  80391. private _midtonesCurve;
  80392. private _shadowsCurve;
  80393. private _positiveCurve;
  80394. private _negativeCurve;
  80395. private _globalHue;
  80396. private _globalDensity;
  80397. private _globalSaturation;
  80398. private _globalExposure;
  80399. /**
  80400. * Gets the global Hue value.
  80401. * 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).
  80402. */
  80403. get globalHue(): number;
  80404. /**
  80405. * Sets the global Hue value.
  80406. * 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).
  80407. */
  80408. set globalHue(value: number);
  80409. /**
  80410. * Gets the global Density value.
  80411. * 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.
  80412. * Values less than zero provide a filter of opposite hue.
  80413. */
  80414. get globalDensity(): number;
  80415. /**
  80416. * Sets the global Density value.
  80417. * 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.
  80418. * Values less than zero provide a filter of opposite hue.
  80419. */
  80420. set globalDensity(value: number);
  80421. /**
  80422. * Gets the global Saturation value.
  80423. * 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.
  80424. */
  80425. get globalSaturation(): number;
  80426. /**
  80427. * Sets the global Saturation value.
  80428. * 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.
  80429. */
  80430. set globalSaturation(value: number);
  80431. /**
  80432. * Gets the global Exposure value.
  80433. * 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.
  80434. */
  80435. get globalExposure(): number;
  80436. /**
  80437. * Sets the global Exposure value.
  80438. * 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.
  80439. */
  80440. set globalExposure(value: number);
  80441. private _highlightsHue;
  80442. private _highlightsDensity;
  80443. private _highlightsSaturation;
  80444. private _highlightsExposure;
  80445. /**
  80446. * Gets the highlights Hue value.
  80447. * 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).
  80448. */
  80449. get highlightsHue(): number;
  80450. /**
  80451. * Sets the highlights Hue value.
  80452. * 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).
  80453. */
  80454. set highlightsHue(value: number);
  80455. /**
  80456. * Gets the highlights Density value.
  80457. * 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.
  80458. * Values less than zero provide a filter of opposite hue.
  80459. */
  80460. get highlightsDensity(): number;
  80461. /**
  80462. * Sets the highlights Density value.
  80463. * 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.
  80464. * Values less than zero provide a filter of opposite hue.
  80465. */
  80466. set highlightsDensity(value: number);
  80467. /**
  80468. * Gets the highlights Saturation value.
  80469. * 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.
  80470. */
  80471. get highlightsSaturation(): number;
  80472. /**
  80473. * Sets the highlights Saturation value.
  80474. * 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.
  80475. */
  80476. set highlightsSaturation(value: number);
  80477. /**
  80478. * Gets the highlights Exposure value.
  80479. * 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.
  80480. */
  80481. get highlightsExposure(): number;
  80482. /**
  80483. * Sets the highlights Exposure value.
  80484. * 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.
  80485. */
  80486. set highlightsExposure(value: number);
  80487. private _midtonesHue;
  80488. private _midtonesDensity;
  80489. private _midtonesSaturation;
  80490. private _midtonesExposure;
  80491. /**
  80492. * Gets the midtones Hue value.
  80493. * 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).
  80494. */
  80495. get midtonesHue(): number;
  80496. /**
  80497. * Sets the midtones Hue value.
  80498. * 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).
  80499. */
  80500. set midtonesHue(value: number);
  80501. /**
  80502. * Gets the midtones Density value.
  80503. * 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.
  80504. * Values less than zero provide a filter of opposite hue.
  80505. */
  80506. get midtonesDensity(): number;
  80507. /**
  80508. * Sets the midtones Density value.
  80509. * 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.
  80510. * Values less than zero provide a filter of opposite hue.
  80511. */
  80512. set midtonesDensity(value: number);
  80513. /**
  80514. * Gets the midtones Saturation value.
  80515. * 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.
  80516. */
  80517. get midtonesSaturation(): number;
  80518. /**
  80519. * Sets the midtones Saturation value.
  80520. * 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.
  80521. */
  80522. set midtonesSaturation(value: number);
  80523. /**
  80524. * Gets the midtones Exposure value.
  80525. * 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.
  80526. */
  80527. get midtonesExposure(): number;
  80528. /**
  80529. * Sets the midtones Exposure value.
  80530. * 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.
  80531. */
  80532. set midtonesExposure(value: number);
  80533. private _shadowsHue;
  80534. private _shadowsDensity;
  80535. private _shadowsSaturation;
  80536. private _shadowsExposure;
  80537. /**
  80538. * Gets the shadows Hue value.
  80539. * 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).
  80540. */
  80541. get shadowsHue(): number;
  80542. /**
  80543. * Sets the shadows Hue value.
  80544. * 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).
  80545. */
  80546. set shadowsHue(value: number);
  80547. /**
  80548. * Gets the shadows Density value.
  80549. * 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.
  80550. * Values less than zero provide a filter of opposite hue.
  80551. */
  80552. get shadowsDensity(): number;
  80553. /**
  80554. * Sets the shadows Density value.
  80555. * 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.
  80556. * Values less than zero provide a filter of opposite hue.
  80557. */
  80558. set shadowsDensity(value: number);
  80559. /**
  80560. * Gets the shadows Saturation value.
  80561. * 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.
  80562. */
  80563. get shadowsSaturation(): number;
  80564. /**
  80565. * Sets the shadows Saturation value.
  80566. * 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.
  80567. */
  80568. set shadowsSaturation(value: number);
  80569. /**
  80570. * Gets the shadows Exposure value.
  80571. * 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.
  80572. */
  80573. get shadowsExposure(): number;
  80574. /**
  80575. * Sets the shadows Exposure value.
  80576. * 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.
  80577. */
  80578. set shadowsExposure(value: number);
  80579. /**
  80580. * Returns the class name
  80581. * @returns The class name
  80582. */
  80583. getClassName(): string;
  80584. /**
  80585. * Binds the color curves to the shader.
  80586. * @param colorCurves The color curve to bind
  80587. * @param effect The effect to bind to
  80588. * @param positiveUniform The positive uniform shader parameter
  80589. * @param neutralUniform The neutral uniform shader parameter
  80590. * @param negativeUniform The negative uniform shader parameter
  80591. */
  80592. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  80593. /**
  80594. * Prepare the list of uniforms associated with the ColorCurves effects.
  80595. * @param uniformsList The list of uniforms used in the effect
  80596. */
  80597. static PrepareUniforms(uniformsList: string[]): void;
  80598. /**
  80599. * Returns color grading data based on a hue, density, saturation and exposure value.
  80600. * @param filterHue The hue of the color filter.
  80601. * @param filterDensity The density of the color filter.
  80602. * @param saturation The saturation.
  80603. * @param exposure The exposure.
  80604. * @param result The result data container.
  80605. */
  80606. private getColorGradingDataToRef;
  80607. /**
  80608. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  80609. * @param value The input slider value in range [-100,100].
  80610. * @returns Adjusted value.
  80611. */
  80612. private static applyColorGradingSliderNonlinear;
  80613. /**
  80614. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  80615. * @param hue The hue (H) input.
  80616. * @param saturation The saturation (S) input.
  80617. * @param brightness The brightness (B) input.
  80618. * @result An RGBA color represented as Vector4.
  80619. */
  80620. private static fromHSBToRef;
  80621. /**
  80622. * Returns a value clamped between min and max
  80623. * @param value The value to clamp
  80624. * @param min The minimum of value
  80625. * @param max The maximum of value
  80626. * @returns The clamped value.
  80627. */
  80628. private static clamp;
  80629. /**
  80630. * Clones the current color curve instance.
  80631. * @return The cloned curves
  80632. */
  80633. clone(): ColorCurves;
  80634. /**
  80635. * Serializes the current color curve instance to a json representation.
  80636. * @return a JSON representation
  80637. */
  80638. serialize(): any;
  80639. /**
  80640. * Parses the color curve from a json representation.
  80641. * @param source the JSON source to parse
  80642. * @return The parsed curves
  80643. */
  80644. static Parse(source: any): ColorCurves;
  80645. }
  80646. }
  80647. declare module BABYLON {
  80648. /**
  80649. * Interface to follow in your material defines to integrate easily the
  80650. * Image proccessing functions.
  80651. * @hidden
  80652. */
  80653. export interface IImageProcessingConfigurationDefines {
  80654. IMAGEPROCESSING: boolean;
  80655. VIGNETTE: boolean;
  80656. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80657. VIGNETTEBLENDMODEOPAQUE: boolean;
  80658. TONEMAPPING: boolean;
  80659. TONEMAPPING_ACES: boolean;
  80660. CONTRAST: boolean;
  80661. EXPOSURE: boolean;
  80662. COLORCURVES: boolean;
  80663. COLORGRADING: boolean;
  80664. COLORGRADING3D: boolean;
  80665. SAMPLER3DGREENDEPTH: boolean;
  80666. SAMPLER3DBGRMAP: boolean;
  80667. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80668. }
  80669. /**
  80670. * @hidden
  80671. */
  80672. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  80673. IMAGEPROCESSING: boolean;
  80674. VIGNETTE: boolean;
  80675. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80676. VIGNETTEBLENDMODEOPAQUE: boolean;
  80677. TONEMAPPING: boolean;
  80678. TONEMAPPING_ACES: boolean;
  80679. CONTRAST: boolean;
  80680. COLORCURVES: boolean;
  80681. COLORGRADING: boolean;
  80682. COLORGRADING3D: boolean;
  80683. SAMPLER3DGREENDEPTH: boolean;
  80684. SAMPLER3DBGRMAP: boolean;
  80685. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80686. EXPOSURE: boolean;
  80687. constructor();
  80688. }
  80689. /**
  80690. * This groups together the common properties used for image processing either in direct forward pass
  80691. * or through post processing effect depending on the use of the image processing pipeline in your scene
  80692. * or not.
  80693. */
  80694. export class ImageProcessingConfiguration {
  80695. /**
  80696. * Default tone mapping applied in BabylonJS.
  80697. */
  80698. static readonly TONEMAPPING_STANDARD: number;
  80699. /**
  80700. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  80701. * to other engines rendering to increase portability.
  80702. */
  80703. static readonly TONEMAPPING_ACES: number;
  80704. /**
  80705. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  80706. */
  80707. colorCurves: Nullable<ColorCurves>;
  80708. private _colorCurvesEnabled;
  80709. /**
  80710. * Gets wether the color curves effect is enabled.
  80711. */
  80712. get colorCurvesEnabled(): boolean;
  80713. /**
  80714. * Sets wether the color curves effect is enabled.
  80715. */
  80716. set colorCurvesEnabled(value: boolean);
  80717. private _colorGradingTexture;
  80718. /**
  80719. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80720. */
  80721. get colorGradingTexture(): Nullable<BaseTexture>;
  80722. /**
  80723. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80724. */
  80725. set colorGradingTexture(value: Nullable<BaseTexture>);
  80726. private _colorGradingEnabled;
  80727. /**
  80728. * Gets wether the color grading effect is enabled.
  80729. */
  80730. get colorGradingEnabled(): boolean;
  80731. /**
  80732. * Sets wether the color grading effect is enabled.
  80733. */
  80734. set colorGradingEnabled(value: boolean);
  80735. private _colorGradingWithGreenDepth;
  80736. /**
  80737. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  80738. */
  80739. get colorGradingWithGreenDepth(): boolean;
  80740. /**
  80741. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  80742. */
  80743. set colorGradingWithGreenDepth(value: boolean);
  80744. private _colorGradingBGR;
  80745. /**
  80746. * Gets wether the color grading texture contains BGR values.
  80747. */
  80748. get colorGradingBGR(): boolean;
  80749. /**
  80750. * Sets wether the color grading texture contains BGR values.
  80751. */
  80752. set colorGradingBGR(value: boolean);
  80753. /** @hidden */
  80754. _exposure: number;
  80755. /**
  80756. * Gets the Exposure used in the effect.
  80757. */
  80758. get exposure(): number;
  80759. /**
  80760. * Sets the Exposure used in the effect.
  80761. */
  80762. set exposure(value: number);
  80763. private _toneMappingEnabled;
  80764. /**
  80765. * Gets wether the tone mapping effect is enabled.
  80766. */
  80767. get toneMappingEnabled(): boolean;
  80768. /**
  80769. * Sets wether the tone mapping effect is enabled.
  80770. */
  80771. set toneMappingEnabled(value: boolean);
  80772. private _toneMappingType;
  80773. /**
  80774. * Gets the type of tone mapping effect.
  80775. */
  80776. get toneMappingType(): number;
  80777. /**
  80778. * Sets the type of tone mapping effect used in BabylonJS.
  80779. */
  80780. set toneMappingType(value: number);
  80781. protected _contrast: number;
  80782. /**
  80783. * Gets the contrast used in the effect.
  80784. */
  80785. get contrast(): number;
  80786. /**
  80787. * Sets the contrast used in the effect.
  80788. */
  80789. set contrast(value: number);
  80790. /**
  80791. * Vignette stretch size.
  80792. */
  80793. vignetteStretch: number;
  80794. /**
  80795. * Vignette centre X Offset.
  80796. */
  80797. vignetteCentreX: number;
  80798. /**
  80799. * Vignette centre Y Offset.
  80800. */
  80801. vignetteCentreY: number;
  80802. /**
  80803. * Vignette weight or intensity of the vignette effect.
  80804. */
  80805. vignetteWeight: number;
  80806. /**
  80807. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  80808. * if vignetteEnabled is set to true.
  80809. */
  80810. vignetteColor: Color4;
  80811. /**
  80812. * Camera field of view used by the Vignette effect.
  80813. */
  80814. vignetteCameraFov: number;
  80815. private _vignetteBlendMode;
  80816. /**
  80817. * Gets the vignette blend mode allowing different kind of effect.
  80818. */
  80819. get vignetteBlendMode(): number;
  80820. /**
  80821. * Sets the vignette blend mode allowing different kind of effect.
  80822. */
  80823. set vignetteBlendMode(value: number);
  80824. private _vignetteEnabled;
  80825. /**
  80826. * Gets wether the vignette effect is enabled.
  80827. */
  80828. get vignetteEnabled(): boolean;
  80829. /**
  80830. * Sets wether the vignette effect is enabled.
  80831. */
  80832. set vignetteEnabled(value: boolean);
  80833. private _applyByPostProcess;
  80834. /**
  80835. * Gets wether the image processing is applied through a post process or not.
  80836. */
  80837. get applyByPostProcess(): boolean;
  80838. /**
  80839. * Sets wether the image processing is applied through a post process or not.
  80840. */
  80841. set applyByPostProcess(value: boolean);
  80842. private _isEnabled;
  80843. /**
  80844. * Gets wether the image processing is enabled or not.
  80845. */
  80846. get isEnabled(): boolean;
  80847. /**
  80848. * Sets wether the image processing is enabled or not.
  80849. */
  80850. set isEnabled(value: boolean);
  80851. /**
  80852. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  80853. */
  80854. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  80855. /**
  80856. * Method called each time the image processing information changes requires to recompile the effect.
  80857. */
  80858. protected _updateParameters(): void;
  80859. /**
  80860. * Gets the current class name.
  80861. * @return "ImageProcessingConfiguration"
  80862. */
  80863. getClassName(): string;
  80864. /**
  80865. * Prepare the list of uniforms associated with the Image Processing effects.
  80866. * @param uniforms The list of uniforms used in the effect
  80867. * @param defines the list of defines currently in use
  80868. */
  80869. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  80870. /**
  80871. * Prepare the list of samplers associated with the Image Processing effects.
  80872. * @param samplersList The list of uniforms used in the effect
  80873. * @param defines the list of defines currently in use
  80874. */
  80875. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  80876. /**
  80877. * Prepare the list of defines associated to the shader.
  80878. * @param defines the list of defines to complete
  80879. * @param forPostProcess Define if we are currently in post process mode or not
  80880. */
  80881. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  80882. /**
  80883. * Returns true if all the image processing information are ready.
  80884. * @returns True if ready, otherwise, false
  80885. */
  80886. isReady(): boolean;
  80887. /**
  80888. * Binds the image processing to the shader.
  80889. * @param effect The effect to bind to
  80890. * @param overrideAspectRatio Override the aspect ratio of the effect
  80891. */
  80892. bind(effect: Effect, overrideAspectRatio?: number): void;
  80893. /**
  80894. * Clones the current image processing instance.
  80895. * @return The cloned image processing
  80896. */
  80897. clone(): ImageProcessingConfiguration;
  80898. /**
  80899. * Serializes the current image processing instance to a json representation.
  80900. * @return a JSON representation
  80901. */
  80902. serialize(): any;
  80903. /**
  80904. * Parses the image processing from a json representation.
  80905. * @param source the JSON source to parse
  80906. * @return The parsed image processing
  80907. */
  80908. static Parse(source: any): ImageProcessingConfiguration;
  80909. private static _VIGNETTEMODE_MULTIPLY;
  80910. private static _VIGNETTEMODE_OPAQUE;
  80911. /**
  80912. * Used to apply the vignette as a mix with the pixel color.
  80913. */
  80914. static get VIGNETTEMODE_MULTIPLY(): number;
  80915. /**
  80916. * Used to apply the vignette as a replacement of the pixel color.
  80917. */
  80918. static get VIGNETTEMODE_OPAQUE(): number;
  80919. }
  80920. }
  80921. declare module BABYLON {
  80922. /** @hidden */
  80923. export var postprocessVertexShader: {
  80924. name: string;
  80925. shader: string;
  80926. };
  80927. }
  80928. declare module BABYLON {
  80929. interface ThinEngine {
  80930. /**
  80931. * Creates a new render target texture
  80932. * @param size defines the size of the texture
  80933. * @param options defines the options used to create the texture
  80934. * @returns a new render target texture stored in an InternalTexture
  80935. */
  80936. createRenderTargetTexture(size: number | {
  80937. width: number;
  80938. height: number;
  80939. layers?: number;
  80940. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  80941. /**
  80942. * Creates a depth stencil texture.
  80943. * This is only available in WebGL 2 or with the depth texture extension available.
  80944. * @param size The size of face edge in the texture.
  80945. * @param options The options defining the texture.
  80946. * @returns The texture
  80947. */
  80948. createDepthStencilTexture(size: number | {
  80949. width: number;
  80950. height: number;
  80951. layers?: number;
  80952. }, options: DepthTextureCreationOptions): InternalTexture;
  80953. /** @hidden */
  80954. _createDepthStencilTexture(size: number | {
  80955. width: number;
  80956. height: number;
  80957. layers?: number;
  80958. }, options: DepthTextureCreationOptions): InternalTexture;
  80959. }
  80960. }
  80961. declare module BABYLON {
  80962. /** Defines supported spaces */
  80963. export enum Space {
  80964. /** Local (object) space */
  80965. LOCAL = 0,
  80966. /** World space */
  80967. WORLD = 1,
  80968. /** Bone space */
  80969. BONE = 2
  80970. }
  80971. /** Defines the 3 main axes */
  80972. export class Axis {
  80973. /** X axis */
  80974. static X: Vector3;
  80975. /** Y axis */
  80976. static Y: Vector3;
  80977. /** Z axis */
  80978. static Z: Vector3;
  80979. }
  80980. }
  80981. declare module BABYLON {
  80982. /**
  80983. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  80984. * This is the base of the follow, arc rotate cameras and Free camera
  80985. * @see http://doc.babylonjs.com/features/cameras
  80986. */
  80987. export class TargetCamera extends Camera {
  80988. private static _RigCamTransformMatrix;
  80989. private static _TargetTransformMatrix;
  80990. private static _TargetFocalPoint;
  80991. /**
  80992. * Define the current direction the camera is moving to
  80993. */
  80994. cameraDirection: Vector3;
  80995. /**
  80996. * Define the current rotation the camera is rotating to
  80997. */
  80998. cameraRotation: Vector2;
  80999. /**
  81000. * When set, the up vector of the camera will be updated by the rotation of the camera
  81001. */
  81002. updateUpVectorFromRotation: boolean;
  81003. private _tmpQuaternion;
  81004. /**
  81005. * Define the current rotation of the camera
  81006. */
  81007. rotation: Vector3;
  81008. /**
  81009. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81010. */
  81011. rotationQuaternion: Quaternion;
  81012. /**
  81013. * Define the current speed of the camera
  81014. */
  81015. speed: number;
  81016. /**
  81017. * Add constraint to the camera to prevent it to move freely in all directions and
  81018. * around all axis.
  81019. */
  81020. noRotationConstraint: boolean;
  81021. /**
  81022. * Define the current target of the camera as an object or a position.
  81023. */
  81024. lockedTarget: any;
  81025. /** @hidden */
  81026. _currentTarget: Vector3;
  81027. /** @hidden */
  81028. _initialFocalDistance: number;
  81029. /** @hidden */
  81030. _viewMatrix: Matrix;
  81031. /** @hidden */
  81032. _camMatrix: Matrix;
  81033. /** @hidden */
  81034. _cameraTransformMatrix: Matrix;
  81035. /** @hidden */
  81036. _cameraRotationMatrix: Matrix;
  81037. /** @hidden */
  81038. _referencePoint: Vector3;
  81039. /** @hidden */
  81040. _transformedReferencePoint: Vector3;
  81041. protected _globalCurrentTarget: Vector3;
  81042. protected _globalCurrentUpVector: Vector3;
  81043. /** @hidden */
  81044. _reset: () => void;
  81045. private _defaultUp;
  81046. /**
  81047. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81048. * This is the base of the follow, arc rotate cameras and Free camera
  81049. * @see http://doc.babylonjs.com/features/cameras
  81050. * @param name Defines the name of the camera in the scene
  81051. * @param position Defines the start position of the camera in the scene
  81052. * @param scene Defines the scene the camera belongs to
  81053. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81054. */
  81055. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81056. /**
  81057. * Gets the position in front of the camera at a given distance.
  81058. * @param distance The distance from the camera we want the position to be
  81059. * @returns the position
  81060. */
  81061. getFrontPosition(distance: number): Vector3;
  81062. /** @hidden */
  81063. _getLockedTargetPosition(): Nullable<Vector3>;
  81064. private _storedPosition;
  81065. private _storedRotation;
  81066. private _storedRotationQuaternion;
  81067. /**
  81068. * Store current camera state of the camera (fov, position, rotation, etc..)
  81069. * @returns the camera
  81070. */
  81071. storeState(): Camera;
  81072. /**
  81073. * Restored camera state. You must call storeState() first
  81074. * @returns whether it was successful or not
  81075. * @hidden
  81076. */
  81077. _restoreStateValues(): boolean;
  81078. /** @hidden */
  81079. _initCache(): void;
  81080. /** @hidden */
  81081. _updateCache(ignoreParentClass?: boolean): void;
  81082. /** @hidden */
  81083. _isSynchronizedViewMatrix(): boolean;
  81084. /** @hidden */
  81085. _computeLocalCameraSpeed(): number;
  81086. /**
  81087. * Defines the target the camera should look at.
  81088. * @param target Defines the new target as a Vector or a mesh
  81089. */
  81090. setTarget(target: Vector3): void;
  81091. /**
  81092. * Return the current target position of the camera. This value is expressed in local space.
  81093. * @returns the target position
  81094. */
  81095. getTarget(): Vector3;
  81096. /** @hidden */
  81097. _decideIfNeedsToMove(): boolean;
  81098. /** @hidden */
  81099. _updatePosition(): void;
  81100. /** @hidden */
  81101. _checkInputs(): void;
  81102. protected _updateCameraRotationMatrix(): void;
  81103. /**
  81104. * 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)
  81105. * @returns the current camera
  81106. */
  81107. private _rotateUpVectorWithCameraRotationMatrix;
  81108. private _cachedRotationZ;
  81109. private _cachedQuaternionRotationZ;
  81110. /** @hidden */
  81111. _getViewMatrix(): Matrix;
  81112. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81113. /**
  81114. * @hidden
  81115. */
  81116. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81117. /**
  81118. * @hidden
  81119. */
  81120. _updateRigCameras(): void;
  81121. private _getRigCamPositionAndTarget;
  81122. /**
  81123. * Gets the current object class name.
  81124. * @return the class name
  81125. */
  81126. getClassName(): string;
  81127. }
  81128. }
  81129. declare module BABYLON {
  81130. /**
  81131. * Gather the list of keyboard event types as constants.
  81132. */
  81133. export class KeyboardEventTypes {
  81134. /**
  81135. * The keydown event is fired when a key becomes active (pressed).
  81136. */
  81137. static readonly KEYDOWN: number;
  81138. /**
  81139. * The keyup event is fired when a key has been released.
  81140. */
  81141. static readonly KEYUP: number;
  81142. }
  81143. /**
  81144. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81145. */
  81146. export class KeyboardInfo {
  81147. /**
  81148. * Defines the type of event (KeyboardEventTypes)
  81149. */
  81150. type: number;
  81151. /**
  81152. * Defines the related dom event
  81153. */
  81154. event: KeyboardEvent;
  81155. /**
  81156. * Instantiates a new keyboard info.
  81157. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81158. * @param type Defines the type of event (KeyboardEventTypes)
  81159. * @param event Defines the related dom event
  81160. */
  81161. constructor(
  81162. /**
  81163. * Defines the type of event (KeyboardEventTypes)
  81164. */
  81165. type: number,
  81166. /**
  81167. * Defines the related dom event
  81168. */
  81169. event: KeyboardEvent);
  81170. }
  81171. /**
  81172. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81173. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81174. */
  81175. export class KeyboardInfoPre extends KeyboardInfo {
  81176. /**
  81177. * Defines the type of event (KeyboardEventTypes)
  81178. */
  81179. type: number;
  81180. /**
  81181. * Defines the related dom event
  81182. */
  81183. event: KeyboardEvent;
  81184. /**
  81185. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81186. */
  81187. skipOnPointerObservable: boolean;
  81188. /**
  81189. * Instantiates a new keyboard pre info.
  81190. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81191. * @param type Defines the type of event (KeyboardEventTypes)
  81192. * @param event Defines the related dom event
  81193. */
  81194. constructor(
  81195. /**
  81196. * Defines the type of event (KeyboardEventTypes)
  81197. */
  81198. type: number,
  81199. /**
  81200. * Defines the related dom event
  81201. */
  81202. event: KeyboardEvent);
  81203. }
  81204. }
  81205. declare module BABYLON {
  81206. /**
  81207. * Manage the keyboard inputs to control the movement of a free camera.
  81208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81209. */
  81210. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81211. /**
  81212. * Defines the camera the input is attached to.
  81213. */
  81214. camera: FreeCamera;
  81215. /**
  81216. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81217. */
  81218. keysUp: number[];
  81219. /**
  81220. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81221. */
  81222. keysDown: number[];
  81223. /**
  81224. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81225. */
  81226. keysLeft: number[];
  81227. /**
  81228. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81229. */
  81230. keysRight: number[];
  81231. private _keys;
  81232. private _onCanvasBlurObserver;
  81233. private _onKeyboardObserver;
  81234. private _engine;
  81235. private _scene;
  81236. /**
  81237. * Attach the input controls to a specific dom element to get the input from.
  81238. * @param element Defines the element the controls should be listened from
  81239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81240. */
  81241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81242. /**
  81243. * Detach the current controls from the specified dom element.
  81244. * @param element Defines the element to stop listening the inputs from
  81245. */
  81246. detachControl(element: Nullable<HTMLElement>): void;
  81247. /**
  81248. * Update the current camera state depending on the inputs that have been used this frame.
  81249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81250. */
  81251. checkInputs(): void;
  81252. /**
  81253. * Gets the class name of the current intput.
  81254. * @returns the class name
  81255. */
  81256. getClassName(): string;
  81257. /** @hidden */
  81258. _onLostFocus(): void;
  81259. /**
  81260. * Get the friendly name associated with the input class.
  81261. * @returns the input friendly name
  81262. */
  81263. getSimpleName(): string;
  81264. }
  81265. }
  81266. declare module BABYLON {
  81267. /**
  81268. * Interface describing all the common properties and methods a shadow light needs to implement.
  81269. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  81270. * as well as binding the different shadow properties to the effects.
  81271. */
  81272. export interface IShadowLight extends Light {
  81273. /**
  81274. * The light id in the scene (used in scene.findLighById for instance)
  81275. */
  81276. id: string;
  81277. /**
  81278. * The position the shdow will be casted from.
  81279. */
  81280. position: Vector3;
  81281. /**
  81282. * In 2d mode (needCube being false), the direction used to cast the shadow.
  81283. */
  81284. direction: Vector3;
  81285. /**
  81286. * The transformed position. Position of the light in world space taking parenting in account.
  81287. */
  81288. transformedPosition: Vector3;
  81289. /**
  81290. * The transformed direction. Direction of the light in world space taking parenting in account.
  81291. */
  81292. transformedDirection: Vector3;
  81293. /**
  81294. * The friendly name of the light in the scene.
  81295. */
  81296. name: string;
  81297. /**
  81298. * Defines the shadow projection clipping minimum z value.
  81299. */
  81300. shadowMinZ: number;
  81301. /**
  81302. * Defines the shadow projection clipping maximum z value.
  81303. */
  81304. shadowMaxZ: number;
  81305. /**
  81306. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81307. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81308. */
  81309. computeTransformedInformation(): boolean;
  81310. /**
  81311. * Gets the scene the light belongs to.
  81312. * @returns The scene
  81313. */
  81314. getScene(): Scene;
  81315. /**
  81316. * Callback defining a custom Projection Matrix Builder.
  81317. * This can be used to override the default projection matrix computation.
  81318. */
  81319. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81320. /**
  81321. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81322. * @param matrix The materix to updated with the projection information
  81323. * @param viewMatrix The transform matrix of the light
  81324. * @param renderList The list of mesh to render in the map
  81325. * @returns The current light
  81326. */
  81327. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81328. /**
  81329. * Gets the current depth scale used in ESM.
  81330. * @returns The scale
  81331. */
  81332. getDepthScale(): number;
  81333. /**
  81334. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81335. * @returns true if a cube texture needs to be use
  81336. */
  81337. needCube(): boolean;
  81338. /**
  81339. * Detects if the projection matrix requires to be recomputed this frame.
  81340. * @returns true if it requires to be recomputed otherwise, false.
  81341. */
  81342. needProjectionMatrixCompute(): boolean;
  81343. /**
  81344. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81345. */
  81346. forceProjectionMatrixCompute(): void;
  81347. /**
  81348. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81349. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81350. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81351. */
  81352. getShadowDirection(faceIndex?: number): Vector3;
  81353. /**
  81354. * Gets the minZ used for shadow according to both the scene and the light.
  81355. * @param activeCamera The camera we are returning the min for
  81356. * @returns the depth min z
  81357. */
  81358. getDepthMinZ(activeCamera: Camera): number;
  81359. /**
  81360. * Gets the maxZ used for shadow according to both the scene and the light.
  81361. * @param activeCamera The camera we are returning the max for
  81362. * @returns the depth max z
  81363. */
  81364. getDepthMaxZ(activeCamera: Camera): number;
  81365. }
  81366. /**
  81367. * Base implementation IShadowLight
  81368. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  81369. */
  81370. export abstract class ShadowLight extends Light implements IShadowLight {
  81371. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  81372. protected _position: Vector3;
  81373. protected _setPosition(value: Vector3): void;
  81374. /**
  81375. * Sets the position the shadow will be casted from. Also use as the light position for both
  81376. * point and spot lights.
  81377. */
  81378. get position(): Vector3;
  81379. /**
  81380. * Sets the position the shadow will be casted from. Also use as the light position for both
  81381. * point and spot lights.
  81382. */
  81383. set position(value: Vector3);
  81384. protected _direction: Vector3;
  81385. protected _setDirection(value: Vector3): void;
  81386. /**
  81387. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  81388. * Also use as the light direction on spot and directional lights.
  81389. */
  81390. get direction(): Vector3;
  81391. /**
  81392. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  81393. * Also use as the light direction on spot and directional lights.
  81394. */
  81395. set direction(value: Vector3);
  81396. protected _shadowMinZ: number;
  81397. /**
  81398. * Gets the shadow projection clipping minimum z value.
  81399. */
  81400. get shadowMinZ(): number;
  81401. /**
  81402. * Sets the shadow projection clipping minimum z value.
  81403. */
  81404. set shadowMinZ(value: number);
  81405. protected _shadowMaxZ: number;
  81406. /**
  81407. * Sets the shadow projection clipping maximum z value.
  81408. */
  81409. get shadowMaxZ(): number;
  81410. /**
  81411. * Gets the shadow projection clipping maximum z value.
  81412. */
  81413. set shadowMaxZ(value: number);
  81414. /**
  81415. * Callback defining a custom Projection Matrix Builder.
  81416. * This can be used to override the default projection matrix computation.
  81417. */
  81418. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81419. /**
  81420. * The transformed position. Position of the light in world space taking parenting in account.
  81421. */
  81422. transformedPosition: Vector3;
  81423. /**
  81424. * The transformed direction. Direction of the light in world space taking parenting in account.
  81425. */
  81426. transformedDirection: Vector3;
  81427. private _needProjectionMatrixCompute;
  81428. /**
  81429. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81430. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81431. */
  81432. computeTransformedInformation(): boolean;
  81433. /**
  81434. * Return the depth scale used for the shadow map.
  81435. * @returns the depth scale.
  81436. */
  81437. getDepthScale(): number;
  81438. /**
  81439. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81440. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81441. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81442. */
  81443. getShadowDirection(faceIndex?: number): Vector3;
  81444. /**
  81445. * Returns the ShadowLight absolute position in the World.
  81446. * @returns the position vector in world space
  81447. */
  81448. getAbsolutePosition(): Vector3;
  81449. /**
  81450. * Sets the ShadowLight direction toward the passed target.
  81451. * @param target The point to target in local space
  81452. * @returns the updated ShadowLight direction
  81453. */
  81454. setDirectionToTarget(target: Vector3): Vector3;
  81455. /**
  81456. * Returns the light rotation in euler definition.
  81457. * @returns the x y z rotation in local space.
  81458. */
  81459. getRotation(): Vector3;
  81460. /**
  81461. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81462. * @returns true if a cube texture needs to be use
  81463. */
  81464. needCube(): boolean;
  81465. /**
  81466. * Detects if the projection matrix requires to be recomputed this frame.
  81467. * @returns true if it requires to be recomputed otherwise, false.
  81468. */
  81469. needProjectionMatrixCompute(): boolean;
  81470. /**
  81471. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81472. */
  81473. forceProjectionMatrixCompute(): void;
  81474. /** @hidden */
  81475. _initCache(): void;
  81476. /** @hidden */
  81477. _isSynchronized(): boolean;
  81478. /**
  81479. * Computes the world matrix of the node
  81480. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81481. * @returns the world matrix
  81482. */
  81483. computeWorldMatrix(force?: boolean): Matrix;
  81484. /**
  81485. * Gets the minZ used for shadow according to both the scene and the light.
  81486. * @param activeCamera The camera we are returning the min for
  81487. * @returns the depth min z
  81488. */
  81489. getDepthMinZ(activeCamera: Camera): number;
  81490. /**
  81491. * Gets the maxZ used for shadow according to both the scene and the light.
  81492. * @param activeCamera The camera we are returning the max for
  81493. * @returns the depth max z
  81494. */
  81495. getDepthMaxZ(activeCamera: Camera): number;
  81496. /**
  81497. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81498. * @param matrix The materix to updated with the projection information
  81499. * @param viewMatrix The transform matrix of the light
  81500. * @param renderList The list of mesh to render in the map
  81501. * @returns The current light
  81502. */
  81503. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81504. }
  81505. }
  81506. declare module BABYLON {
  81507. /**
  81508. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  81509. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  81510. */
  81511. export class EffectFallbacks implements IEffectFallbacks {
  81512. private _defines;
  81513. private _currentRank;
  81514. private _maxRank;
  81515. private _mesh;
  81516. /**
  81517. * Removes the fallback from the bound mesh.
  81518. */
  81519. unBindMesh(): void;
  81520. /**
  81521. * Adds a fallback on the specified property.
  81522. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81523. * @param define The name of the define in the shader
  81524. */
  81525. addFallback(rank: number, define: string): void;
  81526. /**
  81527. * Sets the mesh to use CPU skinning when needing to fallback.
  81528. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81529. * @param mesh The mesh to use the fallbacks.
  81530. */
  81531. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  81532. /**
  81533. * Checks to see if more fallbacks are still availible.
  81534. */
  81535. get hasMoreFallbacks(): boolean;
  81536. /**
  81537. * Removes the defines that should be removed when falling back.
  81538. * @param currentDefines defines the current define statements for the shader.
  81539. * @param effect defines the current effect we try to compile
  81540. * @returns The resulting defines with defines of the current rank removed.
  81541. */
  81542. reduce(currentDefines: string, effect: Effect): string;
  81543. }
  81544. }
  81545. declare module BABYLON {
  81546. /**
  81547. * "Static Class" containing the most commonly used helper while dealing with material for
  81548. * rendering purpose.
  81549. *
  81550. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  81551. *
  81552. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  81553. */
  81554. export class MaterialHelper {
  81555. /**
  81556. * Bind the current view position to an effect.
  81557. * @param effect The effect to be bound
  81558. * @param scene The scene the eyes position is used from
  81559. */
  81560. static BindEyePosition(effect: Effect, scene: Scene): void;
  81561. /**
  81562. * Helps preparing the defines values about the UVs in used in the effect.
  81563. * UVs are shared as much as we can accross channels in the shaders.
  81564. * @param texture The texture we are preparing the UVs for
  81565. * @param defines The defines to update
  81566. * @param key The channel key "diffuse", "specular"... used in the shader
  81567. */
  81568. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  81569. /**
  81570. * Binds a texture matrix value to its corrsponding uniform
  81571. * @param texture The texture to bind the matrix for
  81572. * @param uniformBuffer The uniform buffer receivin the data
  81573. * @param key The channel key "diffuse", "specular"... used in the shader
  81574. */
  81575. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  81576. /**
  81577. * Gets the current status of the fog (should it be enabled?)
  81578. * @param mesh defines the mesh to evaluate for fog support
  81579. * @param scene defines the hosting scene
  81580. * @returns true if fog must be enabled
  81581. */
  81582. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  81583. /**
  81584. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  81585. * @param mesh defines the current mesh
  81586. * @param scene defines the current scene
  81587. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  81588. * @param pointsCloud defines if point cloud rendering has to be turned on
  81589. * @param fogEnabled defines if fog has to be turned on
  81590. * @param alphaTest defines if alpha testing has to be turned on
  81591. * @param defines defines the current list of defines
  81592. */
  81593. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  81594. /**
  81595. * Helper used to prepare the list of defines associated with frame values for shader compilation
  81596. * @param scene defines the current scene
  81597. * @param engine defines the current engine
  81598. * @param defines specifies the list of active defines
  81599. * @param useInstances defines if instances have to be turned on
  81600. * @param useClipPlane defines if clip plane have to be turned on
  81601. */
  81602. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  81603. /**
  81604. * Prepares the defines for bones
  81605. * @param mesh The mesh containing the geometry data we will draw
  81606. * @param defines The defines to update
  81607. */
  81608. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  81609. /**
  81610. * Prepares the defines for morph targets
  81611. * @param mesh The mesh containing the geometry data we will draw
  81612. * @param defines The defines to update
  81613. */
  81614. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  81615. /**
  81616. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  81617. * @param mesh The mesh containing the geometry data we will draw
  81618. * @param defines The defines to update
  81619. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  81620. * @param useBones Precise whether bones should be used or not (override mesh info)
  81621. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  81622. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  81623. * @returns false if defines are considered not dirty and have not been checked
  81624. */
  81625. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  81626. /**
  81627. * Prepares the defines related to multiview
  81628. * @param scene The scene we are intending to draw
  81629. * @param defines The defines to update
  81630. */
  81631. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  81632. /**
  81633. * Prepares the defines related to the light information passed in parameter
  81634. * @param scene The scene we are intending to draw
  81635. * @param mesh The mesh the effect is compiling for
  81636. * @param light The light the effect is compiling for
  81637. * @param lightIndex The index of the light
  81638. * @param defines The defines to update
  81639. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81640. * @param state Defines the current state regarding what is needed (normals, etc...)
  81641. */
  81642. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  81643. needNormals: boolean;
  81644. needRebuild: boolean;
  81645. shadowEnabled: boolean;
  81646. specularEnabled: boolean;
  81647. lightmapMode: boolean;
  81648. }): void;
  81649. /**
  81650. * Prepares the defines related to the light information passed in parameter
  81651. * @param scene The scene we are intending to draw
  81652. * @param mesh The mesh the effect is compiling for
  81653. * @param defines The defines to update
  81654. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81655. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  81656. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  81657. * @returns true if normals will be required for the rest of the effect
  81658. */
  81659. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  81660. /**
  81661. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  81662. * @param lightIndex defines the light index
  81663. * @param uniformsList The uniform list
  81664. * @param samplersList The sampler list
  81665. * @param projectedLightTexture defines if projected texture must be used
  81666. * @param uniformBuffersList defines an optional list of uniform buffers
  81667. */
  81668. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  81669. /**
  81670. * Prepares the uniforms and samplers list to be used in the effect
  81671. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  81672. * @param samplersList The sampler list
  81673. * @param defines The defines helping in the list generation
  81674. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  81675. */
  81676. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  81677. /**
  81678. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  81679. * @param defines The defines to update while falling back
  81680. * @param fallbacks The authorized effect fallbacks
  81681. * @param maxSimultaneousLights The maximum number of lights allowed
  81682. * @param rank the current rank of the Effect
  81683. * @returns The newly affected rank
  81684. */
  81685. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  81686. private static _TmpMorphInfluencers;
  81687. /**
  81688. * Prepares the list of attributes required for morph targets according to the effect defines.
  81689. * @param attribs The current list of supported attribs
  81690. * @param mesh The mesh to prepare the morph targets attributes for
  81691. * @param influencers The number of influencers
  81692. */
  81693. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  81694. /**
  81695. * Prepares the list of attributes required for morph targets according to the effect defines.
  81696. * @param attribs The current list of supported attribs
  81697. * @param mesh The mesh to prepare the morph targets attributes for
  81698. * @param defines The current Defines of the effect
  81699. */
  81700. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  81701. /**
  81702. * Prepares the list of attributes required for bones according to the effect defines.
  81703. * @param attribs The current list of supported attribs
  81704. * @param mesh The mesh to prepare the bones attributes for
  81705. * @param defines The current Defines of the effect
  81706. * @param fallbacks The current efffect fallback strategy
  81707. */
  81708. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  81709. /**
  81710. * Check and prepare the list of attributes required for instances according to the effect defines.
  81711. * @param attribs The current list of supported attribs
  81712. * @param defines The current MaterialDefines of the effect
  81713. */
  81714. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  81715. /**
  81716. * Add the list of attributes required for instances to the attribs array.
  81717. * @param attribs The current list of supported attribs
  81718. */
  81719. static PushAttributesForInstances(attribs: string[]): void;
  81720. /**
  81721. * Binds the light information to the effect.
  81722. * @param light The light containing the generator
  81723. * @param effect The effect we are binding the data to
  81724. * @param lightIndex The light index in the effect used to render
  81725. */
  81726. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  81727. /**
  81728. * Binds the lights information from the scene to the effect for the given mesh.
  81729. * @param light Light to bind
  81730. * @param lightIndex Light index
  81731. * @param scene The scene where the light belongs to
  81732. * @param effect The effect we are binding the data to
  81733. * @param useSpecular Defines if specular is supported
  81734. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81735. */
  81736. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81737. /**
  81738. * Binds the lights information from the scene to the effect for the given mesh.
  81739. * @param scene The scene the lights belongs to
  81740. * @param mesh The mesh we are binding the information to render
  81741. * @param effect The effect we are binding the data to
  81742. * @param defines The generated defines for the effect
  81743. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  81744. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81745. */
  81746. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  81747. private static _tempFogColor;
  81748. /**
  81749. * Binds the fog information from the scene to the effect for the given mesh.
  81750. * @param scene The scene the lights belongs to
  81751. * @param mesh The mesh we are binding the information to render
  81752. * @param effect The effect we are binding the data to
  81753. * @param linearSpace Defines if the fog effect is applied in linear space
  81754. */
  81755. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  81756. /**
  81757. * Binds the bones information from the mesh to the effect.
  81758. * @param mesh The mesh we are binding the information to render
  81759. * @param effect The effect we are binding the data to
  81760. */
  81761. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  81762. /**
  81763. * Binds the morph targets information from the mesh to the effect.
  81764. * @param abstractMesh The mesh we are binding the information to render
  81765. * @param effect The effect we are binding the data to
  81766. */
  81767. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  81768. /**
  81769. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  81770. * @param defines The generated defines used in the effect
  81771. * @param effect The effect we are binding the data to
  81772. * @param scene The scene we are willing to render with logarithmic scale for
  81773. */
  81774. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  81775. /**
  81776. * Binds the clip plane information from the scene to the effect.
  81777. * @param scene The scene the clip plane information are extracted from
  81778. * @param effect The effect we are binding the data to
  81779. */
  81780. static BindClipPlane(effect: Effect, scene: Scene): void;
  81781. }
  81782. }
  81783. declare module BABYLON {
  81784. /** @hidden */
  81785. export var packingFunctions: {
  81786. name: string;
  81787. shader: string;
  81788. };
  81789. }
  81790. declare module BABYLON {
  81791. /** @hidden */
  81792. export var shadowMapPixelShader: {
  81793. name: string;
  81794. shader: string;
  81795. };
  81796. }
  81797. declare module BABYLON {
  81798. /** @hidden */
  81799. export var bonesDeclaration: {
  81800. name: string;
  81801. shader: string;
  81802. };
  81803. }
  81804. declare module BABYLON {
  81805. /** @hidden */
  81806. export var morphTargetsVertexGlobalDeclaration: {
  81807. name: string;
  81808. shader: string;
  81809. };
  81810. }
  81811. declare module BABYLON {
  81812. /** @hidden */
  81813. export var morphTargetsVertexDeclaration: {
  81814. name: string;
  81815. shader: string;
  81816. };
  81817. }
  81818. declare module BABYLON {
  81819. /** @hidden */
  81820. export var instancesDeclaration: {
  81821. name: string;
  81822. shader: string;
  81823. };
  81824. }
  81825. declare module BABYLON {
  81826. /** @hidden */
  81827. export var helperFunctions: {
  81828. name: string;
  81829. shader: string;
  81830. };
  81831. }
  81832. declare module BABYLON {
  81833. /** @hidden */
  81834. export var morphTargetsVertex: {
  81835. name: string;
  81836. shader: string;
  81837. };
  81838. }
  81839. declare module BABYLON {
  81840. /** @hidden */
  81841. export var instancesVertex: {
  81842. name: string;
  81843. shader: string;
  81844. };
  81845. }
  81846. declare module BABYLON {
  81847. /** @hidden */
  81848. export var bonesVertex: {
  81849. name: string;
  81850. shader: string;
  81851. };
  81852. }
  81853. declare module BABYLON {
  81854. /** @hidden */
  81855. export var shadowMapVertexShader: {
  81856. name: string;
  81857. shader: string;
  81858. };
  81859. }
  81860. declare module BABYLON {
  81861. /** @hidden */
  81862. export var depthBoxBlurPixelShader: {
  81863. name: string;
  81864. shader: string;
  81865. };
  81866. }
  81867. declare module BABYLON {
  81868. /**
  81869. * Defines the options associated with the creation of a custom shader for a shadow generator.
  81870. */
  81871. export interface ICustomShaderOptions {
  81872. /**
  81873. * Gets or sets the custom shader name to use
  81874. */
  81875. shaderName: string;
  81876. /**
  81877. * The list of attribute names used in the shader
  81878. */
  81879. attributes?: string[];
  81880. /**
  81881. * The list of unifrom names used in the shader
  81882. */
  81883. uniforms?: string[];
  81884. /**
  81885. * The list of sampler names used in the shader
  81886. */
  81887. samplers?: string[];
  81888. /**
  81889. * The list of defines used in the shader
  81890. */
  81891. defines?: string[];
  81892. }
  81893. /**
  81894. * Interface to implement to create a shadow generator compatible with BJS.
  81895. */
  81896. export interface IShadowGenerator {
  81897. /**
  81898. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  81899. * @returns The render target texture if present otherwise, null
  81900. */
  81901. getShadowMap(): Nullable<RenderTargetTexture>;
  81902. /**
  81903. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  81904. * @param subMesh The submesh we want to render in the shadow map
  81905. * @param useInstances Defines wether will draw in the map using instances
  81906. * @returns true if ready otherwise, false
  81907. */
  81908. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81909. /**
  81910. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  81911. * @param defines Defines of the material we want to update
  81912. * @param lightIndex Index of the light in the enabled light list of the material
  81913. */
  81914. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  81915. /**
  81916. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  81917. * defined in the generator but impacting the effect).
  81918. * It implies the unifroms available on the materials are the standard BJS ones.
  81919. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  81920. * @param effect The effect we are binfing the information for
  81921. */
  81922. bindShadowLight(lightIndex: string, effect: Effect): void;
  81923. /**
  81924. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  81925. * (eq to shadow prjection matrix * light transform matrix)
  81926. * @returns The transform matrix used to create the shadow map
  81927. */
  81928. getTransformMatrix(): Matrix;
  81929. /**
  81930. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  81931. * Cube and 2D textures for instance.
  81932. */
  81933. recreateShadowMap(): void;
  81934. /**
  81935. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81936. * @param onCompiled Callback triggered at the and of the effects compilation
  81937. * @param options Sets of optional options forcing the compilation with different modes
  81938. */
  81939. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  81940. useInstances: boolean;
  81941. }>): void;
  81942. /**
  81943. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81944. * @param options Sets of optional options forcing the compilation with different modes
  81945. * @returns A promise that resolves when the compilation completes
  81946. */
  81947. forceCompilationAsync(options?: Partial<{
  81948. useInstances: boolean;
  81949. }>): Promise<void>;
  81950. /**
  81951. * Serializes the shadow generator setup to a json object.
  81952. * @returns The serialized JSON object
  81953. */
  81954. serialize(): any;
  81955. /**
  81956. * Disposes the Shadow map and related Textures and effects.
  81957. */
  81958. dispose(): void;
  81959. }
  81960. /**
  81961. * Default implementation IShadowGenerator.
  81962. * This is the main object responsible of generating shadows in the framework.
  81963. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  81964. */
  81965. export class ShadowGenerator implements IShadowGenerator {
  81966. /**
  81967. * Name of the shadow generator class
  81968. */
  81969. static CLASSNAME: string;
  81970. /**
  81971. * Shadow generator mode None: no filtering applied.
  81972. */
  81973. static readonly FILTER_NONE: number;
  81974. /**
  81975. * Shadow generator mode ESM: Exponential Shadow Mapping.
  81976. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81977. */
  81978. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  81979. /**
  81980. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  81981. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  81982. */
  81983. static readonly FILTER_POISSONSAMPLING: number;
  81984. /**
  81985. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  81986. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81987. */
  81988. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  81989. /**
  81990. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  81991. * edge artifacts on steep falloff.
  81992. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81993. */
  81994. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  81995. /**
  81996. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  81997. * edge artifacts on steep falloff.
  81998. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81999. */
  82000. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  82001. /**
  82002. * Shadow generator mode PCF: Percentage Closer Filtering
  82003. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82004. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  82005. */
  82006. static readonly FILTER_PCF: number;
  82007. /**
  82008. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  82009. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82010. * Contact Hardening
  82011. */
  82012. static readonly FILTER_PCSS: number;
  82013. /**
  82014. * Reserved for PCF and PCSS
  82015. * Highest Quality.
  82016. *
  82017. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  82018. *
  82019. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  82020. */
  82021. static readonly QUALITY_HIGH: number;
  82022. /**
  82023. * Reserved for PCF and PCSS
  82024. * Good tradeoff for quality/perf cross devices
  82025. *
  82026. * Execute PCF on a 3*3 kernel.
  82027. *
  82028. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  82029. */
  82030. static readonly QUALITY_MEDIUM: number;
  82031. /**
  82032. * Reserved for PCF and PCSS
  82033. * The lowest quality but the fastest.
  82034. *
  82035. * Execute PCF on a 1*1 kernel.
  82036. *
  82037. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  82038. */
  82039. static readonly QUALITY_LOW: number;
  82040. /** Gets or sets the custom shader name to use */
  82041. customShaderOptions: ICustomShaderOptions;
  82042. /**
  82043. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  82044. */
  82045. onBeforeShadowMapRenderObservable: Observable<Effect>;
  82046. /**
  82047. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  82048. */
  82049. onAfterShadowMapRenderObservable: Observable<Effect>;
  82050. /**
  82051. * Observable triggered before a mesh is rendered in the shadow map.
  82052. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  82053. */
  82054. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  82055. /**
  82056. * Observable triggered after a mesh is rendered in the shadow map.
  82057. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82058. */
  82059. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82060. protected _bias: number;
  82061. /**
  82062. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82063. */
  82064. get bias(): number;
  82065. /**
  82066. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82067. */
  82068. set bias(bias: number);
  82069. protected _normalBias: number;
  82070. /**
  82071. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82072. */
  82073. get normalBias(): number;
  82074. /**
  82075. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82076. */
  82077. set normalBias(normalBias: number);
  82078. protected _blurBoxOffset: number;
  82079. /**
  82080. * Gets the blur box offset: offset applied during the blur pass.
  82081. * Only useful if useKernelBlur = false
  82082. */
  82083. get blurBoxOffset(): number;
  82084. /**
  82085. * Sets the blur box offset: offset applied during the blur pass.
  82086. * Only useful if useKernelBlur = false
  82087. */
  82088. set blurBoxOffset(value: number);
  82089. protected _blurScale: number;
  82090. /**
  82091. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82092. * 2 means half of the size.
  82093. */
  82094. get blurScale(): number;
  82095. /**
  82096. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82097. * 2 means half of the size.
  82098. */
  82099. set blurScale(value: number);
  82100. protected _blurKernel: number;
  82101. /**
  82102. * Gets the blur kernel: kernel size of the blur pass.
  82103. * Only useful if useKernelBlur = true
  82104. */
  82105. get blurKernel(): number;
  82106. /**
  82107. * Sets the blur kernel: kernel size of the blur pass.
  82108. * Only useful if useKernelBlur = true
  82109. */
  82110. set blurKernel(value: number);
  82111. protected _useKernelBlur: boolean;
  82112. /**
  82113. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82114. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82115. */
  82116. get useKernelBlur(): boolean;
  82117. /**
  82118. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82119. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82120. */
  82121. set useKernelBlur(value: boolean);
  82122. protected _depthScale: number;
  82123. /**
  82124. * Gets the depth scale used in ESM mode.
  82125. */
  82126. get depthScale(): number;
  82127. /**
  82128. * Sets the depth scale used in ESM mode.
  82129. * This can override the scale stored on the light.
  82130. */
  82131. set depthScale(value: number);
  82132. protected _validateFilter(filter: number): number;
  82133. protected _filter: number;
  82134. /**
  82135. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82136. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82137. */
  82138. get filter(): number;
  82139. /**
  82140. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82141. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82142. */
  82143. set filter(value: number);
  82144. /**
  82145. * Gets if the current filter is set to Poisson Sampling.
  82146. */
  82147. get usePoissonSampling(): boolean;
  82148. /**
  82149. * Sets the current filter to Poisson Sampling.
  82150. */
  82151. set usePoissonSampling(value: boolean);
  82152. /**
  82153. * Gets if the current filter is set to ESM.
  82154. */
  82155. get useExponentialShadowMap(): boolean;
  82156. /**
  82157. * Sets the current filter is to ESM.
  82158. */
  82159. set useExponentialShadowMap(value: boolean);
  82160. /**
  82161. * Gets if the current filter is set to filtered ESM.
  82162. */
  82163. get useBlurExponentialShadowMap(): boolean;
  82164. /**
  82165. * Gets if the current filter is set to filtered ESM.
  82166. */
  82167. set useBlurExponentialShadowMap(value: boolean);
  82168. /**
  82169. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82170. * exponential to prevent steep falloff artifacts).
  82171. */
  82172. get useCloseExponentialShadowMap(): boolean;
  82173. /**
  82174. * Sets the current filter to "close ESM" (using the inverse of the
  82175. * exponential to prevent steep falloff artifacts).
  82176. */
  82177. set useCloseExponentialShadowMap(value: boolean);
  82178. /**
  82179. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82180. * exponential to prevent steep falloff artifacts).
  82181. */
  82182. get useBlurCloseExponentialShadowMap(): boolean;
  82183. /**
  82184. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82185. * exponential to prevent steep falloff artifacts).
  82186. */
  82187. set useBlurCloseExponentialShadowMap(value: boolean);
  82188. /**
  82189. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82190. */
  82191. get usePercentageCloserFiltering(): boolean;
  82192. /**
  82193. * Sets the current filter to "PCF" (percentage closer filtering).
  82194. */
  82195. set usePercentageCloserFiltering(value: boolean);
  82196. protected _filteringQuality: number;
  82197. /**
  82198. * Gets the PCF or PCSS Quality.
  82199. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82200. */
  82201. get filteringQuality(): number;
  82202. /**
  82203. * Sets the PCF or PCSS Quality.
  82204. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82205. */
  82206. set filteringQuality(filteringQuality: number);
  82207. /**
  82208. * Gets if the current filter is set to "PCSS" (contact hardening).
  82209. */
  82210. get useContactHardeningShadow(): boolean;
  82211. /**
  82212. * Sets the current filter to "PCSS" (contact hardening).
  82213. */
  82214. set useContactHardeningShadow(value: boolean);
  82215. protected _contactHardeningLightSizeUVRatio: number;
  82216. /**
  82217. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82218. * Using a ratio helps keeping shape stability independently of the map size.
  82219. *
  82220. * It does not account for the light projection as it was having too much
  82221. * instability during the light setup or during light position changes.
  82222. *
  82223. * Only valid if useContactHardeningShadow is true.
  82224. */
  82225. get contactHardeningLightSizeUVRatio(): number;
  82226. /**
  82227. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82228. * Using a ratio helps keeping shape stability independently of the map size.
  82229. *
  82230. * It does not account for the light projection as it was having too much
  82231. * instability during the light setup or during light position changes.
  82232. *
  82233. * Only valid if useContactHardeningShadow is true.
  82234. */
  82235. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  82236. protected _darkness: number;
  82237. /** Gets or sets the actual darkness of a shadow */
  82238. get darkness(): number;
  82239. set darkness(value: number);
  82240. /**
  82241. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  82242. * 0 means strongest and 1 would means no shadow.
  82243. * @returns the darkness.
  82244. */
  82245. getDarkness(): number;
  82246. /**
  82247. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  82248. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  82249. * @returns the shadow generator allowing fluent coding.
  82250. */
  82251. setDarkness(darkness: number): ShadowGenerator;
  82252. protected _transparencyShadow: boolean;
  82253. /** Gets or sets the ability to have transparent shadow */
  82254. get transparencyShadow(): boolean;
  82255. set transparencyShadow(value: boolean);
  82256. /**
  82257. * Sets the ability to have transparent shadow (boolean).
  82258. * @param transparent True if transparent else False
  82259. * @returns the shadow generator allowing fluent coding
  82260. */
  82261. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  82262. protected _shadowMap: Nullable<RenderTargetTexture>;
  82263. protected _shadowMap2: Nullable<RenderTargetTexture>;
  82264. /**
  82265. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82266. * @returns The render target texture if present otherwise, null
  82267. */
  82268. getShadowMap(): Nullable<RenderTargetTexture>;
  82269. /**
  82270. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  82271. * @returns The render target texture if the shadow map is present otherwise, null
  82272. */
  82273. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  82274. /**
  82275. * Gets the class name of that object
  82276. * @returns "ShadowGenerator"
  82277. */
  82278. getClassName(): string;
  82279. /**
  82280. * Helper function to add a mesh and its descendants to the list of shadow casters.
  82281. * @param mesh Mesh to add
  82282. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  82283. * @returns the Shadow Generator itself
  82284. */
  82285. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82286. /**
  82287. * Helper function to remove a mesh and its descendants from the list of shadow casters
  82288. * @param mesh Mesh to remove
  82289. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  82290. * @returns the Shadow Generator itself
  82291. */
  82292. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82293. /**
  82294. * Controls the extent to which the shadows fade out at the edge of the frustum
  82295. */
  82296. frustumEdgeFalloff: number;
  82297. protected _light: IShadowLight;
  82298. /**
  82299. * Returns the associated light object.
  82300. * @returns the light generating the shadow
  82301. */
  82302. getLight(): IShadowLight;
  82303. /**
  82304. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  82305. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  82306. * It might on the other hand introduce peter panning.
  82307. */
  82308. forceBackFacesOnly: boolean;
  82309. protected _scene: Scene;
  82310. protected _lightDirection: Vector3;
  82311. protected _effect: Effect;
  82312. protected _viewMatrix: Matrix;
  82313. protected _projectionMatrix: Matrix;
  82314. protected _transformMatrix: Matrix;
  82315. protected _cachedPosition: Vector3;
  82316. protected _cachedDirection: Vector3;
  82317. protected _cachedDefines: string;
  82318. protected _currentRenderID: number;
  82319. protected _boxBlurPostprocess: Nullable<PostProcess>;
  82320. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  82321. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  82322. protected _blurPostProcesses: PostProcess[];
  82323. protected _mapSize: number;
  82324. protected _currentFaceIndex: number;
  82325. protected _currentFaceIndexCache: number;
  82326. protected _textureType: number;
  82327. protected _defaultTextureMatrix: Matrix;
  82328. protected _storedUniqueId: Nullable<number>;
  82329. /** @hidden */
  82330. static _SceneComponentInitialization: (scene: Scene) => void;
  82331. /**
  82332. * Creates a ShadowGenerator object.
  82333. * A ShadowGenerator is the required tool to use the shadows.
  82334. * Each light casting shadows needs to use its own ShadowGenerator.
  82335. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  82336. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  82337. * @param light The light object generating the shadows.
  82338. * @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.
  82339. */
  82340. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  82341. protected _initializeGenerator(): void;
  82342. protected _createTargetRenderTexture(): void;
  82343. protected _initializeShadowMap(): void;
  82344. protected _initializeBlurRTTAndPostProcesses(): void;
  82345. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  82346. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  82347. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  82348. protected _applyFilterValues(): void;
  82349. /**
  82350. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82351. * @param onCompiled Callback triggered at the and of the effects compilation
  82352. * @param options Sets of optional options forcing the compilation with different modes
  82353. */
  82354. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82355. useInstances: boolean;
  82356. }>): void;
  82357. /**
  82358. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82359. * @param options Sets of optional options forcing the compilation with different modes
  82360. * @returns A promise that resolves when the compilation completes
  82361. */
  82362. forceCompilationAsync(options?: Partial<{
  82363. useInstances: boolean;
  82364. }>): Promise<void>;
  82365. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  82366. /**
  82367. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82368. * @param subMesh The submesh we want to render in the shadow map
  82369. * @param useInstances Defines wether will draw in the map using instances
  82370. * @returns true if ready otherwise, false
  82371. */
  82372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82373. /**
  82374. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82375. * @param defines Defines of the material we want to update
  82376. * @param lightIndex Index of the light in the enabled light list of the material
  82377. */
  82378. prepareDefines(defines: any, lightIndex: number): void;
  82379. /**
  82380. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82381. * defined in the generator but impacting the effect).
  82382. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82383. * @param effect The effect we are binfing the information for
  82384. */
  82385. bindShadowLight(lightIndex: string, effect: Effect): void;
  82386. /**
  82387. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82388. * (eq to shadow prjection matrix * light transform matrix)
  82389. * @returns The transform matrix used to create the shadow map
  82390. */
  82391. getTransformMatrix(): Matrix;
  82392. /**
  82393. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82394. * Cube and 2D textures for instance.
  82395. */
  82396. recreateShadowMap(): void;
  82397. protected _disposeBlurPostProcesses(): void;
  82398. protected _disposeRTTandPostProcesses(): void;
  82399. /**
  82400. * Disposes the ShadowGenerator.
  82401. * Returns nothing.
  82402. */
  82403. dispose(): void;
  82404. /**
  82405. * Serializes the shadow generator setup to a json object.
  82406. * @returns The serialized JSON object
  82407. */
  82408. serialize(): any;
  82409. /**
  82410. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  82411. * @param parsedShadowGenerator The JSON object to parse
  82412. * @param scene The scene to create the shadow map for
  82413. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  82414. * @returns The parsed shadow generator
  82415. */
  82416. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  82417. }
  82418. }
  82419. declare module BABYLON {
  82420. /**
  82421. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  82422. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  82423. * 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.
  82424. */
  82425. export abstract class Light extends Node {
  82426. /**
  82427. * Falloff Default: light is falling off following the material specification:
  82428. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  82429. */
  82430. static readonly FALLOFF_DEFAULT: number;
  82431. /**
  82432. * Falloff Physical: light is falling off following the inverse squared distance law.
  82433. */
  82434. static readonly FALLOFF_PHYSICAL: number;
  82435. /**
  82436. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  82437. * to enhance interoperability with other engines.
  82438. */
  82439. static readonly FALLOFF_GLTF: number;
  82440. /**
  82441. * Falloff Standard: light is falling off like in the standard material
  82442. * to enhance interoperability with other materials.
  82443. */
  82444. static readonly FALLOFF_STANDARD: number;
  82445. /**
  82446. * If every light affecting the material is in this lightmapMode,
  82447. * material.lightmapTexture adds or multiplies
  82448. * (depends on material.useLightmapAsShadowmap)
  82449. * after every other light calculations.
  82450. */
  82451. static readonly LIGHTMAP_DEFAULT: number;
  82452. /**
  82453. * material.lightmapTexture as only diffuse lighting from this light
  82454. * adds only specular lighting from this light
  82455. * adds dynamic shadows
  82456. */
  82457. static readonly LIGHTMAP_SPECULAR: number;
  82458. /**
  82459. * material.lightmapTexture as only lighting
  82460. * no light calculation from this light
  82461. * only adds dynamic shadows from this light
  82462. */
  82463. static readonly LIGHTMAP_SHADOWSONLY: number;
  82464. /**
  82465. * Each light type uses the default quantity according to its type:
  82466. * point/spot lights use luminous intensity
  82467. * directional lights use illuminance
  82468. */
  82469. static readonly INTENSITYMODE_AUTOMATIC: number;
  82470. /**
  82471. * lumen (lm)
  82472. */
  82473. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  82474. /**
  82475. * candela (lm/sr)
  82476. */
  82477. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  82478. /**
  82479. * lux (lm/m^2)
  82480. */
  82481. static readonly INTENSITYMODE_ILLUMINANCE: number;
  82482. /**
  82483. * nit (cd/m^2)
  82484. */
  82485. static readonly INTENSITYMODE_LUMINANCE: number;
  82486. /**
  82487. * Light type const id of the point light.
  82488. */
  82489. static readonly LIGHTTYPEID_POINTLIGHT: number;
  82490. /**
  82491. * Light type const id of the directional light.
  82492. */
  82493. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  82494. /**
  82495. * Light type const id of the spot light.
  82496. */
  82497. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  82498. /**
  82499. * Light type const id of the hemispheric light.
  82500. */
  82501. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  82502. /**
  82503. * Diffuse gives the basic color to an object.
  82504. */
  82505. diffuse: Color3;
  82506. /**
  82507. * Specular produces a highlight color on an object.
  82508. * Note: This is note affecting PBR materials.
  82509. */
  82510. specular: Color3;
  82511. /**
  82512. * Defines the falloff type for this light. This lets overrriding how punctual light are
  82513. * falling off base on range or angle.
  82514. * This can be set to any values in Light.FALLOFF_x.
  82515. *
  82516. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  82517. * other types of materials.
  82518. */
  82519. falloffType: number;
  82520. /**
  82521. * Strength of the light.
  82522. * Note: By default it is define in the framework own unit.
  82523. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  82524. */
  82525. intensity: number;
  82526. private _range;
  82527. protected _inverseSquaredRange: number;
  82528. /**
  82529. * Defines how far from the source the light is impacting in scene units.
  82530. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82531. */
  82532. get range(): number;
  82533. /**
  82534. * Defines how far from the source the light is impacting in scene units.
  82535. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82536. */
  82537. set range(value: number);
  82538. /**
  82539. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  82540. * of light.
  82541. */
  82542. private _photometricScale;
  82543. private _intensityMode;
  82544. /**
  82545. * Gets the photometric scale used to interpret the intensity.
  82546. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82547. */
  82548. get intensityMode(): number;
  82549. /**
  82550. * Sets the photometric scale used to interpret the intensity.
  82551. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82552. */
  82553. set intensityMode(value: number);
  82554. private _radius;
  82555. /**
  82556. * Gets the light radius used by PBR Materials to simulate soft area lights.
  82557. */
  82558. get radius(): number;
  82559. /**
  82560. * sets the light radius used by PBR Materials to simulate soft area lights.
  82561. */
  82562. set radius(value: number);
  82563. private _renderPriority;
  82564. /**
  82565. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  82566. * exceeding the number allowed of the materials.
  82567. */
  82568. renderPriority: number;
  82569. private _shadowEnabled;
  82570. /**
  82571. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82572. * the current shadow generator.
  82573. */
  82574. get shadowEnabled(): boolean;
  82575. /**
  82576. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82577. * the current shadow generator.
  82578. */
  82579. set shadowEnabled(value: boolean);
  82580. private _includedOnlyMeshes;
  82581. /**
  82582. * Gets the only meshes impacted by this light.
  82583. */
  82584. get includedOnlyMeshes(): AbstractMesh[];
  82585. /**
  82586. * Sets the only meshes impacted by this light.
  82587. */
  82588. set includedOnlyMeshes(value: AbstractMesh[]);
  82589. private _excludedMeshes;
  82590. /**
  82591. * Gets the meshes not impacted by this light.
  82592. */
  82593. get excludedMeshes(): AbstractMesh[];
  82594. /**
  82595. * Sets the meshes not impacted by this light.
  82596. */
  82597. set excludedMeshes(value: AbstractMesh[]);
  82598. private _excludeWithLayerMask;
  82599. /**
  82600. * Gets the layer id use to find what meshes are not impacted by the light.
  82601. * Inactive if 0
  82602. */
  82603. get excludeWithLayerMask(): number;
  82604. /**
  82605. * Sets the layer id use to find what meshes are not impacted by the light.
  82606. * Inactive if 0
  82607. */
  82608. set excludeWithLayerMask(value: number);
  82609. private _includeOnlyWithLayerMask;
  82610. /**
  82611. * Gets the layer id use to find what meshes are impacted by the light.
  82612. * Inactive if 0
  82613. */
  82614. get includeOnlyWithLayerMask(): number;
  82615. /**
  82616. * Sets the layer id use to find what meshes are impacted by the light.
  82617. * Inactive if 0
  82618. */
  82619. set includeOnlyWithLayerMask(value: number);
  82620. private _lightmapMode;
  82621. /**
  82622. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82623. */
  82624. get lightmapMode(): number;
  82625. /**
  82626. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82627. */
  82628. set lightmapMode(value: number);
  82629. /**
  82630. * Shadow generator associted to the light.
  82631. * @hidden Internal use only.
  82632. */
  82633. _shadowGenerator: Nullable<IShadowGenerator>;
  82634. /**
  82635. * @hidden Internal use only.
  82636. */
  82637. _excludedMeshesIds: string[];
  82638. /**
  82639. * @hidden Internal use only.
  82640. */
  82641. _includedOnlyMeshesIds: string[];
  82642. /**
  82643. * The current light unifom buffer.
  82644. * @hidden Internal use only.
  82645. */
  82646. _uniformBuffer: UniformBuffer;
  82647. /** @hidden */
  82648. _renderId: number;
  82649. /**
  82650. * Creates a Light object in the scene.
  82651. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82652. * @param name The firendly name of the light
  82653. * @param scene The scene the light belongs too
  82654. */
  82655. constructor(name: string, scene: Scene);
  82656. protected abstract _buildUniformLayout(): void;
  82657. /**
  82658. * Sets the passed Effect "effect" with the Light information.
  82659. * @param effect The effect to update
  82660. * @param lightIndex The index of the light in the effect to update
  82661. * @returns The light
  82662. */
  82663. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  82664. /**
  82665. * Sets the passed Effect "effect" with the Light textures.
  82666. * @param effect The effect to update
  82667. * @param lightIndex The index of the light in the effect to update
  82668. * @returns The light
  82669. */
  82670. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  82671. /**
  82672. * Binds the lights information from the scene to the effect for the given mesh.
  82673. * @param lightIndex Light index
  82674. * @param scene The scene where the light belongs to
  82675. * @param effect The effect we are binding the data to
  82676. * @param useSpecular Defines if specular is supported
  82677. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82678. */
  82679. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82680. /**
  82681. * Sets the passed Effect "effect" with the Light information.
  82682. * @param effect The effect to update
  82683. * @param lightDataUniformName The uniform used to store light data (position or direction)
  82684. * @returns The light
  82685. */
  82686. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  82687. /**
  82688. * Returns the string "Light".
  82689. * @returns the class name
  82690. */
  82691. getClassName(): string;
  82692. /** @hidden */
  82693. readonly _isLight: boolean;
  82694. /**
  82695. * Converts the light information to a readable string for debug purpose.
  82696. * @param fullDetails Supports for multiple levels of logging within scene loading
  82697. * @returns the human readable light info
  82698. */
  82699. toString(fullDetails?: boolean): string;
  82700. /** @hidden */
  82701. protected _syncParentEnabledState(): void;
  82702. /**
  82703. * Set the enabled state of this node.
  82704. * @param value - the new enabled state
  82705. */
  82706. setEnabled(value: boolean): void;
  82707. /**
  82708. * Returns the Light associated shadow generator if any.
  82709. * @return the associated shadow generator.
  82710. */
  82711. getShadowGenerator(): Nullable<IShadowGenerator>;
  82712. /**
  82713. * Returns a Vector3, the absolute light position in the World.
  82714. * @returns the world space position of the light
  82715. */
  82716. getAbsolutePosition(): Vector3;
  82717. /**
  82718. * Specifies if the light will affect the passed mesh.
  82719. * @param mesh The mesh to test against the light
  82720. * @return true the mesh is affected otherwise, false.
  82721. */
  82722. canAffectMesh(mesh: AbstractMesh): boolean;
  82723. /**
  82724. * Sort function to order lights for rendering.
  82725. * @param a First Light object to compare to second.
  82726. * @param b Second Light object to compare first.
  82727. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  82728. */
  82729. static CompareLightsPriority(a: Light, b: Light): number;
  82730. /**
  82731. * Releases resources associated with this node.
  82732. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82733. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82734. */
  82735. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82736. /**
  82737. * Returns the light type ID (integer).
  82738. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82739. */
  82740. getTypeID(): number;
  82741. /**
  82742. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  82743. * @returns the scaled intensity in intensity mode unit
  82744. */
  82745. getScaledIntensity(): number;
  82746. /**
  82747. * Returns a new Light object, named "name", from the current one.
  82748. * @param name The name of the cloned light
  82749. * @returns the new created light
  82750. */
  82751. clone(name: string): Nullable<Light>;
  82752. /**
  82753. * Serializes the current light into a Serialization object.
  82754. * @returns the serialized object.
  82755. */
  82756. serialize(): any;
  82757. /**
  82758. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  82759. * This new light is named "name" and added to the passed scene.
  82760. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  82761. * @param name The friendly name of the light
  82762. * @param scene The scene the new light will belong to
  82763. * @returns the constructor function
  82764. */
  82765. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  82766. /**
  82767. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  82768. * @param parsedLight The JSON representation of the light
  82769. * @param scene The scene to create the parsed light in
  82770. * @returns the created light after parsing
  82771. */
  82772. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  82773. private _hookArrayForExcluded;
  82774. private _hookArrayForIncludedOnly;
  82775. private _resyncMeshes;
  82776. /**
  82777. * Forces the meshes to update their light related information in their rendering used effects
  82778. * @hidden Internal Use Only
  82779. */
  82780. _markMeshesAsLightDirty(): void;
  82781. /**
  82782. * Recomputes the cached photometric scale if needed.
  82783. */
  82784. private _computePhotometricScale;
  82785. /**
  82786. * Returns the Photometric Scale according to the light type and intensity mode.
  82787. */
  82788. private _getPhotometricScale;
  82789. /**
  82790. * Reorder the light in the scene according to their defined priority.
  82791. * @hidden Internal Use Only
  82792. */
  82793. _reorderLightsInScene(): void;
  82794. /**
  82795. * Prepares the list of defines specific to the light type.
  82796. * @param defines the list of defines
  82797. * @param lightIndex defines the index of the light for the effect
  82798. */
  82799. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82800. }
  82801. }
  82802. declare module BABYLON {
  82803. /**
  82804. * Interface used to define Action
  82805. */
  82806. export interface IAction {
  82807. /**
  82808. * Trigger for the action
  82809. */
  82810. trigger: number;
  82811. /** Options of the trigger */
  82812. triggerOptions: any;
  82813. /**
  82814. * Gets the trigger parameters
  82815. * @returns the trigger parameters
  82816. */
  82817. getTriggerParameter(): any;
  82818. /**
  82819. * Internal only - executes current action event
  82820. * @hidden
  82821. */
  82822. _executeCurrent(evt?: ActionEvent): void;
  82823. /**
  82824. * Serialize placeholder for child classes
  82825. * @param parent of child
  82826. * @returns the serialized object
  82827. */
  82828. serialize(parent: any): any;
  82829. /**
  82830. * Internal only
  82831. * @hidden
  82832. */
  82833. _prepare(): void;
  82834. /**
  82835. * Internal only - manager for action
  82836. * @hidden
  82837. */
  82838. _actionManager: AbstractActionManager;
  82839. /**
  82840. * Adds action to chain of actions, may be a DoNothingAction
  82841. * @param action defines the next action to execute
  82842. * @returns The action passed in
  82843. * @see https://www.babylonjs-playground.com/#1T30HR#0
  82844. */
  82845. then(action: IAction): IAction;
  82846. }
  82847. /**
  82848. * The action to be carried out following a trigger
  82849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  82850. */
  82851. export class Action implements IAction {
  82852. /** the trigger, with or without parameters, for the action */
  82853. triggerOptions: any;
  82854. /**
  82855. * Trigger for the action
  82856. */
  82857. trigger: number;
  82858. /**
  82859. * Internal only - manager for action
  82860. * @hidden
  82861. */
  82862. _actionManager: ActionManager;
  82863. private _nextActiveAction;
  82864. private _child;
  82865. private _condition?;
  82866. private _triggerParameter;
  82867. /**
  82868. * An event triggered prior to action being executed.
  82869. */
  82870. onBeforeExecuteObservable: Observable<Action>;
  82871. /**
  82872. * Creates a new Action
  82873. * @param triggerOptions the trigger, with or without parameters, for the action
  82874. * @param condition an optional determinant of action
  82875. */
  82876. constructor(
  82877. /** the trigger, with or without parameters, for the action */
  82878. triggerOptions: any, condition?: Condition);
  82879. /**
  82880. * Internal only
  82881. * @hidden
  82882. */
  82883. _prepare(): void;
  82884. /**
  82885. * Gets the trigger parameters
  82886. * @returns the trigger parameters
  82887. */
  82888. getTriggerParameter(): any;
  82889. /**
  82890. * Internal only - executes current action event
  82891. * @hidden
  82892. */
  82893. _executeCurrent(evt?: ActionEvent): void;
  82894. /**
  82895. * Execute placeholder for child classes
  82896. * @param evt optional action event
  82897. */
  82898. execute(evt?: ActionEvent): void;
  82899. /**
  82900. * Skips to next active action
  82901. */
  82902. skipToNextActiveAction(): void;
  82903. /**
  82904. * Adds action to chain of actions, may be a DoNothingAction
  82905. * @param action defines the next action to execute
  82906. * @returns The action passed in
  82907. * @see https://www.babylonjs-playground.com/#1T30HR#0
  82908. */
  82909. then(action: Action): Action;
  82910. /**
  82911. * Internal only
  82912. * @hidden
  82913. */
  82914. _getProperty(propertyPath: string): string;
  82915. /**
  82916. * Internal only
  82917. * @hidden
  82918. */
  82919. _getEffectiveTarget(target: any, propertyPath: string): any;
  82920. /**
  82921. * Serialize placeholder for child classes
  82922. * @param parent of child
  82923. * @returns the serialized object
  82924. */
  82925. serialize(parent: any): any;
  82926. /**
  82927. * Internal only called by serialize
  82928. * @hidden
  82929. */
  82930. protected _serialize(serializedAction: any, parent?: any): any;
  82931. /**
  82932. * Internal only
  82933. * @hidden
  82934. */
  82935. static _SerializeValueAsString: (value: any) => string;
  82936. /**
  82937. * Internal only
  82938. * @hidden
  82939. */
  82940. static _GetTargetProperty: (target: Node | Scene) => {
  82941. name: string;
  82942. targetType: string;
  82943. value: string;
  82944. };
  82945. }
  82946. }
  82947. declare module BABYLON {
  82948. /**
  82949. * A Condition applied to an Action
  82950. */
  82951. export class Condition {
  82952. /**
  82953. * Internal only - manager for action
  82954. * @hidden
  82955. */
  82956. _actionManager: ActionManager;
  82957. /**
  82958. * Internal only
  82959. * @hidden
  82960. */
  82961. _evaluationId: number;
  82962. /**
  82963. * Internal only
  82964. * @hidden
  82965. */
  82966. _currentResult: boolean;
  82967. /**
  82968. * Creates a new Condition
  82969. * @param actionManager the manager of the action the condition is applied to
  82970. */
  82971. constructor(actionManager: ActionManager);
  82972. /**
  82973. * Check if the current condition is valid
  82974. * @returns a boolean
  82975. */
  82976. isValid(): boolean;
  82977. /**
  82978. * Internal only
  82979. * @hidden
  82980. */
  82981. _getProperty(propertyPath: string): string;
  82982. /**
  82983. * Internal only
  82984. * @hidden
  82985. */
  82986. _getEffectiveTarget(target: any, propertyPath: string): any;
  82987. /**
  82988. * Serialize placeholder for child classes
  82989. * @returns the serialized object
  82990. */
  82991. serialize(): any;
  82992. /**
  82993. * Internal only
  82994. * @hidden
  82995. */
  82996. protected _serialize(serializedCondition: any): any;
  82997. }
  82998. /**
  82999. * Defines specific conditional operators as extensions of Condition
  83000. */
  83001. export class ValueCondition extends Condition {
  83002. /** path to specify the property of the target the conditional operator uses */
  83003. propertyPath: string;
  83004. /** the value compared by the conditional operator against the current value of the property */
  83005. value: any;
  83006. /** the conditional operator, default ValueCondition.IsEqual */
  83007. operator: number;
  83008. /**
  83009. * Internal only
  83010. * @hidden
  83011. */
  83012. private static _IsEqual;
  83013. /**
  83014. * Internal only
  83015. * @hidden
  83016. */
  83017. private static _IsDifferent;
  83018. /**
  83019. * Internal only
  83020. * @hidden
  83021. */
  83022. private static _IsGreater;
  83023. /**
  83024. * Internal only
  83025. * @hidden
  83026. */
  83027. private static _IsLesser;
  83028. /**
  83029. * returns the number for IsEqual
  83030. */
  83031. static get IsEqual(): number;
  83032. /**
  83033. * Returns the number for IsDifferent
  83034. */
  83035. static get IsDifferent(): number;
  83036. /**
  83037. * Returns the number for IsGreater
  83038. */
  83039. static get IsGreater(): number;
  83040. /**
  83041. * Returns the number for IsLesser
  83042. */
  83043. static get IsLesser(): number;
  83044. /**
  83045. * Internal only The action manager for the condition
  83046. * @hidden
  83047. */
  83048. _actionManager: ActionManager;
  83049. /**
  83050. * Internal only
  83051. * @hidden
  83052. */
  83053. private _target;
  83054. /**
  83055. * Internal only
  83056. * @hidden
  83057. */
  83058. private _effectiveTarget;
  83059. /**
  83060. * Internal only
  83061. * @hidden
  83062. */
  83063. private _property;
  83064. /**
  83065. * Creates a new ValueCondition
  83066. * @param actionManager manager for the action the condition applies to
  83067. * @param target for the action
  83068. * @param propertyPath path to specify the property of the target the conditional operator uses
  83069. * @param value the value compared by the conditional operator against the current value of the property
  83070. * @param operator the conditional operator, default ValueCondition.IsEqual
  83071. */
  83072. constructor(actionManager: ActionManager, target: any,
  83073. /** path to specify the property of the target the conditional operator uses */
  83074. propertyPath: string,
  83075. /** the value compared by the conditional operator against the current value of the property */
  83076. value: any,
  83077. /** the conditional operator, default ValueCondition.IsEqual */
  83078. operator?: number);
  83079. /**
  83080. * Compares the given value with the property value for the specified conditional operator
  83081. * @returns the result of the comparison
  83082. */
  83083. isValid(): boolean;
  83084. /**
  83085. * Serialize the ValueCondition into a JSON compatible object
  83086. * @returns serialization object
  83087. */
  83088. serialize(): any;
  83089. /**
  83090. * Gets the name of the conditional operator for the ValueCondition
  83091. * @param operator the conditional operator
  83092. * @returns the name
  83093. */
  83094. static GetOperatorName(operator: number): string;
  83095. }
  83096. /**
  83097. * Defines a predicate condition as an extension of Condition
  83098. */
  83099. export class PredicateCondition extends Condition {
  83100. /** defines the predicate function used to validate the condition */
  83101. predicate: () => boolean;
  83102. /**
  83103. * Internal only - manager for action
  83104. * @hidden
  83105. */
  83106. _actionManager: ActionManager;
  83107. /**
  83108. * Creates a new PredicateCondition
  83109. * @param actionManager manager for the action the condition applies to
  83110. * @param predicate defines the predicate function used to validate the condition
  83111. */
  83112. constructor(actionManager: ActionManager,
  83113. /** defines the predicate function used to validate the condition */
  83114. predicate: () => boolean);
  83115. /**
  83116. * @returns the validity of the predicate condition
  83117. */
  83118. isValid(): boolean;
  83119. }
  83120. /**
  83121. * Defines a state condition as an extension of Condition
  83122. */
  83123. export class StateCondition extends Condition {
  83124. /** Value to compare with target state */
  83125. value: string;
  83126. /**
  83127. * Internal only - manager for action
  83128. * @hidden
  83129. */
  83130. _actionManager: ActionManager;
  83131. /**
  83132. * Internal only
  83133. * @hidden
  83134. */
  83135. private _target;
  83136. /**
  83137. * Creates a new StateCondition
  83138. * @param actionManager manager for the action the condition applies to
  83139. * @param target of the condition
  83140. * @param value to compare with target state
  83141. */
  83142. constructor(actionManager: ActionManager, target: any,
  83143. /** Value to compare with target state */
  83144. value: string);
  83145. /**
  83146. * Gets a boolean indicating if the current condition is met
  83147. * @returns the validity of the state
  83148. */
  83149. isValid(): boolean;
  83150. /**
  83151. * Serialize the StateCondition into a JSON compatible object
  83152. * @returns serialization object
  83153. */
  83154. serialize(): any;
  83155. }
  83156. }
  83157. declare module BABYLON {
  83158. /**
  83159. * This defines an action responsible to toggle a boolean once triggered.
  83160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83161. */
  83162. export class SwitchBooleanAction extends Action {
  83163. /**
  83164. * The path to the boolean property in the target object
  83165. */
  83166. propertyPath: string;
  83167. private _target;
  83168. private _effectiveTarget;
  83169. private _property;
  83170. /**
  83171. * Instantiate the action
  83172. * @param triggerOptions defines the trigger options
  83173. * @param target defines the object containing the boolean
  83174. * @param propertyPath defines the path to the boolean property in the target object
  83175. * @param condition defines the trigger related conditions
  83176. */
  83177. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83178. /** @hidden */
  83179. _prepare(): void;
  83180. /**
  83181. * Execute the action toggle the boolean value.
  83182. */
  83183. execute(): void;
  83184. /**
  83185. * Serializes the actions and its related information.
  83186. * @param parent defines the object to serialize in
  83187. * @returns the serialized object
  83188. */
  83189. serialize(parent: any): any;
  83190. }
  83191. /**
  83192. * This defines an action responsible to set a the state field of the target
  83193. * to a desired value once triggered.
  83194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83195. */
  83196. export class SetStateAction extends Action {
  83197. /**
  83198. * The value to store in the state field.
  83199. */
  83200. value: string;
  83201. private _target;
  83202. /**
  83203. * Instantiate the action
  83204. * @param triggerOptions defines the trigger options
  83205. * @param target defines the object containing the state property
  83206. * @param value defines the value to store in the state field
  83207. * @param condition defines the trigger related conditions
  83208. */
  83209. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83210. /**
  83211. * Execute the action and store the value on the target state property.
  83212. */
  83213. execute(): void;
  83214. /**
  83215. * Serializes the actions and its related information.
  83216. * @param parent defines the object to serialize in
  83217. * @returns the serialized object
  83218. */
  83219. serialize(parent: any): any;
  83220. }
  83221. /**
  83222. * This defines an action responsible to set a property of the target
  83223. * to a desired value once triggered.
  83224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83225. */
  83226. export class SetValueAction extends Action {
  83227. /**
  83228. * The path of the property to set in the target.
  83229. */
  83230. propertyPath: string;
  83231. /**
  83232. * The value to set in the property
  83233. */
  83234. value: any;
  83235. private _target;
  83236. private _effectiveTarget;
  83237. private _property;
  83238. /**
  83239. * Instantiate the action
  83240. * @param triggerOptions defines the trigger options
  83241. * @param target defines the object containing the property
  83242. * @param propertyPath defines the path of the property to set in the target
  83243. * @param value defines the value to set in the property
  83244. * @param condition defines the trigger related conditions
  83245. */
  83246. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83247. /** @hidden */
  83248. _prepare(): void;
  83249. /**
  83250. * Execute the action and set the targetted property to the desired value.
  83251. */
  83252. execute(): void;
  83253. /**
  83254. * Serializes the actions and its related information.
  83255. * @param parent defines the object to serialize in
  83256. * @returns the serialized object
  83257. */
  83258. serialize(parent: any): any;
  83259. }
  83260. /**
  83261. * This defines an action responsible to increment the target value
  83262. * to a desired value once triggered.
  83263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83264. */
  83265. export class IncrementValueAction extends Action {
  83266. /**
  83267. * The path of the property to increment in the target.
  83268. */
  83269. propertyPath: string;
  83270. /**
  83271. * The value we should increment the property by.
  83272. */
  83273. value: any;
  83274. private _target;
  83275. private _effectiveTarget;
  83276. private _property;
  83277. /**
  83278. * Instantiate the action
  83279. * @param triggerOptions defines the trigger options
  83280. * @param target defines the object containing the property
  83281. * @param propertyPath defines the path of the property to increment in the target
  83282. * @param value defines the value value we should increment the property by
  83283. * @param condition defines the trigger related conditions
  83284. */
  83285. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83286. /** @hidden */
  83287. _prepare(): void;
  83288. /**
  83289. * Execute the action and increment the target of the value amount.
  83290. */
  83291. execute(): void;
  83292. /**
  83293. * Serializes the actions and its related information.
  83294. * @param parent defines the object to serialize in
  83295. * @returns the serialized object
  83296. */
  83297. serialize(parent: any): any;
  83298. }
  83299. /**
  83300. * This defines an action responsible to start an animation once triggered.
  83301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83302. */
  83303. export class PlayAnimationAction extends Action {
  83304. /**
  83305. * Where the animation should start (animation frame)
  83306. */
  83307. from: number;
  83308. /**
  83309. * Where the animation should stop (animation frame)
  83310. */
  83311. to: number;
  83312. /**
  83313. * Define if the animation should loop or stop after the first play.
  83314. */
  83315. loop?: boolean;
  83316. private _target;
  83317. /**
  83318. * Instantiate the action
  83319. * @param triggerOptions defines the trigger options
  83320. * @param target defines the target animation or animation name
  83321. * @param from defines from where the animation should start (animation frame)
  83322. * @param end defines where the animation should stop (animation frame)
  83323. * @param loop defines if the animation should loop or stop after the first play
  83324. * @param condition defines the trigger related conditions
  83325. */
  83326. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  83327. /** @hidden */
  83328. _prepare(): void;
  83329. /**
  83330. * Execute the action and play the animation.
  83331. */
  83332. execute(): void;
  83333. /**
  83334. * Serializes the actions and its related information.
  83335. * @param parent defines the object to serialize in
  83336. * @returns the serialized object
  83337. */
  83338. serialize(parent: any): any;
  83339. }
  83340. /**
  83341. * This defines an action responsible to stop an animation once triggered.
  83342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83343. */
  83344. export class StopAnimationAction extends Action {
  83345. private _target;
  83346. /**
  83347. * Instantiate the action
  83348. * @param triggerOptions defines the trigger options
  83349. * @param target defines the target animation or animation name
  83350. * @param condition defines the trigger related conditions
  83351. */
  83352. constructor(triggerOptions: any, target: any, condition?: Condition);
  83353. /** @hidden */
  83354. _prepare(): void;
  83355. /**
  83356. * Execute the action and stop the animation.
  83357. */
  83358. execute(): void;
  83359. /**
  83360. * Serializes the actions and its related information.
  83361. * @param parent defines the object to serialize in
  83362. * @returns the serialized object
  83363. */
  83364. serialize(parent: any): any;
  83365. }
  83366. /**
  83367. * This defines an action responsible that does nothing once triggered.
  83368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83369. */
  83370. export class DoNothingAction extends Action {
  83371. /**
  83372. * Instantiate the action
  83373. * @param triggerOptions defines the trigger options
  83374. * @param condition defines the trigger related conditions
  83375. */
  83376. constructor(triggerOptions?: any, condition?: Condition);
  83377. /**
  83378. * Execute the action and do nothing.
  83379. */
  83380. execute(): void;
  83381. /**
  83382. * Serializes the actions and its related information.
  83383. * @param parent defines the object to serialize in
  83384. * @returns the serialized object
  83385. */
  83386. serialize(parent: any): any;
  83387. }
  83388. /**
  83389. * This defines an action responsible to trigger several actions once triggered.
  83390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83391. */
  83392. export class CombineAction extends Action {
  83393. /**
  83394. * The list of aggregated animations to run.
  83395. */
  83396. children: Action[];
  83397. /**
  83398. * Instantiate the action
  83399. * @param triggerOptions defines the trigger options
  83400. * @param children defines the list of aggregated animations to run
  83401. * @param condition defines the trigger related conditions
  83402. */
  83403. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  83404. /** @hidden */
  83405. _prepare(): void;
  83406. /**
  83407. * Execute the action and executes all the aggregated actions.
  83408. */
  83409. execute(evt: ActionEvent): void;
  83410. /**
  83411. * Serializes the actions and its related information.
  83412. * @param parent defines the object to serialize in
  83413. * @returns the serialized object
  83414. */
  83415. serialize(parent: any): any;
  83416. }
  83417. /**
  83418. * This defines an action responsible to run code (external event) once triggered.
  83419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83420. */
  83421. export class ExecuteCodeAction extends Action {
  83422. /**
  83423. * The callback function to run.
  83424. */
  83425. func: (evt: ActionEvent) => void;
  83426. /**
  83427. * Instantiate the action
  83428. * @param triggerOptions defines the trigger options
  83429. * @param func defines the callback function to run
  83430. * @param condition defines the trigger related conditions
  83431. */
  83432. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  83433. /**
  83434. * Execute the action and run the attached code.
  83435. */
  83436. execute(evt: ActionEvent): void;
  83437. }
  83438. /**
  83439. * This defines an action responsible to set the parent property of the target once triggered.
  83440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83441. */
  83442. export class SetParentAction extends Action {
  83443. private _parent;
  83444. private _target;
  83445. /**
  83446. * Instantiate the action
  83447. * @param triggerOptions defines the trigger options
  83448. * @param target defines the target containing the parent property
  83449. * @param parent defines from where the animation should start (animation frame)
  83450. * @param condition defines the trigger related conditions
  83451. */
  83452. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  83453. /** @hidden */
  83454. _prepare(): void;
  83455. /**
  83456. * Execute the action and set the parent property.
  83457. */
  83458. execute(): void;
  83459. /**
  83460. * Serializes the actions and its related information.
  83461. * @param parent defines the object to serialize in
  83462. * @returns the serialized object
  83463. */
  83464. serialize(parent: any): any;
  83465. }
  83466. }
  83467. declare module BABYLON {
  83468. /**
  83469. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  83470. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  83471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83472. */
  83473. export class ActionManager extends AbstractActionManager {
  83474. /**
  83475. * Nothing
  83476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83477. */
  83478. static readonly NothingTrigger: number;
  83479. /**
  83480. * On pick
  83481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83482. */
  83483. static readonly OnPickTrigger: number;
  83484. /**
  83485. * On left pick
  83486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83487. */
  83488. static readonly OnLeftPickTrigger: number;
  83489. /**
  83490. * On right pick
  83491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83492. */
  83493. static readonly OnRightPickTrigger: number;
  83494. /**
  83495. * On center pick
  83496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83497. */
  83498. static readonly OnCenterPickTrigger: number;
  83499. /**
  83500. * On pick down
  83501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83502. */
  83503. static readonly OnPickDownTrigger: number;
  83504. /**
  83505. * On double pick
  83506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83507. */
  83508. static readonly OnDoublePickTrigger: number;
  83509. /**
  83510. * On pick up
  83511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83512. */
  83513. static readonly OnPickUpTrigger: number;
  83514. /**
  83515. * On pick out.
  83516. * This trigger will only be raised if you also declared a OnPickDown
  83517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83518. */
  83519. static readonly OnPickOutTrigger: number;
  83520. /**
  83521. * On long press
  83522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83523. */
  83524. static readonly OnLongPressTrigger: number;
  83525. /**
  83526. * On pointer over
  83527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83528. */
  83529. static readonly OnPointerOverTrigger: number;
  83530. /**
  83531. * On pointer out
  83532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83533. */
  83534. static readonly OnPointerOutTrigger: number;
  83535. /**
  83536. * On every frame
  83537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83538. */
  83539. static readonly OnEveryFrameTrigger: number;
  83540. /**
  83541. * On intersection enter
  83542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83543. */
  83544. static readonly OnIntersectionEnterTrigger: number;
  83545. /**
  83546. * On intersection exit
  83547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83548. */
  83549. static readonly OnIntersectionExitTrigger: number;
  83550. /**
  83551. * On key down
  83552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83553. */
  83554. static readonly OnKeyDownTrigger: number;
  83555. /**
  83556. * On key up
  83557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83558. */
  83559. static readonly OnKeyUpTrigger: number;
  83560. private _scene;
  83561. /**
  83562. * Creates a new action manager
  83563. * @param scene defines the hosting scene
  83564. */
  83565. constructor(scene: Scene);
  83566. /**
  83567. * Releases all associated resources
  83568. */
  83569. dispose(): void;
  83570. /**
  83571. * Gets hosting scene
  83572. * @returns the hosting scene
  83573. */
  83574. getScene(): Scene;
  83575. /**
  83576. * Does this action manager handles actions of any of the given triggers
  83577. * @param triggers defines the triggers to be tested
  83578. * @return a boolean indicating whether one (or more) of the triggers is handled
  83579. */
  83580. hasSpecificTriggers(triggers: number[]): boolean;
  83581. /**
  83582. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83583. * speed.
  83584. * @param triggerA defines the trigger to be tested
  83585. * @param triggerB defines the trigger to be tested
  83586. * @return a boolean indicating whether one (or more) of the triggers is handled
  83587. */
  83588. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83589. /**
  83590. * Does this action manager handles actions of a given trigger
  83591. * @param trigger defines the trigger to be tested
  83592. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83593. * @return whether the trigger is handled
  83594. */
  83595. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83596. /**
  83597. * Does this action manager has pointer triggers
  83598. */
  83599. get hasPointerTriggers(): boolean;
  83600. /**
  83601. * Does this action manager has pick triggers
  83602. */
  83603. get hasPickTriggers(): boolean;
  83604. /**
  83605. * Registers an action to this action manager
  83606. * @param action defines the action to be registered
  83607. * @return the action amended (prepared) after registration
  83608. */
  83609. registerAction(action: IAction): Nullable<IAction>;
  83610. /**
  83611. * Unregisters an action to this action manager
  83612. * @param action defines the action to be unregistered
  83613. * @return a boolean indicating whether the action has been unregistered
  83614. */
  83615. unregisterAction(action: IAction): Boolean;
  83616. /**
  83617. * Process a specific trigger
  83618. * @param trigger defines the trigger to process
  83619. * @param evt defines the event details to be processed
  83620. */
  83621. processTrigger(trigger: number, evt?: IActionEvent): void;
  83622. /** @hidden */
  83623. _getEffectiveTarget(target: any, propertyPath: string): any;
  83624. /** @hidden */
  83625. _getProperty(propertyPath: string): string;
  83626. /**
  83627. * Serialize this manager to a JSON object
  83628. * @param name defines the property name to store this manager
  83629. * @returns a JSON representation of this manager
  83630. */
  83631. serialize(name: string): any;
  83632. /**
  83633. * Creates a new ActionManager from a JSON data
  83634. * @param parsedActions defines the JSON data to read from
  83635. * @param object defines the hosting mesh
  83636. * @param scene defines the hosting scene
  83637. */
  83638. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  83639. /**
  83640. * Get a trigger name by index
  83641. * @param trigger defines the trigger index
  83642. * @returns a trigger name
  83643. */
  83644. static GetTriggerName(trigger: number): string;
  83645. }
  83646. }
  83647. declare module BABYLON {
  83648. /**
  83649. * Class representing a ray with position and direction
  83650. */
  83651. export class Ray {
  83652. /** origin point */
  83653. origin: Vector3;
  83654. /** direction */
  83655. direction: Vector3;
  83656. /** length of the ray */
  83657. length: number;
  83658. private static readonly TmpVector3;
  83659. private _tmpRay;
  83660. /**
  83661. * Creates a new ray
  83662. * @param origin origin point
  83663. * @param direction direction
  83664. * @param length length of the ray
  83665. */
  83666. constructor(
  83667. /** origin point */
  83668. origin: Vector3,
  83669. /** direction */
  83670. direction: Vector3,
  83671. /** length of the ray */
  83672. length?: number);
  83673. /**
  83674. * Checks if the ray intersects a box
  83675. * @param minimum bound of the box
  83676. * @param maximum bound of the box
  83677. * @param intersectionTreshold extra extend to be added to the box in all direction
  83678. * @returns if the box was hit
  83679. */
  83680. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83681. /**
  83682. * Checks if the ray intersects a box
  83683. * @param box the bounding box to check
  83684. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83685. * @returns if the box was hit
  83686. */
  83687. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83688. /**
  83689. * If the ray hits a sphere
  83690. * @param sphere the bounding sphere to check
  83691. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83692. * @returns true if it hits the sphere
  83693. */
  83694. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83695. /**
  83696. * If the ray hits a triange
  83697. * @param vertex0 triangle vertex
  83698. * @param vertex1 triangle vertex
  83699. * @param vertex2 triangle vertex
  83700. * @returns intersection information if hit
  83701. */
  83702. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83703. /**
  83704. * Checks if ray intersects a plane
  83705. * @param plane the plane to check
  83706. * @returns the distance away it was hit
  83707. */
  83708. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83709. /**
  83710. * Calculate the intercept of a ray on a given axis
  83711. * @param axis to check 'x' | 'y' | 'z'
  83712. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83713. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83714. */
  83715. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83716. /**
  83717. * Checks if ray intersects a mesh
  83718. * @param mesh the mesh to check
  83719. * @param fastCheck if only the bounding box should checked
  83720. * @returns picking info of the intersecton
  83721. */
  83722. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83723. /**
  83724. * Checks if ray intersects a mesh
  83725. * @param meshes the meshes to check
  83726. * @param fastCheck if only the bounding box should checked
  83727. * @param results array to store result in
  83728. * @returns Array of picking infos
  83729. */
  83730. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83731. private _comparePickingInfo;
  83732. private static smallnum;
  83733. private static rayl;
  83734. /**
  83735. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83736. * @param sega the first point of the segment to test the intersection against
  83737. * @param segb the second point of the segment to test the intersection against
  83738. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83739. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83740. */
  83741. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83742. /**
  83743. * Update the ray from viewport position
  83744. * @param x position
  83745. * @param y y position
  83746. * @param viewportWidth viewport width
  83747. * @param viewportHeight viewport height
  83748. * @param world world matrix
  83749. * @param view view matrix
  83750. * @param projection projection matrix
  83751. * @returns this ray updated
  83752. */
  83753. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83754. /**
  83755. * Creates a ray with origin and direction of 0,0,0
  83756. * @returns the new ray
  83757. */
  83758. static Zero(): Ray;
  83759. /**
  83760. * Creates a new ray from screen space and viewport
  83761. * @param x position
  83762. * @param y y position
  83763. * @param viewportWidth viewport width
  83764. * @param viewportHeight viewport height
  83765. * @param world world matrix
  83766. * @param view view matrix
  83767. * @param projection projection matrix
  83768. * @returns new ray
  83769. */
  83770. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83771. /**
  83772. * 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
  83773. * transformed to the given world matrix.
  83774. * @param origin The origin point
  83775. * @param end The end point
  83776. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83777. * @returns the new ray
  83778. */
  83779. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83780. /**
  83781. * Transforms a ray by a matrix
  83782. * @param ray ray to transform
  83783. * @param matrix matrix to apply
  83784. * @returns the resulting new ray
  83785. */
  83786. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83787. /**
  83788. * Transforms a ray by a matrix
  83789. * @param ray ray to transform
  83790. * @param matrix matrix to apply
  83791. * @param result ray to store result in
  83792. */
  83793. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83794. /**
  83795. * Unproject a ray from screen space to object space
  83796. * @param sourceX defines the screen space x coordinate to use
  83797. * @param sourceY defines the screen space y coordinate to use
  83798. * @param viewportWidth defines the current width of the viewport
  83799. * @param viewportHeight defines the current height of the viewport
  83800. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83801. * @param view defines the view matrix to use
  83802. * @param projection defines the projection matrix to use
  83803. */
  83804. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83805. }
  83806. /**
  83807. * Type used to define predicate used to select faces when a mesh intersection is detected
  83808. */
  83809. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83810. interface Scene {
  83811. /** @hidden */
  83812. _tempPickingRay: Nullable<Ray>;
  83813. /** @hidden */
  83814. _cachedRayForTransform: Ray;
  83815. /** @hidden */
  83816. _pickWithRayInverseMatrix: Matrix;
  83817. /** @hidden */
  83818. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83819. /** @hidden */
  83820. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83821. }
  83822. }
  83823. declare module BABYLON {
  83824. /**
  83825. * Groups all the scene component constants in one place to ease maintenance.
  83826. * @hidden
  83827. */
  83828. export class SceneComponentConstants {
  83829. static readonly NAME_EFFECTLAYER: string;
  83830. static readonly NAME_LAYER: string;
  83831. static readonly NAME_LENSFLARESYSTEM: string;
  83832. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83833. static readonly NAME_PARTICLESYSTEM: string;
  83834. static readonly NAME_GAMEPAD: string;
  83835. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83836. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83837. static readonly NAME_DEPTHRENDERER: string;
  83838. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83839. static readonly NAME_SPRITE: string;
  83840. static readonly NAME_OUTLINERENDERER: string;
  83841. static readonly NAME_PROCEDURALTEXTURE: string;
  83842. static readonly NAME_SHADOWGENERATOR: string;
  83843. static readonly NAME_OCTREE: string;
  83844. static readonly NAME_PHYSICSENGINE: string;
  83845. static readonly NAME_AUDIO: string;
  83846. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83847. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83848. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83849. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83850. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83851. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83852. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83853. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83854. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83855. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83856. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83857. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83858. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83859. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83860. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83861. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83862. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83863. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83864. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83865. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83866. static readonly STEP_AFTERRENDER_AUDIO: number;
  83867. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83868. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83869. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83870. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83871. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83872. static readonly STEP_POINTERMOVE_SPRITE: number;
  83873. static readonly STEP_POINTERDOWN_SPRITE: number;
  83874. static readonly STEP_POINTERUP_SPRITE: number;
  83875. }
  83876. /**
  83877. * This represents a scene component.
  83878. *
  83879. * This is used to decouple the dependency the scene is having on the different workloads like
  83880. * layers, post processes...
  83881. */
  83882. export interface ISceneComponent {
  83883. /**
  83884. * The name of the component. Each component must have a unique name.
  83885. */
  83886. name: string;
  83887. /**
  83888. * The scene the component belongs to.
  83889. */
  83890. scene: Scene;
  83891. /**
  83892. * Register the component to one instance of a scene.
  83893. */
  83894. register(): void;
  83895. /**
  83896. * Rebuilds the elements related to this component in case of
  83897. * context lost for instance.
  83898. */
  83899. rebuild(): void;
  83900. /**
  83901. * Disposes the component and the associated ressources.
  83902. */
  83903. dispose(): void;
  83904. }
  83905. /**
  83906. * This represents a SERIALIZABLE scene component.
  83907. *
  83908. * This extends Scene Component to add Serialization methods on top.
  83909. */
  83910. export interface ISceneSerializableComponent extends ISceneComponent {
  83911. /**
  83912. * Adds all the elements from the container to the scene
  83913. * @param container the container holding the elements
  83914. */
  83915. addFromContainer(container: AbstractScene): void;
  83916. /**
  83917. * Removes all the elements in the container from the scene
  83918. * @param container contains the elements to remove
  83919. * @param dispose if the removed element should be disposed (default: false)
  83920. */
  83921. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83922. /**
  83923. * Serializes the component data to the specified json object
  83924. * @param serializationObject The object to serialize to
  83925. */
  83926. serialize(serializationObject: any): void;
  83927. }
  83928. /**
  83929. * Strong typing of a Mesh related stage step action
  83930. */
  83931. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83932. /**
  83933. * Strong typing of a Evaluate Sub Mesh related stage step action
  83934. */
  83935. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83936. /**
  83937. * Strong typing of a Active Mesh related stage step action
  83938. */
  83939. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83940. /**
  83941. * Strong typing of a Camera related stage step action
  83942. */
  83943. export type CameraStageAction = (camera: Camera) => void;
  83944. /**
  83945. * Strong typing of a Camera Frame buffer related stage step action
  83946. */
  83947. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83948. /**
  83949. * Strong typing of a Render Target related stage step action
  83950. */
  83951. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83952. /**
  83953. * Strong typing of a RenderingGroup related stage step action
  83954. */
  83955. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83956. /**
  83957. * Strong typing of a Mesh Render related stage step action
  83958. */
  83959. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83960. /**
  83961. * Strong typing of a simple stage step action
  83962. */
  83963. export type SimpleStageAction = () => void;
  83964. /**
  83965. * Strong typing of a render target action.
  83966. */
  83967. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83968. /**
  83969. * Strong typing of a pointer move action.
  83970. */
  83971. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83972. /**
  83973. * Strong typing of a pointer up/down action.
  83974. */
  83975. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83976. /**
  83977. * Representation of a stage in the scene (Basically a list of ordered steps)
  83978. * @hidden
  83979. */
  83980. export class Stage<T extends Function> extends Array<{
  83981. index: number;
  83982. component: ISceneComponent;
  83983. action: T;
  83984. }> {
  83985. /**
  83986. * Hide ctor from the rest of the world.
  83987. * @param items The items to add.
  83988. */
  83989. private constructor();
  83990. /**
  83991. * Creates a new Stage.
  83992. * @returns A new instance of a Stage
  83993. */
  83994. static Create<T extends Function>(): Stage<T>;
  83995. /**
  83996. * Registers a step in an ordered way in the targeted stage.
  83997. * @param index Defines the position to register the step in
  83998. * @param component Defines the component attached to the step
  83999. * @param action Defines the action to launch during the step
  84000. */
  84001. registerStep(index: number, component: ISceneComponent, action: T): void;
  84002. /**
  84003. * Clears all the steps from the stage.
  84004. */
  84005. clear(): void;
  84006. }
  84007. }
  84008. declare module BABYLON {
  84009. interface Scene {
  84010. /** @hidden */
  84011. _pointerOverSprite: Nullable<Sprite>;
  84012. /** @hidden */
  84013. _pickedDownSprite: Nullable<Sprite>;
  84014. /** @hidden */
  84015. _tempSpritePickingRay: Nullable<Ray>;
  84016. /**
  84017. * All of the sprite managers added to this scene
  84018. * @see http://doc.babylonjs.com/babylon101/sprites
  84019. */
  84020. spriteManagers: Array<ISpriteManager>;
  84021. /**
  84022. * An event triggered when sprites rendering is about to start
  84023. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84024. */
  84025. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84026. /**
  84027. * An event triggered when sprites rendering is done
  84028. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84029. */
  84030. onAfterSpritesRenderingObservable: Observable<Scene>;
  84031. /** @hidden */
  84032. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84033. /** Launch a ray to try to pick a sprite in the scene
  84034. * @param x position on screen
  84035. * @param y position on screen
  84036. * @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
  84037. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84038. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84039. * @returns a PickingInfo
  84040. */
  84041. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84042. /** Use the given ray to pick a sprite in the scene
  84043. * @param ray The ray (in world space) to use to pick meshes
  84044. * @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
  84045. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84046. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84047. * @returns a PickingInfo
  84048. */
  84049. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84050. /** @hidden */
  84051. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84052. /** Launch a ray to try to pick sprites in the scene
  84053. * @param x position on screen
  84054. * @param y position on screen
  84055. * @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
  84056. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84057. * @returns a PickingInfo array
  84058. */
  84059. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84060. /** Use the given ray to pick sprites in the scene
  84061. * @param ray The ray (in world space) to use to pick meshes
  84062. * @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
  84063. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84064. * @returns a PickingInfo array
  84065. */
  84066. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84067. /**
  84068. * Force the sprite under the pointer
  84069. * @param sprite defines the sprite to use
  84070. */
  84071. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84072. /**
  84073. * Gets the sprite under the pointer
  84074. * @returns a Sprite or null if no sprite is under the pointer
  84075. */
  84076. getPointerOverSprite(): Nullable<Sprite>;
  84077. }
  84078. /**
  84079. * Defines the sprite scene component responsible to manage sprites
  84080. * in a given scene.
  84081. */
  84082. export class SpriteSceneComponent implements ISceneComponent {
  84083. /**
  84084. * The component name helpfull to identify the component in the list of scene components.
  84085. */
  84086. readonly name: string;
  84087. /**
  84088. * The scene the component belongs to.
  84089. */
  84090. scene: Scene;
  84091. /** @hidden */
  84092. private _spritePredicate;
  84093. /**
  84094. * Creates a new instance of the component for the given scene
  84095. * @param scene Defines the scene to register the component in
  84096. */
  84097. constructor(scene: Scene);
  84098. /**
  84099. * Registers the component in a given scene
  84100. */
  84101. register(): void;
  84102. /**
  84103. * Rebuilds the elements related to this component in case of
  84104. * context lost for instance.
  84105. */
  84106. rebuild(): void;
  84107. /**
  84108. * Disposes the component and the associated ressources.
  84109. */
  84110. dispose(): void;
  84111. private _pickSpriteButKeepRay;
  84112. private _pointerMove;
  84113. private _pointerDown;
  84114. private _pointerUp;
  84115. }
  84116. }
  84117. declare module BABYLON {
  84118. /** @hidden */
  84119. export var fogFragmentDeclaration: {
  84120. name: string;
  84121. shader: string;
  84122. };
  84123. }
  84124. declare module BABYLON {
  84125. /** @hidden */
  84126. export var fogFragment: {
  84127. name: string;
  84128. shader: string;
  84129. };
  84130. }
  84131. declare module BABYLON {
  84132. /** @hidden */
  84133. export var spritesPixelShader: {
  84134. name: string;
  84135. shader: string;
  84136. };
  84137. }
  84138. declare module BABYLON {
  84139. /** @hidden */
  84140. export var fogVertexDeclaration: {
  84141. name: string;
  84142. shader: string;
  84143. };
  84144. }
  84145. declare module BABYLON {
  84146. /** @hidden */
  84147. export var spritesVertexShader: {
  84148. name: string;
  84149. shader: string;
  84150. };
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84155. */
  84156. export interface ISpriteManager extends IDisposable {
  84157. /**
  84158. * Restricts the camera to viewing objects with the same layerMask.
  84159. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84160. */
  84161. layerMask: number;
  84162. /**
  84163. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84164. */
  84165. isPickable: boolean;
  84166. /**
  84167. * Specifies the rendering group id for this mesh (0 by default)
  84168. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84169. */
  84170. renderingGroupId: number;
  84171. /**
  84172. * Defines the list of sprites managed by the manager.
  84173. */
  84174. sprites: Array<Sprite>;
  84175. /**
  84176. * Tests the intersection of a sprite with a specific ray.
  84177. * @param ray The ray we are sending to test the collision
  84178. * @param camera The camera space we are sending rays in
  84179. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84180. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84181. * @returns picking info or null.
  84182. */
  84183. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84184. /**
  84185. * Intersects the sprites with a ray
  84186. * @param ray defines the ray to intersect with
  84187. * @param camera defines the current active camera
  84188. * @param predicate defines a predicate used to select candidate sprites
  84189. * @returns null if no hit or a PickingInfo array
  84190. */
  84191. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84192. /**
  84193. * Renders the list of sprites on screen.
  84194. */
  84195. render(): void;
  84196. }
  84197. /**
  84198. * Class used to manage multiple sprites on the same spritesheet
  84199. * @see http://doc.babylonjs.com/babylon101/sprites
  84200. */
  84201. export class SpriteManager implements ISpriteManager {
  84202. /** defines the manager's name */
  84203. name: string;
  84204. /** Gets the list of sprites */
  84205. sprites: Sprite[];
  84206. /** Gets or sets the rendering group id (0 by default) */
  84207. renderingGroupId: number;
  84208. /** Gets or sets camera layer mask */
  84209. layerMask: number;
  84210. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84211. fogEnabled: boolean;
  84212. /** Gets or sets a boolean indicating if the sprites are pickable */
  84213. isPickable: boolean;
  84214. /** Defines the default width of a cell in the spritesheet */
  84215. cellWidth: number;
  84216. /** Defines the default height of a cell in the spritesheet */
  84217. cellHeight: number;
  84218. /** Associative array from JSON sprite data file */
  84219. private _cellData;
  84220. /** Array of sprite names from JSON sprite data file */
  84221. private _spriteMap;
  84222. /** True when packed cell data from JSON file is ready*/
  84223. private _packedAndReady;
  84224. /**
  84225. * An event triggered when the manager is disposed.
  84226. */
  84227. onDisposeObservable: Observable<SpriteManager>;
  84228. private _onDisposeObserver;
  84229. /**
  84230. * Callback called when the manager is disposed
  84231. */
  84232. set onDispose(callback: () => void);
  84233. private _capacity;
  84234. private _fromPacked;
  84235. private _spriteTexture;
  84236. private _epsilon;
  84237. private _scene;
  84238. private _vertexData;
  84239. private _buffer;
  84240. private _vertexBuffers;
  84241. private _indexBuffer;
  84242. private _effectBase;
  84243. private _effectFog;
  84244. /**
  84245. * Gets or sets the spritesheet texture
  84246. */
  84247. get texture(): Texture;
  84248. set texture(value: Texture);
  84249. /**
  84250. * Creates a new sprite manager
  84251. * @param name defines the manager's name
  84252. * @param imgUrl defines the sprite sheet url
  84253. * @param capacity defines the maximum allowed number of sprites
  84254. * @param cellSize defines the size of a sprite cell
  84255. * @param scene defines the hosting scene
  84256. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84257. * @param samplingMode defines the smapling mode to use with spritesheet
  84258. * @param fromPacked set to false; do not alter
  84259. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84260. */
  84261. constructor(
  84262. /** defines the manager's name */
  84263. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84264. private _makePacked;
  84265. private _appendSpriteVertex;
  84266. /**
  84267. * Intersects the sprites with a ray
  84268. * @param ray defines the ray to intersect with
  84269. * @param camera defines the current active camera
  84270. * @param predicate defines a predicate used to select candidate sprites
  84271. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84272. * @returns null if no hit or a PickingInfo
  84273. */
  84274. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84275. /**
  84276. * Intersects the sprites with a ray
  84277. * @param ray defines the ray to intersect with
  84278. * @param camera defines the current active camera
  84279. * @param predicate defines a predicate used to select candidate sprites
  84280. * @returns null if no hit or a PickingInfo array
  84281. */
  84282. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84283. /**
  84284. * Render all child sprites
  84285. */
  84286. render(): void;
  84287. /**
  84288. * Release associated resources
  84289. */
  84290. dispose(): void;
  84291. }
  84292. }
  84293. declare module BABYLON {
  84294. /**
  84295. * Class used to represent a sprite
  84296. * @see http://doc.babylonjs.com/babylon101/sprites
  84297. */
  84298. export class Sprite {
  84299. /** defines the name */
  84300. name: string;
  84301. /** Gets or sets the current world position */
  84302. position: Vector3;
  84303. /** Gets or sets the main color */
  84304. color: Color4;
  84305. /** Gets or sets the width */
  84306. width: number;
  84307. /** Gets or sets the height */
  84308. height: number;
  84309. /** Gets or sets rotation angle */
  84310. angle: number;
  84311. /** Gets or sets the cell index in the sprite sheet */
  84312. cellIndex: number;
  84313. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  84314. cellRef: string;
  84315. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  84316. invertU: number;
  84317. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  84318. invertV: number;
  84319. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  84320. disposeWhenFinishedAnimating: boolean;
  84321. /** Gets the list of attached animations */
  84322. animations: Animation[];
  84323. /** Gets or sets a boolean indicating if the sprite can be picked */
  84324. isPickable: boolean;
  84325. /**
  84326. * Gets or sets the associated action manager
  84327. */
  84328. actionManager: Nullable<ActionManager>;
  84329. private _animationStarted;
  84330. private _loopAnimation;
  84331. private _fromIndex;
  84332. private _toIndex;
  84333. private _delay;
  84334. private _direction;
  84335. private _manager;
  84336. private _time;
  84337. private _onAnimationEnd;
  84338. /**
  84339. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  84340. */
  84341. isVisible: boolean;
  84342. /**
  84343. * Gets or sets the sprite size
  84344. */
  84345. get size(): number;
  84346. set size(value: number);
  84347. /**
  84348. * Creates a new Sprite
  84349. * @param name defines the name
  84350. * @param manager defines the manager
  84351. */
  84352. constructor(
  84353. /** defines the name */
  84354. name: string, manager: ISpriteManager);
  84355. /**
  84356. * Starts an animation
  84357. * @param from defines the initial key
  84358. * @param to defines the end key
  84359. * @param loop defines if the animation must loop
  84360. * @param delay defines the start delay (in ms)
  84361. * @param onAnimationEnd defines a callback to call when animation ends
  84362. */
  84363. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  84364. /** Stops current animation (if any) */
  84365. stopAnimation(): void;
  84366. /** @hidden */
  84367. _animate(deltaTime: number): void;
  84368. /** Release associated resources */
  84369. dispose(): void;
  84370. }
  84371. }
  84372. declare module BABYLON {
  84373. /**
  84374. * Information about the result of picking within a scene
  84375. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  84376. */
  84377. export class PickingInfo {
  84378. /** @hidden */
  84379. _pickingUnavailable: boolean;
  84380. /**
  84381. * If the pick collided with an object
  84382. */
  84383. hit: boolean;
  84384. /**
  84385. * Distance away where the pick collided
  84386. */
  84387. distance: number;
  84388. /**
  84389. * The location of pick collision
  84390. */
  84391. pickedPoint: Nullable<Vector3>;
  84392. /**
  84393. * The mesh corresponding the the pick collision
  84394. */
  84395. pickedMesh: Nullable<AbstractMesh>;
  84396. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  84397. bu: number;
  84398. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  84399. bv: number;
  84400. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  84401. faceId: number;
  84402. /** Id of the the submesh that was picked */
  84403. subMeshId: number;
  84404. /** If a sprite was picked, this will be the sprite the pick collided with */
  84405. pickedSprite: Nullable<Sprite>;
  84406. /**
  84407. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  84408. */
  84409. originMesh: Nullable<AbstractMesh>;
  84410. /**
  84411. * The ray that was used to perform the picking.
  84412. */
  84413. ray: Nullable<Ray>;
  84414. /**
  84415. * Gets the normal correspodning to the face the pick collided with
  84416. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  84417. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  84418. * @returns The normal correspodning to the face the pick collided with
  84419. */
  84420. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  84421. /**
  84422. * Gets the texture coordinates of where the pick occured
  84423. * @returns the vector containing the coordnates of the texture
  84424. */
  84425. getTextureCoordinates(): Nullable<Vector2>;
  84426. }
  84427. }
  84428. declare module BABYLON {
  84429. /**
  84430. * Gather the list of pointer event types as constants.
  84431. */
  84432. export class PointerEventTypes {
  84433. /**
  84434. * 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.
  84435. */
  84436. static readonly POINTERDOWN: number;
  84437. /**
  84438. * The pointerup event is fired when a pointer is no longer active.
  84439. */
  84440. static readonly POINTERUP: number;
  84441. /**
  84442. * The pointermove event is fired when a pointer changes coordinates.
  84443. */
  84444. static readonly POINTERMOVE: number;
  84445. /**
  84446. * The pointerwheel event is fired when a mouse wheel has been rotated.
  84447. */
  84448. static readonly POINTERWHEEL: number;
  84449. /**
  84450. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  84451. */
  84452. static readonly POINTERPICK: number;
  84453. /**
  84454. * The pointertap event is fired when a the object has been touched and released without drag.
  84455. */
  84456. static readonly POINTERTAP: number;
  84457. /**
  84458. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  84459. */
  84460. static readonly POINTERDOUBLETAP: number;
  84461. }
  84462. /**
  84463. * Base class of pointer info types.
  84464. */
  84465. export class PointerInfoBase {
  84466. /**
  84467. * Defines the type of event (PointerEventTypes)
  84468. */
  84469. type: number;
  84470. /**
  84471. * Defines the related dom event
  84472. */
  84473. event: PointerEvent | MouseWheelEvent;
  84474. /**
  84475. * Instantiates the base class of pointers info.
  84476. * @param type Defines the type of event (PointerEventTypes)
  84477. * @param event Defines the related dom event
  84478. */
  84479. constructor(
  84480. /**
  84481. * Defines the type of event (PointerEventTypes)
  84482. */
  84483. type: number,
  84484. /**
  84485. * Defines the related dom event
  84486. */
  84487. event: PointerEvent | MouseWheelEvent);
  84488. }
  84489. /**
  84490. * This class is used to store pointer related info for the onPrePointerObservable event.
  84491. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  84492. */
  84493. export class PointerInfoPre extends PointerInfoBase {
  84494. /**
  84495. * Ray from a pointer if availible (eg. 6dof controller)
  84496. */
  84497. ray: Nullable<Ray>;
  84498. /**
  84499. * Defines the local position of the pointer on the canvas.
  84500. */
  84501. localPosition: Vector2;
  84502. /**
  84503. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  84504. */
  84505. skipOnPointerObservable: boolean;
  84506. /**
  84507. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  84508. * @param type Defines the type of event (PointerEventTypes)
  84509. * @param event Defines the related dom event
  84510. * @param localX Defines the local x coordinates of the pointer when the event occured
  84511. * @param localY Defines the local y coordinates of the pointer when the event occured
  84512. */
  84513. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  84514. }
  84515. /**
  84516. * This type contains all the data related to a pointer event in Babylon.js.
  84517. * 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.
  84518. */
  84519. export class PointerInfo extends PointerInfoBase {
  84520. /**
  84521. * Defines the picking info associated to the info (if any)\
  84522. */
  84523. pickInfo: Nullable<PickingInfo>;
  84524. /**
  84525. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  84526. * @param type Defines the type of event (PointerEventTypes)
  84527. * @param event Defines the related dom event
  84528. * @param pickInfo Defines the picking info associated to the info (if any)\
  84529. */
  84530. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  84531. /**
  84532. * Defines the picking info associated to the info (if any)\
  84533. */
  84534. pickInfo: Nullable<PickingInfo>);
  84535. }
  84536. /**
  84537. * Data relating to a touch event on the screen.
  84538. */
  84539. export interface PointerTouch {
  84540. /**
  84541. * X coordinate of touch.
  84542. */
  84543. x: number;
  84544. /**
  84545. * Y coordinate of touch.
  84546. */
  84547. y: number;
  84548. /**
  84549. * Id of touch. Unique for each finger.
  84550. */
  84551. pointerId: number;
  84552. /**
  84553. * Event type passed from DOM.
  84554. */
  84555. type: any;
  84556. }
  84557. }
  84558. declare module BABYLON {
  84559. /**
  84560. * Manage the mouse inputs to control the movement of a free camera.
  84561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84562. */
  84563. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  84564. /**
  84565. * Define if touch is enabled in the mouse input
  84566. */
  84567. touchEnabled: boolean;
  84568. /**
  84569. * Defines the camera the input is attached to.
  84570. */
  84571. camera: FreeCamera;
  84572. /**
  84573. * Defines the buttons associated with the input to handle camera move.
  84574. */
  84575. buttons: number[];
  84576. /**
  84577. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  84578. */
  84579. angularSensibility: number;
  84580. private _pointerInput;
  84581. private _onMouseMove;
  84582. private _observer;
  84583. private previousPosition;
  84584. /**
  84585. * Observable for when a pointer move event occurs containing the move offset
  84586. */
  84587. onPointerMovedObservable: Observable<{
  84588. offsetX: number;
  84589. offsetY: number;
  84590. }>;
  84591. /**
  84592. * @hidden
  84593. * If the camera should be rotated automatically based on pointer movement
  84594. */
  84595. _allowCameraRotation: boolean;
  84596. /**
  84597. * Manage the mouse inputs to control the movement of a free camera.
  84598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84599. * @param touchEnabled Defines if touch is enabled or not
  84600. */
  84601. constructor(
  84602. /**
  84603. * Define if touch is enabled in the mouse input
  84604. */
  84605. touchEnabled?: boolean);
  84606. /**
  84607. * Attach the input controls to a specific dom element to get the input from.
  84608. * @param element Defines the element the controls should be listened from
  84609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84610. */
  84611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84612. /**
  84613. * Called on JS contextmenu event.
  84614. * Override this method to provide functionality.
  84615. */
  84616. protected onContextMenu(evt: PointerEvent): void;
  84617. /**
  84618. * Detach the current controls from the specified dom element.
  84619. * @param element Defines the element to stop listening the inputs from
  84620. */
  84621. detachControl(element: Nullable<HTMLElement>): void;
  84622. /**
  84623. * Gets the class name of the current intput.
  84624. * @returns the class name
  84625. */
  84626. getClassName(): string;
  84627. /**
  84628. * Get the friendly name associated with the input class.
  84629. * @returns the input friendly name
  84630. */
  84631. getSimpleName(): string;
  84632. }
  84633. }
  84634. declare module BABYLON {
  84635. /**
  84636. * Manage the touch inputs to control the movement of a free camera.
  84637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84638. */
  84639. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  84640. /**
  84641. * Defines the camera the input is attached to.
  84642. */
  84643. camera: FreeCamera;
  84644. /**
  84645. * Defines the touch sensibility for rotation.
  84646. * The higher the faster.
  84647. */
  84648. touchAngularSensibility: number;
  84649. /**
  84650. * Defines the touch sensibility for move.
  84651. * The higher the faster.
  84652. */
  84653. touchMoveSensibility: number;
  84654. private _offsetX;
  84655. private _offsetY;
  84656. private _pointerPressed;
  84657. private _pointerInput;
  84658. private _observer;
  84659. private _onLostFocus;
  84660. /**
  84661. * Attach the input controls to a specific dom element to get the input from.
  84662. * @param element Defines the element the controls should be listened from
  84663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84664. */
  84665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84666. /**
  84667. * Detach the current controls from the specified dom element.
  84668. * @param element Defines the element to stop listening the inputs from
  84669. */
  84670. detachControl(element: Nullable<HTMLElement>): void;
  84671. /**
  84672. * Update the current camera state depending on the inputs that have been used this frame.
  84673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84674. */
  84675. checkInputs(): void;
  84676. /**
  84677. * Gets the class name of the current intput.
  84678. * @returns the class name
  84679. */
  84680. getClassName(): string;
  84681. /**
  84682. * Get the friendly name associated with the input class.
  84683. * @returns the input friendly name
  84684. */
  84685. getSimpleName(): string;
  84686. }
  84687. }
  84688. declare module BABYLON {
  84689. /**
  84690. * Default Inputs manager for the FreeCamera.
  84691. * It groups all the default supported inputs for ease of use.
  84692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84693. */
  84694. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  84695. /**
  84696. * @hidden
  84697. */
  84698. _mouseInput: Nullable<FreeCameraMouseInput>;
  84699. /**
  84700. * Instantiates a new FreeCameraInputsManager.
  84701. * @param camera Defines the camera the inputs belong to
  84702. */
  84703. constructor(camera: FreeCamera);
  84704. /**
  84705. * Add keyboard input support to the input manager.
  84706. * @returns the current input manager
  84707. */
  84708. addKeyboard(): FreeCameraInputsManager;
  84709. /**
  84710. * Add mouse input support to the input manager.
  84711. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  84712. * @returns the current input manager
  84713. */
  84714. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  84715. /**
  84716. * Removes the mouse input support from the manager
  84717. * @returns the current input manager
  84718. */
  84719. removeMouse(): FreeCameraInputsManager;
  84720. /**
  84721. * Add touch input support to the input manager.
  84722. * @returns the current input manager
  84723. */
  84724. addTouch(): FreeCameraInputsManager;
  84725. /**
  84726. * Remove all attached input methods from a camera
  84727. */
  84728. clear(): void;
  84729. }
  84730. }
  84731. declare module BABYLON {
  84732. /**
  84733. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84734. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  84735. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84736. */
  84737. export class FreeCamera extends TargetCamera {
  84738. /**
  84739. * Define the collision ellipsoid of the camera.
  84740. * This is helpful to simulate a camera body like the player body around the camera
  84741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  84742. */
  84743. ellipsoid: Vector3;
  84744. /**
  84745. * Define an offset for the position of the ellipsoid around the camera.
  84746. * This can be helpful to determine the center of the body near the gravity center of the body
  84747. * instead of its head.
  84748. */
  84749. ellipsoidOffset: Vector3;
  84750. /**
  84751. * Enable or disable collisions of the camera with the rest of the scene objects.
  84752. */
  84753. checkCollisions: boolean;
  84754. /**
  84755. * Enable or disable gravity on the camera.
  84756. */
  84757. applyGravity: boolean;
  84758. /**
  84759. * Define the input manager associated to the camera.
  84760. */
  84761. inputs: FreeCameraInputsManager;
  84762. /**
  84763. * Gets the input sensibility for a mouse input. (default is 2000.0)
  84764. * Higher values reduce sensitivity.
  84765. */
  84766. get angularSensibility(): number;
  84767. /**
  84768. * Sets the input sensibility for a mouse input. (default is 2000.0)
  84769. * Higher values reduce sensitivity.
  84770. */
  84771. set angularSensibility(value: number);
  84772. /**
  84773. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84774. */
  84775. get keysUp(): number[];
  84776. set keysUp(value: number[]);
  84777. /**
  84778. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84779. */
  84780. get keysDown(): number[];
  84781. set keysDown(value: number[]);
  84782. /**
  84783. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84784. */
  84785. get keysLeft(): number[];
  84786. set keysLeft(value: number[]);
  84787. /**
  84788. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84789. */
  84790. get keysRight(): number[];
  84791. set keysRight(value: number[]);
  84792. /**
  84793. * Event raised when the camera collide with a mesh in the scene.
  84794. */
  84795. onCollide: (collidedMesh: AbstractMesh) => void;
  84796. private _collider;
  84797. private _needMoveForGravity;
  84798. private _oldPosition;
  84799. private _diffPosition;
  84800. private _newPosition;
  84801. /** @hidden */
  84802. _localDirection: Vector3;
  84803. /** @hidden */
  84804. _transformedDirection: Vector3;
  84805. /**
  84806. * Instantiates a Free Camera.
  84807. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84808. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  84809. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84810. * @param name Define the name of the camera in the scene
  84811. * @param position Define the start position of the camera in the scene
  84812. * @param scene Define the scene the camera belongs to
  84813. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84814. */
  84815. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84816. /**
  84817. * Attached controls to the current camera.
  84818. * @param element Defines the element the controls should be listened from
  84819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84820. */
  84821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84822. /**
  84823. * Detach the current controls from the camera.
  84824. * The camera will stop reacting to inputs.
  84825. * @param element Defines the element to stop listening the inputs from
  84826. */
  84827. detachControl(element: HTMLElement): void;
  84828. private _collisionMask;
  84829. /**
  84830. * Define a collision mask to limit the list of object the camera can collide with
  84831. */
  84832. get collisionMask(): number;
  84833. set collisionMask(mask: number);
  84834. /** @hidden */
  84835. _collideWithWorld(displacement: Vector3): void;
  84836. private _onCollisionPositionChange;
  84837. /** @hidden */
  84838. _checkInputs(): void;
  84839. /** @hidden */
  84840. _decideIfNeedsToMove(): boolean;
  84841. /** @hidden */
  84842. _updatePosition(): void;
  84843. /**
  84844. * Destroy the camera and release the current resources hold by it.
  84845. */
  84846. dispose(): void;
  84847. /**
  84848. * Gets the current object class name.
  84849. * @return the class name
  84850. */
  84851. getClassName(): string;
  84852. }
  84853. }
  84854. declare module BABYLON {
  84855. /**
  84856. * Represents a gamepad control stick position
  84857. */
  84858. export class StickValues {
  84859. /**
  84860. * The x component of the control stick
  84861. */
  84862. x: number;
  84863. /**
  84864. * The y component of the control stick
  84865. */
  84866. y: number;
  84867. /**
  84868. * Initializes the gamepad x and y control stick values
  84869. * @param x The x component of the gamepad control stick value
  84870. * @param y The y component of the gamepad control stick value
  84871. */
  84872. constructor(
  84873. /**
  84874. * The x component of the control stick
  84875. */
  84876. x: number,
  84877. /**
  84878. * The y component of the control stick
  84879. */
  84880. y: number);
  84881. }
  84882. /**
  84883. * An interface which manages callbacks for gamepad button changes
  84884. */
  84885. export interface GamepadButtonChanges {
  84886. /**
  84887. * Called when a gamepad has been changed
  84888. */
  84889. changed: boolean;
  84890. /**
  84891. * Called when a gamepad press event has been triggered
  84892. */
  84893. pressChanged: boolean;
  84894. /**
  84895. * Called when a touch event has been triggered
  84896. */
  84897. touchChanged: boolean;
  84898. /**
  84899. * Called when a value has changed
  84900. */
  84901. valueChanged: boolean;
  84902. }
  84903. /**
  84904. * Represents a gamepad
  84905. */
  84906. export class Gamepad {
  84907. /**
  84908. * The id of the gamepad
  84909. */
  84910. id: string;
  84911. /**
  84912. * The index of the gamepad
  84913. */
  84914. index: number;
  84915. /**
  84916. * The browser gamepad
  84917. */
  84918. browserGamepad: any;
  84919. /**
  84920. * Specifies what type of gamepad this represents
  84921. */
  84922. type: number;
  84923. private _leftStick;
  84924. private _rightStick;
  84925. /** @hidden */
  84926. _isConnected: boolean;
  84927. private _leftStickAxisX;
  84928. private _leftStickAxisY;
  84929. private _rightStickAxisX;
  84930. private _rightStickAxisY;
  84931. /**
  84932. * Triggered when the left control stick has been changed
  84933. */
  84934. private _onleftstickchanged;
  84935. /**
  84936. * Triggered when the right control stick has been changed
  84937. */
  84938. private _onrightstickchanged;
  84939. /**
  84940. * Represents a gamepad controller
  84941. */
  84942. static GAMEPAD: number;
  84943. /**
  84944. * Represents a generic controller
  84945. */
  84946. static GENERIC: number;
  84947. /**
  84948. * Represents an XBox controller
  84949. */
  84950. static XBOX: number;
  84951. /**
  84952. * Represents a pose-enabled controller
  84953. */
  84954. static POSE_ENABLED: number;
  84955. /**
  84956. * Represents an Dual Shock controller
  84957. */
  84958. static DUALSHOCK: number;
  84959. /**
  84960. * Specifies whether the left control stick should be Y-inverted
  84961. */
  84962. protected _invertLeftStickY: boolean;
  84963. /**
  84964. * Specifies if the gamepad has been connected
  84965. */
  84966. get isConnected(): boolean;
  84967. /**
  84968. * Initializes the gamepad
  84969. * @param id The id of the gamepad
  84970. * @param index The index of the gamepad
  84971. * @param browserGamepad The browser gamepad
  84972. * @param leftStickX The x component of the left joystick
  84973. * @param leftStickY The y component of the left joystick
  84974. * @param rightStickX The x component of the right joystick
  84975. * @param rightStickY The y component of the right joystick
  84976. */
  84977. constructor(
  84978. /**
  84979. * The id of the gamepad
  84980. */
  84981. id: string,
  84982. /**
  84983. * The index of the gamepad
  84984. */
  84985. index: number,
  84986. /**
  84987. * The browser gamepad
  84988. */
  84989. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  84990. /**
  84991. * Callback triggered when the left joystick has changed
  84992. * @param callback
  84993. */
  84994. onleftstickchanged(callback: (values: StickValues) => void): void;
  84995. /**
  84996. * Callback triggered when the right joystick has changed
  84997. * @param callback
  84998. */
  84999. onrightstickchanged(callback: (values: StickValues) => void): void;
  85000. /**
  85001. * Gets the left joystick
  85002. */
  85003. get leftStick(): StickValues;
  85004. /**
  85005. * Sets the left joystick values
  85006. */
  85007. set leftStick(newValues: StickValues);
  85008. /**
  85009. * Gets the right joystick
  85010. */
  85011. get rightStick(): StickValues;
  85012. /**
  85013. * Sets the right joystick value
  85014. */
  85015. set rightStick(newValues: StickValues);
  85016. /**
  85017. * Updates the gamepad joystick positions
  85018. */
  85019. update(): void;
  85020. /**
  85021. * Disposes the gamepad
  85022. */
  85023. dispose(): void;
  85024. }
  85025. /**
  85026. * Represents a generic gamepad
  85027. */
  85028. export class GenericPad extends Gamepad {
  85029. private _buttons;
  85030. private _onbuttondown;
  85031. private _onbuttonup;
  85032. /**
  85033. * Observable triggered when a button has been pressed
  85034. */
  85035. onButtonDownObservable: Observable<number>;
  85036. /**
  85037. * Observable triggered when a button has been released
  85038. */
  85039. onButtonUpObservable: Observable<number>;
  85040. /**
  85041. * Callback triggered when a button has been pressed
  85042. * @param callback Called when a button has been pressed
  85043. */
  85044. onbuttondown(callback: (buttonPressed: number) => void): void;
  85045. /**
  85046. * Callback triggered when a button has been released
  85047. * @param callback Called when a button has been released
  85048. */
  85049. onbuttonup(callback: (buttonReleased: number) => void): void;
  85050. /**
  85051. * Initializes the generic gamepad
  85052. * @param id The id of the generic gamepad
  85053. * @param index The index of the generic gamepad
  85054. * @param browserGamepad The browser gamepad
  85055. */
  85056. constructor(id: string, index: number, browserGamepad: any);
  85057. private _setButtonValue;
  85058. /**
  85059. * Updates the generic gamepad
  85060. */
  85061. update(): void;
  85062. /**
  85063. * Disposes the generic gamepad
  85064. */
  85065. dispose(): void;
  85066. }
  85067. }
  85068. declare module BABYLON {
  85069. interface Engine {
  85070. /**
  85071. * Creates a raw texture
  85072. * @param data defines the data to store in the texture
  85073. * @param width defines the width of the texture
  85074. * @param height defines the height of the texture
  85075. * @param format defines the format of the data
  85076. * @param generateMipMaps defines if the engine should generate the mip levels
  85077. * @param invertY defines if data must be stored with Y axis inverted
  85078. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85079. * @param compression defines the compression used (null by default)
  85080. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85081. * @returns the raw texture inside an InternalTexture
  85082. */
  85083. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85084. /**
  85085. * Update a raw texture
  85086. * @param texture defines the texture to update
  85087. * @param data defines the data to store in the texture
  85088. * @param format defines the format of the data
  85089. * @param invertY defines if data must be stored with Y axis inverted
  85090. */
  85091. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85092. /**
  85093. * Update a raw texture
  85094. * @param texture defines the texture to update
  85095. * @param data defines the data to store in the texture
  85096. * @param format defines the format of the data
  85097. * @param invertY defines if data must be stored with Y axis inverted
  85098. * @param compression defines the compression used (null by default)
  85099. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85100. */
  85101. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85102. /**
  85103. * Creates a new raw cube texture
  85104. * @param data defines the array of data to use to create each face
  85105. * @param size defines the size of the textures
  85106. * @param format defines the format of the data
  85107. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85108. * @param generateMipMaps defines if the engine should generate the mip levels
  85109. * @param invertY defines if data must be stored with Y axis inverted
  85110. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85111. * @param compression defines the compression used (null by default)
  85112. * @returns the cube texture as an InternalTexture
  85113. */
  85114. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85115. /**
  85116. * Update a raw cube texture
  85117. * @param texture defines the texture to udpdate
  85118. * @param data defines the data to store
  85119. * @param format defines the data format
  85120. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85121. * @param invertY defines if data must be stored with Y axis inverted
  85122. */
  85123. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85124. /**
  85125. * Update a raw cube texture
  85126. * @param texture defines the texture to udpdate
  85127. * @param data defines the data to store
  85128. * @param format defines the data format
  85129. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85130. * @param invertY defines if data must be stored with Y axis inverted
  85131. * @param compression defines the compression used (null by default)
  85132. */
  85133. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85134. /**
  85135. * Update a raw cube texture
  85136. * @param texture defines the texture to udpdate
  85137. * @param data defines the data to store
  85138. * @param format defines the data format
  85139. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85140. * @param invertY defines if data must be stored with Y axis inverted
  85141. * @param compression defines the compression used (null by default)
  85142. * @param level defines which level of the texture to update
  85143. */
  85144. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85145. /**
  85146. * Creates a new raw cube texture from a specified url
  85147. * @param url defines the url where the data is located
  85148. * @param scene defines the current scene
  85149. * @param size defines the size of the textures
  85150. * @param format defines the format of the data
  85151. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85152. * @param noMipmap defines if the engine should avoid generating the mip levels
  85153. * @param callback defines a callback used to extract texture data from loaded data
  85154. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85155. * @param onLoad defines a callback called when texture is loaded
  85156. * @param onError defines a callback called if there is an error
  85157. * @returns the cube texture as an InternalTexture
  85158. */
  85159. 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;
  85160. /**
  85161. * Creates a new raw cube texture from a specified url
  85162. * @param url defines the url where the data is located
  85163. * @param scene defines the current scene
  85164. * @param size defines the size of the textures
  85165. * @param format defines the format of the data
  85166. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85167. * @param noMipmap defines if the engine should avoid generating the mip levels
  85168. * @param callback defines a callback used to extract texture data from loaded data
  85169. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85170. * @param onLoad defines a callback called when texture is loaded
  85171. * @param onError defines a callback called if there is an error
  85172. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85173. * @param invertY defines if data must be stored with Y axis inverted
  85174. * @returns the cube texture as an InternalTexture
  85175. */
  85176. 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;
  85177. /**
  85178. * Creates a new raw 3D texture
  85179. * @param data defines the data used to create the texture
  85180. * @param width defines the width of the texture
  85181. * @param height defines the height of the texture
  85182. * @param depth defines the depth of the texture
  85183. * @param format defines the format of the texture
  85184. * @param generateMipMaps defines if the engine must generate mip levels
  85185. * @param invertY defines if data must be stored with Y axis inverted
  85186. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85187. * @param compression defines the compressed used (can be null)
  85188. * @param textureType defines the compressed used (can be null)
  85189. * @returns a new raw 3D texture (stored in an InternalTexture)
  85190. */
  85191. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85192. /**
  85193. * Update a raw 3D texture
  85194. * @param texture defines the texture to update
  85195. * @param data defines the data to store
  85196. * @param format defines the data format
  85197. * @param invertY defines if data must be stored with Y axis inverted
  85198. */
  85199. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85200. /**
  85201. * Update a raw 3D texture
  85202. * @param texture defines the texture to update
  85203. * @param data defines the data to store
  85204. * @param format defines the data format
  85205. * @param invertY defines if data must be stored with Y axis inverted
  85206. * @param compression defines the used compression (can be null)
  85207. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85208. */
  85209. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85210. /**
  85211. * Creates a new raw 2D array texture
  85212. * @param data defines the data used to create the texture
  85213. * @param width defines the width of the texture
  85214. * @param height defines the height of the texture
  85215. * @param depth defines the number of layers of the texture
  85216. * @param format defines the format of the texture
  85217. * @param generateMipMaps defines if the engine must generate mip levels
  85218. * @param invertY defines if data must be stored with Y axis inverted
  85219. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85220. * @param compression defines the compressed used (can be null)
  85221. * @param textureType defines the compressed used (can be null)
  85222. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85223. */
  85224. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85225. /**
  85226. * Update a raw 2D array texture
  85227. * @param texture defines the texture to update
  85228. * @param data defines the data to store
  85229. * @param format defines the data format
  85230. * @param invertY defines if data must be stored with Y axis inverted
  85231. */
  85232. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85233. /**
  85234. * Update a raw 2D array texture
  85235. * @param texture defines the texture to update
  85236. * @param data defines the data to store
  85237. * @param format defines the data format
  85238. * @param invertY defines if data must be stored with Y axis inverted
  85239. * @param compression defines the used compression (can be null)
  85240. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85241. */
  85242. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85243. }
  85244. }
  85245. declare module BABYLON {
  85246. /**
  85247. * Raw texture can help creating a texture directly from an array of data.
  85248. * This can be super useful if you either get the data from an uncompressed source or
  85249. * if you wish to create your texture pixel by pixel.
  85250. */
  85251. export class RawTexture extends Texture {
  85252. /**
  85253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85254. */
  85255. format: number;
  85256. private _engine;
  85257. /**
  85258. * Instantiates a new RawTexture.
  85259. * Raw texture can help creating a texture directly from an array of data.
  85260. * This can be super useful if you either get the data from an uncompressed source or
  85261. * if you wish to create your texture pixel by pixel.
  85262. * @param data define the array of data to use to create the texture
  85263. * @param width define the width of the texture
  85264. * @param height define the height of the texture
  85265. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85266. * @param scene define the scene the texture belongs to
  85267. * @param generateMipMaps define whether mip maps should be generated or not
  85268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85270. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85271. */
  85272. constructor(data: ArrayBufferView, width: number, height: number,
  85273. /**
  85274. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85275. */
  85276. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85277. /**
  85278. * Updates the texture underlying data.
  85279. * @param data Define the new data of the texture
  85280. */
  85281. update(data: ArrayBufferView): void;
  85282. /**
  85283. * Creates a luminance texture from some data.
  85284. * @param data Define the texture data
  85285. * @param width Define the width of the texture
  85286. * @param height Define the height of the texture
  85287. * @param scene Define the scene the texture belongs to
  85288. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85289. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85290. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85291. * @returns the luminance texture
  85292. */
  85293. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85294. /**
  85295. * Creates a luminance alpha texture from some data.
  85296. * @param data Define the texture data
  85297. * @param width Define the width of the texture
  85298. * @param height Define the height of the texture
  85299. * @param scene Define the scene the texture belongs to
  85300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85303. * @returns the luminance alpha texture
  85304. */
  85305. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85306. /**
  85307. * Creates an alpha texture from some data.
  85308. * @param data Define the texture data
  85309. * @param width Define the width of the texture
  85310. * @param height Define the height of the texture
  85311. * @param scene Define the scene the texture belongs to
  85312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85315. * @returns the alpha texture
  85316. */
  85317. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85318. /**
  85319. * Creates a RGB texture from some data.
  85320. * @param data Define the texture data
  85321. * @param width Define the width of the texture
  85322. * @param height Define the height of the texture
  85323. * @param scene Define the scene the texture belongs to
  85324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85327. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85328. * @returns the RGB alpha texture
  85329. */
  85330. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85331. /**
  85332. * Creates a RGBA texture from some data.
  85333. * @param data Define the texture data
  85334. * @param width Define the width of the texture
  85335. * @param height Define the height of the texture
  85336. * @param scene Define the scene the texture belongs to
  85337. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85338. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85339. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85340. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85341. * @returns the RGBA texture
  85342. */
  85343. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85344. /**
  85345. * Creates a R texture from some data.
  85346. * @param data Define the texture data
  85347. * @param width Define the width of the texture
  85348. * @param height Define the height of the texture
  85349. * @param scene Define the scene the texture belongs to
  85350. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85351. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85352. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85353. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85354. * @returns the R texture
  85355. */
  85356. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85357. }
  85358. }
  85359. declare module BABYLON {
  85360. /**
  85361. * Interface for the size containing width and height
  85362. */
  85363. export interface ISize {
  85364. /**
  85365. * Width
  85366. */
  85367. width: number;
  85368. /**
  85369. * Heighht
  85370. */
  85371. height: number;
  85372. }
  85373. /**
  85374. * Size containing widht and height
  85375. */
  85376. export class Size implements ISize {
  85377. /**
  85378. * Width
  85379. */
  85380. width: number;
  85381. /**
  85382. * Height
  85383. */
  85384. height: number;
  85385. /**
  85386. * Creates a Size object from the given width and height (floats).
  85387. * @param width width of the new size
  85388. * @param height height of the new size
  85389. */
  85390. constructor(width: number, height: number);
  85391. /**
  85392. * Returns a string with the Size width and height
  85393. * @returns a string with the Size width and height
  85394. */
  85395. toString(): string;
  85396. /**
  85397. * "Size"
  85398. * @returns the string "Size"
  85399. */
  85400. getClassName(): string;
  85401. /**
  85402. * Returns the Size hash code.
  85403. * @returns a hash code for a unique width and height
  85404. */
  85405. getHashCode(): number;
  85406. /**
  85407. * Updates the current size from the given one.
  85408. * @param src the given size
  85409. */
  85410. copyFrom(src: Size): void;
  85411. /**
  85412. * Updates in place the current Size from the given floats.
  85413. * @param width width of the new size
  85414. * @param height height of the new size
  85415. * @returns the updated Size.
  85416. */
  85417. copyFromFloats(width: number, height: number): Size;
  85418. /**
  85419. * Updates in place the current Size from the given floats.
  85420. * @param width width to set
  85421. * @param height height to set
  85422. * @returns the updated Size.
  85423. */
  85424. set(width: number, height: number): Size;
  85425. /**
  85426. * Multiplies the width and height by numbers
  85427. * @param w factor to multiple the width by
  85428. * @param h factor to multiple the height by
  85429. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85430. */
  85431. multiplyByFloats(w: number, h: number): Size;
  85432. /**
  85433. * Clones the size
  85434. * @returns a new Size copied from the given one.
  85435. */
  85436. clone(): Size;
  85437. /**
  85438. * True if the current Size and the given one width and height are strictly equal.
  85439. * @param other the other size to compare against
  85440. * @returns True if the current Size and the given one width and height are strictly equal.
  85441. */
  85442. equals(other: Size): boolean;
  85443. /**
  85444. * The surface of the Size : width * height (float).
  85445. */
  85446. get surface(): number;
  85447. /**
  85448. * Create a new size of zero
  85449. * @returns a new Size set to (0.0, 0.0)
  85450. */
  85451. static Zero(): Size;
  85452. /**
  85453. * Sums the width and height of two sizes
  85454. * @param otherSize size to add to this size
  85455. * @returns a new Size set as the addition result of the current Size and the given one.
  85456. */
  85457. add(otherSize: Size): Size;
  85458. /**
  85459. * Subtracts the width and height of two
  85460. * @param otherSize size to subtract to this size
  85461. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85462. */
  85463. subtract(otherSize: Size): Size;
  85464. /**
  85465. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85466. * @param start starting size to lerp between
  85467. * @param end end size to lerp between
  85468. * @param amount amount to lerp between the start and end values
  85469. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85470. */
  85471. static Lerp(start: Size, end: Size, amount: number): Size;
  85472. }
  85473. }
  85474. declare module BABYLON {
  85475. /**
  85476. * Defines a runtime animation
  85477. */
  85478. export class RuntimeAnimation {
  85479. private _events;
  85480. /**
  85481. * The current frame of the runtime animation
  85482. */
  85483. private _currentFrame;
  85484. /**
  85485. * The animation used by the runtime animation
  85486. */
  85487. private _animation;
  85488. /**
  85489. * The target of the runtime animation
  85490. */
  85491. private _target;
  85492. /**
  85493. * The initiating animatable
  85494. */
  85495. private _host;
  85496. /**
  85497. * The original value of the runtime animation
  85498. */
  85499. private _originalValue;
  85500. /**
  85501. * The original blend value of the runtime animation
  85502. */
  85503. private _originalBlendValue;
  85504. /**
  85505. * The offsets cache of the runtime animation
  85506. */
  85507. private _offsetsCache;
  85508. /**
  85509. * The high limits cache of the runtime animation
  85510. */
  85511. private _highLimitsCache;
  85512. /**
  85513. * Specifies if the runtime animation has been stopped
  85514. */
  85515. private _stopped;
  85516. /**
  85517. * The blending factor of the runtime animation
  85518. */
  85519. private _blendingFactor;
  85520. /**
  85521. * The BabylonJS scene
  85522. */
  85523. private _scene;
  85524. /**
  85525. * The current value of the runtime animation
  85526. */
  85527. private _currentValue;
  85528. /** @hidden */
  85529. _animationState: _IAnimationState;
  85530. /**
  85531. * The active target of the runtime animation
  85532. */
  85533. private _activeTargets;
  85534. private _currentActiveTarget;
  85535. private _directTarget;
  85536. /**
  85537. * The target path of the runtime animation
  85538. */
  85539. private _targetPath;
  85540. /**
  85541. * The weight of the runtime animation
  85542. */
  85543. private _weight;
  85544. /**
  85545. * The ratio offset of the runtime animation
  85546. */
  85547. private _ratioOffset;
  85548. /**
  85549. * The previous delay of the runtime animation
  85550. */
  85551. private _previousDelay;
  85552. /**
  85553. * The previous ratio of the runtime animation
  85554. */
  85555. private _previousRatio;
  85556. private _enableBlending;
  85557. private _keys;
  85558. private _minFrame;
  85559. private _maxFrame;
  85560. private _minValue;
  85561. private _maxValue;
  85562. private _targetIsArray;
  85563. /**
  85564. * Gets the current frame of the runtime animation
  85565. */
  85566. get currentFrame(): number;
  85567. /**
  85568. * Gets the weight of the runtime animation
  85569. */
  85570. get weight(): number;
  85571. /**
  85572. * Gets the current value of the runtime animation
  85573. */
  85574. get currentValue(): any;
  85575. /**
  85576. * Gets the target path of the runtime animation
  85577. */
  85578. get targetPath(): string;
  85579. /**
  85580. * Gets the actual target of the runtime animation
  85581. */
  85582. get target(): any;
  85583. /** @hidden */
  85584. _onLoop: () => void;
  85585. /**
  85586. * Create a new RuntimeAnimation object
  85587. * @param target defines the target of the animation
  85588. * @param animation defines the source animation object
  85589. * @param scene defines the hosting scene
  85590. * @param host defines the initiating Animatable
  85591. */
  85592. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  85593. private _preparePath;
  85594. /**
  85595. * Gets the animation from the runtime animation
  85596. */
  85597. get animation(): Animation;
  85598. /**
  85599. * Resets the runtime animation to the beginning
  85600. * @param restoreOriginal defines whether to restore the target property to the original value
  85601. */
  85602. reset(restoreOriginal?: boolean): void;
  85603. /**
  85604. * Specifies if the runtime animation is stopped
  85605. * @returns Boolean specifying if the runtime animation is stopped
  85606. */
  85607. isStopped(): boolean;
  85608. /**
  85609. * Disposes of the runtime animation
  85610. */
  85611. dispose(): void;
  85612. /**
  85613. * Apply the interpolated value to the target
  85614. * @param currentValue defines the value computed by the animation
  85615. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  85616. */
  85617. setValue(currentValue: any, weight: number): void;
  85618. private _getOriginalValues;
  85619. private _setValue;
  85620. /**
  85621. * Gets the loop pmode of the runtime animation
  85622. * @returns Loop Mode
  85623. */
  85624. private _getCorrectLoopMode;
  85625. /**
  85626. * Move the current animation to a given frame
  85627. * @param frame defines the frame to move to
  85628. */
  85629. goToFrame(frame: number): void;
  85630. /**
  85631. * @hidden Internal use only
  85632. */
  85633. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  85634. /**
  85635. * Execute the current animation
  85636. * @param delay defines the delay to add to the current frame
  85637. * @param from defines the lower bound of the animation range
  85638. * @param to defines the upper bound of the animation range
  85639. * @param loop defines if the current animation must loop
  85640. * @param speedRatio defines the current speed ratio
  85641. * @param weight defines the weight of the animation (default is -1 so no weight)
  85642. * @param onLoop optional callback called when animation loops
  85643. * @returns a boolean indicating if the animation is running
  85644. */
  85645. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  85646. }
  85647. }
  85648. declare module BABYLON {
  85649. /**
  85650. * Class used to store an actual running animation
  85651. */
  85652. export class Animatable {
  85653. /** defines the target object */
  85654. target: any;
  85655. /** defines the starting frame number (default is 0) */
  85656. fromFrame: number;
  85657. /** defines the ending frame number (default is 100) */
  85658. toFrame: number;
  85659. /** defines if the animation must loop (default is false) */
  85660. loopAnimation: boolean;
  85661. /** defines a callback to call when animation ends if it is not looping */
  85662. onAnimationEnd?: (() => void) | null | undefined;
  85663. /** defines a callback to call when animation loops */
  85664. onAnimationLoop?: (() => void) | null | undefined;
  85665. private _localDelayOffset;
  85666. private _pausedDelay;
  85667. private _runtimeAnimations;
  85668. private _paused;
  85669. private _scene;
  85670. private _speedRatio;
  85671. private _weight;
  85672. private _syncRoot;
  85673. /**
  85674. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  85675. * This will only apply for non looping animation (default is true)
  85676. */
  85677. disposeOnEnd: boolean;
  85678. /**
  85679. * Gets a boolean indicating if the animation has started
  85680. */
  85681. animationStarted: boolean;
  85682. /**
  85683. * Observer raised when the animation ends
  85684. */
  85685. onAnimationEndObservable: Observable<Animatable>;
  85686. /**
  85687. * Observer raised when the animation loops
  85688. */
  85689. onAnimationLoopObservable: Observable<Animatable>;
  85690. /**
  85691. * Gets the root Animatable used to synchronize and normalize animations
  85692. */
  85693. get syncRoot(): Nullable<Animatable>;
  85694. /**
  85695. * Gets the current frame of the first RuntimeAnimation
  85696. * Used to synchronize Animatables
  85697. */
  85698. get masterFrame(): number;
  85699. /**
  85700. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  85701. */
  85702. get weight(): number;
  85703. set weight(value: number);
  85704. /**
  85705. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  85706. */
  85707. get speedRatio(): number;
  85708. set speedRatio(value: number);
  85709. /**
  85710. * Creates a new Animatable
  85711. * @param scene defines the hosting scene
  85712. * @param target defines the target object
  85713. * @param fromFrame defines the starting frame number (default is 0)
  85714. * @param toFrame defines the ending frame number (default is 100)
  85715. * @param loopAnimation defines if the animation must loop (default is false)
  85716. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  85717. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  85718. * @param animations defines a group of animation to add to the new Animatable
  85719. * @param onAnimationLoop defines a callback to call when animation loops
  85720. */
  85721. constructor(scene: Scene,
  85722. /** defines the target object */
  85723. target: any,
  85724. /** defines the starting frame number (default is 0) */
  85725. fromFrame?: number,
  85726. /** defines the ending frame number (default is 100) */
  85727. toFrame?: number,
  85728. /** defines if the animation must loop (default is false) */
  85729. loopAnimation?: boolean, speedRatio?: number,
  85730. /** defines a callback to call when animation ends if it is not looping */
  85731. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  85732. /** defines a callback to call when animation loops */
  85733. onAnimationLoop?: (() => void) | null | undefined);
  85734. /**
  85735. * Synchronize and normalize current Animatable with a source Animatable
  85736. * This is useful when using animation weights and when animations are not of the same length
  85737. * @param root defines the root Animatable to synchronize with
  85738. * @returns the current Animatable
  85739. */
  85740. syncWith(root: Animatable): Animatable;
  85741. /**
  85742. * Gets the list of runtime animations
  85743. * @returns an array of RuntimeAnimation
  85744. */
  85745. getAnimations(): RuntimeAnimation[];
  85746. /**
  85747. * Adds more animations to the current animatable
  85748. * @param target defines the target of the animations
  85749. * @param animations defines the new animations to add
  85750. */
  85751. appendAnimations(target: any, animations: Animation[]): void;
  85752. /**
  85753. * Gets the source animation for a specific property
  85754. * @param property defines the propertyu to look for
  85755. * @returns null or the source animation for the given property
  85756. */
  85757. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  85758. /**
  85759. * Gets the runtime animation for a specific property
  85760. * @param property defines the propertyu to look for
  85761. * @returns null or the runtime animation for the given property
  85762. */
  85763. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  85764. /**
  85765. * Resets the animatable to its original state
  85766. */
  85767. reset(): void;
  85768. /**
  85769. * Allows the animatable to blend with current running animations
  85770. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85771. * @param blendingSpeed defines the blending speed to use
  85772. */
  85773. enableBlending(blendingSpeed: number): void;
  85774. /**
  85775. * Disable animation blending
  85776. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85777. */
  85778. disableBlending(): void;
  85779. /**
  85780. * Jump directly to a given frame
  85781. * @param frame defines the frame to jump to
  85782. */
  85783. goToFrame(frame: number): void;
  85784. /**
  85785. * Pause the animation
  85786. */
  85787. pause(): void;
  85788. /**
  85789. * Restart the animation
  85790. */
  85791. restart(): void;
  85792. private _raiseOnAnimationEnd;
  85793. /**
  85794. * Stop and delete the current animation
  85795. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  85796. * @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)
  85797. */
  85798. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  85799. /**
  85800. * Wait asynchronously for the animation to end
  85801. * @returns a promise which will be fullfilled when the animation ends
  85802. */
  85803. waitAsync(): Promise<Animatable>;
  85804. /** @hidden */
  85805. _animate(delay: number): boolean;
  85806. }
  85807. interface Scene {
  85808. /** @hidden */
  85809. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  85810. /** @hidden */
  85811. _processLateAnimationBindingsForMatrices(holder: {
  85812. totalWeight: number;
  85813. animations: RuntimeAnimation[];
  85814. originalValue: Matrix;
  85815. }): any;
  85816. /** @hidden */
  85817. _processLateAnimationBindingsForQuaternions(holder: {
  85818. totalWeight: number;
  85819. animations: RuntimeAnimation[];
  85820. originalValue: Quaternion;
  85821. }, refQuaternion: Quaternion): Quaternion;
  85822. /** @hidden */
  85823. _processLateAnimationBindings(): void;
  85824. /**
  85825. * Will start the animation sequence of a given target
  85826. * @param target defines the target
  85827. * @param from defines from which frame should animation start
  85828. * @param to defines until which frame should animation run.
  85829. * @param weight defines the weight to apply to the animation (1.0 by default)
  85830. * @param loop defines if the animation loops
  85831. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85832. * @param onAnimationEnd defines the function to be executed when the animation ends
  85833. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85834. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  85835. * @param onAnimationLoop defines the callback to call when an animation loops
  85836. * @returns the animatable object created for this animation
  85837. */
  85838. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  85839. /**
  85840. * Will start the animation sequence of a given target
  85841. * @param target defines the target
  85842. * @param from defines from which frame should animation start
  85843. * @param to defines until which frame should animation run.
  85844. * @param loop defines if the animation loops
  85845. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85846. * @param onAnimationEnd defines the function to be executed when the animation ends
  85847. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85848. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  85849. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  85850. * @param onAnimationLoop defines the callback to call when an animation loops
  85851. * @returns the animatable object created for this animation
  85852. */
  85853. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  85854. /**
  85855. * Will start the animation sequence of a given target and its hierarchy
  85856. * @param target defines the target
  85857. * @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.
  85858. * @param from defines from which frame should animation start
  85859. * @param to defines until which frame should animation run.
  85860. * @param loop defines if the animation loops
  85861. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85862. * @param onAnimationEnd defines the function to be executed when the animation ends
  85863. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85864. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  85865. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  85866. * @param onAnimationLoop defines the callback to call when an animation loops
  85867. * @returns the list of created animatables
  85868. */
  85869. 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[];
  85870. /**
  85871. * Begin a new animation on a given node
  85872. * @param target defines the target where the animation will take place
  85873. * @param animations defines the list of animations to start
  85874. * @param from defines the initial value
  85875. * @param to defines the final value
  85876. * @param loop defines if you want animation to loop (off by default)
  85877. * @param speedRatio defines the speed ratio to apply to all animations
  85878. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85879. * @param onAnimationLoop defines the callback to call when an animation loops
  85880. * @returns the list of created animatables
  85881. */
  85882. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  85883. /**
  85884. * Begin a new animation on a given node and its hierarchy
  85885. * @param target defines the root node where the animation will take place
  85886. * @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.
  85887. * @param animations defines the list of animations to start
  85888. * @param from defines the initial value
  85889. * @param to defines the final value
  85890. * @param loop defines if you want animation to loop (off by default)
  85891. * @param speedRatio defines the speed ratio to apply to all animations
  85892. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85893. * @param onAnimationLoop defines the callback to call when an animation loops
  85894. * @returns the list of animatables created for all nodes
  85895. */
  85896. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  85897. /**
  85898. * Gets the animatable associated with a specific target
  85899. * @param target defines the target of the animatable
  85900. * @returns the required animatable if found
  85901. */
  85902. getAnimatableByTarget(target: any): Nullable<Animatable>;
  85903. /**
  85904. * Gets all animatables associated with a given target
  85905. * @param target defines the target to look animatables for
  85906. * @returns an array of Animatables
  85907. */
  85908. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  85909. /**
  85910. * Stops and removes all animations that have been applied to the scene
  85911. */
  85912. stopAllAnimations(): void;
  85913. /**
  85914. * Gets the current delta time used by animation engine
  85915. */
  85916. deltaTime: number;
  85917. }
  85918. interface Bone {
  85919. /**
  85920. * Copy an animation range from another bone
  85921. * @param source defines the source bone
  85922. * @param rangeName defines the range name to copy
  85923. * @param frameOffset defines the frame offset
  85924. * @param rescaleAsRequired defines if rescaling must be applied if required
  85925. * @param skelDimensionsRatio defines the scaling ratio
  85926. * @returns true if operation was successful
  85927. */
  85928. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  85929. }
  85930. }
  85931. declare module BABYLON {
  85932. /**
  85933. * Class used to override all child animations of a given target
  85934. */
  85935. export class AnimationPropertiesOverride {
  85936. /**
  85937. * Gets or sets a value indicating if animation blending must be used
  85938. */
  85939. enableBlending: boolean;
  85940. /**
  85941. * Gets or sets the blending speed to use when enableBlending is true
  85942. */
  85943. blendingSpeed: number;
  85944. /**
  85945. * Gets or sets the default loop mode to use
  85946. */
  85947. loopMode: number;
  85948. }
  85949. }
  85950. declare module BABYLON {
  85951. /**
  85952. * Class used to handle skinning animations
  85953. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  85954. */
  85955. export class Skeleton implements IAnimatable {
  85956. /** defines the skeleton name */
  85957. name: string;
  85958. /** defines the skeleton Id */
  85959. id: string;
  85960. /**
  85961. * Defines the list of child bones
  85962. */
  85963. bones: Bone[];
  85964. /**
  85965. * Defines an estimate of the dimension of the skeleton at rest
  85966. */
  85967. dimensionsAtRest: Vector3;
  85968. /**
  85969. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  85970. */
  85971. needInitialSkinMatrix: boolean;
  85972. /**
  85973. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  85974. */
  85975. overrideMesh: Nullable<AbstractMesh>;
  85976. /**
  85977. * Gets the list of animations attached to this skeleton
  85978. */
  85979. animations: Array<Animation>;
  85980. private _scene;
  85981. private _isDirty;
  85982. private _transformMatrices;
  85983. private _transformMatrixTexture;
  85984. private _meshesWithPoseMatrix;
  85985. private _animatables;
  85986. private _identity;
  85987. private _synchronizedWithMesh;
  85988. private _ranges;
  85989. private _lastAbsoluteTransformsUpdateId;
  85990. private _canUseTextureForBones;
  85991. private _uniqueId;
  85992. /** @hidden */
  85993. _numBonesWithLinkedTransformNode: number;
  85994. /** @hidden */
  85995. _hasWaitingData: Nullable<boolean>;
  85996. /**
  85997. * Specifies if the skeleton should be serialized
  85998. */
  85999. doNotSerialize: boolean;
  86000. private _useTextureToStoreBoneMatrices;
  86001. /**
  86002. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  86003. * Please note that this option is not available if the hardware does not support it
  86004. */
  86005. get useTextureToStoreBoneMatrices(): boolean;
  86006. set useTextureToStoreBoneMatrices(value: boolean);
  86007. private _animationPropertiesOverride;
  86008. /**
  86009. * Gets or sets the animation properties override
  86010. */
  86011. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86012. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  86013. /**
  86014. * List of inspectable custom properties (used by the Inspector)
  86015. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86016. */
  86017. inspectableCustomProperties: IInspectable[];
  86018. /**
  86019. * An observable triggered before computing the skeleton's matrices
  86020. */
  86021. onBeforeComputeObservable: Observable<Skeleton>;
  86022. /**
  86023. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  86024. */
  86025. get isUsingTextureForMatrices(): boolean;
  86026. /**
  86027. * Gets the unique ID of this skeleton
  86028. */
  86029. get uniqueId(): number;
  86030. /**
  86031. * Creates a new skeleton
  86032. * @param name defines the skeleton name
  86033. * @param id defines the skeleton Id
  86034. * @param scene defines the hosting scene
  86035. */
  86036. constructor(
  86037. /** defines the skeleton name */
  86038. name: string,
  86039. /** defines the skeleton Id */
  86040. id: string, scene: Scene);
  86041. /**
  86042. * Gets the current object class name.
  86043. * @return the class name
  86044. */
  86045. getClassName(): string;
  86046. /**
  86047. * Returns an array containing the root bones
  86048. * @returns an array containing the root bones
  86049. */
  86050. getChildren(): Array<Bone>;
  86051. /**
  86052. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  86053. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86054. * @returns a Float32Array containing matrices data
  86055. */
  86056. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  86057. /**
  86058. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  86059. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86060. * @returns a raw texture containing the data
  86061. */
  86062. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86063. /**
  86064. * Gets the current hosting scene
  86065. * @returns a scene object
  86066. */
  86067. getScene(): Scene;
  86068. /**
  86069. * Gets a string representing the current skeleton data
  86070. * @param fullDetails defines a boolean indicating if we want a verbose version
  86071. * @returns a string representing the current skeleton data
  86072. */
  86073. toString(fullDetails?: boolean): string;
  86074. /**
  86075. * Get bone's index searching by name
  86076. * @param name defines bone's name to search for
  86077. * @return the indice of the bone. Returns -1 if not found
  86078. */
  86079. getBoneIndexByName(name: string): number;
  86080. /**
  86081. * Creater a new animation range
  86082. * @param name defines the name of the range
  86083. * @param from defines the start key
  86084. * @param to defines the end key
  86085. */
  86086. createAnimationRange(name: string, from: number, to: number): void;
  86087. /**
  86088. * Delete a specific animation range
  86089. * @param name defines the name of the range
  86090. * @param deleteFrames defines if frames must be removed as well
  86091. */
  86092. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86093. /**
  86094. * Gets a specific animation range
  86095. * @param name defines the name of the range to look for
  86096. * @returns the requested animation range or null if not found
  86097. */
  86098. getAnimationRange(name: string): Nullable<AnimationRange>;
  86099. /**
  86100. * Gets the list of all animation ranges defined on this skeleton
  86101. * @returns an array
  86102. */
  86103. getAnimationRanges(): Nullable<AnimationRange>[];
  86104. /**
  86105. * Copy animation range from a source skeleton.
  86106. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86107. * @param source defines the source skeleton
  86108. * @param name defines the name of the range to copy
  86109. * @param rescaleAsRequired defines if rescaling must be applied if required
  86110. * @returns true if operation was successful
  86111. */
  86112. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86113. /**
  86114. * Forces the skeleton to go to rest pose
  86115. */
  86116. returnToRest(): void;
  86117. private _getHighestAnimationFrame;
  86118. /**
  86119. * Begin a specific animation range
  86120. * @param name defines the name of the range to start
  86121. * @param loop defines if looping must be turned on (false by default)
  86122. * @param speedRatio defines the speed ratio to apply (1 by default)
  86123. * @param onAnimationEnd defines a callback which will be called when animation will end
  86124. * @returns a new animatable
  86125. */
  86126. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86127. /** @hidden */
  86128. _markAsDirty(): void;
  86129. /** @hidden */
  86130. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86131. /** @hidden */
  86132. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86133. private _computeTransformMatrices;
  86134. /**
  86135. * Build all resources required to render a skeleton
  86136. */
  86137. prepare(): void;
  86138. /**
  86139. * Gets the list of animatables currently running for this skeleton
  86140. * @returns an array of animatables
  86141. */
  86142. getAnimatables(): IAnimatable[];
  86143. /**
  86144. * Clone the current skeleton
  86145. * @param name defines the name of the new skeleton
  86146. * @param id defines the id of the new skeleton
  86147. * @returns the new skeleton
  86148. */
  86149. clone(name: string, id?: string): Skeleton;
  86150. /**
  86151. * Enable animation blending for this skeleton
  86152. * @param blendingSpeed defines the blending speed to apply
  86153. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86154. */
  86155. enableBlending(blendingSpeed?: number): void;
  86156. /**
  86157. * Releases all resources associated with the current skeleton
  86158. */
  86159. dispose(): void;
  86160. /**
  86161. * Serialize the skeleton in a JSON object
  86162. * @returns a JSON object
  86163. */
  86164. serialize(): any;
  86165. /**
  86166. * Creates a new skeleton from serialized data
  86167. * @param parsedSkeleton defines the serialized data
  86168. * @param scene defines the hosting scene
  86169. * @returns a new skeleton
  86170. */
  86171. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86172. /**
  86173. * Compute all node absolute transforms
  86174. * @param forceUpdate defines if computation must be done even if cache is up to date
  86175. */
  86176. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86177. /**
  86178. * Gets the root pose matrix
  86179. * @returns a matrix
  86180. */
  86181. getPoseMatrix(): Nullable<Matrix>;
  86182. /**
  86183. * Sorts bones per internal index
  86184. */
  86185. sortBones(): void;
  86186. private _sortBones;
  86187. }
  86188. }
  86189. declare module BABYLON {
  86190. /**
  86191. * Class used to store bone information
  86192. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86193. */
  86194. export class Bone extends Node {
  86195. /**
  86196. * defines the bone name
  86197. */
  86198. name: string;
  86199. private static _tmpVecs;
  86200. private static _tmpQuat;
  86201. private static _tmpMats;
  86202. /**
  86203. * Gets the list of child bones
  86204. */
  86205. children: Bone[];
  86206. /** Gets the animations associated with this bone */
  86207. animations: Animation[];
  86208. /**
  86209. * Gets or sets bone length
  86210. */
  86211. length: number;
  86212. /**
  86213. * @hidden Internal only
  86214. * Set this value to map this bone to a different index in the transform matrices
  86215. * Set this value to -1 to exclude the bone from the transform matrices
  86216. */
  86217. _index: Nullable<number>;
  86218. private _skeleton;
  86219. private _localMatrix;
  86220. private _restPose;
  86221. private _baseMatrix;
  86222. private _absoluteTransform;
  86223. private _invertedAbsoluteTransform;
  86224. private _parent;
  86225. private _scalingDeterminant;
  86226. private _worldTransform;
  86227. private _localScaling;
  86228. private _localRotation;
  86229. private _localPosition;
  86230. private _needToDecompose;
  86231. private _needToCompose;
  86232. /** @hidden */
  86233. _linkedTransformNode: Nullable<TransformNode>;
  86234. /** @hidden */
  86235. _waitingTransformNodeId: Nullable<string>;
  86236. /** @hidden */
  86237. get _matrix(): Matrix;
  86238. /** @hidden */
  86239. set _matrix(value: Matrix);
  86240. /**
  86241. * Create a new bone
  86242. * @param name defines the bone name
  86243. * @param skeleton defines the parent skeleton
  86244. * @param parentBone defines the parent (can be null if the bone is the root)
  86245. * @param localMatrix defines the local matrix
  86246. * @param restPose defines the rest pose matrix
  86247. * @param baseMatrix defines the base matrix
  86248. * @param index defines index of the bone in the hiearchy
  86249. */
  86250. constructor(
  86251. /**
  86252. * defines the bone name
  86253. */
  86254. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  86255. /**
  86256. * Gets the current object class name.
  86257. * @return the class name
  86258. */
  86259. getClassName(): string;
  86260. /**
  86261. * Gets the parent skeleton
  86262. * @returns a skeleton
  86263. */
  86264. getSkeleton(): Skeleton;
  86265. /**
  86266. * Gets parent bone
  86267. * @returns a bone or null if the bone is the root of the bone hierarchy
  86268. */
  86269. getParent(): Nullable<Bone>;
  86270. /**
  86271. * Returns an array containing the root bones
  86272. * @returns an array containing the root bones
  86273. */
  86274. getChildren(): Array<Bone>;
  86275. /**
  86276. * Gets the node index in matrix array generated for rendering
  86277. * @returns the node index
  86278. */
  86279. getIndex(): number;
  86280. /**
  86281. * Sets the parent bone
  86282. * @param parent defines the parent (can be null if the bone is the root)
  86283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86284. */
  86285. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  86286. /**
  86287. * Gets the local matrix
  86288. * @returns a matrix
  86289. */
  86290. getLocalMatrix(): Matrix;
  86291. /**
  86292. * Gets the base matrix (initial matrix which remains unchanged)
  86293. * @returns a matrix
  86294. */
  86295. getBaseMatrix(): Matrix;
  86296. /**
  86297. * Gets the rest pose matrix
  86298. * @returns a matrix
  86299. */
  86300. getRestPose(): Matrix;
  86301. /**
  86302. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  86303. */
  86304. getWorldMatrix(): Matrix;
  86305. /**
  86306. * Sets the local matrix to rest pose matrix
  86307. */
  86308. returnToRest(): void;
  86309. /**
  86310. * Gets the inverse of the absolute transform matrix.
  86311. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  86312. * @returns a matrix
  86313. */
  86314. getInvertedAbsoluteTransform(): Matrix;
  86315. /**
  86316. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  86317. * @returns a matrix
  86318. */
  86319. getAbsoluteTransform(): Matrix;
  86320. /**
  86321. * Links with the given transform node.
  86322. * The local matrix of this bone is copied from the transform node every frame.
  86323. * @param transformNode defines the transform node to link to
  86324. */
  86325. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  86326. /**
  86327. * Gets the node used to drive the bone's transformation
  86328. * @returns a transform node or null
  86329. */
  86330. getTransformNode(): Nullable<TransformNode>;
  86331. /** Gets or sets current position (in local space) */
  86332. get position(): Vector3;
  86333. set position(newPosition: Vector3);
  86334. /** Gets or sets current rotation (in local space) */
  86335. get rotation(): Vector3;
  86336. set rotation(newRotation: Vector3);
  86337. /** Gets or sets current rotation quaternion (in local space) */
  86338. get rotationQuaternion(): Quaternion;
  86339. set rotationQuaternion(newRotation: Quaternion);
  86340. /** Gets or sets current scaling (in local space) */
  86341. get scaling(): Vector3;
  86342. set scaling(newScaling: Vector3);
  86343. /**
  86344. * Gets the animation properties override
  86345. */
  86346. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86347. private _decompose;
  86348. private _compose;
  86349. /**
  86350. * Update the base and local matrices
  86351. * @param matrix defines the new base or local matrix
  86352. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86353. * @param updateLocalMatrix defines if the local matrix should be updated
  86354. */
  86355. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  86356. /** @hidden */
  86357. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  86358. /**
  86359. * Flag the bone as dirty (Forcing it to update everything)
  86360. */
  86361. markAsDirty(): void;
  86362. /** @hidden */
  86363. _markAsDirtyAndCompose(): void;
  86364. private _markAsDirtyAndDecompose;
  86365. /**
  86366. * Translate the bone in local or world space
  86367. * @param vec The amount to translate the bone
  86368. * @param space The space that the translation is in
  86369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86370. */
  86371. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86372. /**
  86373. * Set the postion of the bone in local or world space
  86374. * @param position The position to set the bone
  86375. * @param space The space that the position is in
  86376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86377. */
  86378. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86379. /**
  86380. * Set the absolute position of the bone (world space)
  86381. * @param position The position to set the bone
  86382. * @param mesh The mesh that this bone is attached to
  86383. */
  86384. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  86385. /**
  86386. * Scale the bone on the x, y and z axes (in local space)
  86387. * @param x The amount to scale the bone on the x axis
  86388. * @param y The amount to scale the bone on the y axis
  86389. * @param z The amount to scale the bone on the z axis
  86390. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  86391. */
  86392. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  86393. /**
  86394. * Set the bone scaling in local space
  86395. * @param scale defines the scaling vector
  86396. */
  86397. setScale(scale: Vector3): void;
  86398. /**
  86399. * Gets the current scaling in local space
  86400. * @returns the current scaling vector
  86401. */
  86402. getScale(): Vector3;
  86403. /**
  86404. * Gets the current scaling in local space and stores it in a target vector
  86405. * @param result defines the target vector
  86406. */
  86407. getScaleToRef(result: Vector3): void;
  86408. /**
  86409. * Set the yaw, pitch, and roll of the bone in local or world space
  86410. * @param yaw The rotation of the bone on the y axis
  86411. * @param pitch The rotation of the bone on the x axis
  86412. * @param roll The rotation of the bone on the z axis
  86413. * @param space The space that the axes of rotation are in
  86414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86415. */
  86416. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  86417. /**
  86418. * Add a rotation to the bone on an axis in local or world space
  86419. * @param axis The axis to rotate the bone on
  86420. * @param amount The amount to rotate the bone
  86421. * @param space The space that the axis is in
  86422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86423. */
  86424. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  86425. /**
  86426. * Set the rotation of the bone to a particular axis angle in local or world space
  86427. * @param axis The axis to rotate the bone on
  86428. * @param angle The angle that the bone should be rotated to
  86429. * @param space The space that the axis is in
  86430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86431. */
  86432. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  86433. /**
  86434. * Set the euler rotation of the bone in local of world space
  86435. * @param rotation The euler rotation that the bone should be set to
  86436. * @param space The space that the rotation is in
  86437. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86438. */
  86439. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86440. /**
  86441. * Set the quaternion rotation of the bone in local of world space
  86442. * @param quat The quaternion rotation that the bone should be set to
  86443. * @param space The space that the rotation is in
  86444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86445. */
  86446. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  86447. /**
  86448. * Set the rotation matrix of the bone in local of world space
  86449. * @param rotMat The rotation matrix that the bone should be set to
  86450. * @param space The space that the rotation is in
  86451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86452. */
  86453. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  86454. private _rotateWithMatrix;
  86455. private _getNegativeRotationToRef;
  86456. /**
  86457. * Get the position of the bone in local or world space
  86458. * @param space The space that the returned position is in
  86459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86460. * @returns The position of the bone
  86461. */
  86462. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86463. /**
  86464. * Copy the position of the bone to a vector3 in local or world space
  86465. * @param space The space that the returned position is in
  86466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86467. * @param result The vector3 to copy the position to
  86468. */
  86469. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  86470. /**
  86471. * Get the absolute position of the bone (world space)
  86472. * @param mesh The mesh that this bone is attached to
  86473. * @returns The absolute position of the bone
  86474. */
  86475. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  86476. /**
  86477. * Copy the absolute position of the bone (world space) to the result param
  86478. * @param mesh The mesh that this bone is attached to
  86479. * @param result The vector3 to copy the absolute position to
  86480. */
  86481. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  86482. /**
  86483. * Compute the absolute transforms of this bone and its children
  86484. */
  86485. computeAbsoluteTransforms(): void;
  86486. /**
  86487. * Get the world direction from an axis that is in the local space of the bone
  86488. * @param localAxis The local direction that is used to compute the world direction
  86489. * @param mesh The mesh that this bone is attached to
  86490. * @returns The world direction
  86491. */
  86492. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86493. /**
  86494. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  86495. * @param localAxis The local direction that is used to compute the world direction
  86496. * @param mesh The mesh that this bone is attached to
  86497. * @param result The vector3 that the world direction will be copied to
  86498. */
  86499. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86500. /**
  86501. * Get the euler rotation of the bone in local or world space
  86502. * @param space The space that the rotation should be in
  86503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86504. * @returns The euler rotation
  86505. */
  86506. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86507. /**
  86508. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  86509. * @param space The space that the rotation should be in
  86510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86511. * @param result The vector3 that the rotation should be copied to
  86512. */
  86513. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86514. /**
  86515. * Get the quaternion rotation of the bone in either local or world space
  86516. * @param space The space that the rotation should be in
  86517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86518. * @returns The quaternion rotation
  86519. */
  86520. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  86521. /**
  86522. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  86523. * @param space The space that the rotation should be in
  86524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86525. * @param result The quaternion that the rotation should be copied to
  86526. */
  86527. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  86528. /**
  86529. * Get the rotation matrix of the bone in local or world space
  86530. * @param space The space that the rotation should be in
  86531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86532. * @returns The rotation matrix
  86533. */
  86534. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  86535. /**
  86536. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  86537. * @param space The space that the rotation should be in
  86538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86539. * @param result The quaternion that the rotation should be copied to
  86540. */
  86541. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  86542. /**
  86543. * Get the world position of a point that is in the local space of the bone
  86544. * @param position The local position
  86545. * @param mesh The mesh that this bone is attached to
  86546. * @returns The world position
  86547. */
  86548. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86549. /**
  86550. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  86551. * @param position The local position
  86552. * @param mesh The mesh that this bone is attached to
  86553. * @param result The vector3 that the world position should be copied to
  86554. */
  86555. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86556. /**
  86557. * Get the local position of a point that is in world space
  86558. * @param position The world position
  86559. * @param mesh The mesh that this bone is attached to
  86560. * @returns The local position
  86561. */
  86562. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86563. /**
  86564. * Get the local position of a point that is in world space and copy it to the result param
  86565. * @param position The world position
  86566. * @param mesh The mesh that this bone is attached to
  86567. * @param result The vector3 that the local position should be copied to
  86568. */
  86569. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86570. }
  86571. }
  86572. declare module BABYLON {
  86573. /**
  86574. * 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.
  86575. * @see https://doc.babylonjs.com/how_to/transformnode
  86576. */
  86577. export class TransformNode extends Node {
  86578. /**
  86579. * Object will not rotate to face the camera
  86580. */
  86581. static BILLBOARDMODE_NONE: number;
  86582. /**
  86583. * Object will rotate to face the camera but only on the x axis
  86584. */
  86585. static BILLBOARDMODE_X: number;
  86586. /**
  86587. * Object will rotate to face the camera but only on the y axis
  86588. */
  86589. static BILLBOARDMODE_Y: number;
  86590. /**
  86591. * Object will rotate to face the camera but only on the z axis
  86592. */
  86593. static BILLBOARDMODE_Z: number;
  86594. /**
  86595. * Object will rotate to face the camera
  86596. */
  86597. static BILLBOARDMODE_ALL: number;
  86598. /**
  86599. * Object will rotate to face the camera's position instead of orientation
  86600. */
  86601. static BILLBOARDMODE_USE_POSITION: number;
  86602. private _forward;
  86603. private _forwardInverted;
  86604. private _up;
  86605. private _right;
  86606. private _rightInverted;
  86607. private _position;
  86608. private _rotation;
  86609. private _rotationQuaternion;
  86610. protected _scaling: Vector3;
  86611. protected _isDirty: boolean;
  86612. private _transformToBoneReferal;
  86613. private _isAbsoluteSynced;
  86614. private _billboardMode;
  86615. /**
  86616. * Gets or sets the billboard mode. Default is 0.
  86617. *
  86618. * | Value | Type | Description |
  86619. * | --- | --- | --- |
  86620. * | 0 | BILLBOARDMODE_NONE | |
  86621. * | 1 | BILLBOARDMODE_X | |
  86622. * | 2 | BILLBOARDMODE_Y | |
  86623. * | 4 | BILLBOARDMODE_Z | |
  86624. * | 7 | BILLBOARDMODE_ALL | |
  86625. *
  86626. */
  86627. get billboardMode(): number;
  86628. set billboardMode(value: number);
  86629. private _preserveParentRotationForBillboard;
  86630. /**
  86631. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86632. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86633. */
  86634. get preserveParentRotationForBillboard(): boolean;
  86635. set preserveParentRotationForBillboard(value: boolean);
  86636. /**
  86637. * 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
  86638. */
  86639. scalingDeterminant: number;
  86640. private _infiniteDistance;
  86641. /**
  86642. * Gets or sets the distance of the object to max, often used by skybox
  86643. */
  86644. get infiniteDistance(): boolean;
  86645. set infiniteDistance(value: boolean);
  86646. /**
  86647. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86648. * By default the system will update normals to compensate
  86649. */
  86650. ignoreNonUniformScaling: boolean;
  86651. /**
  86652. * 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
  86653. */
  86654. reIntegrateRotationIntoRotationQuaternion: boolean;
  86655. /** @hidden */
  86656. _poseMatrix: Nullable<Matrix>;
  86657. /** @hidden */
  86658. _localMatrix: Matrix;
  86659. private _usePivotMatrix;
  86660. private _absolutePosition;
  86661. private _absoluteScaling;
  86662. private _absoluteRotationQuaternion;
  86663. private _pivotMatrix;
  86664. private _pivotMatrixInverse;
  86665. protected _postMultiplyPivotMatrix: boolean;
  86666. protected _isWorldMatrixFrozen: boolean;
  86667. /** @hidden */
  86668. _indexInSceneTransformNodesArray: number;
  86669. /**
  86670. * An event triggered after the world matrix is updated
  86671. */
  86672. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86673. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86674. /**
  86675. * Gets a string identifying the name of the class
  86676. * @returns "TransformNode" string
  86677. */
  86678. getClassName(): string;
  86679. /**
  86680. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86681. */
  86682. get position(): Vector3;
  86683. set position(newPosition: Vector3);
  86684. /**
  86685. * 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)).
  86686. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86687. */
  86688. get rotation(): Vector3;
  86689. set rotation(newRotation: Vector3);
  86690. /**
  86691. * 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)).
  86692. */
  86693. get scaling(): Vector3;
  86694. set scaling(newScaling: Vector3);
  86695. /**
  86696. * 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).
  86697. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86698. */
  86699. get rotationQuaternion(): Nullable<Quaternion>;
  86700. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86701. /**
  86702. * The forward direction of that transform in world space.
  86703. */
  86704. get forward(): Vector3;
  86705. /**
  86706. * The up direction of that transform in world space.
  86707. */
  86708. get up(): Vector3;
  86709. /**
  86710. * The right direction of that transform in world space.
  86711. */
  86712. get right(): Vector3;
  86713. /**
  86714. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86715. * @param matrix the matrix to copy the pose from
  86716. * @returns this TransformNode.
  86717. */
  86718. updatePoseMatrix(matrix: Matrix): TransformNode;
  86719. /**
  86720. * Returns the mesh Pose matrix.
  86721. * @returns the pose matrix
  86722. */
  86723. getPoseMatrix(): Matrix;
  86724. /** @hidden */
  86725. _isSynchronized(): boolean;
  86726. /** @hidden */
  86727. _initCache(): void;
  86728. /**
  86729. * Flag the transform node as dirty (Forcing it to update everything)
  86730. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86731. * @returns this transform node
  86732. */
  86733. markAsDirty(property: string): TransformNode;
  86734. /**
  86735. * Returns the current mesh absolute position.
  86736. * Returns a Vector3.
  86737. */
  86738. get absolutePosition(): Vector3;
  86739. /**
  86740. * Returns the current mesh absolute scaling.
  86741. * Returns a Vector3.
  86742. */
  86743. get absoluteScaling(): Vector3;
  86744. /**
  86745. * Returns the current mesh absolute rotation.
  86746. * Returns a Quaternion.
  86747. */
  86748. get absoluteRotationQuaternion(): Quaternion;
  86749. /**
  86750. * Sets a new matrix to apply before all other transformation
  86751. * @param matrix defines the transform matrix
  86752. * @returns the current TransformNode
  86753. */
  86754. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86755. /**
  86756. * Sets a new pivot matrix to the current node
  86757. * @param matrix defines the new pivot matrix to use
  86758. * @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
  86759. * @returns the current TransformNode
  86760. */
  86761. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86762. /**
  86763. * Returns the mesh pivot matrix.
  86764. * Default : Identity.
  86765. * @returns the matrix
  86766. */
  86767. getPivotMatrix(): Matrix;
  86768. /**
  86769. * Instantiate (when possible) or clone that node with its hierarchy
  86770. * @param newParent defines the new parent to use for the instance (or clone)
  86771. * @param options defines options to configure how copy is done
  86772. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86773. * @returns an instance (or a clone) of the current node with its hiearchy
  86774. */
  86775. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86776. doNotInstantiate: boolean;
  86777. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86778. /**
  86779. * Prevents the World matrix to be computed any longer
  86780. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86781. * @returns the TransformNode.
  86782. */
  86783. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86784. /**
  86785. * Allows back the World matrix computation.
  86786. * @returns the TransformNode.
  86787. */
  86788. unfreezeWorldMatrix(): this;
  86789. /**
  86790. * True if the World matrix has been frozen.
  86791. */
  86792. get isWorldMatrixFrozen(): boolean;
  86793. /**
  86794. * Retuns the mesh absolute position in the World.
  86795. * @returns a Vector3.
  86796. */
  86797. getAbsolutePosition(): Vector3;
  86798. /**
  86799. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86800. * @param absolutePosition the absolute position to set
  86801. * @returns the TransformNode.
  86802. */
  86803. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86804. /**
  86805. * Sets the mesh position in its local space.
  86806. * @param vector3 the position to set in localspace
  86807. * @returns the TransformNode.
  86808. */
  86809. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86810. /**
  86811. * Returns the mesh position in the local space from the current World matrix values.
  86812. * @returns a new Vector3.
  86813. */
  86814. getPositionExpressedInLocalSpace(): Vector3;
  86815. /**
  86816. * Translates the mesh along the passed Vector3 in its local space.
  86817. * @param vector3 the distance to translate in localspace
  86818. * @returns the TransformNode.
  86819. */
  86820. locallyTranslate(vector3: Vector3): TransformNode;
  86821. private static _lookAtVectorCache;
  86822. /**
  86823. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86824. * @param targetPoint the position (must be in same space as current mesh) to look at
  86825. * @param yawCor optional yaw (y-axis) correction in radians
  86826. * @param pitchCor optional pitch (x-axis) correction in radians
  86827. * @param rollCor optional roll (z-axis) correction in radians
  86828. * @param space the choosen space of the target
  86829. * @returns the TransformNode.
  86830. */
  86831. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86832. /**
  86833. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86834. * This Vector3 is expressed in the World space.
  86835. * @param localAxis axis to rotate
  86836. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86837. */
  86838. getDirection(localAxis: Vector3): Vector3;
  86839. /**
  86840. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86841. * localAxis is expressed in the mesh local space.
  86842. * result is computed in the Wordl space from the mesh World matrix.
  86843. * @param localAxis axis to rotate
  86844. * @param result the resulting transformnode
  86845. * @returns this TransformNode.
  86846. */
  86847. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86848. /**
  86849. * Sets this transform node rotation to the given local axis.
  86850. * @param localAxis the axis in local space
  86851. * @param yawCor optional yaw (y-axis) correction in radians
  86852. * @param pitchCor optional pitch (x-axis) correction in radians
  86853. * @param rollCor optional roll (z-axis) correction in radians
  86854. * @returns this TransformNode
  86855. */
  86856. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86857. /**
  86858. * Sets a new pivot point to the current node
  86859. * @param point defines the new pivot point to use
  86860. * @param space defines if the point is in world or local space (local by default)
  86861. * @returns the current TransformNode
  86862. */
  86863. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86864. /**
  86865. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86866. * @returns the pivot point
  86867. */
  86868. getPivotPoint(): Vector3;
  86869. /**
  86870. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86871. * @param result the vector3 to store the result
  86872. * @returns this TransformNode.
  86873. */
  86874. getPivotPointToRef(result: Vector3): TransformNode;
  86875. /**
  86876. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86877. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86878. */
  86879. getAbsolutePivotPoint(): Vector3;
  86880. /**
  86881. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86882. * @param result vector3 to store the result
  86883. * @returns this TransformNode.
  86884. */
  86885. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86886. /**
  86887. * Defines the passed node as the parent of the current node.
  86888. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86889. * @see https://doc.babylonjs.com/how_to/parenting
  86890. * @param node the node ot set as the parent
  86891. * @returns this TransformNode.
  86892. */
  86893. setParent(node: Nullable<Node>): TransformNode;
  86894. private _nonUniformScaling;
  86895. /**
  86896. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86897. */
  86898. get nonUniformScaling(): boolean;
  86899. /** @hidden */
  86900. _updateNonUniformScalingState(value: boolean): boolean;
  86901. /**
  86902. * Attach the current TransformNode to another TransformNode associated with a bone
  86903. * @param bone Bone affecting the TransformNode
  86904. * @param affectedTransformNode TransformNode associated with the bone
  86905. * @returns this object
  86906. */
  86907. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  86908. /**
  86909. * Detach the transform node if its associated with a bone
  86910. * @returns this object
  86911. */
  86912. detachFromBone(): TransformNode;
  86913. private static _rotationAxisCache;
  86914. /**
  86915. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  86916. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  86917. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  86918. * The passed axis is also normalized.
  86919. * @param axis the axis to rotate around
  86920. * @param amount the amount to rotate in radians
  86921. * @param space Space to rotate in (Default: local)
  86922. * @returns the TransformNode.
  86923. */
  86924. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86925. /**
  86926. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  86927. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  86928. * The passed axis is also normalized. .
  86929. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  86930. * @param point the point to rotate around
  86931. * @param axis the axis to rotate around
  86932. * @param amount the amount to rotate in radians
  86933. * @returns the TransformNode
  86934. */
  86935. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  86936. /**
  86937. * Translates the mesh along the axis vector for the passed distance in the given space.
  86938. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  86939. * @param axis the axis to translate in
  86940. * @param distance the distance to translate
  86941. * @param space Space to rotate in (Default: local)
  86942. * @returns the TransformNode.
  86943. */
  86944. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86945. /**
  86946. * Adds a rotation step to the mesh current rotation.
  86947. * x, y, z are Euler angles expressed in radians.
  86948. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  86949. * This means this rotation is made in the mesh local space only.
  86950. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  86951. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  86952. * ```javascript
  86953. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  86954. * ```
  86955. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  86956. * 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.
  86957. * @param x Rotation to add
  86958. * @param y Rotation to add
  86959. * @param z Rotation to add
  86960. * @returns the TransformNode.
  86961. */
  86962. addRotation(x: number, y: number, z: number): TransformNode;
  86963. /**
  86964. * @hidden
  86965. */
  86966. protected _getEffectiveParent(): Nullable<Node>;
  86967. /**
  86968. * Computes the world matrix of the node
  86969. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86970. * @returns the world matrix
  86971. */
  86972. computeWorldMatrix(force?: boolean): Matrix;
  86973. /**
  86974. * Resets this nodeTransform's local matrix to Matrix.Identity().
  86975. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  86976. */
  86977. resetLocalMatrix(independentOfChildren?: boolean): void;
  86978. protected _afterComputeWorldMatrix(): void;
  86979. /**
  86980. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  86981. * @param func callback function to add
  86982. *
  86983. * @returns the TransformNode.
  86984. */
  86985. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  86986. /**
  86987. * Removes a registered callback function.
  86988. * @param func callback function to remove
  86989. * @returns the TransformNode.
  86990. */
  86991. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  86992. /**
  86993. * Gets the position of the current mesh in camera space
  86994. * @param camera defines the camera to use
  86995. * @returns a position
  86996. */
  86997. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  86998. /**
  86999. * Returns the distance from the mesh to the active camera
  87000. * @param camera defines the camera to use
  87001. * @returns the distance
  87002. */
  87003. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87004. /**
  87005. * Clone the current transform node
  87006. * @param name Name of the new clone
  87007. * @param newParent New parent for the clone
  87008. * @param doNotCloneChildren Do not clone children hierarchy
  87009. * @returns the new transform node
  87010. */
  87011. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87012. /**
  87013. * Serializes the objects information.
  87014. * @param currentSerializationObject defines the object to serialize in
  87015. * @returns the serialized object
  87016. */
  87017. serialize(currentSerializationObject?: any): any;
  87018. /**
  87019. * Returns a new TransformNode object parsed from the source provided.
  87020. * @param parsedTransformNode is the source.
  87021. * @param scene the scne the object belongs to
  87022. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87023. * @returns a new TransformNode object parsed from the source provided.
  87024. */
  87025. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87026. /**
  87027. * Get all child-transformNodes of this node
  87028. * @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
  87029. * @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
  87030. * @returns an array of TransformNode
  87031. */
  87032. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87033. /**
  87034. * Releases resources associated with this transform node.
  87035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87037. */
  87038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87039. /**
  87040. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87041. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87042. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87043. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87044. * @returns the current mesh
  87045. */
  87046. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87047. private _syncAbsoluteScalingAndRotation;
  87048. }
  87049. }
  87050. declare module BABYLON {
  87051. /**
  87052. * Defines the types of pose enabled controllers that are supported
  87053. */
  87054. export enum PoseEnabledControllerType {
  87055. /**
  87056. * HTC Vive
  87057. */
  87058. VIVE = 0,
  87059. /**
  87060. * Oculus Rift
  87061. */
  87062. OCULUS = 1,
  87063. /**
  87064. * Windows mixed reality
  87065. */
  87066. WINDOWS = 2,
  87067. /**
  87068. * Samsung gear VR
  87069. */
  87070. GEAR_VR = 3,
  87071. /**
  87072. * Google Daydream
  87073. */
  87074. DAYDREAM = 4,
  87075. /**
  87076. * Generic
  87077. */
  87078. GENERIC = 5
  87079. }
  87080. /**
  87081. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87082. */
  87083. export interface MutableGamepadButton {
  87084. /**
  87085. * Value of the button/trigger
  87086. */
  87087. value: number;
  87088. /**
  87089. * If the button/trigger is currently touched
  87090. */
  87091. touched: boolean;
  87092. /**
  87093. * If the button/trigger is currently pressed
  87094. */
  87095. pressed: boolean;
  87096. }
  87097. /**
  87098. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87099. * @hidden
  87100. */
  87101. export interface ExtendedGamepadButton extends GamepadButton {
  87102. /**
  87103. * If the button/trigger is currently pressed
  87104. */
  87105. readonly pressed: boolean;
  87106. /**
  87107. * If the button/trigger is currently touched
  87108. */
  87109. readonly touched: boolean;
  87110. /**
  87111. * Value of the button/trigger
  87112. */
  87113. readonly value: number;
  87114. }
  87115. /** @hidden */
  87116. export interface _GamePadFactory {
  87117. /**
  87118. * Returns wether or not the current gamepad can be created for this type of controller.
  87119. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87120. * @returns true if it can be created, otherwise false
  87121. */
  87122. canCreate(gamepadInfo: any): boolean;
  87123. /**
  87124. * Creates a new instance of the Gamepad.
  87125. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87126. * @returns the new gamepad instance
  87127. */
  87128. create(gamepadInfo: any): Gamepad;
  87129. }
  87130. /**
  87131. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87132. */
  87133. export class PoseEnabledControllerHelper {
  87134. /** @hidden */
  87135. static _ControllerFactories: _GamePadFactory[];
  87136. /** @hidden */
  87137. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87138. /**
  87139. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87140. * @param vrGamepad the gamepad to initialized
  87141. * @returns a vr controller of the type the gamepad identified as
  87142. */
  87143. static InitiateController(vrGamepad: any): Gamepad;
  87144. }
  87145. /**
  87146. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87147. */
  87148. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87149. /**
  87150. * If the controller is used in a webXR session
  87151. */
  87152. isXR: boolean;
  87153. private _deviceRoomPosition;
  87154. private _deviceRoomRotationQuaternion;
  87155. /**
  87156. * The device position in babylon space
  87157. */
  87158. devicePosition: Vector3;
  87159. /**
  87160. * The device rotation in babylon space
  87161. */
  87162. deviceRotationQuaternion: Quaternion;
  87163. /**
  87164. * The scale factor of the device in babylon space
  87165. */
  87166. deviceScaleFactor: number;
  87167. /**
  87168. * (Likely devicePosition should be used instead) The device position in its room space
  87169. */
  87170. position: Vector3;
  87171. /**
  87172. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87173. */
  87174. rotationQuaternion: Quaternion;
  87175. /**
  87176. * The type of controller (Eg. Windows mixed reality)
  87177. */
  87178. controllerType: PoseEnabledControllerType;
  87179. protected _calculatedPosition: Vector3;
  87180. private _calculatedRotation;
  87181. /**
  87182. * The raw pose from the device
  87183. */
  87184. rawPose: DevicePose;
  87185. private _trackPosition;
  87186. private _maxRotationDistFromHeadset;
  87187. private _draggedRoomRotation;
  87188. /**
  87189. * @hidden
  87190. */
  87191. _disableTrackPosition(fixedPosition: Vector3): void;
  87192. /**
  87193. * Internal, the mesh attached to the controller
  87194. * @hidden
  87195. */
  87196. _mesh: Nullable<AbstractMesh>;
  87197. private _poseControlledCamera;
  87198. private _leftHandSystemQuaternion;
  87199. /**
  87200. * Internal, matrix used to convert room space to babylon space
  87201. * @hidden
  87202. */
  87203. _deviceToWorld: Matrix;
  87204. /**
  87205. * Node to be used when casting a ray from the controller
  87206. * @hidden
  87207. */
  87208. _pointingPoseNode: Nullable<TransformNode>;
  87209. /**
  87210. * Name of the child mesh that can be used to cast a ray from the controller
  87211. */
  87212. static readonly POINTING_POSE: string;
  87213. /**
  87214. * Creates a new PoseEnabledController from a gamepad
  87215. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87216. */
  87217. constructor(browserGamepad: any);
  87218. private _workingMatrix;
  87219. /**
  87220. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87221. */
  87222. update(): void;
  87223. /**
  87224. * Updates only the pose device and mesh without doing any button event checking
  87225. */
  87226. protected _updatePoseAndMesh(): void;
  87227. /**
  87228. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  87229. * @param poseData raw pose fromthe device
  87230. */
  87231. updateFromDevice(poseData: DevicePose): void;
  87232. /**
  87233. * @hidden
  87234. */
  87235. _meshAttachedObservable: Observable<AbstractMesh>;
  87236. /**
  87237. * Attaches a mesh to the controller
  87238. * @param mesh the mesh to be attached
  87239. */
  87240. attachToMesh(mesh: AbstractMesh): void;
  87241. /**
  87242. * Attaches the controllers mesh to a camera
  87243. * @param camera the camera the mesh should be attached to
  87244. */
  87245. attachToPoseControlledCamera(camera: TargetCamera): void;
  87246. /**
  87247. * Disposes of the controller
  87248. */
  87249. dispose(): void;
  87250. /**
  87251. * The mesh that is attached to the controller
  87252. */
  87253. get mesh(): Nullable<AbstractMesh>;
  87254. /**
  87255. * Gets the ray of the controller in the direction the controller is pointing
  87256. * @param length the length the resulting ray should be
  87257. * @returns a ray in the direction the controller is pointing
  87258. */
  87259. getForwardRay(length?: number): Ray;
  87260. }
  87261. }
  87262. declare module BABYLON {
  87263. /**
  87264. * Defines the WebVRController object that represents controllers tracked in 3D space
  87265. */
  87266. export abstract class WebVRController extends PoseEnabledController {
  87267. /**
  87268. * Internal, the default controller model for the controller
  87269. */
  87270. protected _defaultModel: Nullable<AbstractMesh>;
  87271. /**
  87272. * Fired when the trigger state has changed
  87273. */
  87274. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  87275. /**
  87276. * Fired when the main button state has changed
  87277. */
  87278. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87279. /**
  87280. * Fired when the secondary button state has changed
  87281. */
  87282. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87283. /**
  87284. * Fired when the pad state has changed
  87285. */
  87286. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  87287. /**
  87288. * Fired when controllers stick values have changed
  87289. */
  87290. onPadValuesChangedObservable: Observable<StickValues>;
  87291. /**
  87292. * Array of button availible on the controller
  87293. */
  87294. protected _buttons: Array<MutableGamepadButton>;
  87295. private _onButtonStateChange;
  87296. /**
  87297. * Fired when a controller button's state has changed
  87298. * @param callback the callback containing the button that was modified
  87299. */
  87300. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  87301. /**
  87302. * X and Y axis corresponding to the controllers joystick
  87303. */
  87304. pad: StickValues;
  87305. /**
  87306. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  87307. */
  87308. hand: string;
  87309. /**
  87310. * The default controller model for the controller
  87311. */
  87312. get defaultModel(): Nullable<AbstractMesh>;
  87313. /**
  87314. * Creates a new WebVRController from a gamepad
  87315. * @param vrGamepad the gamepad that the WebVRController should be created from
  87316. */
  87317. constructor(vrGamepad: any);
  87318. /**
  87319. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  87320. */
  87321. update(): void;
  87322. /**
  87323. * Function to be called when a button is modified
  87324. */
  87325. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  87326. /**
  87327. * Loads a mesh and attaches it to the controller
  87328. * @param scene the scene the mesh should be added to
  87329. * @param meshLoaded callback for when the mesh has been loaded
  87330. */
  87331. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  87332. private _setButtonValue;
  87333. private _changes;
  87334. private _checkChanges;
  87335. /**
  87336. * Disposes of th webVRCOntroller
  87337. */
  87338. dispose(): void;
  87339. }
  87340. }
  87341. declare module BABYLON {
  87342. /**
  87343. * The HemisphericLight simulates the ambient environment light,
  87344. * so the passed direction is the light reflection direction, not the incoming direction.
  87345. */
  87346. export class HemisphericLight extends Light {
  87347. /**
  87348. * The groundColor is the light in the opposite direction to the one specified during creation.
  87349. * 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.
  87350. */
  87351. groundColor: Color3;
  87352. /**
  87353. * The light reflection direction, not the incoming direction.
  87354. */
  87355. direction: Vector3;
  87356. /**
  87357. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  87358. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  87359. * The HemisphericLight can't cast shadows.
  87360. * Documentation : https://doc.babylonjs.com/babylon101/lights
  87361. * @param name The friendly name of the light
  87362. * @param direction The direction of the light reflection
  87363. * @param scene The scene the light belongs to
  87364. */
  87365. constructor(name: string, direction: Vector3, scene: Scene);
  87366. protected _buildUniformLayout(): void;
  87367. /**
  87368. * Returns the string "HemisphericLight".
  87369. * @return The class name
  87370. */
  87371. getClassName(): string;
  87372. /**
  87373. * Sets the HemisphericLight direction towards the passed target (Vector3).
  87374. * Returns the updated direction.
  87375. * @param target The target the direction should point to
  87376. * @return The computed direction
  87377. */
  87378. setDirectionToTarget(target: Vector3): Vector3;
  87379. /**
  87380. * Returns the shadow generator associated to the light.
  87381. * @returns Always null for hemispheric lights because it does not support shadows.
  87382. */
  87383. getShadowGenerator(): Nullable<IShadowGenerator>;
  87384. /**
  87385. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  87386. * @param effect The effect to update
  87387. * @param lightIndex The index of the light in the effect to update
  87388. * @returns The hemispheric light
  87389. */
  87390. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  87391. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  87392. /**
  87393. * Computes the world matrix of the node
  87394. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87395. * @param useWasUpdatedFlag defines a reserved property
  87396. * @returns the world matrix
  87397. */
  87398. computeWorldMatrix(): Matrix;
  87399. /**
  87400. * Returns the integer 3.
  87401. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  87402. */
  87403. getTypeID(): number;
  87404. /**
  87405. * Prepares the list of defines specific to the light type.
  87406. * @param defines the list of defines
  87407. * @param lightIndex defines the index of the light for the effect
  87408. */
  87409. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  87410. }
  87411. }
  87412. declare module BABYLON {
  87413. /** @hidden */
  87414. export var vrMultiviewToSingleviewPixelShader: {
  87415. name: string;
  87416. shader: string;
  87417. };
  87418. }
  87419. declare module BABYLON {
  87420. /**
  87421. * Renders to multiple views with a single draw call
  87422. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  87423. */
  87424. export class MultiviewRenderTarget extends RenderTargetTexture {
  87425. /**
  87426. * Creates a multiview render target
  87427. * @param scene scene used with the render target
  87428. * @param size the size of the render target (used for each view)
  87429. */
  87430. constructor(scene: Scene, size?: number | {
  87431. width: number;
  87432. height: number;
  87433. } | {
  87434. ratio: number;
  87435. });
  87436. /**
  87437. * @hidden
  87438. * @param faceIndex the face index, if its a cube texture
  87439. */
  87440. _bindFrameBuffer(faceIndex?: number): void;
  87441. /**
  87442. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87443. * @returns the view count
  87444. */
  87445. getViewCount(): number;
  87446. }
  87447. }
  87448. declare module BABYLON {
  87449. /**
  87450. * Represents a camera frustum
  87451. */
  87452. export class Frustum {
  87453. /**
  87454. * Gets the planes representing the frustum
  87455. * @param transform matrix to be applied to the returned planes
  87456. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87457. */
  87458. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87459. /**
  87460. * Gets the near frustum plane transformed by the transform matrix
  87461. * @param transform transformation matrix to be applied to the resulting frustum plane
  87462. * @param frustumPlane the resuling frustum plane
  87463. */
  87464. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87465. /**
  87466. * Gets the far frustum plane transformed by the transform matrix
  87467. * @param transform transformation matrix to be applied to the resulting frustum plane
  87468. * @param frustumPlane the resuling frustum plane
  87469. */
  87470. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87471. /**
  87472. * Gets the left frustum plane transformed by the transform matrix
  87473. * @param transform transformation matrix to be applied to the resulting frustum plane
  87474. * @param frustumPlane the resuling frustum plane
  87475. */
  87476. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87477. /**
  87478. * Gets the right frustum plane transformed by the transform matrix
  87479. * @param transform transformation matrix to be applied to the resulting frustum plane
  87480. * @param frustumPlane the resuling frustum plane
  87481. */
  87482. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87483. /**
  87484. * Gets the top frustum plane transformed by the transform matrix
  87485. * @param transform transformation matrix to be applied to the resulting frustum plane
  87486. * @param frustumPlane the resuling frustum plane
  87487. */
  87488. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87489. /**
  87490. * Gets the bottom frustum plane transformed by the transform matrix
  87491. * @param transform transformation matrix to be applied to the resulting frustum plane
  87492. * @param frustumPlane the resuling frustum plane
  87493. */
  87494. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87495. /**
  87496. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87497. * @param transform transformation matrix to be applied to the resulting frustum planes
  87498. * @param frustumPlanes the resuling frustum planes
  87499. */
  87500. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87501. }
  87502. }
  87503. declare module BABYLON {
  87504. interface Engine {
  87505. /**
  87506. * Creates a new multiview render target
  87507. * @param width defines the width of the texture
  87508. * @param height defines the height of the texture
  87509. * @returns the created multiview texture
  87510. */
  87511. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87512. /**
  87513. * Binds a multiview framebuffer to be drawn to
  87514. * @param multiviewTexture texture to bind
  87515. */
  87516. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87517. }
  87518. interface Camera {
  87519. /**
  87520. * @hidden
  87521. * 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)
  87522. */
  87523. _useMultiviewToSingleView: boolean;
  87524. /**
  87525. * @hidden
  87526. * 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)
  87527. */
  87528. _multiviewTexture: Nullable<RenderTargetTexture>;
  87529. /**
  87530. * @hidden
  87531. * ensures the multiview texture of the camera exists and has the specified width/height
  87532. * @param width height to set on the multiview texture
  87533. * @param height width to set on the multiview texture
  87534. */
  87535. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  87536. }
  87537. interface Scene {
  87538. /** @hidden */
  87539. _transformMatrixR: Matrix;
  87540. /** @hidden */
  87541. _multiviewSceneUbo: Nullable<UniformBuffer>;
  87542. /** @hidden */
  87543. _createMultiviewUbo(): void;
  87544. /** @hidden */
  87545. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  87546. /** @hidden */
  87547. _renderMultiviewToSingleView(camera: Camera): void;
  87548. }
  87549. }
  87550. declare module BABYLON {
  87551. /**
  87552. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  87553. * This will not be used for webXR as it supports displaying texture arrays directly
  87554. */
  87555. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  87556. /**
  87557. * Initializes a VRMultiviewToSingleview
  87558. * @param name name of the post process
  87559. * @param camera camera to be applied to
  87560. * @param scaleFactor scaling factor to the size of the output texture
  87561. */
  87562. constructor(name: string, camera: Camera, scaleFactor: number);
  87563. }
  87564. }
  87565. declare module BABYLON {
  87566. /**
  87567. * Interface used to define additional presentation attributes
  87568. */
  87569. export interface IVRPresentationAttributes {
  87570. /**
  87571. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  87572. */
  87573. highRefreshRate: boolean;
  87574. /**
  87575. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  87576. */
  87577. foveationLevel: number;
  87578. }
  87579. interface Engine {
  87580. /** @hidden */
  87581. _vrDisplay: any;
  87582. /** @hidden */
  87583. _vrSupported: boolean;
  87584. /** @hidden */
  87585. _oldSize: Size;
  87586. /** @hidden */
  87587. _oldHardwareScaleFactor: number;
  87588. /** @hidden */
  87589. _vrExclusivePointerMode: boolean;
  87590. /** @hidden */
  87591. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  87592. /** @hidden */
  87593. _onVRDisplayPointerRestricted: () => void;
  87594. /** @hidden */
  87595. _onVRDisplayPointerUnrestricted: () => void;
  87596. /** @hidden */
  87597. _onVrDisplayConnect: Nullable<(display: any) => void>;
  87598. /** @hidden */
  87599. _onVrDisplayDisconnect: Nullable<() => void>;
  87600. /** @hidden */
  87601. _onVrDisplayPresentChange: Nullable<() => void>;
  87602. /**
  87603. * Observable signaled when VR display mode changes
  87604. */
  87605. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87606. /**
  87607. * Observable signaled when VR request present is complete
  87608. */
  87609. onVRRequestPresentComplete: Observable<boolean>;
  87610. /**
  87611. * Observable signaled when VR request present starts
  87612. */
  87613. onVRRequestPresentStart: Observable<Engine>;
  87614. /**
  87615. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  87616. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  87617. */
  87618. isInVRExclusivePointerMode: boolean;
  87619. /**
  87620. * Gets a boolean indicating if a webVR device was detected
  87621. * @returns true if a webVR device was detected
  87622. */
  87623. isVRDevicePresent(): boolean;
  87624. /**
  87625. * Gets the current webVR device
  87626. * @returns the current webVR device (or null)
  87627. */
  87628. getVRDevice(): any;
  87629. /**
  87630. * Initializes a webVR display and starts listening to display change events
  87631. * The onVRDisplayChangedObservable will be notified upon these changes
  87632. * @returns A promise containing a VRDisplay and if vr is supported
  87633. */
  87634. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87635. /** @hidden */
  87636. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  87637. /**
  87638. * Gets or sets the presentation attributes used to configure VR rendering
  87639. */
  87640. vrPresentationAttributes?: IVRPresentationAttributes;
  87641. /**
  87642. * Call this function to switch to webVR mode
  87643. * Will do nothing if webVR is not supported or if there is no webVR device
  87644. * @param options the webvr options provided to the camera. mainly used for multiview
  87645. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87646. */
  87647. enableVR(options: WebVROptions): void;
  87648. /** @hidden */
  87649. _onVRFullScreenTriggered(): void;
  87650. }
  87651. }
  87652. declare module BABYLON {
  87653. /**
  87654. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  87655. * IMPORTANT!! The data is right-hand data.
  87656. * @export
  87657. * @interface DevicePose
  87658. */
  87659. export interface DevicePose {
  87660. /**
  87661. * The position of the device, values in array are [x,y,z].
  87662. */
  87663. readonly position: Nullable<Float32Array>;
  87664. /**
  87665. * The linearVelocity of the device, values in array are [x,y,z].
  87666. */
  87667. readonly linearVelocity: Nullable<Float32Array>;
  87668. /**
  87669. * The linearAcceleration of the device, values in array are [x,y,z].
  87670. */
  87671. readonly linearAcceleration: Nullable<Float32Array>;
  87672. /**
  87673. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  87674. */
  87675. readonly orientation: Nullable<Float32Array>;
  87676. /**
  87677. * The angularVelocity of the device, values in array are [x,y,z].
  87678. */
  87679. readonly angularVelocity: Nullable<Float32Array>;
  87680. /**
  87681. * The angularAcceleration of the device, values in array are [x,y,z].
  87682. */
  87683. readonly angularAcceleration: Nullable<Float32Array>;
  87684. }
  87685. /**
  87686. * Interface representing a pose controlled object in Babylon.
  87687. * A pose controlled object has both regular pose values as well as pose values
  87688. * from an external device such as a VR head mounted display
  87689. */
  87690. export interface PoseControlled {
  87691. /**
  87692. * The position of the object in babylon space.
  87693. */
  87694. position: Vector3;
  87695. /**
  87696. * The rotation quaternion of the object in babylon space.
  87697. */
  87698. rotationQuaternion: Quaternion;
  87699. /**
  87700. * The position of the device in babylon space.
  87701. */
  87702. devicePosition?: Vector3;
  87703. /**
  87704. * The rotation quaternion of the device in babylon space.
  87705. */
  87706. deviceRotationQuaternion: Quaternion;
  87707. /**
  87708. * The raw pose coming from the device.
  87709. */
  87710. rawPose: Nullable<DevicePose>;
  87711. /**
  87712. * The scale of the device to be used when translating from device space to babylon space.
  87713. */
  87714. deviceScaleFactor: number;
  87715. /**
  87716. * Updates the poseControlled values based on the input device pose.
  87717. * @param poseData the pose data to update the object with
  87718. */
  87719. updateFromDevice(poseData: DevicePose): void;
  87720. }
  87721. /**
  87722. * Set of options to customize the webVRCamera
  87723. */
  87724. export interface WebVROptions {
  87725. /**
  87726. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  87727. */
  87728. trackPosition?: boolean;
  87729. /**
  87730. * Sets the scale of the vrDevice in babylon space. (default: 1)
  87731. */
  87732. positionScale?: number;
  87733. /**
  87734. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  87735. */
  87736. displayName?: string;
  87737. /**
  87738. * Should the native controller meshes be initialized. (default: true)
  87739. */
  87740. controllerMeshes?: boolean;
  87741. /**
  87742. * Creating a default HemiLight only on controllers. (default: true)
  87743. */
  87744. defaultLightingOnControllers?: boolean;
  87745. /**
  87746. * If you don't want to use the default VR button of the helper. (default: false)
  87747. */
  87748. useCustomVRButton?: boolean;
  87749. /**
  87750. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  87751. */
  87752. customVRButton?: HTMLButtonElement;
  87753. /**
  87754. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  87755. */
  87756. rayLength?: number;
  87757. /**
  87758. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  87759. */
  87760. defaultHeight?: number;
  87761. /**
  87762. * If multiview should be used if availible (default: false)
  87763. */
  87764. useMultiview?: boolean;
  87765. }
  87766. /**
  87767. * This represents a WebVR camera.
  87768. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  87769. * @example http://doc.babylonjs.com/how_to/webvr_camera
  87770. */
  87771. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  87772. private webVROptions;
  87773. /**
  87774. * @hidden
  87775. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  87776. */
  87777. _vrDevice: any;
  87778. /**
  87779. * The rawPose of the vrDevice.
  87780. */
  87781. rawPose: Nullable<DevicePose>;
  87782. private _onVREnabled;
  87783. private _specsVersion;
  87784. private _attached;
  87785. private _frameData;
  87786. protected _descendants: Array<Node>;
  87787. private _deviceRoomPosition;
  87788. /** @hidden */
  87789. _deviceRoomRotationQuaternion: Quaternion;
  87790. private _standingMatrix;
  87791. /**
  87792. * Represents device position in babylon space.
  87793. */
  87794. devicePosition: Vector3;
  87795. /**
  87796. * Represents device rotation in babylon space.
  87797. */
  87798. deviceRotationQuaternion: Quaternion;
  87799. /**
  87800. * The scale of the device to be used when translating from device space to babylon space.
  87801. */
  87802. deviceScaleFactor: number;
  87803. private _deviceToWorld;
  87804. private _worldToDevice;
  87805. /**
  87806. * References to the webVR controllers for the vrDevice.
  87807. */
  87808. controllers: Array<WebVRController>;
  87809. /**
  87810. * Emits an event when a controller is attached.
  87811. */
  87812. onControllersAttachedObservable: Observable<WebVRController[]>;
  87813. /**
  87814. * Emits an event when a controller's mesh has been loaded;
  87815. */
  87816. onControllerMeshLoadedObservable: Observable<WebVRController>;
  87817. /**
  87818. * Emits an event when the HMD's pose has been updated.
  87819. */
  87820. onPoseUpdatedFromDeviceObservable: Observable<any>;
  87821. private _poseSet;
  87822. /**
  87823. * If the rig cameras be used as parent instead of this camera.
  87824. */
  87825. rigParenting: boolean;
  87826. private _lightOnControllers;
  87827. private _defaultHeight?;
  87828. /**
  87829. * Instantiates a WebVRFreeCamera.
  87830. * @param name The name of the WebVRFreeCamera
  87831. * @param position The starting anchor position for the camera
  87832. * @param scene The scene the camera belongs to
  87833. * @param webVROptions a set of customizable options for the webVRCamera
  87834. */
  87835. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  87836. /**
  87837. * Gets the device distance from the ground in meters.
  87838. * @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.
  87839. */
  87840. deviceDistanceToRoomGround(): number;
  87841. /**
  87842. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  87843. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  87844. */
  87845. useStandingMatrix(callback?: (bool: boolean) => void): void;
  87846. /**
  87847. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  87848. * @returns A promise with a boolean set to if the standing matrix is supported.
  87849. */
  87850. useStandingMatrixAsync(): Promise<boolean>;
  87851. /**
  87852. * Disposes the camera
  87853. */
  87854. dispose(): void;
  87855. /**
  87856. * Gets a vrController by name.
  87857. * @param name The name of the controller to retreive
  87858. * @returns the controller matching the name specified or null if not found
  87859. */
  87860. getControllerByName(name: string): Nullable<WebVRController>;
  87861. private _leftController;
  87862. /**
  87863. * The controller corresponding to the users left hand.
  87864. */
  87865. get leftController(): Nullable<WebVRController>;
  87866. private _rightController;
  87867. /**
  87868. * The controller corresponding to the users right hand.
  87869. */
  87870. get rightController(): Nullable<WebVRController>;
  87871. /**
  87872. * Casts a ray forward from the vrCamera's gaze.
  87873. * @param length Length of the ray (default: 100)
  87874. * @returns the ray corresponding to the gaze
  87875. */
  87876. getForwardRay(length?: number): Ray;
  87877. /**
  87878. * @hidden
  87879. * Updates the camera based on device's frame data
  87880. */
  87881. _checkInputs(): void;
  87882. /**
  87883. * Updates the poseControlled values based on the input device pose.
  87884. * @param poseData Pose coming from the device
  87885. */
  87886. updateFromDevice(poseData: DevicePose): void;
  87887. private _htmlElementAttached;
  87888. private _detachIfAttached;
  87889. /**
  87890. * WebVR's attach control will start broadcasting frames to the device.
  87891. * Note that in certain browsers (chrome for example) this function must be called
  87892. * within a user-interaction callback. Example:
  87893. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  87894. *
  87895. * @param element html element to attach the vrDevice to
  87896. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  87897. */
  87898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87899. /**
  87900. * Detaches the camera from the html element and disables VR
  87901. *
  87902. * @param element html element to detach from
  87903. */
  87904. detachControl(element: HTMLElement): void;
  87905. /**
  87906. * @returns the name of this class
  87907. */
  87908. getClassName(): string;
  87909. /**
  87910. * Calls resetPose on the vrDisplay
  87911. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  87912. */
  87913. resetToCurrentRotation(): void;
  87914. /**
  87915. * @hidden
  87916. * Updates the rig cameras (left and right eye)
  87917. */
  87918. _updateRigCameras(): void;
  87919. private _workingVector;
  87920. private _oneVector;
  87921. private _workingMatrix;
  87922. private updateCacheCalled;
  87923. private _correctPositionIfNotTrackPosition;
  87924. /**
  87925. * @hidden
  87926. * Updates the cached values of the camera
  87927. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  87928. */
  87929. _updateCache(ignoreParentClass?: boolean): void;
  87930. /**
  87931. * @hidden
  87932. * Get current device position in babylon world
  87933. */
  87934. _computeDevicePosition(): void;
  87935. /**
  87936. * Updates the current device position and rotation in the babylon world
  87937. */
  87938. update(): void;
  87939. /**
  87940. * @hidden
  87941. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  87942. * @returns an identity matrix
  87943. */
  87944. _getViewMatrix(): Matrix;
  87945. private _tmpMatrix;
  87946. /**
  87947. * This function is called by the two RIG cameras.
  87948. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  87949. * @hidden
  87950. */
  87951. _getWebVRViewMatrix(): Matrix;
  87952. /** @hidden */
  87953. _getWebVRProjectionMatrix(): Matrix;
  87954. private _onGamepadConnectedObserver;
  87955. private _onGamepadDisconnectedObserver;
  87956. private _updateCacheWhenTrackingDisabledObserver;
  87957. /**
  87958. * Initializes the controllers and their meshes
  87959. */
  87960. initControllers(): void;
  87961. }
  87962. }
  87963. declare module BABYLON {
  87964. /**
  87965. * Size options for a post process
  87966. */
  87967. export type PostProcessOptions = {
  87968. width: number;
  87969. height: number;
  87970. };
  87971. /**
  87972. * PostProcess can be used to apply a shader to a texture after it has been rendered
  87973. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  87974. */
  87975. export class PostProcess {
  87976. /** Name of the PostProcess. */
  87977. name: string;
  87978. /**
  87979. * Gets or sets the unique id of the post process
  87980. */
  87981. uniqueId: number;
  87982. /**
  87983. * Width of the texture to apply the post process on
  87984. */
  87985. width: number;
  87986. /**
  87987. * Height of the texture to apply the post process on
  87988. */
  87989. height: number;
  87990. /**
  87991. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  87992. * @hidden
  87993. */
  87994. _outputTexture: Nullable<InternalTexture>;
  87995. /**
  87996. * Sampling mode used by the shader
  87997. * See https://doc.babylonjs.com/classes/3.1/texture
  87998. */
  87999. renderTargetSamplingMode: number;
  88000. /**
  88001. * Clear color to use when screen clearing
  88002. */
  88003. clearColor: Color4;
  88004. /**
  88005. * If the buffer needs to be cleared before applying the post process. (default: true)
  88006. * Should be set to false if shader will overwrite all previous pixels.
  88007. */
  88008. autoClear: boolean;
  88009. /**
  88010. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  88011. */
  88012. alphaMode: number;
  88013. /**
  88014. * Sets the setAlphaBlendConstants of the babylon engine
  88015. */
  88016. alphaConstants: Color4;
  88017. /**
  88018. * Animations to be used for the post processing
  88019. */
  88020. animations: Animation[];
  88021. /**
  88022. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  88023. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  88024. */
  88025. enablePixelPerfectMode: boolean;
  88026. /**
  88027. * Force the postprocess to be applied without taking in account viewport
  88028. */
  88029. forceFullscreenViewport: boolean;
  88030. /**
  88031. * List of inspectable custom properties (used by the Inspector)
  88032. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88033. */
  88034. inspectableCustomProperties: IInspectable[];
  88035. /**
  88036. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  88037. *
  88038. * | Value | Type | Description |
  88039. * | ----- | ----------------------------------- | ----------- |
  88040. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  88041. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  88042. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  88043. *
  88044. */
  88045. scaleMode: number;
  88046. /**
  88047. * Force textures to be a power of two (default: false)
  88048. */
  88049. alwaysForcePOT: boolean;
  88050. private _samples;
  88051. /**
  88052. * Number of sample textures (default: 1)
  88053. */
  88054. get samples(): number;
  88055. set samples(n: number);
  88056. /**
  88057. * Modify the scale of the post process to be the same as the viewport (default: false)
  88058. */
  88059. adaptScaleToCurrentViewport: boolean;
  88060. private _camera;
  88061. private _scene;
  88062. private _engine;
  88063. private _options;
  88064. private _reusable;
  88065. private _textureType;
  88066. private _textureFormat;
  88067. /**
  88068. * Smart array of input and output textures for the post process.
  88069. * @hidden
  88070. */
  88071. _textures: SmartArray<InternalTexture>;
  88072. /**
  88073. * The index in _textures that corresponds to the output texture.
  88074. * @hidden
  88075. */
  88076. _currentRenderTextureInd: number;
  88077. private _effect;
  88078. private _samplers;
  88079. private _fragmentUrl;
  88080. private _vertexUrl;
  88081. private _parameters;
  88082. private _scaleRatio;
  88083. protected _indexParameters: any;
  88084. private _shareOutputWithPostProcess;
  88085. private _texelSize;
  88086. private _forcedOutputTexture;
  88087. /**
  88088. * Returns the fragment url or shader name used in the post process.
  88089. * @returns the fragment url or name in the shader store.
  88090. */
  88091. getEffectName(): string;
  88092. /**
  88093. * An event triggered when the postprocess is activated.
  88094. */
  88095. onActivateObservable: Observable<Camera>;
  88096. private _onActivateObserver;
  88097. /**
  88098. * A function that is added to the onActivateObservable
  88099. */
  88100. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88101. /**
  88102. * An event triggered when the postprocess changes its size.
  88103. */
  88104. onSizeChangedObservable: Observable<PostProcess>;
  88105. private _onSizeChangedObserver;
  88106. /**
  88107. * A function that is added to the onSizeChangedObservable
  88108. */
  88109. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88110. /**
  88111. * An event triggered when the postprocess applies its effect.
  88112. */
  88113. onApplyObservable: Observable<Effect>;
  88114. private _onApplyObserver;
  88115. /**
  88116. * A function that is added to the onApplyObservable
  88117. */
  88118. set onApply(callback: (effect: Effect) => void);
  88119. /**
  88120. * An event triggered before rendering the postprocess
  88121. */
  88122. onBeforeRenderObservable: Observable<Effect>;
  88123. private _onBeforeRenderObserver;
  88124. /**
  88125. * A function that is added to the onBeforeRenderObservable
  88126. */
  88127. set onBeforeRender(callback: (effect: Effect) => void);
  88128. /**
  88129. * An event triggered after rendering the postprocess
  88130. */
  88131. onAfterRenderObservable: Observable<Effect>;
  88132. private _onAfterRenderObserver;
  88133. /**
  88134. * A function that is added to the onAfterRenderObservable
  88135. */
  88136. set onAfterRender(callback: (efect: Effect) => void);
  88137. /**
  88138. * 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
  88139. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88140. */
  88141. get inputTexture(): InternalTexture;
  88142. set inputTexture(value: InternalTexture);
  88143. /**
  88144. * Gets the camera which post process is applied to.
  88145. * @returns The camera the post process is applied to.
  88146. */
  88147. getCamera(): Camera;
  88148. /**
  88149. * Gets the texel size of the postprocess.
  88150. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88151. */
  88152. get texelSize(): Vector2;
  88153. /**
  88154. * Creates a new instance PostProcess
  88155. * @param name The name of the PostProcess.
  88156. * @param fragmentUrl The url of the fragment shader to be used.
  88157. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88158. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88159. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88160. * @param camera The camera to apply the render pass to.
  88161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88162. * @param engine The engine which the post process will be applied. (default: current engine)
  88163. * @param reusable If the post process can be reused on the same frame. (default: false)
  88164. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88165. * @param textureType Type of textures used when performing the post process. (default: 0)
  88166. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88167. * @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
  88168. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88169. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88170. */
  88171. constructor(
  88172. /** Name of the PostProcess. */
  88173. 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);
  88174. /**
  88175. * Gets a string idenfifying the name of the class
  88176. * @returns "PostProcess" string
  88177. */
  88178. getClassName(): string;
  88179. /**
  88180. * Gets the engine which this post process belongs to.
  88181. * @returns The engine the post process was enabled with.
  88182. */
  88183. getEngine(): Engine;
  88184. /**
  88185. * The effect that is created when initializing the post process.
  88186. * @returns The created effect corresponding the the postprocess.
  88187. */
  88188. getEffect(): Effect;
  88189. /**
  88190. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88191. * @param postProcess The post process to share the output with.
  88192. * @returns This post process.
  88193. */
  88194. shareOutputWith(postProcess: PostProcess): PostProcess;
  88195. /**
  88196. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88197. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88198. */
  88199. useOwnOutput(): void;
  88200. /**
  88201. * Updates the effect with the current post process compile time values and recompiles the shader.
  88202. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88203. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88204. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88205. * @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
  88206. * @param onCompiled Called when the shader has been compiled.
  88207. * @param onError Called if there is an error when compiling a shader.
  88208. */
  88209. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88210. /**
  88211. * The post process is reusable if it can be used multiple times within one frame.
  88212. * @returns If the post process is reusable
  88213. */
  88214. isReusable(): boolean;
  88215. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88216. markTextureDirty(): void;
  88217. /**
  88218. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88219. * 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.
  88220. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88221. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88222. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88223. * @returns The target texture that was bound to be written to.
  88224. */
  88225. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  88226. /**
  88227. * If the post process is supported.
  88228. */
  88229. get isSupported(): boolean;
  88230. /**
  88231. * The aspect ratio of the output texture.
  88232. */
  88233. get aspectRatio(): number;
  88234. /**
  88235. * Get a value indicating if the post-process is ready to be used
  88236. * @returns true if the post-process is ready (shader is compiled)
  88237. */
  88238. isReady(): boolean;
  88239. /**
  88240. * Binds all textures and uniforms to the shader, this will be run on every pass.
  88241. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  88242. */
  88243. apply(): Nullable<Effect>;
  88244. private _disposeTextures;
  88245. /**
  88246. * Disposes the post process.
  88247. * @param camera The camera to dispose the post process on.
  88248. */
  88249. dispose(camera?: Camera): void;
  88250. }
  88251. }
  88252. declare module BABYLON {
  88253. /** @hidden */
  88254. export var kernelBlurVaryingDeclaration: {
  88255. name: string;
  88256. shader: string;
  88257. };
  88258. }
  88259. declare module BABYLON {
  88260. /** @hidden */
  88261. export var kernelBlurFragment: {
  88262. name: string;
  88263. shader: string;
  88264. };
  88265. }
  88266. declare module BABYLON {
  88267. /** @hidden */
  88268. export var kernelBlurFragment2: {
  88269. name: string;
  88270. shader: string;
  88271. };
  88272. }
  88273. declare module BABYLON {
  88274. /** @hidden */
  88275. export var kernelBlurPixelShader: {
  88276. name: string;
  88277. shader: string;
  88278. };
  88279. }
  88280. declare module BABYLON {
  88281. /** @hidden */
  88282. export var kernelBlurVertex: {
  88283. name: string;
  88284. shader: string;
  88285. };
  88286. }
  88287. declare module BABYLON {
  88288. /** @hidden */
  88289. export var kernelBlurVertexShader: {
  88290. name: string;
  88291. shader: string;
  88292. };
  88293. }
  88294. declare module BABYLON {
  88295. /**
  88296. * The Blur Post Process which blurs an image based on a kernel and direction.
  88297. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  88298. */
  88299. export class BlurPostProcess extends PostProcess {
  88300. /** The direction in which to blur the image. */
  88301. direction: Vector2;
  88302. private blockCompilation;
  88303. protected _kernel: number;
  88304. protected _idealKernel: number;
  88305. protected _packedFloat: boolean;
  88306. private _staticDefines;
  88307. /**
  88308. * Sets the length in pixels of the blur sample region
  88309. */
  88310. set kernel(v: number);
  88311. /**
  88312. * Gets the length in pixels of the blur sample region
  88313. */
  88314. get kernel(): number;
  88315. /**
  88316. * Sets wether or not the blur needs to unpack/repack floats
  88317. */
  88318. set packedFloat(v: boolean);
  88319. /**
  88320. * Gets wether or not the blur is unpacking/repacking floats
  88321. */
  88322. get packedFloat(): boolean;
  88323. /**
  88324. * Creates a new instance BlurPostProcess
  88325. * @param name The name of the effect.
  88326. * @param direction The direction in which to blur the image.
  88327. * @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.
  88328. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88329. * @param camera The camera to apply the render pass to.
  88330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88331. * @param engine The engine which the post process will be applied. (default: current engine)
  88332. * @param reusable If the post process can be reused on the same frame. (default: false)
  88333. * @param textureType Type of textures used when performing the post process. (default: 0)
  88334. * @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)
  88335. */
  88336. constructor(name: string,
  88337. /** The direction in which to blur the image. */
  88338. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  88339. /**
  88340. * Updates the effect with the current post process compile time values and recompiles the shader.
  88341. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88342. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88343. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88344. * @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
  88345. * @param onCompiled Called when the shader has been compiled.
  88346. * @param onError Called if there is an error when compiling a shader.
  88347. */
  88348. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88349. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88350. /**
  88351. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  88352. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  88353. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  88354. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  88355. * The gaps between physical kernels are compensated for in the weighting of the samples
  88356. * @param idealKernel Ideal blur kernel.
  88357. * @return Nearest best kernel.
  88358. */
  88359. protected _nearestBestKernel(idealKernel: number): number;
  88360. /**
  88361. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  88362. * @param x The point on the Gaussian distribution to sample.
  88363. * @return the value of the Gaussian function at x.
  88364. */
  88365. protected _gaussianWeight(x: number): number;
  88366. /**
  88367. * Generates a string that can be used as a floating point number in GLSL.
  88368. * @param x Value to print.
  88369. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  88370. * @return GLSL float string.
  88371. */
  88372. protected _glslFloat(x: number, decimalFigures?: number): string;
  88373. }
  88374. }
  88375. declare module BABYLON {
  88376. /**
  88377. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88378. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88379. * You can then easily use it as a reflectionTexture on a flat surface.
  88380. * In case the surface is not a plane, please consider relying on reflection probes.
  88381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88382. */
  88383. export class MirrorTexture extends RenderTargetTexture {
  88384. private scene;
  88385. /**
  88386. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  88387. * 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.
  88388. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88389. */
  88390. mirrorPlane: Plane;
  88391. /**
  88392. * Define the blur ratio used to blur the reflection if needed.
  88393. */
  88394. set blurRatio(value: number);
  88395. get blurRatio(): number;
  88396. /**
  88397. * Define the adaptive blur kernel used to blur the reflection if needed.
  88398. * This will autocompute the closest best match for the `blurKernel`
  88399. */
  88400. set adaptiveBlurKernel(value: number);
  88401. /**
  88402. * Define the blur kernel used to blur the reflection if needed.
  88403. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88404. */
  88405. set blurKernel(value: number);
  88406. /**
  88407. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  88408. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88409. */
  88410. set blurKernelX(value: number);
  88411. get blurKernelX(): number;
  88412. /**
  88413. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  88414. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88415. */
  88416. set blurKernelY(value: number);
  88417. get blurKernelY(): number;
  88418. private _autoComputeBlurKernel;
  88419. protected _onRatioRescale(): void;
  88420. private _updateGammaSpace;
  88421. private _imageProcessingConfigChangeObserver;
  88422. private _transformMatrix;
  88423. private _mirrorMatrix;
  88424. private _savedViewMatrix;
  88425. private _blurX;
  88426. private _blurY;
  88427. private _adaptiveBlurKernel;
  88428. private _blurKernelX;
  88429. private _blurKernelY;
  88430. private _blurRatio;
  88431. /**
  88432. * Instantiates a Mirror Texture.
  88433. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88434. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88435. * You can then easily use it as a reflectionTexture on a flat surface.
  88436. * In case the surface is not a plane, please consider relying on reflection probes.
  88437. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88438. * @param name
  88439. * @param size
  88440. * @param scene
  88441. * @param generateMipMaps
  88442. * @param type
  88443. * @param samplingMode
  88444. * @param generateDepthBuffer
  88445. */
  88446. constructor(name: string, size: number | {
  88447. width: number;
  88448. height: number;
  88449. } | {
  88450. ratio: number;
  88451. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  88452. private _preparePostProcesses;
  88453. /**
  88454. * Clone the mirror texture.
  88455. * @returns the cloned texture
  88456. */
  88457. clone(): MirrorTexture;
  88458. /**
  88459. * Serialize the texture to a JSON representation you could use in Parse later on
  88460. * @returns the serialized JSON representation
  88461. */
  88462. serialize(): any;
  88463. /**
  88464. * Dispose the texture and release its associated resources.
  88465. */
  88466. dispose(): void;
  88467. }
  88468. }
  88469. declare module BABYLON {
  88470. /**
  88471. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88472. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88473. */
  88474. export class Texture extends BaseTexture {
  88475. /**
  88476. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  88477. */
  88478. static SerializeBuffers: boolean;
  88479. /** @hidden */
  88480. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  88481. /** @hidden */
  88482. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  88483. /** @hidden */
  88484. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  88485. /** nearest is mag = nearest and min = nearest and mip = linear */
  88486. static readonly NEAREST_SAMPLINGMODE: number;
  88487. /** nearest is mag = nearest and min = nearest and mip = linear */
  88488. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  88489. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88490. static readonly BILINEAR_SAMPLINGMODE: number;
  88491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88492. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  88493. /** Trilinear is mag = linear and min = linear and mip = linear */
  88494. static readonly TRILINEAR_SAMPLINGMODE: number;
  88495. /** Trilinear is mag = linear and min = linear and mip = linear */
  88496. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  88497. /** mag = nearest and min = nearest and mip = nearest */
  88498. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  88499. /** mag = nearest and min = linear and mip = nearest */
  88500. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  88501. /** mag = nearest and min = linear and mip = linear */
  88502. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  88503. /** mag = nearest and min = linear and mip = none */
  88504. static readonly NEAREST_LINEAR: number;
  88505. /** mag = nearest and min = nearest and mip = none */
  88506. static readonly NEAREST_NEAREST: number;
  88507. /** mag = linear and min = nearest and mip = nearest */
  88508. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  88509. /** mag = linear and min = nearest and mip = linear */
  88510. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  88511. /** mag = linear and min = linear and mip = none */
  88512. static readonly LINEAR_LINEAR: number;
  88513. /** mag = linear and min = nearest and mip = none */
  88514. static readonly LINEAR_NEAREST: number;
  88515. /** Explicit coordinates mode */
  88516. static readonly EXPLICIT_MODE: number;
  88517. /** Spherical coordinates mode */
  88518. static readonly SPHERICAL_MODE: number;
  88519. /** Planar coordinates mode */
  88520. static readonly PLANAR_MODE: number;
  88521. /** Cubic coordinates mode */
  88522. static readonly CUBIC_MODE: number;
  88523. /** Projection coordinates mode */
  88524. static readonly PROJECTION_MODE: number;
  88525. /** Inverse Cubic coordinates mode */
  88526. static readonly SKYBOX_MODE: number;
  88527. /** Inverse Cubic coordinates mode */
  88528. static readonly INVCUBIC_MODE: number;
  88529. /** Equirectangular coordinates mode */
  88530. static readonly EQUIRECTANGULAR_MODE: number;
  88531. /** Equirectangular Fixed coordinates mode */
  88532. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  88533. /** Equirectangular Fixed Mirrored coordinates mode */
  88534. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  88535. /** Texture is not repeating outside of 0..1 UVs */
  88536. static readonly CLAMP_ADDRESSMODE: number;
  88537. /** Texture is repeating outside of 0..1 UVs */
  88538. static readonly WRAP_ADDRESSMODE: number;
  88539. /** Texture is repeating and mirrored */
  88540. static readonly MIRROR_ADDRESSMODE: number;
  88541. /**
  88542. * 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
  88543. */
  88544. static UseSerializedUrlIfAny: boolean;
  88545. /**
  88546. * Define the url of the texture.
  88547. */
  88548. url: Nullable<string>;
  88549. /**
  88550. * Define an offset on the texture to offset the u coordinates of the UVs
  88551. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88552. */
  88553. uOffset: number;
  88554. /**
  88555. * Define an offset on the texture to offset the v coordinates of the UVs
  88556. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88557. */
  88558. vOffset: number;
  88559. /**
  88560. * Define an offset on the texture to scale the u coordinates of the UVs
  88561. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88562. */
  88563. uScale: number;
  88564. /**
  88565. * Define an offset on the texture to scale the v coordinates of the UVs
  88566. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88567. */
  88568. vScale: number;
  88569. /**
  88570. * Define an offset on the texture to rotate around the u coordinates of the UVs
  88571. * @see http://doc.babylonjs.com/how_to/more_materials
  88572. */
  88573. uAng: number;
  88574. /**
  88575. * Define an offset on the texture to rotate around the v coordinates of the UVs
  88576. * @see http://doc.babylonjs.com/how_to/more_materials
  88577. */
  88578. vAng: number;
  88579. /**
  88580. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  88581. * @see http://doc.babylonjs.com/how_to/more_materials
  88582. */
  88583. wAng: number;
  88584. /**
  88585. * Defines the center of rotation (U)
  88586. */
  88587. uRotationCenter: number;
  88588. /**
  88589. * Defines the center of rotation (V)
  88590. */
  88591. vRotationCenter: number;
  88592. /**
  88593. * Defines the center of rotation (W)
  88594. */
  88595. wRotationCenter: number;
  88596. /**
  88597. * Are mip maps generated for this texture or not.
  88598. */
  88599. get noMipmap(): boolean;
  88600. /**
  88601. * List of inspectable custom properties (used by the Inspector)
  88602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88603. */
  88604. inspectableCustomProperties: Nullable<IInspectable[]>;
  88605. private _noMipmap;
  88606. /** @hidden */
  88607. _invertY: boolean;
  88608. private _rowGenerationMatrix;
  88609. private _cachedTextureMatrix;
  88610. private _projectionModeMatrix;
  88611. private _t0;
  88612. private _t1;
  88613. private _t2;
  88614. private _cachedUOffset;
  88615. private _cachedVOffset;
  88616. private _cachedUScale;
  88617. private _cachedVScale;
  88618. private _cachedUAng;
  88619. private _cachedVAng;
  88620. private _cachedWAng;
  88621. private _cachedProjectionMatrixId;
  88622. private _cachedCoordinatesMode;
  88623. /** @hidden */
  88624. protected _initialSamplingMode: number;
  88625. /** @hidden */
  88626. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  88627. private _deleteBuffer;
  88628. protected _format: Nullable<number>;
  88629. private _delayedOnLoad;
  88630. private _delayedOnError;
  88631. private _mimeType?;
  88632. /**
  88633. * Observable triggered once the texture has been loaded.
  88634. */
  88635. onLoadObservable: Observable<Texture>;
  88636. protected _isBlocking: boolean;
  88637. /**
  88638. * Is the texture preventing material to render while loading.
  88639. * If false, a default texture will be used instead of the loading one during the preparation step.
  88640. */
  88641. set isBlocking(value: boolean);
  88642. get isBlocking(): boolean;
  88643. /**
  88644. * Get the current sampling mode associated with the texture.
  88645. */
  88646. get samplingMode(): number;
  88647. /**
  88648. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  88649. */
  88650. get invertY(): boolean;
  88651. /**
  88652. * Instantiates a new texture.
  88653. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88654. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88655. * @param url defines the url of the picture to load as a texture
  88656. * @param scene defines the scene or engine the texture will belong to
  88657. * @param noMipmap defines if the texture will require mip maps or not
  88658. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  88659. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88660. * @param onLoad defines a callback triggered when the texture has been loaded
  88661. * @param onError defines a callback triggered when an error occurred during the loading session
  88662. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  88663. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  88664. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88665. * @param mimeType defines an optional mime type information
  88666. */
  88667. 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);
  88668. /**
  88669. * Update the url (and optional buffer) of this texture if url was null during construction.
  88670. * @param url the url of the texture
  88671. * @param buffer the buffer of the texture (defaults to null)
  88672. * @param onLoad callback called when the texture is loaded (defaults to null)
  88673. */
  88674. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  88675. /**
  88676. * Finish the loading sequence of a texture flagged as delayed load.
  88677. * @hidden
  88678. */
  88679. delayLoad(): void;
  88680. private _prepareRowForTextureGeneration;
  88681. /**
  88682. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  88683. * @returns the transform matrix of the texture.
  88684. */
  88685. getTextureMatrix(uBase?: number): Matrix;
  88686. /**
  88687. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  88688. * @returns The reflection texture transform
  88689. */
  88690. getReflectionTextureMatrix(): Matrix;
  88691. /**
  88692. * Clones the texture.
  88693. * @returns the cloned texture
  88694. */
  88695. clone(): Texture;
  88696. /**
  88697. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88698. * @returns The JSON representation of the texture
  88699. */
  88700. serialize(): any;
  88701. /**
  88702. * Get the current class name of the texture useful for serialization or dynamic coding.
  88703. * @returns "Texture"
  88704. */
  88705. getClassName(): string;
  88706. /**
  88707. * Dispose the texture and release its associated resources.
  88708. */
  88709. dispose(): void;
  88710. /**
  88711. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  88712. * @param parsedTexture Define the JSON representation of the texture
  88713. * @param scene Define the scene the parsed texture should be instantiated in
  88714. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  88715. * @returns The parsed texture if successful
  88716. */
  88717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  88718. /**
  88719. * Creates a texture from its base 64 representation.
  88720. * @param data Define the base64 payload without the data: prefix
  88721. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88722. * @param scene Define the scene the texture should belong to
  88723. * @param noMipmap Forces the texture to not create mip map information if true
  88724. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88725. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88726. * @param onLoad define a callback triggered when the texture has been loaded
  88727. * @param onError define a callback triggered when an error occurred during the loading session
  88728. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88729. * @returns the created texture
  88730. */
  88731. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  88732. /**
  88733. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  88734. * @param data Define the base64 payload without the data: prefix
  88735. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88736. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  88737. * @param scene Define the scene the texture should belong to
  88738. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  88739. * @param noMipmap Forces the texture to not create mip map information if true
  88740. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88741. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88742. * @param onLoad define a callback triggered when the texture has been loaded
  88743. * @param onError define a callback triggered when an error occurred during the loading session
  88744. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88745. * @returns the created texture
  88746. */
  88747. 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;
  88748. }
  88749. }
  88750. declare module BABYLON {
  88751. /**
  88752. * PostProcessManager is used to manage one or more post processes or post process pipelines
  88753. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88754. */
  88755. export class PostProcessManager {
  88756. private _scene;
  88757. private _indexBuffer;
  88758. private _vertexBuffers;
  88759. /**
  88760. * Creates a new instance PostProcess
  88761. * @param scene The scene that the post process is associated with.
  88762. */
  88763. constructor(scene: Scene);
  88764. private _prepareBuffers;
  88765. private _buildIndexBuffer;
  88766. /**
  88767. * Rebuilds the vertex buffers of the manager.
  88768. * @hidden
  88769. */
  88770. _rebuild(): void;
  88771. /**
  88772. * Prepares a frame to be run through a post process.
  88773. * @param sourceTexture The input texture to the post procesess. (default: null)
  88774. * @param postProcesses An array of post processes to be run. (default: null)
  88775. * @returns True if the post processes were able to be run.
  88776. * @hidden
  88777. */
  88778. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  88779. /**
  88780. * Manually render a set of post processes to a texture.
  88781. * @param postProcesses An array of post processes to be run.
  88782. * @param targetTexture The target texture to render to.
  88783. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  88784. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  88785. * @param lodLevel defines which lod of the texture to render to
  88786. */
  88787. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  88788. /**
  88789. * Finalize the result of the output of the postprocesses.
  88790. * @param doNotPresent If true the result will not be displayed to the screen.
  88791. * @param targetTexture The target texture to render to.
  88792. * @param faceIndex The index of the face to bind the target texture to.
  88793. * @param postProcesses The array of post processes to render.
  88794. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  88795. * @hidden
  88796. */
  88797. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  88798. /**
  88799. * Disposes of the post process manager.
  88800. */
  88801. dispose(): void;
  88802. }
  88803. }
  88804. declare module BABYLON {
  88805. /** Interface used by value gradients (color, factor, ...) */
  88806. export interface IValueGradient {
  88807. /**
  88808. * Gets or sets the gradient value (between 0 and 1)
  88809. */
  88810. gradient: number;
  88811. }
  88812. /** Class used to store color4 gradient */
  88813. export class ColorGradient implements IValueGradient {
  88814. /**
  88815. * Gets or sets the gradient value (between 0 and 1)
  88816. */
  88817. gradient: number;
  88818. /**
  88819. * Gets or sets first associated color
  88820. */
  88821. color1: Color4;
  88822. /**
  88823. * Gets or sets second associated color
  88824. */
  88825. color2?: Color4;
  88826. /**
  88827. * Will get a color picked randomly between color1 and color2.
  88828. * If color2 is undefined then color1 will be used
  88829. * @param result defines the target Color4 to store the result in
  88830. */
  88831. getColorToRef(result: Color4): void;
  88832. }
  88833. /** Class used to store color 3 gradient */
  88834. export class Color3Gradient implements IValueGradient {
  88835. /**
  88836. * Gets or sets the gradient value (between 0 and 1)
  88837. */
  88838. gradient: number;
  88839. /**
  88840. * Gets or sets the associated color
  88841. */
  88842. color: Color3;
  88843. }
  88844. /** Class used to store factor gradient */
  88845. export class FactorGradient implements IValueGradient {
  88846. /**
  88847. * Gets or sets the gradient value (between 0 and 1)
  88848. */
  88849. gradient: number;
  88850. /**
  88851. * Gets or sets first associated factor
  88852. */
  88853. factor1: number;
  88854. /**
  88855. * Gets or sets second associated factor
  88856. */
  88857. factor2?: number;
  88858. /**
  88859. * Will get a number picked randomly between factor1 and factor2.
  88860. * If factor2 is undefined then factor1 will be used
  88861. * @returns the picked number
  88862. */
  88863. getFactor(): number;
  88864. }
  88865. /**
  88866. * Helper used to simplify some generic gradient tasks
  88867. */
  88868. export class GradientHelper {
  88869. /**
  88870. * Gets the current gradient from an array of IValueGradient
  88871. * @param ratio defines the current ratio to get
  88872. * @param gradients defines the array of IValueGradient
  88873. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88874. */
  88875. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88876. }
  88877. }
  88878. declare module BABYLON {
  88879. interface ThinEngine {
  88880. /**
  88881. * Creates a dynamic texture
  88882. * @param width defines the width of the texture
  88883. * @param height defines the height of the texture
  88884. * @param generateMipMaps defines if the engine should generate the mip levels
  88885. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88886. * @returns the dynamic texture inside an InternalTexture
  88887. */
  88888. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88889. /**
  88890. * Update the content of a dynamic texture
  88891. * @param texture defines the texture to update
  88892. * @param canvas defines the canvas containing the source
  88893. * @param invertY defines if data must be stored with Y axis inverted
  88894. * @param premulAlpha defines if alpha is stored as premultiplied
  88895. * @param format defines the format of the data
  88896. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88897. */
  88898. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88899. }
  88900. }
  88901. declare module BABYLON {
  88902. /**
  88903. * Helper class used to generate a canvas to manipulate images
  88904. */
  88905. export class CanvasGenerator {
  88906. /**
  88907. * Create a new canvas (or offscreen canvas depending on the context)
  88908. * @param width defines the expected width
  88909. * @param height defines the expected height
  88910. * @return a new canvas or offscreen canvas
  88911. */
  88912. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88913. }
  88914. }
  88915. declare module BABYLON {
  88916. /**
  88917. * A class extending Texture allowing drawing on a texture
  88918. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88919. */
  88920. export class DynamicTexture extends Texture {
  88921. private _generateMipMaps;
  88922. private _canvas;
  88923. private _context;
  88924. private _engine;
  88925. /**
  88926. * Creates a DynamicTexture
  88927. * @param name defines the name of the texture
  88928. * @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
  88929. * @param scene defines the scene where you want the texture
  88930. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88931. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88932. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88933. */
  88934. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88935. /**
  88936. * Get the current class name of the texture useful for serialization or dynamic coding.
  88937. * @returns "DynamicTexture"
  88938. */
  88939. getClassName(): string;
  88940. /**
  88941. * Gets the current state of canRescale
  88942. */
  88943. get canRescale(): boolean;
  88944. private _recreate;
  88945. /**
  88946. * Scales the texture
  88947. * @param ratio the scale factor to apply to both width and height
  88948. */
  88949. scale(ratio: number): void;
  88950. /**
  88951. * Resizes the texture
  88952. * @param width the new width
  88953. * @param height the new height
  88954. */
  88955. scaleTo(width: number, height: number): void;
  88956. /**
  88957. * Gets the context of the canvas used by the texture
  88958. * @returns the canvas context of the dynamic texture
  88959. */
  88960. getContext(): CanvasRenderingContext2D;
  88961. /**
  88962. * Clears the texture
  88963. */
  88964. clear(): void;
  88965. /**
  88966. * Updates the texture
  88967. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88968. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88969. */
  88970. update(invertY?: boolean, premulAlpha?: boolean): void;
  88971. /**
  88972. * Draws text onto the texture
  88973. * @param text defines the text to be drawn
  88974. * @param x defines the placement of the text from the left
  88975. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88976. * @param font defines the font to be used with font-style, font-size, font-name
  88977. * @param color defines the color used for the text
  88978. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88979. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88980. * @param update defines whether texture is immediately update (default is true)
  88981. */
  88982. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  88983. /**
  88984. * Clones the texture
  88985. * @returns the clone of the texture.
  88986. */
  88987. clone(): DynamicTexture;
  88988. /**
  88989. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88990. * @returns a serialized dynamic texture object
  88991. */
  88992. serialize(): any;
  88993. /** @hidden */
  88994. _rebuild(): void;
  88995. }
  88996. }
  88997. declare module BABYLON {
  88998. interface AbstractScene {
  88999. /**
  89000. * The list of procedural textures added to the scene
  89001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89002. */
  89003. proceduralTextures: Array<ProceduralTexture>;
  89004. }
  89005. /**
  89006. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89007. * in a given scene.
  89008. */
  89009. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89010. /**
  89011. * The component name helpfull to identify the component in the list of scene components.
  89012. */
  89013. readonly name: string;
  89014. /**
  89015. * The scene the component belongs to.
  89016. */
  89017. scene: Scene;
  89018. /**
  89019. * Creates a new instance of the component for the given scene
  89020. * @param scene Defines the scene to register the component in
  89021. */
  89022. constructor(scene: Scene);
  89023. /**
  89024. * Registers the component in a given scene
  89025. */
  89026. register(): void;
  89027. /**
  89028. * Rebuilds the elements related to this component in case of
  89029. * context lost for instance.
  89030. */
  89031. rebuild(): void;
  89032. /**
  89033. * Disposes the component and the associated ressources.
  89034. */
  89035. dispose(): void;
  89036. private _beforeClear;
  89037. }
  89038. }
  89039. declare module BABYLON {
  89040. interface ThinEngine {
  89041. /**
  89042. * Creates a new render target cube texture
  89043. * @param size defines the size of the texture
  89044. * @param options defines the options used to create the texture
  89045. * @returns a new render target cube texture stored in an InternalTexture
  89046. */
  89047. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89048. }
  89049. }
  89050. declare module BABYLON {
  89051. /** @hidden */
  89052. export var proceduralVertexShader: {
  89053. name: string;
  89054. shader: string;
  89055. };
  89056. }
  89057. declare module BABYLON {
  89058. /**
  89059. * 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.
  89060. * This is the base class of any Procedural texture and contains most of the shareable code.
  89061. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89062. */
  89063. export class ProceduralTexture extends Texture {
  89064. isCube: boolean;
  89065. /**
  89066. * Define if the texture is enabled or not (disabled texture will not render)
  89067. */
  89068. isEnabled: boolean;
  89069. /**
  89070. * Define if the texture must be cleared before rendering (default is true)
  89071. */
  89072. autoClear: boolean;
  89073. /**
  89074. * Callback called when the texture is generated
  89075. */
  89076. onGenerated: () => void;
  89077. /**
  89078. * Event raised when the texture is generated
  89079. */
  89080. onGeneratedObservable: Observable<ProceduralTexture>;
  89081. /** @hidden */
  89082. _generateMipMaps: boolean;
  89083. /** @hidden **/
  89084. _effect: Effect;
  89085. /** @hidden */
  89086. _textures: {
  89087. [key: string]: Texture;
  89088. };
  89089. private _size;
  89090. private _currentRefreshId;
  89091. private _frameId;
  89092. private _refreshRate;
  89093. private _vertexBuffers;
  89094. private _indexBuffer;
  89095. private _uniforms;
  89096. private _samplers;
  89097. private _fragment;
  89098. private _floats;
  89099. private _ints;
  89100. private _floatsArrays;
  89101. private _colors3;
  89102. private _colors4;
  89103. private _vectors2;
  89104. private _vectors3;
  89105. private _matrices;
  89106. private _fallbackTexture;
  89107. private _fallbackTextureUsed;
  89108. private _engine;
  89109. private _cachedDefines;
  89110. private _contentUpdateId;
  89111. private _contentData;
  89112. /**
  89113. * Instantiates a new procedural texture.
  89114. * 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.
  89115. * This is the base class of any Procedural texture and contains most of the shareable code.
  89116. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89117. * @param name Define the name of the texture
  89118. * @param size Define the size of the texture to create
  89119. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89120. * @param scene Define the scene the texture belongs to
  89121. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89122. * @param generateMipMaps Define if the texture should creates mip maps or not
  89123. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89124. */
  89125. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89126. /**
  89127. * The effect that is created when initializing the post process.
  89128. * @returns The created effect corresponding the the postprocess.
  89129. */
  89130. getEffect(): Effect;
  89131. /**
  89132. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89133. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89134. */
  89135. getContent(): Nullable<ArrayBufferView>;
  89136. private _createIndexBuffer;
  89137. /** @hidden */
  89138. _rebuild(): void;
  89139. /**
  89140. * Resets the texture in order to recreate its associated resources.
  89141. * This can be called in case of context loss
  89142. */
  89143. reset(): void;
  89144. protected _getDefines(): string;
  89145. /**
  89146. * Is the texture ready to be used ? (rendered at least once)
  89147. * @returns true if ready, otherwise, false.
  89148. */
  89149. isReady(): boolean;
  89150. /**
  89151. * Resets the refresh counter of the texture and start bak from scratch.
  89152. * Could be useful to regenerate the texture if it is setup to render only once.
  89153. */
  89154. resetRefreshCounter(): void;
  89155. /**
  89156. * Set the fragment shader to use in order to render the texture.
  89157. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89158. */
  89159. setFragment(fragment: any): void;
  89160. /**
  89161. * Define the refresh rate of the texture or the rendering frequency.
  89162. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89163. */
  89164. get refreshRate(): number;
  89165. set refreshRate(value: number);
  89166. /** @hidden */
  89167. _shouldRender(): boolean;
  89168. /**
  89169. * Get the size the texture is rendering at.
  89170. * @returns the size (texture is always squared)
  89171. */
  89172. getRenderSize(): number;
  89173. /**
  89174. * Resize the texture to new value.
  89175. * @param size Define the new size the texture should have
  89176. * @param generateMipMaps Define whether the new texture should create mip maps
  89177. */
  89178. resize(size: number, generateMipMaps: boolean): void;
  89179. private _checkUniform;
  89180. /**
  89181. * Set a texture in the shader program used to render.
  89182. * @param name Define the name of the uniform samplers as defined in the shader
  89183. * @param texture Define the texture to bind to this sampler
  89184. * @return the texture itself allowing "fluent" like uniform updates
  89185. */
  89186. setTexture(name: string, texture: Texture): ProceduralTexture;
  89187. /**
  89188. * Set a float in the shader.
  89189. * @param name Define the name of the uniform as defined in the shader
  89190. * @param value Define the value to give to the uniform
  89191. * @return the texture itself allowing "fluent" like uniform updates
  89192. */
  89193. setFloat(name: string, value: number): ProceduralTexture;
  89194. /**
  89195. * Set a int in the shader.
  89196. * @param name Define the name of the uniform as defined in the shader
  89197. * @param value Define the value to give to the uniform
  89198. * @return the texture itself allowing "fluent" like uniform updates
  89199. */
  89200. setInt(name: string, value: number): ProceduralTexture;
  89201. /**
  89202. * Set an array of floats in the shader.
  89203. * @param name Define the name of the uniform as defined in the shader
  89204. * @param value Define the value to give to the uniform
  89205. * @return the texture itself allowing "fluent" like uniform updates
  89206. */
  89207. setFloats(name: string, value: number[]): ProceduralTexture;
  89208. /**
  89209. * Set a vec3 in the shader from a Color3.
  89210. * @param name Define the name of the uniform as defined in the shader
  89211. * @param value Define the value to give to the uniform
  89212. * @return the texture itself allowing "fluent" like uniform updates
  89213. */
  89214. setColor3(name: string, value: Color3): ProceduralTexture;
  89215. /**
  89216. * Set a vec4 in the shader from a Color4.
  89217. * @param name Define the name of the uniform as defined in the shader
  89218. * @param value Define the value to give to the uniform
  89219. * @return the texture itself allowing "fluent" like uniform updates
  89220. */
  89221. setColor4(name: string, value: Color4): ProceduralTexture;
  89222. /**
  89223. * Set a vec2 in the shader from a Vector2.
  89224. * @param name Define the name of the uniform as defined in the shader
  89225. * @param value Define the value to give to the uniform
  89226. * @return the texture itself allowing "fluent" like uniform updates
  89227. */
  89228. setVector2(name: string, value: Vector2): ProceduralTexture;
  89229. /**
  89230. * Set a vec3 in the shader from a Vector3.
  89231. * @param name Define the name of the uniform as defined in the shader
  89232. * @param value Define the value to give to the uniform
  89233. * @return the texture itself allowing "fluent" like uniform updates
  89234. */
  89235. setVector3(name: string, value: Vector3): ProceduralTexture;
  89236. /**
  89237. * Set a mat4 in the shader from a MAtrix.
  89238. * @param name Define the name of the uniform as defined in the shader
  89239. * @param value Define the value to give to the uniform
  89240. * @return the texture itself allowing "fluent" like uniform updates
  89241. */
  89242. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89243. /**
  89244. * Render the texture to its associated render target.
  89245. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89246. */
  89247. render(useCameraPostProcess?: boolean): void;
  89248. /**
  89249. * Clone the texture.
  89250. * @returns the cloned texture
  89251. */
  89252. clone(): ProceduralTexture;
  89253. /**
  89254. * Dispose the texture and release its asoociated resources.
  89255. */
  89256. dispose(): void;
  89257. }
  89258. }
  89259. declare module BABYLON {
  89260. /**
  89261. * This represents the base class for particle system in Babylon.
  89262. * 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.
  89263. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89264. * @example https://doc.babylonjs.com/babylon101/particles
  89265. */
  89266. export class BaseParticleSystem {
  89267. /**
  89268. * Source color is added to the destination color without alpha affecting the result
  89269. */
  89270. static BLENDMODE_ONEONE: number;
  89271. /**
  89272. * Blend current color and particle color using particle’s alpha
  89273. */
  89274. static BLENDMODE_STANDARD: number;
  89275. /**
  89276. * Add current color and particle color multiplied by particle’s alpha
  89277. */
  89278. static BLENDMODE_ADD: number;
  89279. /**
  89280. * Multiply current color with particle color
  89281. */
  89282. static BLENDMODE_MULTIPLY: number;
  89283. /**
  89284. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89285. */
  89286. static BLENDMODE_MULTIPLYADD: number;
  89287. /**
  89288. * List of animations used by the particle system.
  89289. */
  89290. animations: Animation[];
  89291. /**
  89292. * The id of the Particle system.
  89293. */
  89294. id: string;
  89295. /**
  89296. * The friendly name of the Particle system.
  89297. */
  89298. name: string;
  89299. /**
  89300. * The rendering group used by the Particle system to chose when to render.
  89301. */
  89302. renderingGroupId: number;
  89303. /**
  89304. * The emitter represents the Mesh or position we are attaching the particle system to.
  89305. */
  89306. emitter: Nullable<AbstractMesh | Vector3>;
  89307. /**
  89308. * The maximum number of particles to emit per frame
  89309. */
  89310. emitRate: number;
  89311. /**
  89312. * If you want to launch only a few particles at once, that can be done, as well.
  89313. */
  89314. manualEmitCount: number;
  89315. /**
  89316. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89317. */
  89318. updateSpeed: number;
  89319. /**
  89320. * The amount of time the particle system is running (depends of the overall update speed).
  89321. */
  89322. targetStopDuration: number;
  89323. /**
  89324. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89325. */
  89326. disposeOnStop: boolean;
  89327. /**
  89328. * Minimum power of emitting particles.
  89329. */
  89330. minEmitPower: number;
  89331. /**
  89332. * Maximum power of emitting particles.
  89333. */
  89334. maxEmitPower: number;
  89335. /**
  89336. * Minimum life time of emitting particles.
  89337. */
  89338. minLifeTime: number;
  89339. /**
  89340. * Maximum life time of emitting particles.
  89341. */
  89342. maxLifeTime: number;
  89343. /**
  89344. * Minimum Size of emitting particles.
  89345. */
  89346. minSize: number;
  89347. /**
  89348. * Maximum Size of emitting particles.
  89349. */
  89350. maxSize: number;
  89351. /**
  89352. * Minimum scale of emitting particles on X axis.
  89353. */
  89354. minScaleX: number;
  89355. /**
  89356. * Maximum scale of emitting particles on X axis.
  89357. */
  89358. maxScaleX: number;
  89359. /**
  89360. * Minimum scale of emitting particles on Y axis.
  89361. */
  89362. minScaleY: number;
  89363. /**
  89364. * Maximum scale of emitting particles on Y axis.
  89365. */
  89366. maxScaleY: number;
  89367. /**
  89368. * Gets or sets the minimal initial rotation in radians.
  89369. */
  89370. minInitialRotation: number;
  89371. /**
  89372. * Gets or sets the maximal initial rotation in radians.
  89373. */
  89374. maxInitialRotation: number;
  89375. /**
  89376. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89377. */
  89378. minAngularSpeed: number;
  89379. /**
  89380. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89381. */
  89382. maxAngularSpeed: number;
  89383. /**
  89384. * The texture used to render each particle. (this can be a spritesheet)
  89385. */
  89386. particleTexture: Nullable<Texture>;
  89387. /**
  89388. * The layer mask we are rendering the particles through.
  89389. */
  89390. layerMask: number;
  89391. /**
  89392. * This can help using your own shader to render the particle system.
  89393. * The according effect will be created
  89394. */
  89395. customShader: any;
  89396. /**
  89397. * By default particle system starts as soon as they are created. This prevents the
  89398. * automatic start to happen and let you decide when to start emitting particles.
  89399. */
  89400. preventAutoStart: boolean;
  89401. private _noiseTexture;
  89402. /**
  89403. * Gets or sets a texture used to add random noise to particle positions
  89404. */
  89405. get noiseTexture(): Nullable<ProceduralTexture>;
  89406. set noiseTexture(value: Nullable<ProceduralTexture>);
  89407. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89408. noiseStrength: Vector3;
  89409. /**
  89410. * Callback triggered when the particle animation is ending.
  89411. */
  89412. onAnimationEnd: Nullable<() => void>;
  89413. /**
  89414. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89415. */
  89416. blendMode: number;
  89417. /**
  89418. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89419. * to override the particles.
  89420. */
  89421. forceDepthWrite: boolean;
  89422. /** 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 */
  89423. preWarmCycles: number;
  89424. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89425. preWarmStepOffset: number;
  89426. /**
  89427. * 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)
  89428. */
  89429. spriteCellChangeSpeed: number;
  89430. /**
  89431. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89432. */
  89433. startSpriteCellID: number;
  89434. /**
  89435. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89436. */
  89437. endSpriteCellID: number;
  89438. /**
  89439. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89440. */
  89441. spriteCellWidth: number;
  89442. /**
  89443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89444. */
  89445. spriteCellHeight: number;
  89446. /**
  89447. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89448. */
  89449. spriteRandomStartCell: boolean;
  89450. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89451. translationPivot: Vector2;
  89452. /** @hidden */
  89453. protected _isAnimationSheetEnabled: boolean;
  89454. /**
  89455. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89456. */
  89457. beginAnimationOnStart: boolean;
  89458. /**
  89459. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89460. */
  89461. beginAnimationFrom: number;
  89462. /**
  89463. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89464. */
  89465. beginAnimationTo: number;
  89466. /**
  89467. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89468. */
  89469. beginAnimationLoop: boolean;
  89470. /**
  89471. * Gets or sets a world offset applied to all particles
  89472. */
  89473. worldOffset: Vector3;
  89474. /**
  89475. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89476. */
  89477. get isAnimationSheetEnabled(): boolean;
  89478. set isAnimationSheetEnabled(value: boolean);
  89479. /**
  89480. * Get hosting scene
  89481. * @returns the scene
  89482. */
  89483. getScene(): Scene;
  89484. /**
  89485. * You can use gravity if you want to give an orientation to your particles.
  89486. */
  89487. gravity: Vector3;
  89488. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89489. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89490. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89491. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89492. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89493. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89494. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89495. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89496. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89497. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89498. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89499. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89500. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89501. /**
  89502. * Defines the delay in milliseconds before starting the system (0 by default)
  89503. */
  89504. startDelay: number;
  89505. /**
  89506. * Gets the current list of drag gradients.
  89507. * You must use addDragGradient and removeDragGradient to udpate this list
  89508. * @returns the list of drag gradients
  89509. */
  89510. getDragGradients(): Nullable<Array<FactorGradient>>;
  89511. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89512. limitVelocityDamping: number;
  89513. /**
  89514. * Gets the current list of limit velocity gradients.
  89515. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89516. * @returns the list of limit velocity gradients
  89517. */
  89518. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89519. /**
  89520. * Gets the current list of color gradients.
  89521. * You must use addColorGradient and removeColorGradient to udpate this list
  89522. * @returns the list of color gradients
  89523. */
  89524. getColorGradients(): Nullable<Array<ColorGradient>>;
  89525. /**
  89526. * Gets the current list of size gradients.
  89527. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89528. * @returns the list of size gradients
  89529. */
  89530. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89531. /**
  89532. * Gets the current list of color remap gradients.
  89533. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89534. * @returns the list of color remap gradients
  89535. */
  89536. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89537. /**
  89538. * Gets the current list of alpha remap gradients.
  89539. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89540. * @returns the list of alpha remap gradients
  89541. */
  89542. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89543. /**
  89544. * Gets the current list of life time gradients.
  89545. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89546. * @returns the list of life time gradients
  89547. */
  89548. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89549. /**
  89550. * Gets the current list of angular speed gradients.
  89551. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89552. * @returns the list of angular speed gradients
  89553. */
  89554. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89555. /**
  89556. * Gets the current list of velocity gradients.
  89557. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89558. * @returns the list of velocity gradients
  89559. */
  89560. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89561. /**
  89562. * Gets the current list of start size gradients.
  89563. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89564. * @returns the list of start size gradients
  89565. */
  89566. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89567. /**
  89568. * Gets the current list of emit rate gradients.
  89569. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89570. * @returns the list of emit rate gradients
  89571. */
  89572. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89573. /**
  89574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89576. */
  89577. get direction1(): Vector3;
  89578. set direction1(value: Vector3);
  89579. /**
  89580. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89581. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89582. */
  89583. get direction2(): Vector3;
  89584. set direction2(value: Vector3);
  89585. /**
  89586. * 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.
  89587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89588. */
  89589. get minEmitBox(): Vector3;
  89590. set minEmitBox(value: Vector3);
  89591. /**
  89592. * 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.
  89593. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89594. */
  89595. get maxEmitBox(): Vector3;
  89596. set maxEmitBox(value: Vector3);
  89597. /**
  89598. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89599. */
  89600. color1: Color4;
  89601. /**
  89602. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89603. */
  89604. color2: Color4;
  89605. /**
  89606. * Color the particle will have at the end of its lifetime
  89607. */
  89608. colorDead: Color4;
  89609. /**
  89610. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89611. */
  89612. textureMask: Color4;
  89613. /**
  89614. * The particle emitter type defines the emitter used by the particle system.
  89615. * It can be for example box, sphere, or cone...
  89616. */
  89617. particleEmitterType: IParticleEmitterType;
  89618. /** @hidden */
  89619. _isSubEmitter: boolean;
  89620. /**
  89621. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89622. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89623. */
  89624. billboardMode: number;
  89625. protected _isBillboardBased: boolean;
  89626. /**
  89627. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89628. */
  89629. get isBillboardBased(): boolean;
  89630. set isBillboardBased(value: boolean);
  89631. /**
  89632. * The scene the particle system belongs to.
  89633. */
  89634. protected _scene: Scene;
  89635. /**
  89636. * Local cache of defines for image processing.
  89637. */
  89638. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89639. /**
  89640. * Default configuration related to image processing available in the standard Material.
  89641. */
  89642. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89643. /**
  89644. * Gets the image processing configuration used either in this material.
  89645. */
  89646. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89647. /**
  89648. * Sets the Default image processing configuration used either in the this material.
  89649. *
  89650. * If sets to null, the scene one is in use.
  89651. */
  89652. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89653. /**
  89654. * Attaches a new image processing configuration to the Standard Material.
  89655. * @param configuration
  89656. */
  89657. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89658. /** @hidden */
  89659. protected _reset(): void;
  89660. /** @hidden */
  89661. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89662. /**
  89663. * Instantiates a particle system.
  89664. * 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.
  89665. * @param name The name of the particle system
  89666. */
  89667. constructor(name: string);
  89668. /**
  89669. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89672. * @returns the emitter
  89673. */
  89674. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89675. /**
  89676. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89677. * @param radius The radius of the hemisphere to emit from
  89678. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89679. * @returns the emitter
  89680. */
  89681. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89682. /**
  89683. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89684. * @param radius The radius of the sphere to emit from
  89685. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89686. * @returns the emitter
  89687. */
  89688. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89689. /**
  89690. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89691. * @param radius The radius of the sphere to emit from
  89692. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89693. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89694. * @returns the emitter
  89695. */
  89696. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89697. /**
  89698. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89699. * @param radius The radius of the emission cylinder
  89700. * @param height The height of the emission cylinder
  89701. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89702. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89703. * @returns the emitter
  89704. */
  89705. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89706. /**
  89707. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89708. * @param radius The radius of the cylinder to emit from
  89709. * @param height The height of the emission cylinder
  89710. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89711. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89712. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89713. * @returns the emitter
  89714. */
  89715. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89716. /**
  89717. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89718. * @param radius The radius of the cone to emit from
  89719. * @param angle The base angle of the cone
  89720. * @returns the emitter
  89721. */
  89722. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89723. /**
  89724. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89725. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89726. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89727. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89728. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89729. * @returns the emitter
  89730. */
  89731. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89732. }
  89733. }
  89734. declare module BABYLON {
  89735. /**
  89736. * Type of sub emitter
  89737. */
  89738. export enum SubEmitterType {
  89739. /**
  89740. * Attached to the particle over it's lifetime
  89741. */
  89742. ATTACHED = 0,
  89743. /**
  89744. * Created when the particle dies
  89745. */
  89746. END = 1
  89747. }
  89748. /**
  89749. * Sub emitter class used to emit particles from an existing particle
  89750. */
  89751. export class SubEmitter {
  89752. /**
  89753. * the particle system to be used by the sub emitter
  89754. */
  89755. particleSystem: ParticleSystem;
  89756. /**
  89757. * Type of the submitter (Default: END)
  89758. */
  89759. type: SubEmitterType;
  89760. /**
  89761. * 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)
  89762. * Note: This only is supported when using an emitter of type Mesh
  89763. */
  89764. inheritDirection: boolean;
  89765. /**
  89766. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89767. */
  89768. inheritedVelocityAmount: number;
  89769. /**
  89770. * Creates a sub emitter
  89771. * @param particleSystem the particle system to be used by the sub emitter
  89772. */
  89773. constructor(
  89774. /**
  89775. * the particle system to be used by the sub emitter
  89776. */
  89777. particleSystem: ParticleSystem);
  89778. /**
  89779. * Clones the sub emitter
  89780. * @returns the cloned sub emitter
  89781. */
  89782. clone(): SubEmitter;
  89783. /**
  89784. * Serialize current object to a JSON object
  89785. * @returns the serialized object
  89786. */
  89787. serialize(): any;
  89788. /** @hidden */
  89789. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89790. /**
  89791. * Creates a new SubEmitter from a serialized JSON version
  89792. * @param serializationObject defines the JSON object to read from
  89793. * @param scene defines the hosting scene
  89794. * @param rootUrl defines the rootUrl for data loading
  89795. * @returns a new SubEmitter
  89796. */
  89797. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89798. /** Release associated resources */
  89799. dispose(): void;
  89800. }
  89801. }
  89802. declare module BABYLON {
  89803. /** @hidden */
  89804. export var clipPlaneFragmentDeclaration: {
  89805. name: string;
  89806. shader: string;
  89807. };
  89808. }
  89809. declare module BABYLON {
  89810. /** @hidden */
  89811. export var imageProcessingDeclaration: {
  89812. name: string;
  89813. shader: string;
  89814. };
  89815. }
  89816. declare module BABYLON {
  89817. /** @hidden */
  89818. export var imageProcessingFunctions: {
  89819. name: string;
  89820. shader: string;
  89821. };
  89822. }
  89823. declare module BABYLON {
  89824. /** @hidden */
  89825. export var clipPlaneFragment: {
  89826. name: string;
  89827. shader: string;
  89828. };
  89829. }
  89830. declare module BABYLON {
  89831. /** @hidden */
  89832. export var particlesPixelShader: {
  89833. name: string;
  89834. shader: string;
  89835. };
  89836. }
  89837. declare module BABYLON {
  89838. /** @hidden */
  89839. export var clipPlaneVertexDeclaration: {
  89840. name: string;
  89841. shader: string;
  89842. };
  89843. }
  89844. declare module BABYLON {
  89845. /** @hidden */
  89846. export var clipPlaneVertex: {
  89847. name: string;
  89848. shader: string;
  89849. };
  89850. }
  89851. declare module BABYLON {
  89852. /** @hidden */
  89853. export var particlesVertexShader: {
  89854. name: string;
  89855. shader: string;
  89856. };
  89857. }
  89858. declare module BABYLON {
  89859. /**
  89860. * This represents a particle system in Babylon.
  89861. * 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.
  89862. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89863. * @example https://doc.babylonjs.com/babylon101/particles
  89864. */
  89865. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89866. /**
  89867. * Billboard mode will only apply to Y axis
  89868. */
  89869. static readonly BILLBOARDMODE_Y: number;
  89870. /**
  89871. * Billboard mode will apply to all axes
  89872. */
  89873. static readonly BILLBOARDMODE_ALL: number;
  89874. /**
  89875. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89876. */
  89877. static readonly BILLBOARDMODE_STRETCHED: number;
  89878. /**
  89879. * This function can be defined to provide custom update for active particles.
  89880. * This function will be called instead of regular update (age, position, color, etc.).
  89881. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89882. */
  89883. updateFunction: (particles: Particle[]) => void;
  89884. private _emitterWorldMatrix;
  89885. /**
  89886. * This function can be defined to specify initial direction for every new particle.
  89887. * It by default use the emitterType defined function
  89888. */
  89889. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  89890. /**
  89891. * This function can be defined to specify initial position for every new particle.
  89892. * It by default use the emitterType defined function
  89893. */
  89894. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  89895. /**
  89896. * @hidden
  89897. */
  89898. _inheritedVelocityOffset: Vector3;
  89899. /**
  89900. * An event triggered when the system is disposed
  89901. */
  89902. onDisposeObservable: Observable<ParticleSystem>;
  89903. private _onDisposeObserver;
  89904. /**
  89905. * Sets a callback that will be triggered when the system is disposed
  89906. */
  89907. set onDispose(callback: () => void);
  89908. private _particles;
  89909. private _epsilon;
  89910. private _capacity;
  89911. private _stockParticles;
  89912. private _newPartsExcess;
  89913. private _vertexData;
  89914. private _vertexBuffer;
  89915. private _vertexBuffers;
  89916. private _spriteBuffer;
  89917. private _indexBuffer;
  89918. private _effect;
  89919. private _customEffect;
  89920. private _cachedDefines;
  89921. private _scaledColorStep;
  89922. private _colorDiff;
  89923. private _scaledDirection;
  89924. private _scaledGravity;
  89925. private _currentRenderId;
  89926. private _alive;
  89927. private _useInstancing;
  89928. private _started;
  89929. private _stopped;
  89930. private _actualFrame;
  89931. private _scaledUpdateSpeed;
  89932. private _vertexBufferSize;
  89933. /** @hidden */
  89934. _currentEmitRateGradient: Nullable<FactorGradient>;
  89935. /** @hidden */
  89936. _currentEmitRate1: number;
  89937. /** @hidden */
  89938. _currentEmitRate2: number;
  89939. /** @hidden */
  89940. _currentStartSizeGradient: Nullable<FactorGradient>;
  89941. /** @hidden */
  89942. _currentStartSize1: number;
  89943. /** @hidden */
  89944. _currentStartSize2: number;
  89945. private readonly _rawTextureWidth;
  89946. private _rampGradientsTexture;
  89947. private _useRampGradients;
  89948. /** Gets or sets a boolean indicating that ramp gradients must be used
  89949. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89950. */
  89951. get useRampGradients(): boolean;
  89952. set useRampGradients(value: boolean);
  89953. /**
  89954. * 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.
  89955. * 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: [])
  89956. */
  89957. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89958. private _subEmitters;
  89959. /**
  89960. * @hidden
  89961. * If the particle systems emitter should be disposed when the particle system is disposed
  89962. */
  89963. _disposeEmitterOnDispose: boolean;
  89964. /**
  89965. * The current active Sub-systems, this property is used by the root particle system only.
  89966. */
  89967. activeSubSystems: Array<ParticleSystem>;
  89968. private _rootParticleSystem;
  89969. /**
  89970. * Gets the current list of active particles
  89971. */
  89972. get particles(): Particle[];
  89973. /**
  89974. * Returns the string "ParticleSystem"
  89975. * @returns a string containing the class name
  89976. */
  89977. getClassName(): string;
  89978. /**
  89979. * Instantiates a particle system.
  89980. * 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.
  89981. * @param name The name of the particle system
  89982. * @param capacity The max number of particles alive at the same time
  89983. * @param scene The scene the particle system belongs to
  89984. * @param customEffect a custom effect used to change the way particles are rendered by default
  89985. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89986. * @param epsilon Offset used to render the particles
  89987. */
  89988. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89989. private _addFactorGradient;
  89990. private _removeFactorGradient;
  89991. /**
  89992. * Adds a new life time gradient
  89993. * @param gradient defines the gradient to use (between 0 and 1)
  89994. * @param factor defines the life time factor to affect to the specified gradient
  89995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89996. * @returns the current particle system
  89997. */
  89998. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89999. /**
  90000. * Remove a specific life time gradient
  90001. * @param gradient defines the gradient to remove
  90002. * @returns the current particle system
  90003. */
  90004. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90005. /**
  90006. * Adds a new size gradient
  90007. * @param gradient defines the gradient to use (between 0 and 1)
  90008. * @param factor defines the size factor to affect to the specified gradient
  90009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90010. * @returns the current particle system
  90011. */
  90012. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90013. /**
  90014. * Remove a specific size gradient
  90015. * @param gradient defines the gradient to remove
  90016. * @returns the current particle system
  90017. */
  90018. removeSizeGradient(gradient: number): IParticleSystem;
  90019. /**
  90020. * Adds a new color remap gradient
  90021. * @param gradient defines the gradient to use (between 0 and 1)
  90022. * @param min defines the color remap minimal range
  90023. * @param max defines the color remap maximal range
  90024. * @returns the current particle system
  90025. */
  90026. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90027. /**
  90028. * Remove a specific color remap gradient
  90029. * @param gradient defines the gradient to remove
  90030. * @returns the current particle system
  90031. */
  90032. removeColorRemapGradient(gradient: number): IParticleSystem;
  90033. /**
  90034. * Adds a new alpha remap gradient
  90035. * @param gradient defines the gradient to use (between 0 and 1)
  90036. * @param min defines the alpha remap minimal range
  90037. * @param max defines the alpha remap maximal range
  90038. * @returns the current particle system
  90039. */
  90040. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90041. /**
  90042. * Remove a specific alpha remap gradient
  90043. * @param gradient defines the gradient to remove
  90044. * @returns the current particle system
  90045. */
  90046. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90047. /**
  90048. * Adds a new angular speed gradient
  90049. * @param gradient defines the gradient to use (between 0 and 1)
  90050. * @param factor defines the angular speed to affect to the specified gradient
  90051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90052. * @returns the current particle system
  90053. */
  90054. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90055. /**
  90056. * Remove a specific angular speed gradient
  90057. * @param gradient defines the gradient to remove
  90058. * @returns the current particle system
  90059. */
  90060. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90061. /**
  90062. * Adds a new velocity gradient
  90063. * @param gradient defines the gradient to use (between 0 and 1)
  90064. * @param factor defines the velocity to affect to the specified gradient
  90065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90066. * @returns the current particle system
  90067. */
  90068. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90069. /**
  90070. * Remove a specific velocity gradient
  90071. * @param gradient defines the gradient to remove
  90072. * @returns the current particle system
  90073. */
  90074. removeVelocityGradient(gradient: number): IParticleSystem;
  90075. /**
  90076. * Adds a new limit velocity gradient
  90077. * @param gradient defines the gradient to use (between 0 and 1)
  90078. * @param factor defines the limit velocity value to affect to the specified gradient
  90079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90080. * @returns the current particle system
  90081. */
  90082. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90083. /**
  90084. * Remove a specific limit velocity gradient
  90085. * @param gradient defines the gradient to remove
  90086. * @returns the current particle system
  90087. */
  90088. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90089. /**
  90090. * Adds a new drag gradient
  90091. * @param gradient defines the gradient to use (between 0 and 1)
  90092. * @param factor defines the drag value to affect to the specified gradient
  90093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90094. * @returns the current particle system
  90095. */
  90096. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90097. /**
  90098. * Remove a specific drag gradient
  90099. * @param gradient defines the gradient to remove
  90100. * @returns the current particle system
  90101. */
  90102. removeDragGradient(gradient: number): IParticleSystem;
  90103. /**
  90104. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90105. * @param gradient defines the gradient to use (between 0 and 1)
  90106. * @param factor defines the emit rate value to affect to the specified gradient
  90107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90108. * @returns the current particle system
  90109. */
  90110. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90111. /**
  90112. * Remove a specific emit rate gradient
  90113. * @param gradient defines the gradient to remove
  90114. * @returns the current particle system
  90115. */
  90116. removeEmitRateGradient(gradient: number): IParticleSystem;
  90117. /**
  90118. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90119. * @param gradient defines the gradient to use (between 0 and 1)
  90120. * @param factor defines the start size value to affect to the specified gradient
  90121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90122. * @returns the current particle system
  90123. */
  90124. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90125. /**
  90126. * Remove a specific start size gradient
  90127. * @param gradient defines the gradient to remove
  90128. * @returns the current particle system
  90129. */
  90130. removeStartSizeGradient(gradient: number): IParticleSystem;
  90131. private _createRampGradientTexture;
  90132. /**
  90133. * Gets the current list of ramp gradients.
  90134. * You must use addRampGradient and removeRampGradient to udpate this list
  90135. * @returns the list of ramp gradients
  90136. */
  90137. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90138. /**
  90139. * Adds a new ramp gradient used to remap particle colors
  90140. * @param gradient defines the gradient to use (between 0 and 1)
  90141. * @param color defines the color to affect to the specified gradient
  90142. * @returns the current particle system
  90143. */
  90144. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90145. /**
  90146. * Remove a specific ramp gradient
  90147. * @param gradient defines the gradient to remove
  90148. * @returns the current particle system
  90149. */
  90150. removeRampGradient(gradient: number): ParticleSystem;
  90151. /**
  90152. * Adds a new color gradient
  90153. * @param gradient defines the gradient to use (between 0 and 1)
  90154. * @param color1 defines the color to affect to the specified gradient
  90155. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90156. * @returns this particle system
  90157. */
  90158. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90159. /**
  90160. * Remove a specific color gradient
  90161. * @param gradient defines the gradient to remove
  90162. * @returns this particle system
  90163. */
  90164. removeColorGradient(gradient: number): IParticleSystem;
  90165. private _fetchR;
  90166. protected _reset(): void;
  90167. private _resetEffect;
  90168. private _createVertexBuffers;
  90169. private _createIndexBuffer;
  90170. /**
  90171. * Gets the maximum number of particles active at the same time.
  90172. * @returns The max number of active particles.
  90173. */
  90174. getCapacity(): number;
  90175. /**
  90176. * Gets whether there are still active particles in the system.
  90177. * @returns True if it is alive, otherwise false.
  90178. */
  90179. isAlive(): boolean;
  90180. /**
  90181. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90182. * @returns True if it has been started, otherwise false.
  90183. */
  90184. isStarted(): boolean;
  90185. private _prepareSubEmitterInternalArray;
  90186. /**
  90187. * Starts the particle system and begins to emit
  90188. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90189. */
  90190. start(delay?: number): void;
  90191. /**
  90192. * Stops the particle system.
  90193. * @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.
  90194. */
  90195. stop(stopSubEmitters?: boolean): void;
  90196. /**
  90197. * Remove all active particles
  90198. */
  90199. reset(): void;
  90200. /**
  90201. * @hidden (for internal use only)
  90202. */
  90203. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90204. /**
  90205. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90206. * Its lifetime will start back at 0.
  90207. */
  90208. recycleParticle: (particle: Particle) => void;
  90209. private _stopSubEmitters;
  90210. private _createParticle;
  90211. private _removeFromRoot;
  90212. private _emitFromParticle;
  90213. private _update;
  90214. /** @hidden */
  90215. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90216. /** @hidden */
  90217. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90218. /** @hidden */
  90219. private _getEffect;
  90220. /**
  90221. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90222. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90223. */
  90224. animate(preWarmOnly?: boolean): void;
  90225. private _appendParticleVertices;
  90226. /**
  90227. * Rebuilds the particle system.
  90228. */
  90229. rebuild(): void;
  90230. /**
  90231. * Is this system ready to be used/rendered
  90232. * @return true if the system is ready
  90233. */
  90234. isReady(): boolean;
  90235. private _render;
  90236. /**
  90237. * Renders the particle system in its current state.
  90238. * @returns the current number of particles
  90239. */
  90240. render(): number;
  90241. /**
  90242. * Disposes the particle system and free the associated resources
  90243. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90244. */
  90245. dispose(disposeTexture?: boolean): void;
  90246. /**
  90247. * Clones the particle system.
  90248. * @param name The name of the cloned object
  90249. * @param newEmitter The new emitter to use
  90250. * @returns the cloned particle system
  90251. */
  90252. clone(name: string, newEmitter: any): ParticleSystem;
  90253. /**
  90254. * Serializes the particle system to a JSON object.
  90255. * @returns the JSON object
  90256. */
  90257. serialize(): any;
  90258. /** @hidden */
  90259. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  90260. /** @hidden */
  90261. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90262. /**
  90263. * Parses a JSON object to create a particle system.
  90264. * @param parsedParticleSystem The JSON object to parse
  90265. * @param scene The scene to create the particle system in
  90266. * @param rootUrl The root url to use to load external dependencies like texture
  90267. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90268. * @returns the Parsed particle system
  90269. */
  90270. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90271. }
  90272. }
  90273. declare module BABYLON {
  90274. /**
  90275. * A particle represents one of the element emitted by a particle system.
  90276. * This is mainly define by its coordinates, direction, velocity and age.
  90277. */
  90278. export class Particle {
  90279. /**
  90280. * The particle system the particle belongs to.
  90281. */
  90282. particleSystem: ParticleSystem;
  90283. private static _Count;
  90284. /**
  90285. * Unique ID of the particle
  90286. */
  90287. id: number;
  90288. /**
  90289. * The world position of the particle in the scene.
  90290. */
  90291. position: Vector3;
  90292. /**
  90293. * The world direction of the particle in the scene.
  90294. */
  90295. direction: Vector3;
  90296. /**
  90297. * The color of the particle.
  90298. */
  90299. color: Color4;
  90300. /**
  90301. * The color change of the particle per step.
  90302. */
  90303. colorStep: Color4;
  90304. /**
  90305. * Defines how long will the life of the particle be.
  90306. */
  90307. lifeTime: number;
  90308. /**
  90309. * The current age of the particle.
  90310. */
  90311. age: number;
  90312. /**
  90313. * The current size of the particle.
  90314. */
  90315. size: number;
  90316. /**
  90317. * The current scale of the particle.
  90318. */
  90319. scale: Vector2;
  90320. /**
  90321. * The current angle of the particle.
  90322. */
  90323. angle: number;
  90324. /**
  90325. * Defines how fast is the angle changing.
  90326. */
  90327. angularSpeed: number;
  90328. /**
  90329. * Defines the cell index used by the particle to be rendered from a sprite.
  90330. */
  90331. cellIndex: number;
  90332. /**
  90333. * The information required to support color remapping
  90334. */
  90335. remapData: Vector4;
  90336. /** @hidden */
  90337. _randomCellOffset?: number;
  90338. /** @hidden */
  90339. _initialDirection: Nullable<Vector3>;
  90340. /** @hidden */
  90341. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90342. /** @hidden */
  90343. _initialStartSpriteCellID: number;
  90344. /** @hidden */
  90345. _initialEndSpriteCellID: number;
  90346. /** @hidden */
  90347. _currentColorGradient: Nullable<ColorGradient>;
  90348. /** @hidden */
  90349. _currentColor1: Color4;
  90350. /** @hidden */
  90351. _currentColor2: Color4;
  90352. /** @hidden */
  90353. _currentSizeGradient: Nullable<FactorGradient>;
  90354. /** @hidden */
  90355. _currentSize1: number;
  90356. /** @hidden */
  90357. _currentSize2: number;
  90358. /** @hidden */
  90359. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90360. /** @hidden */
  90361. _currentAngularSpeed1: number;
  90362. /** @hidden */
  90363. _currentAngularSpeed2: number;
  90364. /** @hidden */
  90365. _currentVelocityGradient: Nullable<FactorGradient>;
  90366. /** @hidden */
  90367. _currentVelocity1: number;
  90368. /** @hidden */
  90369. _currentVelocity2: number;
  90370. /** @hidden */
  90371. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90372. /** @hidden */
  90373. _currentLimitVelocity1: number;
  90374. /** @hidden */
  90375. _currentLimitVelocity2: number;
  90376. /** @hidden */
  90377. _currentDragGradient: Nullable<FactorGradient>;
  90378. /** @hidden */
  90379. _currentDrag1: number;
  90380. /** @hidden */
  90381. _currentDrag2: number;
  90382. /** @hidden */
  90383. _randomNoiseCoordinates1: Vector3;
  90384. /** @hidden */
  90385. _randomNoiseCoordinates2: Vector3;
  90386. /**
  90387. * Creates a new instance Particle
  90388. * @param particleSystem the particle system the particle belongs to
  90389. */
  90390. constructor(
  90391. /**
  90392. * The particle system the particle belongs to.
  90393. */
  90394. particleSystem: ParticleSystem);
  90395. private updateCellInfoFromSystem;
  90396. /**
  90397. * Defines how the sprite cell index is updated for the particle
  90398. */
  90399. updateCellIndex(): void;
  90400. /** @hidden */
  90401. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90402. /** @hidden */
  90403. _inheritParticleInfoToSubEmitters(): void;
  90404. /** @hidden */
  90405. _reset(): void;
  90406. /**
  90407. * Copy the properties of particle to another one.
  90408. * @param other the particle to copy the information to.
  90409. */
  90410. copyTo(other: Particle): void;
  90411. }
  90412. }
  90413. declare module BABYLON {
  90414. /**
  90415. * Particle emitter represents a volume emitting particles.
  90416. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90417. */
  90418. export interface IParticleEmitterType {
  90419. /**
  90420. * Called by the particle System when the direction is computed for the created particle.
  90421. * @param worldMatrix is the world matrix of the particle system
  90422. * @param directionToUpdate is the direction vector to update with the result
  90423. * @param particle is the particle we are computed the direction for
  90424. */
  90425. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90426. /**
  90427. * Called by the particle System when the position is computed for the created particle.
  90428. * @param worldMatrix is the world matrix of the particle system
  90429. * @param positionToUpdate is the position vector to update with the result
  90430. * @param particle is the particle we are computed the position for
  90431. */
  90432. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90433. /**
  90434. * Clones the current emitter and returns a copy of it
  90435. * @returns the new emitter
  90436. */
  90437. clone(): IParticleEmitterType;
  90438. /**
  90439. * Called by the GPUParticleSystem to setup the update shader
  90440. * @param effect defines the update shader
  90441. */
  90442. applyToShader(effect: Effect): void;
  90443. /**
  90444. * Returns a string to use to update the GPU particles update shader
  90445. * @returns the effect defines string
  90446. */
  90447. getEffectDefines(): string;
  90448. /**
  90449. * Returns a string representing the class name
  90450. * @returns a string containing the class name
  90451. */
  90452. getClassName(): string;
  90453. /**
  90454. * Serializes the particle system to a JSON object.
  90455. * @returns the JSON object
  90456. */
  90457. serialize(): any;
  90458. /**
  90459. * Parse properties from a JSON object
  90460. * @param serializationObject defines the JSON object
  90461. */
  90462. parse(serializationObject: any): void;
  90463. }
  90464. }
  90465. declare module BABYLON {
  90466. /**
  90467. * Particle emitter emitting particles from the inside of a box.
  90468. * It emits the particles randomly between 2 given directions.
  90469. */
  90470. export class BoxParticleEmitter implements IParticleEmitterType {
  90471. /**
  90472. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90473. */
  90474. direction1: Vector3;
  90475. /**
  90476. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90477. */
  90478. direction2: Vector3;
  90479. /**
  90480. * 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.
  90481. */
  90482. minEmitBox: Vector3;
  90483. /**
  90484. * 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.
  90485. */
  90486. maxEmitBox: Vector3;
  90487. /**
  90488. * Creates a new instance BoxParticleEmitter
  90489. */
  90490. constructor();
  90491. /**
  90492. * Called by the particle System when the direction is computed for the created particle.
  90493. * @param worldMatrix is the world matrix of the particle system
  90494. * @param directionToUpdate is the direction vector to update with the result
  90495. * @param particle is the particle we are computed the direction for
  90496. */
  90497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90498. /**
  90499. * Called by the particle System when the position is computed for the created particle.
  90500. * @param worldMatrix is the world matrix of the particle system
  90501. * @param positionToUpdate is the position vector to update with the result
  90502. * @param particle is the particle we are computed the position for
  90503. */
  90504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90505. /**
  90506. * Clones the current emitter and returns a copy of it
  90507. * @returns the new emitter
  90508. */
  90509. clone(): BoxParticleEmitter;
  90510. /**
  90511. * Called by the GPUParticleSystem to setup the update shader
  90512. * @param effect defines the update shader
  90513. */
  90514. applyToShader(effect: Effect): void;
  90515. /**
  90516. * Returns a string to use to update the GPU particles update shader
  90517. * @returns a string containng the defines string
  90518. */
  90519. getEffectDefines(): string;
  90520. /**
  90521. * Returns the string "BoxParticleEmitter"
  90522. * @returns a string containing the class name
  90523. */
  90524. getClassName(): string;
  90525. /**
  90526. * Serializes the particle system to a JSON object.
  90527. * @returns the JSON object
  90528. */
  90529. serialize(): any;
  90530. /**
  90531. * Parse properties from a JSON object
  90532. * @param serializationObject defines the JSON object
  90533. */
  90534. parse(serializationObject: any): void;
  90535. }
  90536. }
  90537. declare module BABYLON {
  90538. /**
  90539. * Particle emitter emitting particles from the inside of a cone.
  90540. * It emits the particles alongside the cone volume from the base to the particle.
  90541. * The emission direction might be randomized.
  90542. */
  90543. export class ConeParticleEmitter implements IParticleEmitterType {
  90544. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90545. directionRandomizer: number;
  90546. private _radius;
  90547. private _angle;
  90548. private _height;
  90549. /**
  90550. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90551. */
  90552. radiusRange: number;
  90553. /**
  90554. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90555. */
  90556. heightRange: number;
  90557. /**
  90558. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90559. */
  90560. emitFromSpawnPointOnly: boolean;
  90561. /**
  90562. * Gets or sets the radius of the emission cone
  90563. */
  90564. get radius(): number;
  90565. set radius(value: number);
  90566. /**
  90567. * Gets or sets the angle of the emission cone
  90568. */
  90569. get angle(): number;
  90570. set angle(value: number);
  90571. private _buildHeight;
  90572. /**
  90573. * Creates a new instance ConeParticleEmitter
  90574. * @param radius the radius of the emission cone (1 by default)
  90575. * @param angle the cone base angle (PI by default)
  90576. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90577. */
  90578. constructor(radius?: number, angle?: number,
  90579. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90580. directionRandomizer?: number);
  90581. /**
  90582. * Called by the particle System when the direction is computed for the created particle.
  90583. * @param worldMatrix is the world matrix of the particle system
  90584. * @param directionToUpdate is the direction vector to update with the result
  90585. * @param particle is the particle we are computed the direction for
  90586. */
  90587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90588. /**
  90589. * Called by the particle System when the position is computed for the created particle.
  90590. * @param worldMatrix is the world matrix of the particle system
  90591. * @param positionToUpdate is the position vector to update with the result
  90592. * @param particle is the particle we are computed the position for
  90593. */
  90594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90595. /**
  90596. * Clones the current emitter and returns a copy of it
  90597. * @returns the new emitter
  90598. */
  90599. clone(): ConeParticleEmitter;
  90600. /**
  90601. * Called by the GPUParticleSystem to setup the update shader
  90602. * @param effect defines the update shader
  90603. */
  90604. applyToShader(effect: Effect): void;
  90605. /**
  90606. * Returns a string to use to update the GPU particles update shader
  90607. * @returns a string containng the defines string
  90608. */
  90609. getEffectDefines(): string;
  90610. /**
  90611. * Returns the string "ConeParticleEmitter"
  90612. * @returns a string containing the class name
  90613. */
  90614. getClassName(): string;
  90615. /**
  90616. * Serializes the particle system to a JSON object.
  90617. * @returns the JSON object
  90618. */
  90619. serialize(): any;
  90620. /**
  90621. * Parse properties from a JSON object
  90622. * @param serializationObject defines the JSON object
  90623. */
  90624. parse(serializationObject: any): void;
  90625. }
  90626. }
  90627. declare module BABYLON {
  90628. /**
  90629. * Particle emitter emitting particles from the inside of a cylinder.
  90630. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90631. */
  90632. export class CylinderParticleEmitter implements IParticleEmitterType {
  90633. /**
  90634. * The radius of the emission cylinder.
  90635. */
  90636. radius: number;
  90637. /**
  90638. * The height of the emission cylinder.
  90639. */
  90640. height: number;
  90641. /**
  90642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90643. */
  90644. radiusRange: number;
  90645. /**
  90646. * How much to randomize the particle direction [0-1].
  90647. */
  90648. directionRandomizer: number;
  90649. /**
  90650. * Creates a new instance CylinderParticleEmitter
  90651. * @param radius the radius of the emission cylinder (1 by default)
  90652. * @param height the height of the emission cylinder (1 by default)
  90653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90654. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90655. */
  90656. constructor(
  90657. /**
  90658. * The radius of the emission cylinder.
  90659. */
  90660. radius?: number,
  90661. /**
  90662. * The height of the emission cylinder.
  90663. */
  90664. height?: number,
  90665. /**
  90666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90667. */
  90668. radiusRange?: number,
  90669. /**
  90670. * How much to randomize the particle direction [0-1].
  90671. */
  90672. directionRandomizer?: number);
  90673. /**
  90674. * Called by the particle System when the direction is computed for the created particle.
  90675. * @param worldMatrix is the world matrix of the particle system
  90676. * @param directionToUpdate is the direction vector to update with the result
  90677. * @param particle is the particle we are computed the direction for
  90678. */
  90679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90680. /**
  90681. * Called by the particle System when the position is computed for the created particle.
  90682. * @param worldMatrix is the world matrix of the particle system
  90683. * @param positionToUpdate is the position vector to update with the result
  90684. * @param particle is the particle we are computed the position for
  90685. */
  90686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90687. /**
  90688. * Clones the current emitter and returns a copy of it
  90689. * @returns the new emitter
  90690. */
  90691. clone(): CylinderParticleEmitter;
  90692. /**
  90693. * Called by the GPUParticleSystem to setup the update shader
  90694. * @param effect defines the update shader
  90695. */
  90696. applyToShader(effect: Effect): void;
  90697. /**
  90698. * Returns a string to use to update the GPU particles update shader
  90699. * @returns a string containng the defines string
  90700. */
  90701. getEffectDefines(): string;
  90702. /**
  90703. * Returns the string "CylinderParticleEmitter"
  90704. * @returns a string containing the class name
  90705. */
  90706. getClassName(): string;
  90707. /**
  90708. * Serializes the particle system to a JSON object.
  90709. * @returns the JSON object
  90710. */
  90711. serialize(): any;
  90712. /**
  90713. * Parse properties from a JSON object
  90714. * @param serializationObject defines the JSON object
  90715. */
  90716. parse(serializationObject: any): void;
  90717. }
  90718. /**
  90719. * Particle emitter emitting particles from the inside of a cylinder.
  90720. * It emits the particles randomly between two vectors.
  90721. */
  90722. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90723. /**
  90724. * The min limit of the emission direction.
  90725. */
  90726. direction1: Vector3;
  90727. /**
  90728. * The max limit of the emission direction.
  90729. */
  90730. direction2: Vector3;
  90731. /**
  90732. * Creates a new instance CylinderDirectedParticleEmitter
  90733. * @param radius the radius of the emission cylinder (1 by default)
  90734. * @param height the height of the emission cylinder (1 by default)
  90735. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90736. * @param direction1 the min limit of the emission direction (up vector by default)
  90737. * @param direction2 the max limit of the emission direction (up vector by default)
  90738. */
  90739. constructor(radius?: number, height?: number, radiusRange?: number,
  90740. /**
  90741. * The min limit of the emission direction.
  90742. */
  90743. direction1?: Vector3,
  90744. /**
  90745. * The max limit of the emission direction.
  90746. */
  90747. direction2?: Vector3);
  90748. /**
  90749. * Called by the particle System when the direction is computed for the created particle.
  90750. * @param worldMatrix is the world matrix of the particle system
  90751. * @param directionToUpdate is the direction vector to update with the result
  90752. * @param particle is the particle we are computed the direction for
  90753. */
  90754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90755. /**
  90756. * Clones the current emitter and returns a copy of it
  90757. * @returns the new emitter
  90758. */
  90759. clone(): CylinderDirectedParticleEmitter;
  90760. /**
  90761. * Called by the GPUParticleSystem to setup the update shader
  90762. * @param effect defines the update shader
  90763. */
  90764. applyToShader(effect: Effect): void;
  90765. /**
  90766. * Returns a string to use to update the GPU particles update shader
  90767. * @returns a string containng the defines string
  90768. */
  90769. getEffectDefines(): string;
  90770. /**
  90771. * Returns the string "CylinderDirectedParticleEmitter"
  90772. * @returns a string containing the class name
  90773. */
  90774. getClassName(): string;
  90775. /**
  90776. * Serializes the particle system to a JSON object.
  90777. * @returns the JSON object
  90778. */
  90779. serialize(): any;
  90780. /**
  90781. * Parse properties from a JSON object
  90782. * @param serializationObject defines the JSON object
  90783. */
  90784. parse(serializationObject: any): void;
  90785. }
  90786. }
  90787. declare module BABYLON {
  90788. /**
  90789. * Particle emitter emitting particles from the inside of a hemisphere.
  90790. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90791. */
  90792. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90793. /**
  90794. * The radius of the emission hemisphere.
  90795. */
  90796. radius: number;
  90797. /**
  90798. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90799. */
  90800. radiusRange: number;
  90801. /**
  90802. * How much to randomize the particle direction [0-1].
  90803. */
  90804. directionRandomizer: number;
  90805. /**
  90806. * Creates a new instance HemisphericParticleEmitter
  90807. * @param radius the radius of the emission hemisphere (1 by default)
  90808. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90809. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90810. */
  90811. constructor(
  90812. /**
  90813. * The radius of the emission hemisphere.
  90814. */
  90815. radius?: number,
  90816. /**
  90817. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90818. */
  90819. radiusRange?: number,
  90820. /**
  90821. * How much to randomize the particle direction [0-1].
  90822. */
  90823. directionRandomizer?: number);
  90824. /**
  90825. * Called by the particle System when the direction is computed for the created particle.
  90826. * @param worldMatrix is the world matrix of the particle system
  90827. * @param directionToUpdate is the direction vector to update with the result
  90828. * @param particle is the particle we are computed the direction for
  90829. */
  90830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90831. /**
  90832. * Called by the particle System when the position is computed for the created particle.
  90833. * @param worldMatrix is the world matrix of the particle system
  90834. * @param positionToUpdate is the position vector to update with the result
  90835. * @param particle is the particle we are computed the position for
  90836. */
  90837. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90838. /**
  90839. * Clones the current emitter and returns a copy of it
  90840. * @returns the new emitter
  90841. */
  90842. clone(): HemisphericParticleEmitter;
  90843. /**
  90844. * Called by the GPUParticleSystem to setup the update shader
  90845. * @param effect defines the update shader
  90846. */
  90847. applyToShader(effect: Effect): void;
  90848. /**
  90849. * Returns a string to use to update the GPU particles update shader
  90850. * @returns a string containng the defines string
  90851. */
  90852. getEffectDefines(): string;
  90853. /**
  90854. * Returns the string "HemisphericParticleEmitter"
  90855. * @returns a string containing the class name
  90856. */
  90857. getClassName(): string;
  90858. /**
  90859. * Serializes the particle system to a JSON object.
  90860. * @returns the JSON object
  90861. */
  90862. serialize(): any;
  90863. /**
  90864. * Parse properties from a JSON object
  90865. * @param serializationObject defines the JSON object
  90866. */
  90867. parse(serializationObject: any): void;
  90868. }
  90869. }
  90870. declare module BABYLON {
  90871. /**
  90872. * Particle emitter emitting particles from a point.
  90873. * It emits the particles randomly between 2 given directions.
  90874. */
  90875. export class PointParticleEmitter implements IParticleEmitterType {
  90876. /**
  90877. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90878. */
  90879. direction1: Vector3;
  90880. /**
  90881. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90882. */
  90883. direction2: Vector3;
  90884. /**
  90885. * Creates a new instance PointParticleEmitter
  90886. */
  90887. constructor();
  90888. /**
  90889. * Called by the particle System when the direction is computed for the created particle.
  90890. * @param worldMatrix is the world matrix of the particle system
  90891. * @param directionToUpdate is the direction vector to update with the result
  90892. * @param particle is the particle we are computed the direction for
  90893. */
  90894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90895. /**
  90896. * Called by the particle System when the position is computed for the created particle.
  90897. * @param worldMatrix is the world matrix of the particle system
  90898. * @param positionToUpdate is the position vector to update with the result
  90899. * @param particle is the particle we are computed the position for
  90900. */
  90901. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90902. /**
  90903. * Clones the current emitter and returns a copy of it
  90904. * @returns the new emitter
  90905. */
  90906. clone(): PointParticleEmitter;
  90907. /**
  90908. * Called by the GPUParticleSystem to setup the update shader
  90909. * @param effect defines the update shader
  90910. */
  90911. applyToShader(effect: Effect): void;
  90912. /**
  90913. * Returns a string to use to update the GPU particles update shader
  90914. * @returns a string containng the defines string
  90915. */
  90916. getEffectDefines(): string;
  90917. /**
  90918. * Returns the string "PointParticleEmitter"
  90919. * @returns a string containing the class name
  90920. */
  90921. getClassName(): string;
  90922. /**
  90923. * Serializes the particle system to a JSON object.
  90924. * @returns the JSON object
  90925. */
  90926. serialize(): any;
  90927. /**
  90928. * Parse properties from a JSON object
  90929. * @param serializationObject defines the JSON object
  90930. */
  90931. parse(serializationObject: any): void;
  90932. }
  90933. }
  90934. declare module BABYLON {
  90935. /**
  90936. * Particle emitter emitting particles from the inside of a sphere.
  90937. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90938. */
  90939. export class SphereParticleEmitter implements IParticleEmitterType {
  90940. /**
  90941. * The radius of the emission sphere.
  90942. */
  90943. radius: number;
  90944. /**
  90945. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90946. */
  90947. radiusRange: number;
  90948. /**
  90949. * How much to randomize the particle direction [0-1].
  90950. */
  90951. directionRandomizer: number;
  90952. /**
  90953. * Creates a new instance SphereParticleEmitter
  90954. * @param radius the radius of the emission sphere (1 by default)
  90955. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90956. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90957. */
  90958. constructor(
  90959. /**
  90960. * The radius of the emission sphere.
  90961. */
  90962. radius?: number,
  90963. /**
  90964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90965. */
  90966. radiusRange?: number,
  90967. /**
  90968. * How much to randomize the particle direction [0-1].
  90969. */
  90970. directionRandomizer?: number);
  90971. /**
  90972. * Called by the particle System when the direction is computed for the created particle.
  90973. * @param worldMatrix is the world matrix of the particle system
  90974. * @param directionToUpdate is the direction vector to update with the result
  90975. * @param particle is the particle we are computed the direction for
  90976. */
  90977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90978. /**
  90979. * Called by the particle System when the position is computed for the created particle.
  90980. * @param worldMatrix is the world matrix of the particle system
  90981. * @param positionToUpdate is the position vector to update with the result
  90982. * @param particle is the particle we are computed the position for
  90983. */
  90984. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90985. /**
  90986. * Clones the current emitter and returns a copy of it
  90987. * @returns the new emitter
  90988. */
  90989. clone(): SphereParticleEmitter;
  90990. /**
  90991. * Called by the GPUParticleSystem to setup the update shader
  90992. * @param effect defines the update shader
  90993. */
  90994. applyToShader(effect: Effect): void;
  90995. /**
  90996. * Returns a string to use to update the GPU particles update shader
  90997. * @returns a string containng the defines string
  90998. */
  90999. getEffectDefines(): string;
  91000. /**
  91001. * Returns the string "SphereParticleEmitter"
  91002. * @returns a string containing the class name
  91003. */
  91004. getClassName(): string;
  91005. /**
  91006. * Serializes the particle system to a JSON object.
  91007. * @returns the JSON object
  91008. */
  91009. serialize(): any;
  91010. /**
  91011. * Parse properties from a JSON object
  91012. * @param serializationObject defines the JSON object
  91013. */
  91014. parse(serializationObject: any): void;
  91015. }
  91016. /**
  91017. * Particle emitter emitting particles from the inside of a sphere.
  91018. * It emits the particles randomly between two vectors.
  91019. */
  91020. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91021. /**
  91022. * The min limit of the emission direction.
  91023. */
  91024. direction1: Vector3;
  91025. /**
  91026. * The max limit of the emission direction.
  91027. */
  91028. direction2: Vector3;
  91029. /**
  91030. * Creates a new instance SphereDirectedParticleEmitter
  91031. * @param radius the radius of the emission sphere (1 by default)
  91032. * @param direction1 the min limit of the emission direction (up vector by default)
  91033. * @param direction2 the max limit of the emission direction (up vector by default)
  91034. */
  91035. constructor(radius?: number,
  91036. /**
  91037. * The min limit of the emission direction.
  91038. */
  91039. direction1?: Vector3,
  91040. /**
  91041. * The max limit of the emission direction.
  91042. */
  91043. direction2?: Vector3);
  91044. /**
  91045. * Called by the particle System when the direction is computed for the created particle.
  91046. * @param worldMatrix is the world matrix of the particle system
  91047. * @param directionToUpdate is the direction vector to update with the result
  91048. * @param particle is the particle we are computed the direction for
  91049. */
  91050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91051. /**
  91052. * Clones the current emitter and returns a copy of it
  91053. * @returns the new emitter
  91054. */
  91055. clone(): SphereDirectedParticleEmitter;
  91056. /**
  91057. * Called by the GPUParticleSystem to setup the update shader
  91058. * @param effect defines the update shader
  91059. */
  91060. applyToShader(effect: Effect): void;
  91061. /**
  91062. * Returns a string to use to update the GPU particles update shader
  91063. * @returns a string containng the defines string
  91064. */
  91065. getEffectDefines(): string;
  91066. /**
  91067. * Returns the string "SphereDirectedParticleEmitter"
  91068. * @returns a string containing the class name
  91069. */
  91070. getClassName(): string;
  91071. /**
  91072. * Serializes the particle system to a JSON object.
  91073. * @returns the JSON object
  91074. */
  91075. serialize(): any;
  91076. /**
  91077. * Parse properties from a JSON object
  91078. * @param serializationObject defines the JSON object
  91079. */
  91080. parse(serializationObject: any): void;
  91081. }
  91082. }
  91083. declare module BABYLON {
  91084. /**
  91085. * Particle emitter emitting particles from a custom list of positions.
  91086. */
  91087. export class CustomParticleEmitter implements IParticleEmitterType {
  91088. /**
  91089. * Gets or sets the position generator that will create the inital position of each particle.
  91090. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91091. */
  91092. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91093. /**
  91094. * Gets or sets the destination generator that will create the final destination of each particle.
  91095. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91096. */
  91097. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91098. /**
  91099. * Creates a new instance CustomParticleEmitter
  91100. */
  91101. constructor();
  91102. /**
  91103. * Called by the particle System when the direction is computed for the created particle.
  91104. * @param worldMatrix is the world matrix of the particle system
  91105. * @param directionToUpdate is the direction vector to update with the result
  91106. * @param particle is the particle we are computed the direction for
  91107. */
  91108. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91109. /**
  91110. * Called by the particle System when the position is computed for the created particle.
  91111. * @param worldMatrix is the world matrix of the particle system
  91112. * @param positionToUpdate is the position vector to update with the result
  91113. * @param particle is the particle we are computed the position for
  91114. */
  91115. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91116. /**
  91117. * Clones the current emitter and returns a copy of it
  91118. * @returns the new emitter
  91119. */
  91120. clone(): CustomParticleEmitter;
  91121. /**
  91122. * Called by the GPUParticleSystem to setup the update shader
  91123. * @param effect defines the update shader
  91124. */
  91125. applyToShader(effect: Effect): void;
  91126. /**
  91127. * Returns a string to use to update the GPU particles update shader
  91128. * @returns a string containng the defines string
  91129. */
  91130. getEffectDefines(): string;
  91131. /**
  91132. * Returns the string "PointParticleEmitter"
  91133. * @returns a string containing the class name
  91134. */
  91135. getClassName(): string;
  91136. /**
  91137. * Serializes the particle system to a JSON object.
  91138. * @returns the JSON object
  91139. */
  91140. serialize(): any;
  91141. /**
  91142. * Parse properties from a JSON object
  91143. * @param serializationObject defines the JSON object
  91144. */
  91145. parse(serializationObject: any): void;
  91146. }
  91147. }
  91148. declare module BABYLON {
  91149. /**
  91150. * Interface representing a particle system in Babylon.js.
  91151. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91152. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91153. */
  91154. export interface IParticleSystem {
  91155. /**
  91156. * List of animations used by the particle system.
  91157. */
  91158. animations: Animation[];
  91159. /**
  91160. * The id of the Particle system.
  91161. */
  91162. id: string;
  91163. /**
  91164. * The name of the Particle system.
  91165. */
  91166. name: string;
  91167. /**
  91168. * The emitter represents the Mesh or position we are attaching the particle system to.
  91169. */
  91170. emitter: Nullable<AbstractMesh | Vector3>;
  91171. /**
  91172. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91173. */
  91174. isBillboardBased: boolean;
  91175. /**
  91176. * The rendering group used by the Particle system to chose when to render.
  91177. */
  91178. renderingGroupId: number;
  91179. /**
  91180. * The layer mask we are rendering the particles through.
  91181. */
  91182. layerMask: number;
  91183. /**
  91184. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91185. */
  91186. updateSpeed: number;
  91187. /**
  91188. * The amount of time the particle system is running (depends of the overall update speed).
  91189. */
  91190. targetStopDuration: number;
  91191. /**
  91192. * The texture used to render each particle. (this can be a spritesheet)
  91193. */
  91194. particleTexture: Nullable<Texture>;
  91195. /**
  91196. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91197. */
  91198. blendMode: number;
  91199. /**
  91200. * Minimum life time of emitting particles.
  91201. */
  91202. minLifeTime: number;
  91203. /**
  91204. * Maximum life time of emitting particles.
  91205. */
  91206. maxLifeTime: number;
  91207. /**
  91208. * Minimum Size of emitting particles.
  91209. */
  91210. minSize: number;
  91211. /**
  91212. * Maximum Size of emitting particles.
  91213. */
  91214. maxSize: number;
  91215. /**
  91216. * Minimum scale of emitting particles on X axis.
  91217. */
  91218. minScaleX: number;
  91219. /**
  91220. * Maximum scale of emitting particles on X axis.
  91221. */
  91222. maxScaleX: number;
  91223. /**
  91224. * Minimum scale of emitting particles on Y axis.
  91225. */
  91226. minScaleY: number;
  91227. /**
  91228. * Maximum scale of emitting particles on Y axis.
  91229. */
  91230. maxScaleY: number;
  91231. /**
  91232. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91233. */
  91234. color1: Color4;
  91235. /**
  91236. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91237. */
  91238. color2: Color4;
  91239. /**
  91240. * Color the particle will have at the end of its lifetime.
  91241. */
  91242. colorDead: Color4;
  91243. /**
  91244. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91245. */
  91246. emitRate: number;
  91247. /**
  91248. * You can use gravity if you want to give an orientation to your particles.
  91249. */
  91250. gravity: Vector3;
  91251. /**
  91252. * Minimum power of emitting particles.
  91253. */
  91254. minEmitPower: number;
  91255. /**
  91256. * Maximum power of emitting particles.
  91257. */
  91258. maxEmitPower: number;
  91259. /**
  91260. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91261. */
  91262. minAngularSpeed: number;
  91263. /**
  91264. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91265. */
  91266. maxAngularSpeed: number;
  91267. /**
  91268. * Gets or sets the minimal initial rotation in radians.
  91269. */
  91270. minInitialRotation: number;
  91271. /**
  91272. * Gets or sets the maximal initial rotation in radians.
  91273. */
  91274. maxInitialRotation: number;
  91275. /**
  91276. * The particle emitter type defines the emitter used by the particle system.
  91277. * It can be for example box, sphere, or cone...
  91278. */
  91279. particleEmitterType: Nullable<IParticleEmitterType>;
  91280. /**
  91281. * Defines the delay in milliseconds before starting the system (0 by default)
  91282. */
  91283. startDelay: number;
  91284. /**
  91285. * 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
  91286. */
  91287. preWarmCycles: number;
  91288. /**
  91289. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91290. */
  91291. preWarmStepOffset: number;
  91292. /**
  91293. * 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)
  91294. */
  91295. spriteCellChangeSpeed: number;
  91296. /**
  91297. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91298. */
  91299. startSpriteCellID: number;
  91300. /**
  91301. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91302. */
  91303. endSpriteCellID: number;
  91304. /**
  91305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91306. */
  91307. spriteCellWidth: number;
  91308. /**
  91309. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91310. */
  91311. spriteCellHeight: number;
  91312. /**
  91313. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91314. */
  91315. spriteRandomStartCell: boolean;
  91316. /**
  91317. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91318. */
  91319. isAnimationSheetEnabled: boolean;
  91320. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91321. translationPivot: Vector2;
  91322. /**
  91323. * Gets or sets a texture used to add random noise to particle positions
  91324. */
  91325. noiseTexture: Nullable<BaseTexture>;
  91326. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91327. noiseStrength: Vector3;
  91328. /**
  91329. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91330. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91331. */
  91332. billboardMode: number;
  91333. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91334. limitVelocityDamping: number;
  91335. /**
  91336. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91337. */
  91338. beginAnimationOnStart: boolean;
  91339. /**
  91340. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91341. */
  91342. beginAnimationFrom: number;
  91343. /**
  91344. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91345. */
  91346. beginAnimationTo: number;
  91347. /**
  91348. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91349. */
  91350. beginAnimationLoop: boolean;
  91351. /**
  91352. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91353. */
  91354. disposeOnStop: boolean;
  91355. /**
  91356. * Gets the maximum number of particles active at the same time.
  91357. * @returns The max number of active particles.
  91358. */
  91359. getCapacity(): number;
  91360. /**
  91361. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91362. * @returns True if it has been started, otherwise false.
  91363. */
  91364. isStarted(): boolean;
  91365. /**
  91366. * Animates the particle system for this frame.
  91367. */
  91368. animate(): void;
  91369. /**
  91370. * Renders the particle system in its current state.
  91371. * @returns the current number of particles
  91372. */
  91373. render(): number;
  91374. /**
  91375. * Dispose the particle system and frees its associated resources.
  91376. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91377. */
  91378. dispose(disposeTexture?: boolean): void;
  91379. /**
  91380. * Clones the particle system.
  91381. * @param name The name of the cloned object
  91382. * @param newEmitter The new emitter to use
  91383. * @returns the cloned particle system
  91384. */
  91385. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91386. /**
  91387. * Serializes the particle system to a JSON object.
  91388. * @returns the JSON object
  91389. */
  91390. serialize(): any;
  91391. /**
  91392. * Rebuild the particle system
  91393. */
  91394. rebuild(): void;
  91395. /**
  91396. * Starts the particle system and begins to emit
  91397. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91398. */
  91399. start(delay?: number): void;
  91400. /**
  91401. * Stops the particle system.
  91402. */
  91403. stop(): void;
  91404. /**
  91405. * Remove all active particles
  91406. */
  91407. reset(): void;
  91408. /**
  91409. * Is this system ready to be used/rendered
  91410. * @return true if the system is ready
  91411. */
  91412. isReady(): boolean;
  91413. /**
  91414. * Adds a new color gradient
  91415. * @param gradient defines the gradient to use (between 0 and 1)
  91416. * @param color1 defines the color to affect to the specified gradient
  91417. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91418. * @returns the current particle system
  91419. */
  91420. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91421. /**
  91422. * Remove a specific color gradient
  91423. * @param gradient defines the gradient to remove
  91424. * @returns the current particle system
  91425. */
  91426. removeColorGradient(gradient: number): IParticleSystem;
  91427. /**
  91428. * Adds a new size gradient
  91429. * @param gradient defines the gradient to use (between 0 and 1)
  91430. * @param factor defines the size factor to affect to the specified gradient
  91431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91432. * @returns the current particle system
  91433. */
  91434. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91435. /**
  91436. * Remove a specific size gradient
  91437. * @param gradient defines the gradient to remove
  91438. * @returns the current particle system
  91439. */
  91440. removeSizeGradient(gradient: number): IParticleSystem;
  91441. /**
  91442. * Gets the current list of color gradients.
  91443. * You must use addColorGradient and removeColorGradient to udpate this list
  91444. * @returns the list of color gradients
  91445. */
  91446. getColorGradients(): Nullable<Array<ColorGradient>>;
  91447. /**
  91448. * Gets the current list of size gradients.
  91449. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91450. * @returns the list of size gradients
  91451. */
  91452. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91453. /**
  91454. * Gets the current list of angular speed gradients.
  91455. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91456. * @returns the list of angular speed gradients
  91457. */
  91458. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91459. /**
  91460. * Adds a new angular speed gradient
  91461. * @param gradient defines the gradient to use (between 0 and 1)
  91462. * @param factor defines the angular speed to affect to the specified gradient
  91463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91464. * @returns the current particle system
  91465. */
  91466. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91467. /**
  91468. * Remove a specific angular speed gradient
  91469. * @param gradient defines the gradient to remove
  91470. * @returns the current particle system
  91471. */
  91472. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91473. /**
  91474. * Gets the current list of velocity gradients.
  91475. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91476. * @returns the list of velocity gradients
  91477. */
  91478. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91479. /**
  91480. * Adds a new velocity gradient
  91481. * @param gradient defines the gradient to use (between 0 and 1)
  91482. * @param factor defines the velocity to affect to the specified gradient
  91483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91484. * @returns the current particle system
  91485. */
  91486. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91487. /**
  91488. * Remove a specific velocity gradient
  91489. * @param gradient defines the gradient to remove
  91490. * @returns the current particle system
  91491. */
  91492. removeVelocityGradient(gradient: number): IParticleSystem;
  91493. /**
  91494. * Gets the current list of limit velocity gradients.
  91495. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91496. * @returns the list of limit velocity gradients
  91497. */
  91498. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91499. /**
  91500. * Adds a new limit velocity gradient
  91501. * @param gradient defines the gradient to use (between 0 and 1)
  91502. * @param factor defines the limit velocity to affect to the specified gradient
  91503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91504. * @returns the current particle system
  91505. */
  91506. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91507. /**
  91508. * Remove a specific limit velocity gradient
  91509. * @param gradient defines the gradient to remove
  91510. * @returns the current particle system
  91511. */
  91512. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91513. /**
  91514. * Adds a new drag gradient
  91515. * @param gradient defines the gradient to use (between 0 and 1)
  91516. * @param factor defines the drag to affect to the specified gradient
  91517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91518. * @returns the current particle system
  91519. */
  91520. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91521. /**
  91522. * Remove a specific drag gradient
  91523. * @param gradient defines the gradient to remove
  91524. * @returns the current particle system
  91525. */
  91526. removeDragGradient(gradient: number): IParticleSystem;
  91527. /**
  91528. * Gets the current list of drag gradients.
  91529. * You must use addDragGradient and removeDragGradient to udpate this list
  91530. * @returns the list of drag gradients
  91531. */
  91532. getDragGradients(): Nullable<Array<FactorGradient>>;
  91533. /**
  91534. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91535. * @param gradient defines the gradient to use (between 0 and 1)
  91536. * @param factor defines the emit rate to affect to the specified gradient
  91537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91538. * @returns the current particle system
  91539. */
  91540. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91541. /**
  91542. * Remove a specific emit rate gradient
  91543. * @param gradient defines the gradient to remove
  91544. * @returns the current particle system
  91545. */
  91546. removeEmitRateGradient(gradient: number): IParticleSystem;
  91547. /**
  91548. * Gets the current list of emit rate gradients.
  91549. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91550. * @returns the list of emit rate gradients
  91551. */
  91552. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91553. /**
  91554. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91555. * @param gradient defines the gradient to use (between 0 and 1)
  91556. * @param factor defines the start size to affect to the specified gradient
  91557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91558. * @returns the current particle system
  91559. */
  91560. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91561. /**
  91562. * Remove a specific start size gradient
  91563. * @param gradient defines the gradient to remove
  91564. * @returns the current particle system
  91565. */
  91566. removeStartSizeGradient(gradient: number): IParticleSystem;
  91567. /**
  91568. * Gets the current list of start size gradients.
  91569. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91570. * @returns the list of start size gradients
  91571. */
  91572. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91573. /**
  91574. * Adds a new life time gradient
  91575. * @param gradient defines the gradient to use (between 0 and 1)
  91576. * @param factor defines the life time factor to affect to the specified gradient
  91577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91578. * @returns the current particle system
  91579. */
  91580. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91581. /**
  91582. * Remove a specific life time gradient
  91583. * @param gradient defines the gradient to remove
  91584. * @returns the current particle system
  91585. */
  91586. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91587. /**
  91588. * Gets the current list of life time gradients.
  91589. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91590. * @returns the list of life time gradients
  91591. */
  91592. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91593. /**
  91594. * Gets the current list of color gradients.
  91595. * You must use addColorGradient and removeColorGradient to udpate this list
  91596. * @returns the list of color gradients
  91597. */
  91598. getColorGradients(): Nullable<Array<ColorGradient>>;
  91599. /**
  91600. * Adds a new ramp gradient used to remap particle colors
  91601. * @param gradient defines the gradient to use (between 0 and 1)
  91602. * @param color defines the color to affect to the specified gradient
  91603. * @returns the current particle system
  91604. */
  91605. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91606. /**
  91607. * Gets the current list of ramp gradients.
  91608. * You must use addRampGradient and removeRampGradient to udpate this list
  91609. * @returns the list of ramp gradients
  91610. */
  91611. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91612. /** Gets or sets a boolean indicating that ramp gradients must be used
  91613. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91614. */
  91615. useRampGradients: boolean;
  91616. /**
  91617. * Adds a new color remap gradient
  91618. * @param gradient defines the gradient to use (between 0 and 1)
  91619. * @param min defines the color remap minimal range
  91620. * @param max defines the color remap maximal range
  91621. * @returns the current particle system
  91622. */
  91623. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91624. /**
  91625. * Gets the current list of color remap gradients.
  91626. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91627. * @returns the list of color remap gradients
  91628. */
  91629. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91630. /**
  91631. * Adds a new alpha remap gradient
  91632. * @param gradient defines the gradient to use (between 0 and 1)
  91633. * @param min defines the alpha remap minimal range
  91634. * @param max defines the alpha remap maximal range
  91635. * @returns the current particle system
  91636. */
  91637. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91638. /**
  91639. * Gets the current list of alpha remap gradients.
  91640. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91641. * @returns the list of alpha remap gradients
  91642. */
  91643. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91644. /**
  91645. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91648. * @returns the emitter
  91649. */
  91650. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91651. /**
  91652. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91653. * @param radius The radius of the hemisphere to emit from
  91654. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91655. * @returns the emitter
  91656. */
  91657. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91658. /**
  91659. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91660. * @param radius The radius of the sphere to emit from
  91661. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91662. * @returns the emitter
  91663. */
  91664. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91665. /**
  91666. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91667. * @param radius The radius of the sphere to emit from
  91668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91670. * @returns the emitter
  91671. */
  91672. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91673. /**
  91674. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91675. * @param radius The radius of the emission cylinder
  91676. * @param height The height of the emission cylinder
  91677. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91678. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91679. * @returns the emitter
  91680. */
  91681. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91682. /**
  91683. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91684. * @param radius The radius of the cylinder to emit from
  91685. * @param height The height of the emission cylinder
  91686. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91689. * @returns the emitter
  91690. */
  91691. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91692. /**
  91693. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91694. * @param radius The radius of the cone to emit from
  91695. * @param angle The base angle of the cone
  91696. * @returns the emitter
  91697. */
  91698. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91699. /**
  91700. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91703. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91704. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91705. * @returns the emitter
  91706. */
  91707. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91708. /**
  91709. * Get hosting scene
  91710. * @returns the scene
  91711. */
  91712. getScene(): Scene;
  91713. }
  91714. }
  91715. declare module BABYLON {
  91716. /**
  91717. * Creates an instance based on a source mesh.
  91718. */
  91719. export class InstancedMesh extends AbstractMesh {
  91720. private _sourceMesh;
  91721. private _currentLOD;
  91722. /** @hidden */
  91723. _indexInSourceMeshInstanceArray: number;
  91724. constructor(name: string, source: Mesh);
  91725. /**
  91726. * Returns the string "InstancedMesh".
  91727. */
  91728. getClassName(): string;
  91729. /** Gets the list of lights affecting that mesh */
  91730. get lightSources(): Light[];
  91731. _resyncLightSources(): void;
  91732. _resyncLightSource(light: Light): void;
  91733. _removeLightSource(light: Light, dispose: boolean): void;
  91734. /**
  91735. * If the source mesh receives shadows
  91736. */
  91737. get receiveShadows(): boolean;
  91738. /**
  91739. * The material of the source mesh
  91740. */
  91741. get material(): Nullable<Material>;
  91742. /**
  91743. * Visibility of the source mesh
  91744. */
  91745. get visibility(): number;
  91746. /**
  91747. * Skeleton of the source mesh
  91748. */
  91749. get skeleton(): Nullable<Skeleton>;
  91750. /**
  91751. * Rendering ground id of the source mesh
  91752. */
  91753. get renderingGroupId(): number;
  91754. set renderingGroupId(value: number);
  91755. /**
  91756. * Returns the total number of vertices (integer).
  91757. */
  91758. getTotalVertices(): number;
  91759. /**
  91760. * Returns a positive integer : the total number of indices in this mesh geometry.
  91761. * @returns the numner of indices or zero if the mesh has no geometry.
  91762. */
  91763. getTotalIndices(): number;
  91764. /**
  91765. * The source mesh of the instance
  91766. */
  91767. get sourceMesh(): Mesh;
  91768. /**
  91769. * Is this node ready to be used/rendered
  91770. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91771. * @return {boolean} is it ready
  91772. */
  91773. isReady(completeCheck?: boolean): boolean;
  91774. /**
  91775. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91776. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91777. * @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.
  91778. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91779. */
  91780. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91781. /**
  91782. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91783. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91784. * The `data` are either a numeric array either a Float32Array.
  91785. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91786. * 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).
  91787. * Note that a new underlying VertexBuffer object is created each call.
  91788. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91789. *
  91790. * Possible `kind` values :
  91791. * - VertexBuffer.PositionKind
  91792. * - VertexBuffer.UVKind
  91793. * - VertexBuffer.UV2Kind
  91794. * - VertexBuffer.UV3Kind
  91795. * - VertexBuffer.UV4Kind
  91796. * - VertexBuffer.UV5Kind
  91797. * - VertexBuffer.UV6Kind
  91798. * - VertexBuffer.ColorKind
  91799. * - VertexBuffer.MatricesIndicesKind
  91800. * - VertexBuffer.MatricesIndicesExtraKind
  91801. * - VertexBuffer.MatricesWeightsKind
  91802. * - VertexBuffer.MatricesWeightsExtraKind
  91803. *
  91804. * Returns the Mesh.
  91805. */
  91806. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91807. /**
  91808. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91809. * If the mesh has no geometry, it is simply returned as it is.
  91810. * The `data` are either a numeric array either a Float32Array.
  91811. * No new underlying VertexBuffer object is created.
  91812. * 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.
  91813. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91814. *
  91815. * Possible `kind` values :
  91816. * - VertexBuffer.PositionKind
  91817. * - VertexBuffer.UVKind
  91818. * - VertexBuffer.UV2Kind
  91819. * - VertexBuffer.UV3Kind
  91820. * - VertexBuffer.UV4Kind
  91821. * - VertexBuffer.UV5Kind
  91822. * - VertexBuffer.UV6Kind
  91823. * - VertexBuffer.ColorKind
  91824. * - VertexBuffer.MatricesIndicesKind
  91825. * - VertexBuffer.MatricesIndicesExtraKind
  91826. * - VertexBuffer.MatricesWeightsKind
  91827. * - VertexBuffer.MatricesWeightsExtraKind
  91828. *
  91829. * Returns the Mesh.
  91830. */
  91831. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91832. /**
  91833. * Sets the mesh indices.
  91834. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91835. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91836. * This method creates a new index buffer each call.
  91837. * Returns the Mesh.
  91838. */
  91839. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91840. /**
  91841. * Boolean : True if the mesh owns the requested kind of data.
  91842. */
  91843. isVerticesDataPresent(kind: string): boolean;
  91844. /**
  91845. * Returns an array of indices (IndicesArray).
  91846. */
  91847. getIndices(): Nullable<IndicesArray>;
  91848. get _positions(): Nullable<Vector3[]>;
  91849. /**
  91850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91851. * This means the mesh underlying bounding box and sphere are recomputed.
  91852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91853. * @returns the current mesh
  91854. */
  91855. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91856. /** @hidden */
  91857. _preActivate(): InstancedMesh;
  91858. /** @hidden */
  91859. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91860. /** @hidden */
  91861. _postActivate(): void;
  91862. getWorldMatrix(): Matrix;
  91863. get isAnInstance(): boolean;
  91864. /**
  91865. * Returns the current associated LOD AbstractMesh.
  91866. */
  91867. getLOD(camera: Camera): AbstractMesh;
  91868. /** @hidden */
  91869. _syncSubMeshes(): InstancedMesh;
  91870. /** @hidden */
  91871. _generatePointsArray(): boolean;
  91872. /**
  91873. * Creates a new InstancedMesh from the current mesh.
  91874. * - name (string) : the cloned mesh name
  91875. * - newParent (optional Node) : the optional Node to parent the clone to.
  91876. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91877. *
  91878. * Returns the clone.
  91879. */
  91880. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91881. /**
  91882. * Disposes the InstancedMesh.
  91883. * Returns nothing.
  91884. */
  91885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91886. }
  91887. interface Mesh {
  91888. /**
  91889. * Register a custom buffer that will be instanced
  91890. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91891. * @param kind defines the buffer kind
  91892. * @param stride defines the stride in floats
  91893. */
  91894. registerInstancedBuffer(kind: string, stride: number): void;
  91895. /** @hidden */
  91896. _userInstancedBuffersStorage: {
  91897. data: {
  91898. [key: string]: Float32Array;
  91899. };
  91900. sizes: {
  91901. [key: string]: number;
  91902. };
  91903. vertexBuffers: {
  91904. [key: string]: Nullable<VertexBuffer>;
  91905. };
  91906. strides: {
  91907. [key: string]: number;
  91908. };
  91909. };
  91910. }
  91911. interface AbstractMesh {
  91912. /**
  91913. * Object used to store instanced buffers defined by user
  91914. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91915. */
  91916. instancedBuffers: {
  91917. [key: string]: any;
  91918. };
  91919. }
  91920. }
  91921. declare module BABYLON {
  91922. /**
  91923. * Defines the options associated with the creation of a shader material.
  91924. */
  91925. export interface IShaderMaterialOptions {
  91926. /**
  91927. * Does the material work in alpha blend mode
  91928. */
  91929. needAlphaBlending: boolean;
  91930. /**
  91931. * Does the material work in alpha test mode
  91932. */
  91933. needAlphaTesting: boolean;
  91934. /**
  91935. * The list of attribute names used in the shader
  91936. */
  91937. attributes: string[];
  91938. /**
  91939. * The list of unifrom names used in the shader
  91940. */
  91941. uniforms: string[];
  91942. /**
  91943. * The list of UBO names used in the shader
  91944. */
  91945. uniformBuffers: string[];
  91946. /**
  91947. * The list of sampler names used in the shader
  91948. */
  91949. samplers: string[];
  91950. /**
  91951. * The list of defines used in the shader
  91952. */
  91953. defines: string[];
  91954. }
  91955. /**
  91956. * 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.
  91957. *
  91958. * This returned material effects how the mesh will look based on the code in the shaders.
  91959. *
  91960. * @see http://doc.babylonjs.com/how_to/shader_material
  91961. */
  91962. export class ShaderMaterial extends Material {
  91963. private _shaderPath;
  91964. private _options;
  91965. private _textures;
  91966. private _textureArrays;
  91967. private _floats;
  91968. private _ints;
  91969. private _floatsArrays;
  91970. private _colors3;
  91971. private _colors3Arrays;
  91972. private _colors4;
  91973. private _colors4Arrays;
  91974. private _vectors2;
  91975. private _vectors3;
  91976. private _vectors4;
  91977. private _matrices;
  91978. private _matrixArrays;
  91979. private _matrices3x3;
  91980. private _matrices2x2;
  91981. private _vectors2Arrays;
  91982. private _vectors3Arrays;
  91983. private _vectors4Arrays;
  91984. private _cachedWorldViewMatrix;
  91985. private _cachedWorldViewProjectionMatrix;
  91986. private _renderId;
  91987. private _multiview;
  91988. /**
  91989. * Instantiate a new shader material.
  91990. * 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.
  91991. * This returned material effects how the mesh will look based on the code in the shaders.
  91992. * @see http://doc.babylonjs.com/how_to/shader_material
  91993. * @param name Define the name of the material in the scene
  91994. * @param scene Define the scene the material belongs to
  91995. * @param shaderPath Defines the route to the shader code in one of three ways:
  91996. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91997. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91998. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91999. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  92000. * @param options Define the options used to create the shader
  92001. */
  92002. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  92003. /**
  92004. * Gets the shader path used to define the shader code
  92005. * It can be modified to trigger a new compilation
  92006. */
  92007. get shaderPath(): any;
  92008. /**
  92009. * Sets the shader path used to define the shader code
  92010. * It can be modified to trigger a new compilation
  92011. */
  92012. set shaderPath(shaderPath: any);
  92013. /**
  92014. * Gets the options used to compile the shader.
  92015. * They can be modified to trigger a new compilation
  92016. */
  92017. get options(): IShaderMaterialOptions;
  92018. /**
  92019. * Gets the current class name of the material e.g. "ShaderMaterial"
  92020. * Mainly use in serialization.
  92021. * @returns the class name
  92022. */
  92023. getClassName(): string;
  92024. /**
  92025. * Specifies if the material will require alpha blending
  92026. * @returns a boolean specifying if alpha blending is needed
  92027. */
  92028. needAlphaBlending(): boolean;
  92029. /**
  92030. * Specifies if this material should be rendered in alpha test mode
  92031. * @returns a boolean specifying if an alpha test is needed.
  92032. */
  92033. needAlphaTesting(): boolean;
  92034. private _checkUniform;
  92035. /**
  92036. * Set a texture in the shader.
  92037. * @param name Define the name of the uniform samplers as defined in the shader
  92038. * @param texture Define the texture to bind to this sampler
  92039. * @return the material itself allowing "fluent" like uniform updates
  92040. */
  92041. setTexture(name: string, texture: Texture): ShaderMaterial;
  92042. /**
  92043. * Set a texture array in the shader.
  92044. * @param name Define the name of the uniform sampler array as defined in the shader
  92045. * @param textures Define the list of textures to bind to this sampler
  92046. * @return the material itself allowing "fluent" like uniform updates
  92047. */
  92048. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  92049. /**
  92050. * Set a float in the shader.
  92051. * @param name Define the name of the uniform as defined in the shader
  92052. * @param value Define the value to give to the uniform
  92053. * @return the material itself allowing "fluent" like uniform updates
  92054. */
  92055. setFloat(name: string, value: number): ShaderMaterial;
  92056. /**
  92057. * Set a int in the shader.
  92058. * @param name Define the name of the uniform as defined in the shader
  92059. * @param value Define the value to give to the uniform
  92060. * @return the material itself allowing "fluent" like uniform updates
  92061. */
  92062. setInt(name: string, value: number): ShaderMaterial;
  92063. /**
  92064. * Set an array of floats in the shader.
  92065. * @param name Define the name of the uniform as defined in the shader
  92066. * @param value Define the value to give to the uniform
  92067. * @return the material itself allowing "fluent" like uniform updates
  92068. */
  92069. setFloats(name: string, value: number[]): ShaderMaterial;
  92070. /**
  92071. * Set a vec3 in the shader from a Color3.
  92072. * @param name Define the name of the uniform as defined in the shader
  92073. * @param value Define the value to give to the uniform
  92074. * @return the material itself allowing "fluent" like uniform updates
  92075. */
  92076. setColor3(name: string, value: Color3): ShaderMaterial;
  92077. /**
  92078. * Set a vec3 array in the shader from a Color3 array.
  92079. * @param name Define the name of the uniform as defined in the shader
  92080. * @param value Define the value to give to the uniform
  92081. * @return the material itself allowing "fluent" like uniform updates
  92082. */
  92083. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92084. /**
  92085. * Set a vec4 in the shader from a Color4.
  92086. * @param name Define the name of the uniform as defined in the shader
  92087. * @param value Define the value to give to the uniform
  92088. * @return the material itself allowing "fluent" like uniform updates
  92089. */
  92090. setColor4(name: string, value: Color4): ShaderMaterial;
  92091. /**
  92092. * Set a vec4 array in the shader from a Color4 array.
  92093. * @param name Define the name of the uniform as defined in the shader
  92094. * @param value Define the value to give to the uniform
  92095. * @return the material itself allowing "fluent" like uniform updates
  92096. */
  92097. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92098. /**
  92099. * Set a vec2 in the shader from a Vector2.
  92100. * @param name Define the name of the uniform as defined in the shader
  92101. * @param value Define the value to give to the uniform
  92102. * @return the material itself allowing "fluent" like uniform updates
  92103. */
  92104. setVector2(name: string, value: Vector2): ShaderMaterial;
  92105. /**
  92106. * Set a vec3 in the shader from a Vector3.
  92107. * @param name Define the name of the uniform as defined in the shader
  92108. * @param value Define the value to give to the uniform
  92109. * @return the material itself allowing "fluent" like uniform updates
  92110. */
  92111. setVector3(name: string, value: Vector3): ShaderMaterial;
  92112. /**
  92113. * Set a vec4 in the shader from a Vector4.
  92114. * @param name Define the name of the uniform as defined in the shader
  92115. * @param value Define the value to give to the uniform
  92116. * @return the material itself allowing "fluent" like uniform updates
  92117. */
  92118. setVector4(name: string, value: Vector4): ShaderMaterial;
  92119. /**
  92120. * Set a mat4 in the shader from a Matrix.
  92121. * @param name Define the name of the uniform as defined in the shader
  92122. * @param value Define the value to give to the uniform
  92123. * @return the material itself allowing "fluent" like uniform updates
  92124. */
  92125. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92126. /**
  92127. * Set a float32Array in the shader from a matrix array.
  92128. * @param name Define the name of the uniform as defined in the shader
  92129. * @param value Define the value to give to the uniform
  92130. * @return the material itself allowing "fluent" like uniform updates
  92131. */
  92132. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92133. /**
  92134. * Set a mat3 in the shader from a Float32Array.
  92135. * @param name Define the name of the uniform as defined in the shader
  92136. * @param value Define the value to give to the uniform
  92137. * @return the material itself allowing "fluent" like uniform updates
  92138. */
  92139. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92140. /**
  92141. * Set a mat2 in the shader from a Float32Array.
  92142. * @param name Define the name of the uniform as defined in the shader
  92143. * @param value Define the value to give to the uniform
  92144. * @return the material itself allowing "fluent" like uniform updates
  92145. */
  92146. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92147. /**
  92148. * Set a vec2 array in the shader from a number array.
  92149. * @param name Define the name of the uniform as defined in the shader
  92150. * @param value Define the value to give to the uniform
  92151. * @return the material itself allowing "fluent" like uniform updates
  92152. */
  92153. setArray2(name: string, value: number[]): ShaderMaterial;
  92154. /**
  92155. * Set a vec3 array in the shader from a number array.
  92156. * @param name Define the name of the uniform as defined in the shader
  92157. * @param value Define the value to give to the uniform
  92158. * @return the material itself allowing "fluent" like uniform updates
  92159. */
  92160. setArray3(name: string, value: number[]): ShaderMaterial;
  92161. /**
  92162. * Set a vec4 array in the shader from a number array.
  92163. * @param name Define the name of the uniform as defined in the shader
  92164. * @param value Define the value to give to the uniform
  92165. * @return the material itself allowing "fluent" like uniform updates
  92166. */
  92167. setArray4(name: string, value: number[]): ShaderMaterial;
  92168. private _checkCache;
  92169. /**
  92170. * Specifies that the submesh is ready to be used
  92171. * @param mesh defines the mesh to check
  92172. * @param subMesh defines which submesh to check
  92173. * @param useInstances specifies that instances should be used
  92174. * @returns a boolean indicating that the submesh is ready or not
  92175. */
  92176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92177. /**
  92178. * Checks if the material is ready to render the requested mesh
  92179. * @param mesh Define the mesh to render
  92180. * @param useInstances Define whether or not the material is used with instances
  92181. * @returns true if ready, otherwise false
  92182. */
  92183. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92184. /**
  92185. * Binds the world matrix to the material
  92186. * @param world defines the world transformation matrix
  92187. */
  92188. bindOnlyWorldMatrix(world: Matrix): void;
  92189. /**
  92190. * Binds the material to the mesh
  92191. * @param world defines the world transformation matrix
  92192. * @param mesh defines the mesh to bind the material to
  92193. */
  92194. bind(world: Matrix, mesh?: Mesh): void;
  92195. /**
  92196. * Gets the active textures from the material
  92197. * @returns an array of textures
  92198. */
  92199. getActiveTextures(): BaseTexture[];
  92200. /**
  92201. * Specifies if the material uses a texture
  92202. * @param texture defines the texture to check against the material
  92203. * @returns a boolean specifying if the material uses the texture
  92204. */
  92205. hasTexture(texture: BaseTexture): boolean;
  92206. /**
  92207. * Makes a duplicate of the material, and gives it a new name
  92208. * @param name defines the new name for the duplicated material
  92209. * @returns the cloned material
  92210. */
  92211. clone(name: string): ShaderMaterial;
  92212. /**
  92213. * Disposes the material
  92214. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92215. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92216. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92217. */
  92218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92219. /**
  92220. * Serializes this material in a JSON representation
  92221. * @returns the serialized material object
  92222. */
  92223. serialize(): any;
  92224. /**
  92225. * Creates a shader material from parsed shader material data
  92226. * @param source defines the JSON represnetation of the material
  92227. * @param scene defines the hosting scene
  92228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92229. * @returns a new material
  92230. */
  92231. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  92232. }
  92233. }
  92234. declare module BABYLON {
  92235. /** @hidden */
  92236. export var colorPixelShader: {
  92237. name: string;
  92238. shader: string;
  92239. };
  92240. }
  92241. declare module BABYLON {
  92242. /** @hidden */
  92243. export var colorVertexShader: {
  92244. name: string;
  92245. shader: string;
  92246. };
  92247. }
  92248. declare module BABYLON {
  92249. /**
  92250. * Line mesh
  92251. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  92252. */
  92253. export class LinesMesh extends Mesh {
  92254. /**
  92255. * If vertex color should be applied to the mesh
  92256. */
  92257. readonly useVertexColor?: boolean | undefined;
  92258. /**
  92259. * If vertex alpha should be applied to the mesh
  92260. */
  92261. readonly useVertexAlpha?: boolean | undefined;
  92262. /**
  92263. * Color of the line (Default: White)
  92264. */
  92265. color: Color3;
  92266. /**
  92267. * Alpha of the line (Default: 1)
  92268. */
  92269. alpha: number;
  92270. /**
  92271. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92272. * This margin is expressed in world space coordinates, so its value may vary.
  92273. * Default value is 0.1
  92274. */
  92275. intersectionThreshold: number;
  92276. private _colorShader;
  92277. private color4;
  92278. /**
  92279. * Creates a new LinesMesh
  92280. * @param name defines the name
  92281. * @param scene defines the hosting scene
  92282. * @param parent defines the parent mesh if any
  92283. * @param source defines the optional source LinesMesh used to clone data from
  92284. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92285. * When false, achieved by calling a clone(), also passing False.
  92286. * This will make creation of children, recursive.
  92287. * @param useVertexColor defines if this LinesMesh supports vertex color
  92288. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  92289. */
  92290. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  92291. /**
  92292. * If vertex color should be applied to the mesh
  92293. */
  92294. useVertexColor?: boolean | undefined,
  92295. /**
  92296. * If vertex alpha should be applied to the mesh
  92297. */
  92298. useVertexAlpha?: boolean | undefined);
  92299. private _addClipPlaneDefine;
  92300. private _removeClipPlaneDefine;
  92301. isReady(): boolean;
  92302. /**
  92303. * Returns the string "LineMesh"
  92304. */
  92305. getClassName(): string;
  92306. /**
  92307. * @hidden
  92308. */
  92309. get material(): Material;
  92310. /**
  92311. * @hidden
  92312. */
  92313. set material(value: Material);
  92314. /**
  92315. * @hidden
  92316. */
  92317. get checkCollisions(): boolean;
  92318. /** @hidden */
  92319. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92320. /** @hidden */
  92321. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92322. /**
  92323. * Disposes of the line mesh
  92324. * @param doNotRecurse If children should be disposed
  92325. */
  92326. dispose(doNotRecurse?: boolean): void;
  92327. /**
  92328. * Returns a new LineMesh object cloned from the current one.
  92329. */
  92330. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  92331. /**
  92332. * Creates a new InstancedLinesMesh object from the mesh model.
  92333. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92334. * @param name defines the name of the new instance
  92335. * @returns a new InstancedLinesMesh
  92336. */
  92337. createInstance(name: string): InstancedLinesMesh;
  92338. }
  92339. /**
  92340. * Creates an instance based on a source LinesMesh
  92341. */
  92342. export class InstancedLinesMesh extends InstancedMesh {
  92343. /**
  92344. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92345. * This margin is expressed in world space coordinates, so its value may vary.
  92346. * Initilized with the intersectionThreshold value of the source LinesMesh
  92347. */
  92348. intersectionThreshold: number;
  92349. constructor(name: string, source: LinesMesh);
  92350. /**
  92351. * Returns the string "InstancedLinesMesh".
  92352. */
  92353. getClassName(): string;
  92354. }
  92355. }
  92356. declare module BABYLON {
  92357. /** @hidden */
  92358. export var linePixelShader: {
  92359. name: string;
  92360. shader: string;
  92361. };
  92362. }
  92363. declare module BABYLON {
  92364. /** @hidden */
  92365. export var lineVertexShader: {
  92366. name: string;
  92367. shader: string;
  92368. };
  92369. }
  92370. declare module BABYLON {
  92371. interface AbstractMesh {
  92372. /**
  92373. * Gets the edgesRenderer associated with the mesh
  92374. */
  92375. edgesRenderer: Nullable<EdgesRenderer>;
  92376. }
  92377. interface LinesMesh {
  92378. /**
  92379. * Enables the edge rendering mode on the mesh.
  92380. * This mode makes the mesh edges visible
  92381. * @param epsilon defines the maximal distance between two angles to detect a face
  92382. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92383. * @returns the currentAbstractMesh
  92384. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92385. */
  92386. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92387. }
  92388. interface InstancedLinesMesh {
  92389. /**
  92390. * Enables the edge rendering mode on the mesh.
  92391. * This mode makes the mesh edges visible
  92392. * @param epsilon defines the maximal distance between two angles to detect a face
  92393. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92394. * @returns the current InstancedLinesMesh
  92395. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92396. */
  92397. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92398. }
  92399. /**
  92400. * Defines the minimum contract an Edges renderer should follow.
  92401. */
  92402. export interface IEdgesRenderer extends IDisposable {
  92403. /**
  92404. * Gets or sets a boolean indicating if the edgesRenderer is active
  92405. */
  92406. isEnabled: boolean;
  92407. /**
  92408. * Renders the edges of the attached mesh,
  92409. */
  92410. render(): void;
  92411. /**
  92412. * Checks wether or not the edges renderer is ready to render.
  92413. * @return true if ready, otherwise false.
  92414. */
  92415. isReady(): boolean;
  92416. }
  92417. /**
  92418. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92419. */
  92420. export class EdgesRenderer implements IEdgesRenderer {
  92421. /**
  92422. * Define the size of the edges with an orthographic camera
  92423. */
  92424. edgesWidthScalerForOrthographic: number;
  92425. /**
  92426. * Define the size of the edges with a perspective camera
  92427. */
  92428. edgesWidthScalerForPerspective: number;
  92429. protected _source: AbstractMesh;
  92430. protected _linesPositions: number[];
  92431. protected _linesNormals: number[];
  92432. protected _linesIndices: number[];
  92433. protected _epsilon: number;
  92434. protected _indicesCount: number;
  92435. protected _lineShader: ShaderMaterial;
  92436. protected _ib: DataBuffer;
  92437. protected _buffers: {
  92438. [key: string]: Nullable<VertexBuffer>;
  92439. };
  92440. protected _checkVerticesInsteadOfIndices: boolean;
  92441. private _meshRebuildObserver;
  92442. private _meshDisposeObserver;
  92443. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92444. isEnabled: boolean;
  92445. /**
  92446. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92447. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92448. * @param source Mesh used to create edges
  92449. * @param epsilon sum of angles in adjacency to check for edge
  92450. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92451. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92452. */
  92453. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92454. protected _prepareRessources(): void;
  92455. /** @hidden */
  92456. _rebuild(): void;
  92457. /**
  92458. * Releases the required resources for the edges renderer
  92459. */
  92460. dispose(): void;
  92461. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92462. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92463. /**
  92464. * Checks if the pair of p0 and p1 is en edge
  92465. * @param faceIndex
  92466. * @param edge
  92467. * @param faceNormals
  92468. * @param p0
  92469. * @param p1
  92470. * @private
  92471. */
  92472. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92473. /**
  92474. * push line into the position, normal and index buffer
  92475. * @protected
  92476. */
  92477. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92478. /**
  92479. * Generates lines edges from adjacencjes
  92480. * @private
  92481. */
  92482. _generateEdgesLines(): void;
  92483. /**
  92484. * Checks wether or not the edges renderer is ready to render.
  92485. * @return true if ready, otherwise false.
  92486. */
  92487. isReady(): boolean;
  92488. /**
  92489. * Renders the edges of the attached mesh,
  92490. */
  92491. render(): void;
  92492. }
  92493. /**
  92494. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92495. */
  92496. export class LineEdgesRenderer extends EdgesRenderer {
  92497. /**
  92498. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92499. * @param source LineMesh used to generate edges
  92500. * @param epsilon not important (specified angle for edge detection)
  92501. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92502. */
  92503. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92504. /**
  92505. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92506. */
  92507. _generateEdgesLines(): void;
  92508. }
  92509. }
  92510. declare module BABYLON {
  92511. /**
  92512. * This represents the object necessary to create a rendering group.
  92513. * This is exclusively used and created by the rendering manager.
  92514. * To modify the behavior, you use the available helpers in your scene or meshes.
  92515. * @hidden
  92516. */
  92517. export class RenderingGroup {
  92518. index: number;
  92519. private static _zeroVector;
  92520. private _scene;
  92521. private _opaqueSubMeshes;
  92522. private _transparentSubMeshes;
  92523. private _alphaTestSubMeshes;
  92524. private _depthOnlySubMeshes;
  92525. private _particleSystems;
  92526. private _spriteManagers;
  92527. private _opaqueSortCompareFn;
  92528. private _alphaTestSortCompareFn;
  92529. private _transparentSortCompareFn;
  92530. private _renderOpaque;
  92531. private _renderAlphaTest;
  92532. private _renderTransparent;
  92533. /** @hidden */
  92534. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92535. onBeforeTransparentRendering: () => void;
  92536. /**
  92537. * Set the opaque sort comparison function.
  92538. * If null the sub meshes will be render in the order they were created
  92539. */
  92540. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92541. /**
  92542. * Set the alpha test sort comparison function.
  92543. * If null the sub meshes will be render in the order they were created
  92544. */
  92545. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92546. /**
  92547. * Set the transparent sort comparison function.
  92548. * If null the sub meshes will be render in the order they were created
  92549. */
  92550. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92551. /**
  92552. * Creates a new rendering group.
  92553. * @param index The rendering group index
  92554. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92555. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92556. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92557. */
  92558. 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>);
  92559. /**
  92560. * Render all the sub meshes contained in the group.
  92561. * @param customRenderFunction Used to override the default render behaviour of the group.
  92562. * @returns true if rendered some submeshes.
  92563. */
  92564. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92565. /**
  92566. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92567. * @param subMeshes The submeshes to render
  92568. */
  92569. private renderOpaqueSorted;
  92570. /**
  92571. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92572. * @param subMeshes The submeshes to render
  92573. */
  92574. private renderAlphaTestSorted;
  92575. /**
  92576. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92577. * @param subMeshes The submeshes to render
  92578. */
  92579. private renderTransparentSorted;
  92580. /**
  92581. * Renders the submeshes in a specified order.
  92582. * @param subMeshes The submeshes to sort before render
  92583. * @param sortCompareFn The comparison function use to sort
  92584. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92585. * @param transparent Specifies to activate blending if true
  92586. */
  92587. private static renderSorted;
  92588. /**
  92589. * Renders the submeshes in the order they were dispatched (no sort applied).
  92590. * @param subMeshes The submeshes to render
  92591. */
  92592. private static renderUnsorted;
  92593. /**
  92594. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92595. * are rendered back to front if in the same alpha index.
  92596. *
  92597. * @param a The first submesh
  92598. * @param b The second submesh
  92599. * @returns The result of the comparison
  92600. */
  92601. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92602. /**
  92603. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92604. * are rendered back to front.
  92605. *
  92606. * @param a The first submesh
  92607. * @param b The second submesh
  92608. * @returns The result of the comparison
  92609. */
  92610. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92611. /**
  92612. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92613. * are rendered front to back (prevent overdraw).
  92614. *
  92615. * @param a The first submesh
  92616. * @param b The second submesh
  92617. * @returns The result of the comparison
  92618. */
  92619. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92620. /**
  92621. * Resets the different lists of submeshes to prepare a new frame.
  92622. */
  92623. prepare(): void;
  92624. dispose(): void;
  92625. /**
  92626. * Inserts the submesh in its correct queue depending on its material.
  92627. * @param subMesh The submesh to dispatch
  92628. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92629. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92630. */
  92631. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92632. dispatchSprites(spriteManager: ISpriteManager): void;
  92633. dispatchParticles(particleSystem: IParticleSystem): void;
  92634. private _renderParticles;
  92635. private _renderSprites;
  92636. }
  92637. }
  92638. declare module BABYLON {
  92639. /**
  92640. * Interface describing the different options available in the rendering manager
  92641. * regarding Auto Clear between groups.
  92642. */
  92643. export interface IRenderingManagerAutoClearSetup {
  92644. /**
  92645. * Defines whether or not autoclear is enable.
  92646. */
  92647. autoClear: boolean;
  92648. /**
  92649. * Defines whether or not to autoclear the depth buffer.
  92650. */
  92651. depth: boolean;
  92652. /**
  92653. * Defines whether or not to autoclear the stencil buffer.
  92654. */
  92655. stencil: boolean;
  92656. }
  92657. /**
  92658. * This class is used by the onRenderingGroupObservable
  92659. */
  92660. export class RenderingGroupInfo {
  92661. /**
  92662. * The Scene that being rendered
  92663. */
  92664. scene: Scene;
  92665. /**
  92666. * The camera currently used for the rendering pass
  92667. */
  92668. camera: Nullable<Camera>;
  92669. /**
  92670. * The ID of the renderingGroup being processed
  92671. */
  92672. renderingGroupId: number;
  92673. }
  92674. /**
  92675. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92676. * It is enable to manage the different groups as well as the different necessary sort functions.
  92677. * This should not be used directly aside of the few static configurations
  92678. */
  92679. export class RenderingManager {
  92680. /**
  92681. * The max id used for rendering groups (not included)
  92682. */
  92683. static MAX_RENDERINGGROUPS: number;
  92684. /**
  92685. * The min id used for rendering groups (included)
  92686. */
  92687. static MIN_RENDERINGGROUPS: number;
  92688. /**
  92689. * Used to globally prevent autoclearing scenes.
  92690. */
  92691. static AUTOCLEAR: boolean;
  92692. /**
  92693. * @hidden
  92694. */
  92695. _useSceneAutoClearSetup: boolean;
  92696. private _scene;
  92697. private _renderingGroups;
  92698. private _depthStencilBufferAlreadyCleaned;
  92699. private _autoClearDepthStencil;
  92700. private _customOpaqueSortCompareFn;
  92701. private _customAlphaTestSortCompareFn;
  92702. private _customTransparentSortCompareFn;
  92703. private _renderingGroupInfo;
  92704. /**
  92705. * Instantiates a new rendering group for a particular scene
  92706. * @param scene Defines the scene the groups belongs to
  92707. */
  92708. constructor(scene: Scene);
  92709. private _clearDepthStencilBuffer;
  92710. /**
  92711. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92712. * @hidden
  92713. */
  92714. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92715. /**
  92716. * Resets the different information of the group to prepare a new frame
  92717. * @hidden
  92718. */
  92719. reset(): void;
  92720. /**
  92721. * Dispose and release the group and its associated resources.
  92722. * @hidden
  92723. */
  92724. dispose(): void;
  92725. /**
  92726. * Clear the info related to rendering groups preventing retention points during dispose.
  92727. */
  92728. freeRenderingGroups(): void;
  92729. private _prepareRenderingGroup;
  92730. /**
  92731. * Add a sprite manager to the rendering manager in order to render it this frame.
  92732. * @param spriteManager Define the sprite manager to render
  92733. */
  92734. dispatchSprites(spriteManager: ISpriteManager): void;
  92735. /**
  92736. * Add a particle system to the rendering manager in order to render it this frame.
  92737. * @param particleSystem Define the particle system to render
  92738. */
  92739. dispatchParticles(particleSystem: IParticleSystem): void;
  92740. /**
  92741. * Add a submesh to the manager in order to render it this frame
  92742. * @param subMesh The submesh to dispatch
  92743. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92744. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92745. */
  92746. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92747. /**
  92748. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92749. * This allowed control for front to back rendering or reversly depending of the special needs.
  92750. *
  92751. * @param renderingGroupId The rendering group id corresponding to its index
  92752. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92753. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92754. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92755. */
  92756. 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;
  92757. /**
  92758. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92759. *
  92760. * @param renderingGroupId The rendering group id corresponding to its index
  92761. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92762. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92763. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92764. */
  92765. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92766. /**
  92767. * Gets the current auto clear configuration for one rendering group of the rendering
  92768. * manager.
  92769. * @param index the rendering group index to get the information for
  92770. * @returns The auto clear setup for the requested rendering group
  92771. */
  92772. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92773. }
  92774. }
  92775. declare module BABYLON {
  92776. /**
  92777. * This Helps creating a texture that will be created from a camera in your scene.
  92778. * It is basically a dynamic texture that could be used to create special effects for instance.
  92779. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  92780. */
  92781. export class RenderTargetTexture extends Texture {
  92782. isCube: boolean;
  92783. /**
  92784. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  92785. */
  92786. static readonly REFRESHRATE_RENDER_ONCE: number;
  92787. /**
  92788. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  92789. */
  92790. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  92791. /**
  92792. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  92793. * the central point of your effect and can save a lot of performances.
  92794. */
  92795. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  92796. /**
  92797. * Use this predicate to dynamically define the list of mesh you want to render.
  92798. * If set, the renderList property will be overwritten.
  92799. */
  92800. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  92801. private _renderList;
  92802. /**
  92803. * Use this list to define the list of mesh you want to render.
  92804. */
  92805. get renderList(): Nullable<Array<AbstractMesh>>;
  92806. set renderList(value: Nullable<Array<AbstractMesh>>);
  92807. /**
  92808. * Use this function to overload the renderList array at rendering time.
  92809. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  92810. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  92811. * the cube (if the RTT is a cube, else layerOrFace=0).
  92812. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  92813. */
  92814. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  92815. private _hookArray;
  92816. /**
  92817. * Define if particles should be rendered in your texture.
  92818. */
  92819. renderParticles: boolean;
  92820. /**
  92821. * Define if sprites should be rendered in your texture.
  92822. */
  92823. renderSprites: boolean;
  92824. /**
  92825. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  92826. */
  92827. coordinatesMode: number;
  92828. /**
  92829. * Define the camera used to render the texture.
  92830. */
  92831. activeCamera: Nullable<Camera>;
  92832. /**
  92833. * Override the render function of the texture with your own one.
  92834. */
  92835. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  92836. /**
  92837. * Define if camera post processes should be use while rendering the texture.
  92838. */
  92839. useCameraPostProcesses: boolean;
  92840. /**
  92841. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  92842. */
  92843. ignoreCameraViewport: boolean;
  92844. private _postProcessManager;
  92845. private _postProcesses;
  92846. private _resizeObserver;
  92847. /**
  92848. * An event triggered when the texture is unbind.
  92849. */
  92850. onBeforeBindObservable: Observable<RenderTargetTexture>;
  92851. /**
  92852. * An event triggered when the texture is unbind.
  92853. */
  92854. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  92855. private _onAfterUnbindObserver;
  92856. /**
  92857. * Set a after unbind callback in the texture.
  92858. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  92859. */
  92860. set onAfterUnbind(callback: () => void);
  92861. /**
  92862. * An event triggered before rendering the texture
  92863. */
  92864. onBeforeRenderObservable: Observable<number>;
  92865. private _onBeforeRenderObserver;
  92866. /**
  92867. * Set a before render callback in the texture.
  92868. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  92869. */
  92870. set onBeforeRender(callback: (faceIndex: number) => void);
  92871. /**
  92872. * An event triggered after rendering the texture
  92873. */
  92874. onAfterRenderObservable: Observable<number>;
  92875. private _onAfterRenderObserver;
  92876. /**
  92877. * Set a after render callback in the texture.
  92878. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  92879. */
  92880. set onAfterRender(callback: (faceIndex: number) => void);
  92881. /**
  92882. * An event triggered after the texture clear
  92883. */
  92884. onClearObservable: Observable<Engine>;
  92885. private _onClearObserver;
  92886. /**
  92887. * Set a clear callback in the texture.
  92888. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  92889. */
  92890. set onClear(callback: (Engine: Engine) => void);
  92891. /**
  92892. * An event triggered when the texture is resized.
  92893. */
  92894. onResizeObservable: Observable<RenderTargetTexture>;
  92895. /**
  92896. * Define the clear color of the Render Target if it should be different from the scene.
  92897. */
  92898. clearColor: Color4;
  92899. protected _size: number | {
  92900. width: number;
  92901. height: number;
  92902. layers?: number;
  92903. };
  92904. protected _initialSizeParameter: number | {
  92905. width: number;
  92906. height: number;
  92907. } | {
  92908. ratio: number;
  92909. };
  92910. protected _sizeRatio: Nullable<number>;
  92911. /** @hidden */
  92912. _generateMipMaps: boolean;
  92913. protected _renderingManager: RenderingManager;
  92914. /** @hidden */
  92915. _waitingRenderList: string[];
  92916. protected _doNotChangeAspectRatio: boolean;
  92917. protected _currentRefreshId: number;
  92918. protected _refreshRate: number;
  92919. protected _textureMatrix: Matrix;
  92920. protected _samples: number;
  92921. protected _renderTargetOptions: RenderTargetCreationOptions;
  92922. /**
  92923. * Gets render target creation options that were used.
  92924. */
  92925. get renderTargetOptions(): RenderTargetCreationOptions;
  92926. protected _engine: Engine;
  92927. protected _onRatioRescale(): void;
  92928. /**
  92929. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  92930. * It must define where the camera used to render the texture is set
  92931. */
  92932. boundingBoxPosition: Vector3;
  92933. private _boundingBoxSize;
  92934. /**
  92935. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  92936. * When defined, the cubemap will switch to local mode
  92937. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92938. * @example https://www.babylonjs-playground.com/#RNASML
  92939. */
  92940. set boundingBoxSize(value: Vector3);
  92941. get boundingBoxSize(): Vector3;
  92942. /**
  92943. * In case the RTT has been created with a depth texture, get the associated
  92944. * depth texture.
  92945. * Otherwise, return null.
  92946. */
  92947. get depthStencilTexture(): Nullable<InternalTexture>;
  92948. /**
  92949. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  92950. * or used a shadow, depth texture...
  92951. * @param name The friendly name of the texture
  92952. * @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)
  92953. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  92954. * @param generateMipMaps True if mip maps need to be generated after render.
  92955. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  92956. * @param type The type of the buffer in the RTT (int, half float, float...)
  92957. * @param isCube True if a cube texture needs to be created
  92958. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  92959. * @param generateDepthBuffer True to generate a depth buffer
  92960. * @param generateStencilBuffer True to generate a stencil buffer
  92961. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  92962. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  92963. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92964. */
  92965. constructor(name: string, size: number | {
  92966. width: number;
  92967. height: number;
  92968. layers?: number;
  92969. } | {
  92970. ratio: number;
  92971. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  92972. /**
  92973. * Creates a depth stencil texture.
  92974. * This is only available in WebGL 2 or with the depth texture extension available.
  92975. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  92976. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  92977. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  92978. */
  92979. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  92980. private _processSizeParameter;
  92981. /**
  92982. * Define the number of samples to use in case of MSAA.
  92983. * It defaults to one meaning no MSAA has been enabled.
  92984. */
  92985. get samples(): number;
  92986. set samples(value: number);
  92987. /**
  92988. * Resets the refresh counter of the texture and start bak from scratch.
  92989. * Could be useful to regenerate the texture if it is setup to render only once.
  92990. */
  92991. resetRefreshCounter(): void;
  92992. /**
  92993. * Define the refresh rate of the texture or the rendering frequency.
  92994. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92995. */
  92996. get refreshRate(): number;
  92997. set refreshRate(value: number);
  92998. /**
  92999. * Adds a post process to the render target rendering passes.
  93000. * @param postProcess define the post process to add
  93001. */
  93002. addPostProcess(postProcess: PostProcess): void;
  93003. /**
  93004. * Clear all the post processes attached to the render target
  93005. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93006. */
  93007. clearPostProcesses(dispose?: boolean): void;
  93008. /**
  93009. * Remove one of the post process from the list of attached post processes to the texture
  93010. * @param postProcess define the post process to remove from the list
  93011. */
  93012. removePostProcess(postProcess: PostProcess): void;
  93013. /** @hidden */
  93014. _shouldRender(): boolean;
  93015. /**
  93016. * Gets the actual render size of the texture.
  93017. * @returns the width of the render size
  93018. */
  93019. getRenderSize(): number;
  93020. /**
  93021. * Gets the actual render width of the texture.
  93022. * @returns the width of the render size
  93023. */
  93024. getRenderWidth(): number;
  93025. /**
  93026. * Gets the actual render height of the texture.
  93027. * @returns the height of the render size
  93028. */
  93029. getRenderHeight(): number;
  93030. /**
  93031. * Gets the actual number of layers of the texture.
  93032. * @returns the number of layers
  93033. */
  93034. getRenderLayers(): number;
  93035. /**
  93036. * Get if the texture can be rescaled or not.
  93037. */
  93038. get canRescale(): boolean;
  93039. /**
  93040. * Resize the texture using a ratio.
  93041. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93042. */
  93043. scale(ratio: number): void;
  93044. /**
  93045. * Get the texture reflection matrix used to rotate/transform the reflection.
  93046. * @returns the reflection matrix
  93047. */
  93048. getReflectionTextureMatrix(): Matrix;
  93049. /**
  93050. * Resize the texture to a new desired size.
  93051. * Be carrefull as it will recreate all the data in the new texture.
  93052. * @param size Define the new size. It can be:
  93053. * - a number for squared texture,
  93054. * - an object containing { width: number, height: number }
  93055. * - or an object containing a ratio { ratio: number }
  93056. */
  93057. resize(size: number | {
  93058. width: number;
  93059. height: number;
  93060. } | {
  93061. ratio: number;
  93062. }): void;
  93063. private _defaultRenderListPrepared;
  93064. /**
  93065. * Renders all the objects from the render list into the texture.
  93066. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93067. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93068. */
  93069. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93070. private _bestReflectionRenderTargetDimension;
  93071. private _prepareRenderingManager;
  93072. /**
  93073. * @hidden
  93074. * @param faceIndex face index to bind to if this is a cubetexture
  93075. * @param layer defines the index of the texture to bind in the array
  93076. */
  93077. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93078. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93079. private renderToTarget;
  93080. /**
  93081. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93082. * This allowed control for front to back rendering or reversly depending of the special needs.
  93083. *
  93084. * @param renderingGroupId The rendering group id corresponding to its index
  93085. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93086. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93087. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93088. */
  93089. 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;
  93090. /**
  93091. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93092. *
  93093. * @param renderingGroupId The rendering group id corresponding to its index
  93094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93095. */
  93096. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93097. /**
  93098. * Clones the texture.
  93099. * @returns the cloned texture
  93100. */
  93101. clone(): RenderTargetTexture;
  93102. /**
  93103. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93104. * @returns The JSON representation of the texture
  93105. */
  93106. serialize(): any;
  93107. /**
  93108. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93109. */
  93110. disposeFramebufferObjects(): void;
  93111. /**
  93112. * Dispose the texture and release its associated resources.
  93113. */
  93114. dispose(): void;
  93115. /** @hidden */
  93116. _rebuild(): void;
  93117. /**
  93118. * Clear the info related to rendering groups preventing retention point in material dispose.
  93119. */
  93120. freeRenderingGroups(): void;
  93121. /**
  93122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93123. * @returns the view count
  93124. */
  93125. getViewCount(): number;
  93126. }
  93127. }
  93128. declare module BABYLON {
  93129. /**
  93130. * Options for compiling materials.
  93131. */
  93132. export interface IMaterialCompilationOptions {
  93133. /**
  93134. * Defines whether clip planes are enabled.
  93135. */
  93136. clipPlane: boolean;
  93137. /**
  93138. * Defines whether instances are enabled.
  93139. */
  93140. useInstances: boolean;
  93141. }
  93142. /**
  93143. * Base class for the main features of a material in Babylon.js
  93144. */
  93145. export class Material implements IAnimatable {
  93146. /**
  93147. * Returns the triangle fill mode
  93148. */
  93149. static readonly TriangleFillMode: number;
  93150. /**
  93151. * Returns the wireframe mode
  93152. */
  93153. static readonly WireFrameFillMode: number;
  93154. /**
  93155. * Returns the point fill mode
  93156. */
  93157. static readonly PointFillMode: number;
  93158. /**
  93159. * Returns the point list draw mode
  93160. */
  93161. static readonly PointListDrawMode: number;
  93162. /**
  93163. * Returns the line list draw mode
  93164. */
  93165. static readonly LineListDrawMode: number;
  93166. /**
  93167. * Returns the line loop draw mode
  93168. */
  93169. static readonly LineLoopDrawMode: number;
  93170. /**
  93171. * Returns the line strip draw mode
  93172. */
  93173. static readonly LineStripDrawMode: number;
  93174. /**
  93175. * Returns the triangle strip draw mode
  93176. */
  93177. static readonly TriangleStripDrawMode: number;
  93178. /**
  93179. * Returns the triangle fan draw mode
  93180. */
  93181. static readonly TriangleFanDrawMode: number;
  93182. /**
  93183. * Stores the clock-wise side orientation
  93184. */
  93185. static readonly ClockWiseSideOrientation: number;
  93186. /**
  93187. * Stores the counter clock-wise side orientation
  93188. */
  93189. static readonly CounterClockWiseSideOrientation: number;
  93190. /**
  93191. * The dirty texture flag value
  93192. */
  93193. static readonly TextureDirtyFlag: number;
  93194. /**
  93195. * The dirty light flag value
  93196. */
  93197. static readonly LightDirtyFlag: number;
  93198. /**
  93199. * The dirty fresnel flag value
  93200. */
  93201. static readonly FresnelDirtyFlag: number;
  93202. /**
  93203. * The dirty attribute flag value
  93204. */
  93205. static readonly AttributesDirtyFlag: number;
  93206. /**
  93207. * The dirty misc flag value
  93208. */
  93209. static readonly MiscDirtyFlag: number;
  93210. /**
  93211. * The all dirty flag value
  93212. */
  93213. static readonly AllDirtyFlag: number;
  93214. /**
  93215. * The ID of the material
  93216. */
  93217. id: string;
  93218. /**
  93219. * Gets or sets the unique id of the material
  93220. */
  93221. uniqueId: number;
  93222. /**
  93223. * The name of the material
  93224. */
  93225. name: string;
  93226. /**
  93227. * Gets or sets user defined metadata
  93228. */
  93229. metadata: any;
  93230. /**
  93231. * For internal use only. Please do not use.
  93232. */
  93233. reservedDataStore: any;
  93234. /**
  93235. * Specifies if the ready state should be checked on each call
  93236. */
  93237. checkReadyOnEveryCall: boolean;
  93238. /**
  93239. * Specifies if the ready state should be checked once
  93240. */
  93241. checkReadyOnlyOnce: boolean;
  93242. /**
  93243. * The state of the material
  93244. */
  93245. state: string;
  93246. /**
  93247. * The alpha value of the material
  93248. */
  93249. protected _alpha: number;
  93250. /**
  93251. * List of inspectable custom properties (used by the Inspector)
  93252. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93253. */
  93254. inspectableCustomProperties: IInspectable[];
  93255. /**
  93256. * Sets the alpha value of the material
  93257. */
  93258. set alpha(value: number);
  93259. /**
  93260. * Gets the alpha value of the material
  93261. */
  93262. get alpha(): number;
  93263. /**
  93264. * Specifies if back face culling is enabled
  93265. */
  93266. protected _backFaceCulling: boolean;
  93267. /**
  93268. * Sets the back-face culling state
  93269. */
  93270. set backFaceCulling(value: boolean);
  93271. /**
  93272. * Gets the back-face culling state
  93273. */
  93274. get backFaceCulling(): boolean;
  93275. /**
  93276. * Stores the value for side orientation
  93277. */
  93278. sideOrientation: number;
  93279. /**
  93280. * Callback triggered when the material is compiled
  93281. */
  93282. onCompiled: Nullable<(effect: Effect) => void>;
  93283. /**
  93284. * Callback triggered when an error occurs
  93285. */
  93286. onError: Nullable<(effect: Effect, errors: string) => void>;
  93287. /**
  93288. * Callback triggered to get the render target textures
  93289. */
  93290. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  93291. /**
  93292. * Gets a boolean indicating that current material needs to register RTT
  93293. */
  93294. get hasRenderTargetTextures(): boolean;
  93295. /**
  93296. * Specifies if the material should be serialized
  93297. */
  93298. doNotSerialize: boolean;
  93299. /**
  93300. * @hidden
  93301. */
  93302. _storeEffectOnSubMeshes: boolean;
  93303. /**
  93304. * Stores the animations for the material
  93305. */
  93306. animations: Nullable<Array<Animation>>;
  93307. /**
  93308. * An event triggered when the material is disposed
  93309. */
  93310. onDisposeObservable: Observable<Material>;
  93311. /**
  93312. * An observer which watches for dispose events
  93313. */
  93314. private _onDisposeObserver;
  93315. private _onUnBindObservable;
  93316. /**
  93317. * Called during a dispose event
  93318. */
  93319. set onDispose(callback: () => void);
  93320. private _onBindObservable;
  93321. /**
  93322. * An event triggered when the material is bound
  93323. */
  93324. get onBindObservable(): Observable<AbstractMesh>;
  93325. /**
  93326. * An observer which watches for bind events
  93327. */
  93328. private _onBindObserver;
  93329. /**
  93330. * Called during a bind event
  93331. */
  93332. set onBind(callback: (Mesh: AbstractMesh) => void);
  93333. /**
  93334. * An event triggered when the material is unbound
  93335. */
  93336. get onUnBindObservable(): Observable<Material>;
  93337. /**
  93338. * Stores the value of the alpha mode
  93339. */
  93340. private _alphaMode;
  93341. /**
  93342. * Sets the value of the alpha mode.
  93343. *
  93344. * | Value | Type | Description |
  93345. * | --- | --- | --- |
  93346. * | 0 | ALPHA_DISABLE | |
  93347. * | 1 | ALPHA_ADD | |
  93348. * | 2 | ALPHA_COMBINE | |
  93349. * | 3 | ALPHA_SUBTRACT | |
  93350. * | 4 | ALPHA_MULTIPLY | |
  93351. * | 5 | ALPHA_MAXIMIZED | |
  93352. * | 6 | ALPHA_ONEONE | |
  93353. * | 7 | ALPHA_PREMULTIPLIED | |
  93354. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  93355. * | 9 | ALPHA_INTERPOLATE | |
  93356. * | 10 | ALPHA_SCREENMODE | |
  93357. *
  93358. */
  93359. set alphaMode(value: number);
  93360. /**
  93361. * Gets the value of the alpha mode
  93362. */
  93363. get alphaMode(): number;
  93364. /**
  93365. * Stores the state of the need depth pre-pass value
  93366. */
  93367. private _needDepthPrePass;
  93368. /**
  93369. * Sets the need depth pre-pass value
  93370. */
  93371. set needDepthPrePass(value: boolean);
  93372. /**
  93373. * Gets the depth pre-pass value
  93374. */
  93375. get needDepthPrePass(): boolean;
  93376. /**
  93377. * Specifies if depth writing should be disabled
  93378. */
  93379. disableDepthWrite: boolean;
  93380. /**
  93381. * Specifies if depth writing should be forced
  93382. */
  93383. forceDepthWrite: boolean;
  93384. /**
  93385. * Specifies the depth function that should be used. 0 means the default engine function
  93386. */
  93387. depthFunction: number;
  93388. /**
  93389. * Specifies if there should be a separate pass for culling
  93390. */
  93391. separateCullingPass: boolean;
  93392. /**
  93393. * Stores the state specifing if fog should be enabled
  93394. */
  93395. private _fogEnabled;
  93396. /**
  93397. * Sets the state for enabling fog
  93398. */
  93399. set fogEnabled(value: boolean);
  93400. /**
  93401. * Gets the value of the fog enabled state
  93402. */
  93403. get fogEnabled(): boolean;
  93404. /**
  93405. * Stores the size of points
  93406. */
  93407. pointSize: number;
  93408. /**
  93409. * Stores the z offset value
  93410. */
  93411. zOffset: number;
  93412. /**
  93413. * Gets a value specifying if wireframe mode is enabled
  93414. */
  93415. get wireframe(): boolean;
  93416. /**
  93417. * Sets the state of wireframe mode
  93418. */
  93419. set wireframe(value: boolean);
  93420. /**
  93421. * Gets the value specifying if point clouds are enabled
  93422. */
  93423. get pointsCloud(): boolean;
  93424. /**
  93425. * Sets the state of point cloud mode
  93426. */
  93427. set pointsCloud(value: boolean);
  93428. /**
  93429. * Gets the material fill mode
  93430. */
  93431. get fillMode(): number;
  93432. /**
  93433. * Sets the material fill mode
  93434. */
  93435. set fillMode(value: number);
  93436. /**
  93437. * @hidden
  93438. * Stores the effects for the material
  93439. */
  93440. _effect: Nullable<Effect>;
  93441. /**
  93442. * Specifies if uniform buffers should be used
  93443. */
  93444. private _useUBO;
  93445. /**
  93446. * Stores a reference to the scene
  93447. */
  93448. private _scene;
  93449. /**
  93450. * Stores the fill mode state
  93451. */
  93452. private _fillMode;
  93453. /**
  93454. * Specifies if the depth write state should be cached
  93455. */
  93456. private _cachedDepthWriteState;
  93457. /**
  93458. * Specifies if the depth function state should be cached
  93459. */
  93460. private _cachedDepthFunctionState;
  93461. /**
  93462. * Stores the uniform buffer
  93463. */
  93464. protected _uniformBuffer: UniformBuffer;
  93465. /** @hidden */
  93466. _indexInSceneMaterialArray: number;
  93467. /** @hidden */
  93468. meshMap: Nullable<{
  93469. [id: string]: AbstractMesh | undefined;
  93470. }>;
  93471. /**
  93472. * Creates a material instance
  93473. * @param name defines the name of the material
  93474. * @param scene defines the scene to reference
  93475. * @param doNotAdd specifies if the material should be added to the scene
  93476. */
  93477. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  93478. /**
  93479. * Returns a string representation of the current material
  93480. * @param fullDetails defines a boolean indicating which levels of logging is desired
  93481. * @returns a string with material information
  93482. */
  93483. toString(fullDetails?: boolean): string;
  93484. /**
  93485. * Gets the class name of the material
  93486. * @returns a string with the class name of the material
  93487. */
  93488. getClassName(): string;
  93489. /**
  93490. * Specifies if updates for the material been locked
  93491. */
  93492. get isFrozen(): boolean;
  93493. /**
  93494. * Locks updates for the material
  93495. */
  93496. freeze(): void;
  93497. /**
  93498. * Unlocks updates for the material
  93499. */
  93500. unfreeze(): void;
  93501. /**
  93502. * Specifies if the material is ready to be used
  93503. * @param mesh defines the mesh to check
  93504. * @param useInstances specifies if instances should be used
  93505. * @returns a boolean indicating if the material is ready to be used
  93506. */
  93507. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93508. /**
  93509. * Specifies that the submesh is ready to be used
  93510. * @param mesh defines the mesh to check
  93511. * @param subMesh defines which submesh to check
  93512. * @param useInstances specifies that instances should be used
  93513. * @returns a boolean indicating that the submesh is ready or not
  93514. */
  93515. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93516. /**
  93517. * Returns the material effect
  93518. * @returns the effect associated with the material
  93519. */
  93520. getEffect(): Nullable<Effect>;
  93521. /**
  93522. * Returns the current scene
  93523. * @returns a Scene
  93524. */
  93525. getScene(): Scene;
  93526. /**
  93527. * Specifies if the material will require alpha blending
  93528. * @returns a boolean specifying if alpha blending is needed
  93529. */
  93530. needAlphaBlending(): boolean;
  93531. /**
  93532. * Specifies if the mesh will require alpha blending
  93533. * @param mesh defines the mesh to check
  93534. * @returns a boolean specifying if alpha blending is needed for the mesh
  93535. */
  93536. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  93537. /**
  93538. * Specifies if this material should be rendered in alpha test mode
  93539. * @returns a boolean specifying if an alpha test is needed.
  93540. */
  93541. needAlphaTesting(): boolean;
  93542. /**
  93543. * Gets the texture used for the alpha test
  93544. * @returns the texture to use for alpha testing
  93545. */
  93546. getAlphaTestTexture(): Nullable<BaseTexture>;
  93547. /**
  93548. * Marks the material to indicate that it needs to be re-calculated
  93549. */
  93550. markDirty(): void;
  93551. /** @hidden */
  93552. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  93553. /**
  93554. * Binds the material to the mesh
  93555. * @param world defines the world transformation matrix
  93556. * @param mesh defines the mesh to bind the material to
  93557. */
  93558. bind(world: Matrix, mesh?: Mesh): void;
  93559. /**
  93560. * Binds the submesh to the material
  93561. * @param world defines the world transformation matrix
  93562. * @param mesh defines the mesh containing the submesh
  93563. * @param subMesh defines the submesh to bind the material to
  93564. */
  93565. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93566. /**
  93567. * Binds the world matrix to the material
  93568. * @param world defines the world transformation matrix
  93569. */
  93570. bindOnlyWorldMatrix(world: Matrix): void;
  93571. /**
  93572. * Binds the scene's uniform buffer to the effect.
  93573. * @param effect defines the effect to bind to the scene uniform buffer
  93574. * @param sceneUbo defines the uniform buffer storing scene data
  93575. */
  93576. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  93577. /**
  93578. * Binds the view matrix to the effect
  93579. * @param effect defines the effect to bind the view matrix to
  93580. */
  93581. bindView(effect: Effect): void;
  93582. /**
  93583. * Binds the view projection matrix to the effect
  93584. * @param effect defines the effect to bind the view projection matrix to
  93585. */
  93586. bindViewProjection(effect: Effect): void;
  93587. /**
  93588. * Specifies if material alpha testing should be turned on for the mesh
  93589. * @param mesh defines the mesh to check
  93590. */
  93591. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  93592. /**
  93593. * Processes to execute after binding the material to a mesh
  93594. * @param mesh defines the rendered mesh
  93595. */
  93596. protected _afterBind(mesh?: Mesh): void;
  93597. /**
  93598. * Unbinds the material from the mesh
  93599. */
  93600. unbind(): void;
  93601. /**
  93602. * Gets the active textures from the material
  93603. * @returns an array of textures
  93604. */
  93605. getActiveTextures(): BaseTexture[];
  93606. /**
  93607. * Specifies if the material uses a texture
  93608. * @param texture defines the texture to check against the material
  93609. * @returns a boolean specifying if the material uses the texture
  93610. */
  93611. hasTexture(texture: BaseTexture): boolean;
  93612. /**
  93613. * Makes a duplicate of the material, and gives it a new name
  93614. * @param name defines the new name for the duplicated material
  93615. * @returns the cloned material
  93616. */
  93617. clone(name: string): Nullable<Material>;
  93618. /**
  93619. * Gets the meshes bound to the material
  93620. * @returns an array of meshes bound to the material
  93621. */
  93622. getBindedMeshes(): AbstractMesh[];
  93623. /**
  93624. * Force shader compilation
  93625. * @param mesh defines the mesh associated with this material
  93626. * @param onCompiled defines a function to execute once the material is compiled
  93627. * @param options defines the options to configure the compilation
  93628. * @param onError defines a function to execute if the material fails compiling
  93629. */
  93630. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  93631. /**
  93632. * Force shader compilation
  93633. * @param mesh defines the mesh that will use this material
  93634. * @param options defines additional options for compiling the shaders
  93635. * @returns a promise that resolves when the compilation completes
  93636. */
  93637. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  93638. private static readonly _AllDirtyCallBack;
  93639. private static readonly _ImageProcessingDirtyCallBack;
  93640. private static readonly _TextureDirtyCallBack;
  93641. private static readonly _FresnelDirtyCallBack;
  93642. private static readonly _MiscDirtyCallBack;
  93643. private static readonly _LightsDirtyCallBack;
  93644. private static readonly _AttributeDirtyCallBack;
  93645. private static _FresnelAndMiscDirtyCallBack;
  93646. private static _TextureAndMiscDirtyCallBack;
  93647. private static readonly _DirtyCallbackArray;
  93648. private static readonly _RunDirtyCallBacks;
  93649. /**
  93650. * Marks a define in the material to indicate that it needs to be re-computed
  93651. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  93652. */
  93653. markAsDirty(flag: number): void;
  93654. /**
  93655. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  93656. * @param func defines a function which checks material defines against the submeshes
  93657. */
  93658. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  93659. /**
  93660. * Indicates that we need to re-calculated for all submeshes
  93661. */
  93662. protected _markAllSubMeshesAsAllDirty(): void;
  93663. /**
  93664. * Indicates that image processing needs to be re-calculated for all submeshes
  93665. */
  93666. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  93667. /**
  93668. * Indicates that textures need to be re-calculated for all submeshes
  93669. */
  93670. protected _markAllSubMeshesAsTexturesDirty(): void;
  93671. /**
  93672. * Indicates that fresnel needs to be re-calculated for all submeshes
  93673. */
  93674. protected _markAllSubMeshesAsFresnelDirty(): void;
  93675. /**
  93676. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  93677. */
  93678. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  93679. /**
  93680. * Indicates that lights need to be re-calculated for all submeshes
  93681. */
  93682. protected _markAllSubMeshesAsLightsDirty(): void;
  93683. /**
  93684. * Indicates that attributes need to be re-calculated for all submeshes
  93685. */
  93686. protected _markAllSubMeshesAsAttributesDirty(): void;
  93687. /**
  93688. * Indicates that misc needs to be re-calculated for all submeshes
  93689. */
  93690. protected _markAllSubMeshesAsMiscDirty(): void;
  93691. /**
  93692. * Indicates that textures and misc need to be re-calculated for all submeshes
  93693. */
  93694. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  93695. /**
  93696. * Disposes the material
  93697. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93698. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93699. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93700. */
  93701. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93702. /** @hidden */
  93703. private releaseVertexArrayObject;
  93704. /**
  93705. * Serializes this material
  93706. * @returns the serialized material object
  93707. */
  93708. serialize(): any;
  93709. /**
  93710. * Creates a material from parsed material data
  93711. * @param parsedMaterial defines parsed material data
  93712. * @param scene defines the hosting scene
  93713. * @param rootUrl defines the root URL to use to load textures
  93714. * @returns a new material
  93715. */
  93716. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  93717. }
  93718. }
  93719. declare module BABYLON {
  93720. /**
  93721. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93722. * separate meshes. This can be use to improve performances.
  93723. * @see http://doc.babylonjs.com/how_to/multi_materials
  93724. */
  93725. export class MultiMaterial extends Material {
  93726. private _subMaterials;
  93727. /**
  93728. * Gets or Sets the list of Materials used within the multi material.
  93729. * They need to be ordered according to the submeshes order in the associated mesh
  93730. */
  93731. get subMaterials(): Nullable<Material>[];
  93732. set subMaterials(value: Nullable<Material>[]);
  93733. /**
  93734. * Function used to align with Node.getChildren()
  93735. * @returns the list of Materials used within the multi material
  93736. */
  93737. getChildren(): Nullable<Material>[];
  93738. /**
  93739. * Instantiates a new Multi Material
  93740. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93741. * separate meshes. This can be use to improve performances.
  93742. * @see http://doc.babylonjs.com/how_to/multi_materials
  93743. * @param name Define the name in the scene
  93744. * @param scene Define the scene the material belongs to
  93745. */
  93746. constructor(name: string, scene: Scene);
  93747. private _hookArray;
  93748. /**
  93749. * Get one of the submaterial by its index in the submaterials array
  93750. * @param index The index to look the sub material at
  93751. * @returns The Material if the index has been defined
  93752. */
  93753. getSubMaterial(index: number): Nullable<Material>;
  93754. /**
  93755. * Get the list of active textures for the whole sub materials list.
  93756. * @returns All the textures that will be used during the rendering
  93757. */
  93758. getActiveTextures(): BaseTexture[];
  93759. /**
  93760. * Gets the current class name of the material e.g. "MultiMaterial"
  93761. * Mainly use in serialization.
  93762. * @returns the class name
  93763. */
  93764. getClassName(): string;
  93765. /**
  93766. * Checks if the material is ready to render the requested sub mesh
  93767. * @param mesh Define the mesh the submesh belongs to
  93768. * @param subMesh Define the sub mesh to look readyness for
  93769. * @param useInstances Define whether or not the material is used with instances
  93770. * @returns true if ready, otherwise false
  93771. */
  93772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93773. /**
  93774. * Clones the current material and its related sub materials
  93775. * @param name Define the name of the newly cloned material
  93776. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  93777. * @returns the cloned material
  93778. */
  93779. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  93780. /**
  93781. * Serializes the materials into a JSON representation.
  93782. * @returns the JSON representation
  93783. */
  93784. serialize(): any;
  93785. /**
  93786. * Dispose the material and release its associated resources
  93787. * @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)
  93788. * @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)
  93789. * @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)
  93790. */
  93791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  93792. /**
  93793. * Creates a MultiMaterial from parsed MultiMaterial data.
  93794. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  93795. * @param scene defines the hosting scene
  93796. * @returns a new MultiMaterial
  93797. */
  93798. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  93799. }
  93800. }
  93801. declare module BABYLON {
  93802. /**
  93803. * Base class for submeshes
  93804. */
  93805. export class BaseSubMesh {
  93806. /** @hidden */
  93807. _materialDefines: Nullable<MaterialDefines>;
  93808. /** @hidden */
  93809. _materialEffect: Nullable<Effect>;
  93810. /**
  93811. * Gets material defines used by the effect associated to the sub mesh
  93812. */
  93813. get materialDefines(): Nullable<MaterialDefines>;
  93814. /**
  93815. * Sets material defines used by the effect associated to the sub mesh
  93816. */
  93817. set materialDefines(defines: Nullable<MaterialDefines>);
  93818. /**
  93819. * Gets associated effect
  93820. */
  93821. get effect(): Nullable<Effect>;
  93822. /**
  93823. * Sets associated effect (effect used to render this submesh)
  93824. * @param effect defines the effect to associate with
  93825. * @param defines defines the set of defines used to compile this effect
  93826. */
  93827. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  93828. }
  93829. /**
  93830. * Defines a subdivision inside a mesh
  93831. */
  93832. export class SubMesh extends BaseSubMesh implements ICullable {
  93833. /** the material index to use */
  93834. materialIndex: number;
  93835. /** vertex index start */
  93836. verticesStart: number;
  93837. /** vertices count */
  93838. verticesCount: number;
  93839. /** index start */
  93840. indexStart: number;
  93841. /** indices count */
  93842. indexCount: number;
  93843. /** @hidden */
  93844. _linesIndexCount: number;
  93845. private _mesh;
  93846. private _renderingMesh;
  93847. private _boundingInfo;
  93848. private _linesIndexBuffer;
  93849. /** @hidden */
  93850. _lastColliderWorldVertices: Nullable<Vector3[]>;
  93851. /** @hidden */
  93852. _trianglePlanes: Plane[];
  93853. /** @hidden */
  93854. _lastColliderTransformMatrix: Nullable<Matrix>;
  93855. /** @hidden */
  93856. _renderId: number;
  93857. /** @hidden */
  93858. _alphaIndex: number;
  93859. /** @hidden */
  93860. _distanceToCamera: number;
  93861. /** @hidden */
  93862. _id: number;
  93863. private _currentMaterial;
  93864. /**
  93865. * Add a new submesh to a mesh
  93866. * @param materialIndex defines the material index to use
  93867. * @param verticesStart defines vertex index start
  93868. * @param verticesCount defines vertices count
  93869. * @param indexStart defines index start
  93870. * @param indexCount defines indices count
  93871. * @param mesh defines the parent mesh
  93872. * @param renderingMesh defines an optional rendering mesh
  93873. * @param createBoundingBox defines if bounding box should be created for this submesh
  93874. * @returns the new submesh
  93875. */
  93876. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  93877. /**
  93878. * Creates a new submesh
  93879. * @param materialIndex defines the material index to use
  93880. * @param verticesStart defines vertex index start
  93881. * @param verticesCount defines vertices count
  93882. * @param indexStart defines index start
  93883. * @param indexCount defines indices count
  93884. * @param mesh defines the parent mesh
  93885. * @param renderingMesh defines an optional rendering mesh
  93886. * @param createBoundingBox defines if bounding box should be created for this submesh
  93887. */
  93888. constructor(
  93889. /** the material index to use */
  93890. materialIndex: number,
  93891. /** vertex index start */
  93892. verticesStart: number,
  93893. /** vertices count */
  93894. verticesCount: number,
  93895. /** index start */
  93896. indexStart: number,
  93897. /** indices count */
  93898. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  93899. /**
  93900. * Returns true if this submesh covers the entire parent mesh
  93901. * @ignorenaming
  93902. */
  93903. get IsGlobal(): boolean;
  93904. /**
  93905. * Returns the submesh BoudingInfo object
  93906. * @returns current bounding info (or mesh's one if the submesh is global)
  93907. */
  93908. getBoundingInfo(): BoundingInfo;
  93909. /**
  93910. * Sets the submesh BoundingInfo
  93911. * @param boundingInfo defines the new bounding info to use
  93912. * @returns the SubMesh
  93913. */
  93914. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  93915. /**
  93916. * Returns the mesh of the current submesh
  93917. * @return the parent mesh
  93918. */
  93919. getMesh(): AbstractMesh;
  93920. /**
  93921. * Returns the rendering mesh of the submesh
  93922. * @returns the rendering mesh (could be different from parent mesh)
  93923. */
  93924. getRenderingMesh(): Mesh;
  93925. /**
  93926. * Returns the submesh material
  93927. * @returns null or the current material
  93928. */
  93929. getMaterial(): Nullable<Material>;
  93930. /**
  93931. * Sets a new updated BoundingInfo object to the submesh
  93932. * @param data defines an optional position array to use to determine the bounding info
  93933. * @returns the SubMesh
  93934. */
  93935. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  93936. /** @hidden */
  93937. _checkCollision(collider: Collider): boolean;
  93938. /**
  93939. * Updates the submesh BoundingInfo
  93940. * @param world defines the world matrix to use to update the bounding info
  93941. * @returns the submesh
  93942. */
  93943. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  93944. /**
  93945. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  93946. * @param frustumPlanes defines the frustum planes
  93947. * @returns true if the submesh is intersecting with the frustum
  93948. */
  93949. isInFrustum(frustumPlanes: Plane[]): boolean;
  93950. /**
  93951. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  93952. * @param frustumPlanes defines the frustum planes
  93953. * @returns true if the submesh is inside the frustum
  93954. */
  93955. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93956. /**
  93957. * Renders the submesh
  93958. * @param enableAlphaMode defines if alpha needs to be used
  93959. * @returns the submesh
  93960. */
  93961. render(enableAlphaMode: boolean): SubMesh;
  93962. /**
  93963. * @hidden
  93964. */
  93965. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  93966. /**
  93967. * Checks if the submesh intersects with a ray
  93968. * @param ray defines the ray to test
  93969. * @returns true is the passed ray intersects the submesh bounding box
  93970. */
  93971. canIntersects(ray: Ray): boolean;
  93972. /**
  93973. * Intersects current submesh with a ray
  93974. * @param ray defines the ray to test
  93975. * @param positions defines mesh's positions array
  93976. * @param indices defines mesh's indices array
  93977. * @param fastCheck defines if only bounding info should be used
  93978. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93979. * @returns intersection info or null if no intersection
  93980. */
  93981. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  93982. /** @hidden */
  93983. private _intersectLines;
  93984. /** @hidden */
  93985. private _intersectUnIndexedLines;
  93986. /** @hidden */
  93987. private _intersectTriangles;
  93988. /** @hidden */
  93989. private _intersectUnIndexedTriangles;
  93990. /** @hidden */
  93991. _rebuild(): void;
  93992. /**
  93993. * Creates a new submesh from the passed mesh
  93994. * @param newMesh defines the new hosting mesh
  93995. * @param newRenderingMesh defines an optional rendering mesh
  93996. * @returns the new submesh
  93997. */
  93998. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  93999. /**
  94000. * Release associated resources
  94001. */
  94002. dispose(): void;
  94003. /**
  94004. * Gets the class name
  94005. * @returns the string "SubMesh".
  94006. */
  94007. getClassName(): string;
  94008. /**
  94009. * Creates a new submesh from indices data
  94010. * @param materialIndex the index of the main mesh material
  94011. * @param startIndex the index where to start the copy in the mesh indices array
  94012. * @param indexCount the number of indices to copy then from the startIndex
  94013. * @param mesh the main mesh to create the submesh from
  94014. * @param renderingMesh the optional rendering mesh
  94015. * @returns a new submesh
  94016. */
  94017. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94018. }
  94019. }
  94020. declare module BABYLON {
  94021. /**
  94022. * Class used to represent data loading progression
  94023. */
  94024. export class SceneLoaderFlags {
  94025. private static _ForceFullSceneLoadingForIncremental;
  94026. private static _ShowLoadingScreen;
  94027. private static _CleanBoneMatrixWeights;
  94028. private static _loggingLevel;
  94029. /**
  94030. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94031. */
  94032. static get ForceFullSceneLoadingForIncremental(): boolean;
  94033. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94034. /**
  94035. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94036. */
  94037. static get ShowLoadingScreen(): boolean;
  94038. static set ShowLoadingScreen(value: boolean);
  94039. /**
  94040. * Defines the current logging level (while loading the scene)
  94041. * @ignorenaming
  94042. */
  94043. static get loggingLevel(): number;
  94044. static set loggingLevel(value: number);
  94045. /**
  94046. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94047. */
  94048. static get CleanBoneMatrixWeights(): boolean;
  94049. static set CleanBoneMatrixWeights(value: boolean);
  94050. }
  94051. }
  94052. declare module BABYLON {
  94053. /**
  94054. * Class used to store geometry data (vertex buffers + index buffer)
  94055. */
  94056. export class Geometry implements IGetSetVerticesData {
  94057. /**
  94058. * Gets or sets the ID of the geometry
  94059. */
  94060. id: string;
  94061. /**
  94062. * Gets or sets the unique ID of the geometry
  94063. */
  94064. uniqueId: number;
  94065. /**
  94066. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94067. */
  94068. delayLoadState: number;
  94069. /**
  94070. * Gets the file containing the data to load when running in delay load state
  94071. */
  94072. delayLoadingFile: Nullable<string>;
  94073. /**
  94074. * Callback called when the geometry is updated
  94075. */
  94076. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94077. private _scene;
  94078. private _engine;
  94079. private _meshes;
  94080. private _totalVertices;
  94081. /** @hidden */
  94082. _indices: IndicesArray;
  94083. /** @hidden */
  94084. _vertexBuffers: {
  94085. [key: string]: VertexBuffer;
  94086. };
  94087. private _isDisposed;
  94088. private _extend;
  94089. private _boundingBias;
  94090. /** @hidden */
  94091. _delayInfo: Array<string>;
  94092. private _indexBuffer;
  94093. private _indexBufferIsUpdatable;
  94094. /** @hidden */
  94095. _boundingInfo: Nullable<BoundingInfo>;
  94096. /** @hidden */
  94097. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94098. /** @hidden */
  94099. _softwareSkinningFrameId: number;
  94100. private _vertexArrayObjects;
  94101. private _updatable;
  94102. /** @hidden */
  94103. _positions: Nullable<Vector3[]>;
  94104. /**
  94105. * 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
  94106. */
  94107. get boundingBias(): Vector2;
  94108. /**
  94109. * 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
  94110. */
  94111. set boundingBias(value: Vector2);
  94112. /**
  94113. * Static function used to attach a new empty geometry to a mesh
  94114. * @param mesh defines the mesh to attach the geometry to
  94115. * @returns the new Geometry
  94116. */
  94117. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94118. /**
  94119. * Creates a new geometry
  94120. * @param id defines the unique ID
  94121. * @param scene defines the hosting scene
  94122. * @param vertexData defines the VertexData used to get geometry data
  94123. * @param updatable defines if geometry must be updatable (false by default)
  94124. * @param mesh defines the mesh that will be associated with the geometry
  94125. */
  94126. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94127. /**
  94128. * Gets the current extend of the geometry
  94129. */
  94130. get extend(): {
  94131. minimum: Vector3;
  94132. maximum: Vector3;
  94133. };
  94134. /**
  94135. * Gets the hosting scene
  94136. * @returns the hosting Scene
  94137. */
  94138. getScene(): Scene;
  94139. /**
  94140. * Gets the hosting engine
  94141. * @returns the hosting Engine
  94142. */
  94143. getEngine(): Engine;
  94144. /**
  94145. * Defines if the geometry is ready to use
  94146. * @returns true if the geometry is ready to be used
  94147. */
  94148. isReady(): boolean;
  94149. /**
  94150. * Gets a value indicating that the geometry should not be serialized
  94151. */
  94152. get doNotSerialize(): boolean;
  94153. /** @hidden */
  94154. _rebuild(): void;
  94155. /**
  94156. * Affects all geometry data in one call
  94157. * @param vertexData defines the geometry data
  94158. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94159. */
  94160. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94161. /**
  94162. * Set specific vertex data
  94163. * @param kind defines the data kind (Position, normal, etc...)
  94164. * @param data defines the vertex data to use
  94165. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94166. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94167. */
  94168. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94169. /**
  94170. * Removes a specific vertex data
  94171. * @param kind defines the data kind (Position, normal, etc...)
  94172. */
  94173. removeVerticesData(kind: string): void;
  94174. /**
  94175. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  94176. * @param buffer defines the vertex buffer to use
  94177. * @param totalVertices defines the total number of vertices for position kind (could be null)
  94178. */
  94179. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  94180. /**
  94181. * Update a specific vertex buffer
  94182. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  94183. * It will do nothing if the buffer is not updatable
  94184. * @param kind defines the data kind (Position, normal, etc...)
  94185. * @param data defines the data to use
  94186. * @param offset defines the offset in the target buffer where to store the data
  94187. * @param useBytes set to true if the offset is in bytes
  94188. */
  94189. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  94190. /**
  94191. * Update a specific vertex buffer
  94192. * This function will create a new buffer if the current one is not updatable
  94193. * @param kind defines the data kind (Position, normal, etc...)
  94194. * @param data defines the data to use
  94195. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  94196. */
  94197. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  94198. private _updateBoundingInfo;
  94199. /** @hidden */
  94200. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  94201. /**
  94202. * Gets total number of vertices
  94203. * @returns the total number of vertices
  94204. */
  94205. getTotalVertices(): number;
  94206. /**
  94207. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94208. * @param kind defines the data kind (Position, normal, etc...)
  94209. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94210. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94211. * @returns a float array containing vertex data
  94212. */
  94213. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94214. /**
  94215. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  94216. * @param kind defines the data kind (Position, normal, etc...)
  94217. * @returns true if the vertex buffer with the specified kind is updatable
  94218. */
  94219. isVertexBufferUpdatable(kind: string): boolean;
  94220. /**
  94221. * Gets a specific vertex buffer
  94222. * @param kind defines the data kind (Position, normal, etc...)
  94223. * @returns a VertexBuffer
  94224. */
  94225. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94226. /**
  94227. * Returns all vertex buffers
  94228. * @return an object holding all vertex buffers indexed by kind
  94229. */
  94230. getVertexBuffers(): Nullable<{
  94231. [key: string]: VertexBuffer;
  94232. }>;
  94233. /**
  94234. * Gets a boolean indicating if specific vertex buffer is present
  94235. * @param kind defines the data kind (Position, normal, etc...)
  94236. * @returns true if data is present
  94237. */
  94238. isVerticesDataPresent(kind: string): boolean;
  94239. /**
  94240. * Gets a list of all attached data kinds (Position, normal, etc...)
  94241. * @returns a list of string containing all kinds
  94242. */
  94243. getVerticesDataKinds(): string[];
  94244. /**
  94245. * Update index buffer
  94246. * @param indices defines the indices to store in the index buffer
  94247. * @param offset defines the offset in the target buffer where to store the data
  94248. * @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)
  94249. */
  94250. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  94251. /**
  94252. * Creates a new index buffer
  94253. * @param indices defines the indices to store in the index buffer
  94254. * @param totalVertices defines the total number of vertices (could be null)
  94255. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94256. */
  94257. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  94258. /**
  94259. * Return the total number of indices
  94260. * @returns the total number of indices
  94261. */
  94262. getTotalIndices(): number;
  94263. /**
  94264. * Gets the index buffer array
  94265. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94266. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94267. * @returns the index buffer array
  94268. */
  94269. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94270. /**
  94271. * Gets the index buffer
  94272. * @return the index buffer
  94273. */
  94274. getIndexBuffer(): Nullable<DataBuffer>;
  94275. /** @hidden */
  94276. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  94277. /**
  94278. * Release the associated resources for a specific mesh
  94279. * @param mesh defines the source mesh
  94280. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  94281. */
  94282. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  94283. /**
  94284. * Apply current geometry to a given mesh
  94285. * @param mesh defines the mesh to apply geometry to
  94286. */
  94287. applyToMesh(mesh: Mesh): void;
  94288. private _updateExtend;
  94289. private _applyToMesh;
  94290. private notifyUpdate;
  94291. /**
  94292. * Load the geometry if it was flagged as delay loaded
  94293. * @param scene defines the hosting scene
  94294. * @param onLoaded defines a callback called when the geometry is loaded
  94295. */
  94296. load(scene: Scene, onLoaded?: () => void): void;
  94297. private _queueLoad;
  94298. /**
  94299. * Invert the geometry to move from a right handed system to a left handed one.
  94300. */
  94301. toLeftHanded(): void;
  94302. /** @hidden */
  94303. _resetPointsArrayCache(): void;
  94304. /** @hidden */
  94305. _generatePointsArray(): boolean;
  94306. /**
  94307. * Gets a value indicating if the geometry is disposed
  94308. * @returns true if the geometry was disposed
  94309. */
  94310. isDisposed(): boolean;
  94311. private _disposeVertexArrayObjects;
  94312. /**
  94313. * Free all associated resources
  94314. */
  94315. dispose(): void;
  94316. /**
  94317. * Clone the current geometry into a new geometry
  94318. * @param id defines the unique ID of the new geometry
  94319. * @returns a new geometry object
  94320. */
  94321. copy(id: string): Geometry;
  94322. /**
  94323. * Serialize the current geometry info (and not the vertices data) into a JSON object
  94324. * @return a JSON representation of the current geometry data (without the vertices data)
  94325. */
  94326. serialize(): any;
  94327. private toNumberArray;
  94328. /**
  94329. * Serialize all vertices data into a JSON oject
  94330. * @returns a JSON representation of the current geometry data
  94331. */
  94332. serializeVerticeData(): any;
  94333. /**
  94334. * Extracts a clone of a mesh geometry
  94335. * @param mesh defines the source mesh
  94336. * @param id defines the unique ID of the new geometry object
  94337. * @returns the new geometry object
  94338. */
  94339. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  94340. /**
  94341. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  94342. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94343. * Be aware Math.random() could cause collisions, but:
  94344. * "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"
  94345. * @returns a string containing a new GUID
  94346. */
  94347. static RandomId(): string;
  94348. /** @hidden */
  94349. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  94350. private static _CleanMatricesWeights;
  94351. /**
  94352. * Create a new geometry from persisted data (Using .babylon file format)
  94353. * @param parsedVertexData defines the persisted data
  94354. * @param scene defines the hosting scene
  94355. * @param rootUrl defines the root url to use to load assets (like delayed data)
  94356. * @returns the new geometry object
  94357. */
  94358. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  94359. }
  94360. }
  94361. declare module BABYLON {
  94362. /**
  94363. * Define an interface for all classes that will get and set the data on vertices
  94364. */
  94365. export interface IGetSetVerticesData {
  94366. /**
  94367. * Gets a boolean indicating if specific vertex data is present
  94368. * @param kind defines the vertex data kind to use
  94369. * @returns true is data kind is present
  94370. */
  94371. isVerticesDataPresent(kind: string): boolean;
  94372. /**
  94373. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94374. * @param kind defines the data kind (Position, normal, etc...)
  94375. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94376. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94377. * @returns a float array containing vertex data
  94378. */
  94379. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94380. /**
  94381. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94382. * @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.
  94383. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94384. * @returns the indices array or an empty array if the mesh has no geometry
  94385. */
  94386. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94387. /**
  94388. * Set specific vertex data
  94389. * @param kind defines the data kind (Position, normal, etc...)
  94390. * @param data defines the vertex data to use
  94391. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94392. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94393. */
  94394. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  94395. /**
  94396. * Update a specific associated vertex buffer
  94397. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94398. * - VertexBuffer.PositionKind
  94399. * - VertexBuffer.UVKind
  94400. * - VertexBuffer.UV2Kind
  94401. * - VertexBuffer.UV3Kind
  94402. * - VertexBuffer.UV4Kind
  94403. * - VertexBuffer.UV5Kind
  94404. * - VertexBuffer.UV6Kind
  94405. * - VertexBuffer.ColorKind
  94406. * - VertexBuffer.MatricesIndicesKind
  94407. * - VertexBuffer.MatricesIndicesExtraKind
  94408. * - VertexBuffer.MatricesWeightsKind
  94409. * - VertexBuffer.MatricesWeightsExtraKind
  94410. * @param data defines the data source
  94411. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94412. * @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)
  94413. */
  94414. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  94415. /**
  94416. * Creates a new index buffer
  94417. * @param indices defines the indices to store in the index buffer
  94418. * @param totalVertices defines the total number of vertices (could be null)
  94419. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94420. */
  94421. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  94422. }
  94423. /**
  94424. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  94425. */
  94426. export class VertexData {
  94427. /**
  94428. * Mesh side orientation : usually the external or front surface
  94429. */
  94430. static readonly FRONTSIDE: number;
  94431. /**
  94432. * Mesh side orientation : usually the internal or back surface
  94433. */
  94434. static readonly BACKSIDE: number;
  94435. /**
  94436. * Mesh side orientation : both internal and external or front and back surfaces
  94437. */
  94438. static readonly DOUBLESIDE: number;
  94439. /**
  94440. * Mesh side orientation : by default, `FRONTSIDE`
  94441. */
  94442. static readonly DEFAULTSIDE: number;
  94443. /**
  94444. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  94445. */
  94446. positions: Nullable<FloatArray>;
  94447. /**
  94448. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  94449. */
  94450. normals: Nullable<FloatArray>;
  94451. /**
  94452. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  94453. */
  94454. tangents: Nullable<FloatArray>;
  94455. /**
  94456. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94457. */
  94458. uvs: Nullable<FloatArray>;
  94459. /**
  94460. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94461. */
  94462. uvs2: Nullable<FloatArray>;
  94463. /**
  94464. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94465. */
  94466. uvs3: Nullable<FloatArray>;
  94467. /**
  94468. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94469. */
  94470. uvs4: Nullable<FloatArray>;
  94471. /**
  94472. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94473. */
  94474. uvs5: Nullable<FloatArray>;
  94475. /**
  94476. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94477. */
  94478. uvs6: Nullable<FloatArray>;
  94479. /**
  94480. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  94481. */
  94482. colors: Nullable<FloatArray>;
  94483. /**
  94484. * 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).
  94485. */
  94486. matricesIndices: Nullable<FloatArray>;
  94487. /**
  94488. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  94489. */
  94490. matricesWeights: Nullable<FloatArray>;
  94491. /**
  94492. * An array extending the number of possible indices
  94493. */
  94494. matricesIndicesExtra: Nullable<FloatArray>;
  94495. /**
  94496. * An array extending the number of possible weights when the number of indices is extended
  94497. */
  94498. matricesWeightsExtra: Nullable<FloatArray>;
  94499. /**
  94500. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  94501. */
  94502. indices: Nullable<IndicesArray>;
  94503. /**
  94504. * Uses the passed data array to set the set the values for the specified kind of data
  94505. * @param data a linear array of floating numbers
  94506. * @param kind the type of data that is being set, eg positions, colors etc
  94507. */
  94508. set(data: FloatArray, kind: string): void;
  94509. /**
  94510. * Associates the vertexData to the passed Mesh.
  94511. * Sets it as updatable or not (default `false`)
  94512. * @param mesh the mesh the vertexData is applied to
  94513. * @param updatable when used and having the value true allows new data to update the vertexData
  94514. * @returns the VertexData
  94515. */
  94516. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  94517. /**
  94518. * Associates the vertexData to the passed Geometry.
  94519. * Sets it as updatable or not (default `false`)
  94520. * @param geometry the geometry the vertexData is applied to
  94521. * @param updatable when used and having the value true allows new data to update the vertexData
  94522. * @returns VertexData
  94523. */
  94524. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  94525. /**
  94526. * Updates the associated mesh
  94527. * @param mesh the mesh to be updated
  94528. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94529. * @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
  94530. * @returns VertexData
  94531. */
  94532. updateMesh(mesh: Mesh): VertexData;
  94533. /**
  94534. * Updates the associated geometry
  94535. * @param geometry the geometry to be updated
  94536. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94537. * @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
  94538. * @returns VertexData.
  94539. */
  94540. updateGeometry(geometry: Geometry): VertexData;
  94541. private _applyTo;
  94542. private _update;
  94543. /**
  94544. * Transforms each position and each normal of the vertexData according to the passed Matrix
  94545. * @param matrix the transforming matrix
  94546. * @returns the VertexData
  94547. */
  94548. transform(matrix: Matrix): VertexData;
  94549. /**
  94550. * Merges the passed VertexData into the current one
  94551. * @param other the VertexData to be merged into the current one
  94552. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  94553. * @returns the modified VertexData
  94554. */
  94555. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  94556. private _mergeElement;
  94557. private _validate;
  94558. /**
  94559. * Serializes the VertexData
  94560. * @returns a serialized object
  94561. */
  94562. serialize(): any;
  94563. /**
  94564. * Extracts the vertexData from a mesh
  94565. * @param mesh the mesh from which to extract the VertexData
  94566. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  94567. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94568. * @returns the object VertexData associated to the passed mesh
  94569. */
  94570. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94571. /**
  94572. * Extracts the vertexData from the geometry
  94573. * @param geometry the geometry from which to extract the VertexData
  94574. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  94575. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94576. * @returns the object VertexData associated to the passed mesh
  94577. */
  94578. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94579. private static _ExtractFrom;
  94580. /**
  94581. * Creates the VertexData for a Ribbon
  94582. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  94583. * * pathArray array of paths, each of which an array of successive Vector3
  94584. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  94585. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  94586. * * 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
  94587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94588. * * 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)
  94589. * * 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)
  94590. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  94591. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  94592. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  94593. * @returns the VertexData of the ribbon
  94594. */
  94595. static CreateRibbon(options: {
  94596. pathArray: Vector3[][];
  94597. closeArray?: boolean;
  94598. closePath?: boolean;
  94599. offset?: number;
  94600. sideOrientation?: number;
  94601. frontUVs?: Vector4;
  94602. backUVs?: Vector4;
  94603. invertUV?: boolean;
  94604. uvs?: Vector2[];
  94605. colors?: Color4[];
  94606. }): VertexData;
  94607. /**
  94608. * Creates the VertexData for a box
  94609. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94610. * * size sets the width, height and depth of the box to the value of size, optional default 1
  94611. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  94612. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  94613. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  94614. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94615. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94616. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94617. * * 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)
  94618. * * 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)
  94619. * @returns the VertexData of the box
  94620. */
  94621. static CreateBox(options: {
  94622. size?: number;
  94623. width?: number;
  94624. height?: number;
  94625. depth?: number;
  94626. faceUV?: Vector4[];
  94627. faceColors?: Color4[];
  94628. sideOrientation?: number;
  94629. frontUVs?: Vector4;
  94630. backUVs?: Vector4;
  94631. }): VertexData;
  94632. /**
  94633. * Creates the VertexData for a tiled box
  94634. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94635. * * faceTiles sets the pattern, tile size and number of tiles for a face
  94636. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94637. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94639. * @returns the VertexData of the box
  94640. */
  94641. static CreateTiledBox(options: {
  94642. pattern?: number;
  94643. width?: number;
  94644. height?: number;
  94645. depth?: number;
  94646. tileSize?: number;
  94647. tileWidth?: number;
  94648. tileHeight?: number;
  94649. alignHorizontal?: number;
  94650. alignVertical?: number;
  94651. faceUV?: Vector4[];
  94652. faceColors?: Color4[];
  94653. sideOrientation?: number;
  94654. }): VertexData;
  94655. /**
  94656. * Creates the VertexData for a tiled plane
  94657. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94658. * * pattern a limited pattern arrangement depending on the number
  94659. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  94660. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  94661. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  94662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94663. * * 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)
  94664. * * 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)
  94665. * @returns the VertexData of the tiled plane
  94666. */
  94667. static CreateTiledPlane(options: {
  94668. pattern?: number;
  94669. tileSize?: number;
  94670. tileWidth?: number;
  94671. tileHeight?: number;
  94672. size?: number;
  94673. width?: number;
  94674. height?: number;
  94675. alignHorizontal?: number;
  94676. alignVertical?: number;
  94677. sideOrientation?: number;
  94678. frontUVs?: Vector4;
  94679. backUVs?: Vector4;
  94680. }): VertexData;
  94681. /**
  94682. * Creates the VertexData for an ellipsoid, defaults to a sphere
  94683. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94684. * * segments sets the number of horizontal strips optional, default 32
  94685. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  94686. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  94687. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  94688. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  94689. * * 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
  94690. * * 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
  94691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94692. * * 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)
  94693. * * 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)
  94694. * @returns the VertexData of the ellipsoid
  94695. */
  94696. static CreateSphere(options: {
  94697. segments?: number;
  94698. diameter?: number;
  94699. diameterX?: number;
  94700. diameterY?: number;
  94701. diameterZ?: number;
  94702. arc?: number;
  94703. slice?: number;
  94704. sideOrientation?: number;
  94705. frontUVs?: Vector4;
  94706. backUVs?: Vector4;
  94707. }): VertexData;
  94708. /**
  94709. * Creates the VertexData for a cylinder, cone or prism
  94710. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94711. * * height sets the height (y direction) of the cylinder, optional, default 2
  94712. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  94713. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  94714. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  94715. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94716. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  94717. * * 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
  94718. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94719. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94720. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  94721. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  94722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94723. * * 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)
  94724. * * 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)
  94725. * @returns the VertexData of the cylinder, cone or prism
  94726. */
  94727. static CreateCylinder(options: {
  94728. height?: number;
  94729. diameterTop?: number;
  94730. diameterBottom?: number;
  94731. diameter?: number;
  94732. tessellation?: number;
  94733. subdivisions?: number;
  94734. arc?: number;
  94735. faceColors?: Color4[];
  94736. faceUV?: Vector4[];
  94737. hasRings?: boolean;
  94738. enclose?: boolean;
  94739. sideOrientation?: number;
  94740. frontUVs?: Vector4;
  94741. backUVs?: Vector4;
  94742. }): VertexData;
  94743. /**
  94744. * Creates the VertexData for a torus
  94745. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94746. * * diameter the diameter of the torus, optional default 1
  94747. * * thickness the diameter of the tube forming the torus, optional default 0.5
  94748. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94749. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94750. * * 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)
  94751. * * 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)
  94752. * @returns the VertexData of the torus
  94753. */
  94754. static CreateTorus(options: {
  94755. diameter?: number;
  94756. thickness?: number;
  94757. tessellation?: number;
  94758. sideOrientation?: number;
  94759. frontUVs?: Vector4;
  94760. backUVs?: Vector4;
  94761. }): VertexData;
  94762. /**
  94763. * Creates the VertexData of the LineSystem
  94764. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  94765. * - lines an array of lines, each line being an array of successive Vector3
  94766. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  94767. * @returns the VertexData of the LineSystem
  94768. */
  94769. static CreateLineSystem(options: {
  94770. lines: Vector3[][];
  94771. colors?: Nullable<Color4[][]>;
  94772. }): VertexData;
  94773. /**
  94774. * Create the VertexData for a DashedLines
  94775. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  94776. * - points an array successive Vector3
  94777. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  94778. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  94779. * - dashNb the intended total number of dashes, optional, default 200
  94780. * @returns the VertexData for the DashedLines
  94781. */
  94782. static CreateDashedLines(options: {
  94783. points: Vector3[];
  94784. dashSize?: number;
  94785. gapSize?: number;
  94786. dashNb?: number;
  94787. }): VertexData;
  94788. /**
  94789. * Creates the VertexData for a Ground
  94790. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94791. * - width the width (x direction) of the ground, optional, default 1
  94792. * - height the height (z direction) of the ground, optional, default 1
  94793. * - subdivisions the number of subdivisions per side, optional, default 1
  94794. * @returns the VertexData of the Ground
  94795. */
  94796. static CreateGround(options: {
  94797. width?: number;
  94798. height?: number;
  94799. subdivisions?: number;
  94800. subdivisionsX?: number;
  94801. subdivisionsY?: number;
  94802. }): VertexData;
  94803. /**
  94804. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  94805. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94806. * * xmin the ground minimum X coordinate, optional, default -1
  94807. * * zmin the ground minimum Z coordinate, optional, default -1
  94808. * * xmax the ground maximum X coordinate, optional, default 1
  94809. * * zmax the ground maximum Z coordinate, optional, default 1
  94810. * * 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}
  94811. * * 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}
  94812. * @returns the VertexData of the TiledGround
  94813. */
  94814. static CreateTiledGround(options: {
  94815. xmin: number;
  94816. zmin: number;
  94817. xmax: number;
  94818. zmax: number;
  94819. subdivisions?: {
  94820. w: number;
  94821. h: number;
  94822. };
  94823. precision?: {
  94824. w: number;
  94825. h: number;
  94826. };
  94827. }): VertexData;
  94828. /**
  94829. * Creates the VertexData of the Ground designed from a heightmap
  94830. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  94831. * * width the width (x direction) of the ground
  94832. * * height the height (z direction) of the ground
  94833. * * subdivisions the number of subdivisions per side
  94834. * * minHeight the minimum altitude on the ground, optional, default 0
  94835. * * maxHeight the maximum altitude on the ground, optional default 1
  94836. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  94837. * * buffer the array holding the image color data
  94838. * * bufferWidth the width of image
  94839. * * bufferHeight the height of image
  94840. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  94841. * @returns the VertexData of the Ground designed from a heightmap
  94842. */
  94843. static CreateGroundFromHeightMap(options: {
  94844. width: number;
  94845. height: number;
  94846. subdivisions: number;
  94847. minHeight: number;
  94848. maxHeight: number;
  94849. colorFilter: Color3;
  94850. buffer: Uint8Array;
  94851. bufferWidth: number;
  94852. bufferHeight: number;
  94853. alphaFilter: number;
  94854. }): VertexData;
  94855. /**
  94856. * Creates the VertexData for a Plane
  94857. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  94858. * * size sets the width and height of the plane to the value of size, optional default 1
  94859. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  94860. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  94861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94862. * * 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)
  94863. * * 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)
  94864. * @returns the VertexData of the box
  94865. */
  94866. static CreatePlane(options: {
  94867. size?: number;
  94868. width?: number;
  94869. height?: number;
  94870. sideOrientation?: number;
  94871. frontUVs?: Vector4;
  94872. backUVs?: Vector4;
  94873. }): VertexData;
  94874. /**
  94875. * Creates the VertexData of the Disc or regular Polygon
  94876. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  94877. * * radius the radius of the disc, optional default 0.5
  94878. * * tessellation the number of polygon sides, optional, default 64
  94879. * * 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
  94880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94881. * * 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)
  94882. * * 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)
  94883. * @returns the VertexData of the box
  94884. */
  94885. static CreateDisc(options: {
  94886. radius?: number;
  94887. tessellation?: number;
  94888. arc?: number;
  94889. sideOrientation?: number;
  94890. frontUVs?: Vector4;
  94891. backUVs?: Vector4;
  94892. }): VertexData;
  94893. /**
  94894. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  94895. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  94896. * @param polygon a mesh built from polygonTriangulation.build()
  94897. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94898. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94899. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94900. * @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)
  94901. * @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)
  94902. * @returns the VertexData of the Polygon
  94903. */
  94904. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  94905. /**
  94906. * Creates the VertexData of the IcoSphere
  94907. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  94908. * * radius the radius of the IcoSphere, optional default 1
  94909. * * radiusX allows stretching in the x direction, optional, default radius
  94910. * * radiusY allows stretching in the y direction, optional, default radius
  94911. * * radiusZ allows stretching in the z direction, optional, default radius
  94912. * * flat when true creates a flat shaded mesh, optional, default true
  94913. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  94914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94915. * * 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)
  94916. * * 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)
  94917. * @returns the VertexData of the IcoSphere
  94918. */
  94919. static CreateIcoSphere(options: {
  94920. radius?: number;
  94921. radiusX?: number;
  94922. radiusY?: number;
  94923. radiusZ?: number;
  94924. flat?: boolean;
  94925. subdivisions?: number;
  94926. sideOrientation?: number;
  94927. frontUVs?: Vector4;
  94928. backUVs?: Vector4;
  94929. }): VertexData;
  94930. /**
  94931. * Creates the VertexData for a Polyhedron
  94932. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  94933. * * type provided types are:
  94934. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  94935. * * 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)
  94936. * * size the size of the IcoSphere, optional default 1
  94937. * * sizeX allows stretching in the x direction, optional, default size
  94938. * * sizeY allows stretching in the y direction, optional, default size
  94939. * * sizeZ allows stretching in the z direction, optional, default size
  94940. * * 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
  94941. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94942. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94943. * * flat when true creates a flat shaded mesh, optional, default true
  94944. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  94945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94946. * * 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)
  94947. * * 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)
  94948. * @returns the VertexData of the Polyhedron
  94949. */
  94950. static CreatePolyhedron(options: {
  94951. type?: number;
  94952. size?: number;
  94953. sizeX?: number;
  94954. sizeY?: number;
  94955. sizeZ?: number;
  94956. custom?: any;
  94957. faceUV?: Vector4[];
  94958. faceColors?: Color4[];
  94959. flat?: boolean;
  94960. sideOrientation?: number;
  94961. frontUVs?: Vector4;
  94962. backUVs?: Vector4;
  94963. }): VertexData;
  94964. /**
  94965. * Creates the VertexData for a TorusKnot
  94966. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  94967. * * radius the radius of the torus knot, optional, default 2
  94968. * * tube the thickness of the tube, optional, default 0.5
  94969. * * radialSegments the number of sides on each tube segments, optional, default 32
  94970. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  94971. * * p the number of windings around the z axis, optional, default 2
  94972. * * q the number of windings around the x axis, optional, default 3
  94973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94974. * * 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)
  94975. * * 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)
  94976. * @returns the VertexData of the Torus Knot
  94977. */
  94978. static CreateTorusKnot(options: {
  94979. radius?: number;
  94980. tube?: number;
  94981. radialSegments?: number;
  94982. tubularSegments?: number;
  94983. p?: number;
  94984. q?: number;
  94985. sideOrientation?: number;
  94986. frontUVs?: Vector4;
  94987. backUVs?: Vector4;
  94988. }): VertexData;
  94989. /**
  94990. * Compute normals for given positions and indices
  94991. * @param positions an array of vertex positions, [...., x, y, z, ......]
  94992. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  94993. * @param normals an array of vertex normals, [...., x, y, z, ......]
  94994. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  94995. * * facetNormals : optional array of facet normals (vector3)
  94996. * * facetPositions : optional array of facet positions (vector3)
  94997. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  94998. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  94999. * * bInfo : optional bounding info, required for facetPartitioning computation
  95000. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95001. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95002. * * useRightHandedSystem: optional boolean to for right handed system computation
  95003. * * depthSort : optional boolean to enable the facet depth sort computation
  95004. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95005. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95006. */
  95007. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95008. facetNormals?: any;
  95009. facetPositions?: any;
  95010. facetPartitioning?: any;
  95011. ratio?: number;
  95012. bInfo?: any;
  95013. bbSize?: Vector3;
  95014. subDiv?: any;
  95015. useRightHandedSystem?: boolean;
  95016. depthSort?: boolean;
  95017. distanceTo?: Vector3;
  95018. depthSortedFacets?: any;
  95019. }): void;
  95020. /** @hidden */
  95021. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95022. /**
  95023. * Applies VertexData created from the imported parameters to the geometry
  95024. * @param parsedVertexData the parsed data from an imported file
  95025. * @param geometry the geometry to apply the VertexData to
  95026. */
  95027. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95028. }
  95029. }
  95030. declare module BABYLON {
  95031. /**
  95032. * Defines a target to use with MorphTargetManager
  95033. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95034. */
  95035. export class MorphTarget implements IAnimatable {
  95036. /** defines the name of the target */
  95037. name: string;
  95038. /**
  95039. * Gets or sets the list of animations
  95040. */
  95041. animations: Animation[];
  95042. private _scene;
  95043. private _positions;
  95044. private _normals;
  95045. private _tangents;
  95046. private _uvs;
  95047. private _influence;
  95048. private _uniqueId;
  95049. /**
  95050. * Observable raised when the influence changes
  95051. */
  95052. onInfluenceChanged: Observable<boolean>;
  95053. /** @hidden */
  95054. _onDataLayoutChanged: Observable<void>;
  95055. /**
  95056. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95057. */
  95058. get influence(): number;
  95059. set influence(influence: number);
  95060. /**
  95061. * Gets or sets the id of the morph Target
  95062. */
  95063. id: string;
  95064. private _animationPropertiesOverride;
  95065. /**
  95066. * Gets or sets the animation properties override
  95067. */
  95068. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95069. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95070. /**
  95071. * Creates a new MorphTarget
  95072. * @param name defines the name of the target
  95073. * @param influence defines the influence to use
  95074. * @param scene defines the scene the morphtarget belongs to
  95075. */
  95076. constructor(
  95077. /** defines the name of the target */
  95078. name: string, influence?: number, scene?: Nullable<Scene>);
  95079. /**
  95080. * Gets the unique ID of this manager
  95081. */
  95082. get uniqueId(): number;
  95083. /**
  95084. * Gets a boolean defining if the target contains position data
  95085. */
  95086. get hasPositions(): boolean;
  95087. /**
  95088. * Gets a boolean defining if the target contains normal data
  95089. */
  95090. get hasNormals(): boolean;
  95091. /**
  95092. * Gets a boolean defining if the target contains tangent data
  95093. */
  95094. get hasTangents(): boolean;
  95095. /**
  95096. * Gets a boolean defining if the target contains texture coordinates data
  95097. */
  95098. get hasUVs(): boolean;
  95099. /**
  95100. * Affects position data to this target
  95101. * @param data defines the position data to use
  95102. */
  95103. setPositions(data: Nullable<FloatArray>): void;
  95104. /**
  95105. * Gets the position data stored in this target
  95106. * @returns a FloatArray containing the position data (or null if not present)
  95107. */
  95108. getPositions(): Nullable<FloatArray>;
  95109. /**
  95110. * Affects normal data to this target
  95111. * @param data defines the normal data to use
  95112. */
  95113. setNormals(data: Nullable<FloatArray>): void;
  95114. /**
  95115. * Gets the normal data stored in this target
  95116. * @returns a FloatArray containing the normal data (or null if not present)
  95117. */
  95118. getNormals(): Nullable<FloatArray>;
  95119. /**
  95120. * Affects tangent data to this target
  95121. * @param data defines the tangent data to use
  95122. */
  95123. setTangents(data: Nullable<FloatArray>): void;
  95124. /**
  95125. * Gets the tangent data stored in this target
  95126. * @returns a FloatArray containing the tangent data (or null if not present)
  95127. */
  95128. getTangents(): Nullable<FloatArray>;
  95129. /**
  95130. * Affects texture coordinates data to this target
  95131. * @param data defines the texture coordinates data to use
  95132. */
  95133. setUVs(data: Nullable<FloatArray>): void;
  95134. /**
  95135. * Gets the texture coordinates data stored in this target
  95136. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95137. */
  95138. getUVs(): Nullable<FloatArray>;
  95139. /**
  95140. * Clone the current target
  95141. * @returns a new MorphTarget
  95142. */
  95143. clone(): MorphTarget;
  95144. /**
  95145. * Serializes the current target into a Serialization object
  95146. * @returns the serialized object
  95147. */
  95148. serialize(): any;
  95149. /**
  95150. * Returns the string "MorphTarget"
  95151. * @returns "MorphTarget"
  95152. */
  95153. getClassName(): string;
  95154. /**
  95155. * Creates a new target from serialized data
  95156. * @param serializationObject defines the serialized data to use
  95157. * @returns a new MorphTarget
  95158. */
  95159. static Parse(serializationObject: any): MorphTarget;
  95160. /**
  95161. * Creates a MorphTarget from mesh data
  95162. * @param mesh defines the source mesh
  95163. * @param name defines the name to use for the new target
  95164. * @param influence defines the influence to attach to the target
  95165. * @returns a new MorphTarget
  95166. */
  95167. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95168. }
  95169. }
  95170. declare module BABYLON {
  95171. /**
  95172. * This class is used to deform meshes using morphing between different targets
  95173. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95174. */
  95175. export class MorphTargetManager {
  95176. private _targets;
  95177. private _targetInfluenceChangedObservers;
  95178. private _targetDataLayoutChangedObservers;
  95179. private _activeTargets;
  95180. private _scene;
  95181. private _influences;
  95182. private _supportsNormals;
  95183. private _supportsTangents;
  95184. private _supportsUVs;
  95185. private _vertexCount;
  95186. private _uniqueId;
  95187. private _tempInfluences;
  95188. /**
  95189. * Gets or sets a boolean indicating if normals must be morphed
  95190. */
  95191. enableNormalMorphing: boolean;
  95192. /**
  95193. * Gets or sets a boolean indicating if tangents must be morphed
  95194. */
  95195. enableTangentMorphing: boolean;
  95196. /**
  95197. * Gets or sets a boolean indicating if UV must be morphed
  95198. */
  95199. enableUVMorphing: boolean;
  95200. /**
  95201. * Creates a new MorphTargetManager
  95202. * @param scene defines the current scene
  95203. */
  95204. constructor(scene?: Nullable<Scene>);
  95205. /**
  95206. * Gets the unique ID of this manager
  95207. */
  95208. get uniqueId(): number;
  95209. /**
  95210. * Gets the number of vertices handled by this manager
  95211. */
  95212. get vertexCount(): number;
  95213. /**
  95214. * Gets a boolean indicating if this manager supports morphing of normals
  95215. */
  95216. get supportsNormals(): boolean;
  95217. /**
  95218. * Gets a boolean indicating if this manager supports morphing of tangents
  95219. */
  95220. get supportsTangents(): boolean;
  95221. /**
  95222. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  95223. */
  95224. get supportsUVs(): boolean;
  95225. /**
  95226. * Gets the number of targets stored in this manager
  95227. */
  95228. get numTargets(): number;
  95229. /**
  95230. * Gets the number of influencers (ie. the number of targets with influences > 0)
  95231. */
  95232. get numInfluencers(): number;
  95233. /**
  95234. * Gets the list of influences (one per target)
  95235. */
  95236. get influences(): Float32Array;
  95237. /**
  95238. * Gets the active target at specified index. An active target is a target with an influence > 0
  95239. * @param index defines the index to check
  95240. * @returns the requested target
  95241. */
  95242. getActiveTarget(index: number): MorphTarget;
  95243. /**
  95244. * Gets the target at specified index
  95245. * @param index defines the index to check
  95246. * @returns the requested target
  95247. */
  95248. getTarget(index: number): MorphTarget;
  95249. /**
  95250. * Add a new target to this manager
  95251. * @param target defines the target to add
  95252. */
  95253. addTarget(target: MorphTarget): void;
  95254. /**
  95255. * Removes a target from the manager
  95256. * @param target defines the target to remove
  95257. */
  95258. removeTarget(target: MorphTarget): void;
  95259. /**
  95260. * Clone the current manager
  95261. * @returns a new MorphTargetManager
  95262. */
  95263. clone(): MorphTargetManager;
  95264. /**
  95265. * Serializes the current manager into a Serialization object
  95266. * @returns the serialized object
  95267. */
  95268. serialize(): any;
  95269. private _syncActiveTargets;
  95270. /**
  95271. * Syncrhonize the targets with all the meshes using this morph target manager
  95272. */
  95273. synchronize(): void;
  95274. /**
  95275. * Creates a new MorphTargetManager from serialized data
  95276. * @param serializationObject defines the serialized data
  95277. * @param scene defines the hosting scene
  95278. * @returns the new MorphTargetManager
  95279. */
  95280. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  95281. }
  95282. }
  95283. declare module BABYLON {
  95284. /**
  95285. * Class used to represent a specific level of detail of a mesh
  95286. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95287. */
  95288. export class MeshLODLevel {
  95289. /** Defines the distance where this level should start being displayed */
  95290. distance: number;
  95291. /** Defines the mesh to use to render this level */
  95292. mesh: Nullable<Mesh>;
  95293. /**
  95294. * Creates a new LOD level
  95295. * @param distance defines the distance where this level should star being displayed
  95296. * @param mesh defines the mesh to use to render this level
  95297. */
  95298. constructor(
  95299. /** Defines the distance where this level should start being displayed */
  95300. distance: number,
  95301. /** Defines the mesh to use to render this level */
  95302. mesh: Nullable<Mesh>);
  95303. }
  95304. }
  95305. declare module BABYLON {
  95306. /**
  95307. * Mesh representing the gorund
  95308. */
  95309. export class GroundMesh extends Mesh {
  95310. /** If octree should be generated */
  95311. generateOctree: boolean;
  95312. private _heightQuads;
  95313. /** @hidden */
  95314. _subdivisionsX: number;
  95315. /** @hidden */
  95316. _subdivisionsY: number;
  95317. /** @hidden */
  95318. _width: number;
  95319. /** @hidden */
  95320. _height: number;
  95321. /** @hidden */
  95322. _minX: number;
  95323. /** @hidden */
  95324. _maxX: number;
  95325. /** @hidden */
  95326. _minZ: number;
  95327. /** @hidden */
  95328. _maxZ: number;
  95329. constructor(name: string, scene: Scene);
  95330. /**
  95331. * "GroundMesh"
  95332. * @returns "GroundMesh"
  95333. */
  95334. getClassName(): string;
  95335. /**
  95336. * The minimum of x and y subdivisions
  95337. */
  95338. get subdivisions(): number;
  95339. /**
  95340. * X subdivisions
  95341. */
  95342. get subdivisionsX(): number;
  95343. /**
  95344. * Y subdivisions
  95345. */
  95346. get subdivisionsY(): number;
  95347. /**
  95348. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  95349. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95350. * @param chunksCount the number of subdivisions for x and y
  95351. * @param octreeBlocksSize (Default: 32)
  95352. */
  95353. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  95354. /**
  95355. * Returns a height (y) value in the Worl system :
  95356. * the ground altitude at the coordinates (x, z) expressed in the World system.
  95357. * @param x x coordinate
  95358. * @param z z coordinate
  95359. * @returns the ground y position if (x, z) are outside the ground surface.
  95360. */
  95361. getHeightAtCoordinates(x: number, z: number): number;
  95362. /**
  95363. * Returns a normalized vector (Vector3) orthogonal to the ground
  95364. * at the ground coordinates (x, z) expressed in the World system.
  95365. * @param x x coordinate
  95366. * @param z z coordinate
  95367. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  95368. */
  95369. getNormalAtCoordinates(x: number, z: number): Vector3;
  95370. /**
  95371. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  95372. * at the ground coordinates (x, z) expressed in the World system.
  95373. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  95374. * @param x x coordinate
  95375. * @param z z coordinate
  95376. * @param ref vector to store the result
  95377. * @returns the GroundMesh.
  95378. */
  95379. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  95380. /**
  95381. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  95382. * if the ground has been updated.
  95383. * This can be used in the render loop.
  95384. * @returns the GroundMesh.
  95385. */
  95386. updateCoordinateHeights(): GroundMesh;
  95387. private _getFacetAt;
  95388. private _initHeightQuads;
  95389. private _computeHeightQuads;
  95390. /**
  95391. * Serializes this ground mesh
  95392. * @param serializationObject object to write serialization to
  95393. */
  95394. serialize(serializationObject: any): void;
  95395. /**
  95396. * Parses a serialized ground mesh
  95397. * @param parsedMesh the serialized mesh
  95398. * @param scene the scene to create the ground mesh in
  95399. * @returns the created ground mesh
  95400. */
  95401. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  95402. }
  95403. }
  95404. declare module BABYLON {
  95405. /**
  95406. * Interface for Physics-Joint data
  95407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95408. */
  95409. export interface PhysicsJointData {
  95410. /**
  95411. * The main pivot of the joint
  95412. */
  95413. mainPivot?: Vector3;
  95414. /**
  95415. * The connected pivot of the joint
  95416. */
  95417. connectedPivot?: Vector3;
  95418. /**
  95419. * The main axis of the joint
  95420. */
  95421. mainAxis?: Vector3;
  95422. /**
  95423. * The connected axis of the joint
  95424. */
  95425. connectedAxis?: Vector3;
  95426. /**
  95427. * The collision of the joint
  95428. */
  95429. collision?: boolean;
  95430. /**
  95431. * Native Oimo/Cannon/Energy data
  95432. */
  95433. nativeParams?: any;
  95434. }
  95435. /**
  95436. * This is a holder class for the physics joint created by the physics plugin
  95437. * It holds a set of functions to control the underlying joint
  95438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95439. */
  95440. export class PhysicsJoint {
  95441. /**
  95442. * The type of the physics joint
  95443. */
  95444. type: number;
  95445. /**
  95446. * The data for the physics joint
  95447. */
  95448. jointData: PhysicsJointData;
  95449. private _physicsJoint;
  95450. protected _physicsPlugin: IPhysicsEnginePlugin;
  95451. /**
  95452. * Initializes the physics joint
  95453. * @param type The type of the physics joint
  95454. * @param jointData The data for the physics joint
  95455. */
  95456. constructor(
  95457. /**
  95458. * The type of the physics joint
  95459. */
  95460. type: number,
  95461. /**
  95462. * The data for the physics joint
  95463. */
  95464. jointData: PhysicsJointData);
  95465. /**
  95466. * Gets the physics joint
  95467. */
  95468. get physicsJoint(): any;
  95469. /**
  95470. * Sets the physics joint
  95471. */
  95472. set physicsJoint(newJoint: any);
  95473. /**
  95474. * Sets the physics plugin
  95475. */
  95476. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  95477. /**
  95478. * Execute a function that is physics-plugin specific.
  95479. * @param {Function} func the function that will be executed.
  95480. * It accepts two parameters: the physics world and the physics joint
  95481. */
  95482. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  95483. /**
  95484. * Distance-Joint type
  95485. */
  95486. static DistanceJoint: number;
  95487. /**
  95488. * Hinge-Joint type
  95489. */
  95490. static HingeJoint: number;
  95491. /**
  95492. * Ball-and-Socket joint type
  95493. */
  95494. static BallAndSocketJoint: number;
  95495. /**
  95496. * Wheel-Joint type
  95497. */
  95498. static WheelJoint: number;
  95499. /**
  95500. * Slider-Joint type
  95501. */
  95502. static SliderJoint: number;
  95503. /**
  95504. * Prismatic-Joint type
  95505. */
  95506. static PrismaticJoint: number;
  95507. /**
  95508. * Universal-Joint type
  95509. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  95510. */
  95511. static UniversalJoint: number;
  95512. /**
  95513. * Hinge-Joint 2 type
  95514. */
  95515. static Hinge2Joint: number;
  95516. /**
  95517. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  95518. */
  95519. static PointToPointJoint: number;
  95520. /**
  95521. * Spring-Joint type
  95522. */
  95523. static SpringJoint: number;
  95524. /**
  95525. * Lock-Joint type
  95526. */
  95527. static LockJoint: number;
  95528. }
  95529. /**
  95530. * A class representing a physics distance joint
  95531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95532. */
  95533. export class DistanceJoint extends PhysicsJoint {
  95534. /**
  95535. *
  95536. * @param jointData The data for the Distance-Joint
  95537. */
  95538. constructor(jointData: DistanceJointData);
  95539. /**
  95540. * Update the predefined distance.
  95541. * @param maxDistance The maximum preferred distance
  95542. * @param minDistance The minimum preferred distance
  95543. */
  95544. updateDistance(maxDistance: number, minDistance?: number): void;
  95545. }
  95546. /**
  95547. * Represents a Motor-Enabled Joint
  95548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95549. */
  95550. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  95551. /**
  95552. * Initializes the Motor-Enabled Joint
  95553. * @param type The type of the joint
  95554. * @param jointData The physica joint data for the joint
  95555. */
  95556. constructor(type: number, jointData: PhysicsJointData);
  95557. /**
  95558. * Set the motor values.
  95559. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95560. * @param force the force to apply
  95561. * @param maxForce max force for this motor.
  95562. */
  95563. setMotor(force?: number, maxForce?: number): void;
  95564. /**
  95565. * Set the motor's limits.
  95566. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95567. * @param upperLimit The upper limit of the motor
  95568. * @param lowerLimit The lower limit of the motor
  95569. */
  95570. setLimit(upperLimit: number, lowerLimit?: number): void;
  95571. }
  95572. /**
  95573. * This class represents a single physics Hinge-Joint
  95574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95575. */
  95576. export class HingeJoint extends MotorEnabledJoint {
  95577. /**
  95578. * Initializes the Hinge-Joint
  95579. * @param jointData The joint data for the Hinge-Joint
  95580. */
  95581. constructor(jointData: PhysicsJointData);
  95582. /**
  95583. * Set the motor values.
  95584. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95585. * @param {number} force the force to apply
  95586. * @param {number} maxForce max force for this motor.
  95587. */
  95588. setMotor(force?: number, maxForce?: number): void;
  95589. /**
  95590. * Set the motor's limits.
  95591. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95592. * @param upperLimit The upper limit of the motor
  95593. * @param lowerLimit The lower limit of the motor
  95594. */
  95595. setLimit(upperLimit: number, lowerLimit?: number): void;
  95596. }
  95597. /**
  95598. * This class represents a dual hinge physics joint (same as wheel joint)
  95599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95600. */
  95601. export class Hinge2Joint extends MotorEnabledJoint {
  95602. /**
  95603. * Initializes the Hinge2-Joint
  95604. * @param jointData The joint data for the Hinge2-Joint
  95605. */
  95606. constructor(jointData: PhysicsJointData);
  95607. /**
  95608. * Set the motor values.
  95609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95610. * @param {number} targetSpeed the speed the motor is to reach
  95611. * @param {number} maxForce max force for this motor.
  95612. * @param {motorIndex} the motor's index, 0 or 1.
  95613. */
  95614. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  95615. /**
  95616. * Set the motor limits.
  95617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95618. * @param {number} upperLimit the upper limit
  95619. * @param {number} lowerLimit lower limit
  95620. * @param {motorIndex} the motor's index, 0 or 1.
  95621. */
  95622. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95623. }
  95624. /**
  95625. * Interface for a motor enabled joint
  95626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95627. */
  95628. export interface IMotorEnabledJoint {
  95629. /**
  95630. * Physics joint
  95631. */
  95632. physicsJoint: any;
  95633. /**
  95634. * Sets the motor of the motor-enabled joint
  95635. * @param force The force of the motor
  95636. * @param maxForce The maximum force of the motor
  95637. * @param motorIndex The index of the motor
  95638. */
  95639. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  95640. /**
  95641. * Sets the limit of the motor
  95642. * @param upperLimit The upper limit of the motor
  95643. * @param lowerLimit The lower limit of the motor
  95644. * @param motorIndex The index of the motor
  95645. */
  95646. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95647. }
  95648. /**
  95649. * Joint data for a Distance-Joint
  95650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95651. */
  95652. export interface DistanceJointData extends PhysicsJointData {
  95653. /**
  95654. * Max distance the 2 joint objects can be apart
  95655. */
  95656. maxDistance: number;
  95657. }
  95658. /**
  95659. * Joint data from a spring joint
  95660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95661. */
  95662. export interface SpringJointData extends PhysicsJointData {
  95663. /**
  95664. * Length of the spring
  95665. */
  95666. length: number;
  95667. /**
  95668. * Stiffness of the spring
  95669. */
  95670. stiffness: number;
  95671. /**
  95672. * Damping of the spring
  95673. */
  95674. damping: number;
  95675. /** this callback will be called when applying the force to the impostors. */
  95676. forceApplicationCallback: () => void;
  95677. }
  95678. }
  95679. declare module BABYLON {
  95680. /**
  95681. * Holds the data for the raycast result
  95682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95683. */
  95684. export class PhysicsRaycastResult {
  95685. private _hasHit;
  95686. private _hitDistance;
  95687. private _hitNormalWorld;
  95688. private _hitPointWorld;
  95689. private _rayFromWorld;
  95690. private _rayToWorld;
  95691. /**
  95692. * Gets if there was a hit
  95693. */
  95694. get hasHit(): boolean;
  95695. /**
  95696. * Gets the distance from the hit
  95697. */
  95698. get hitDistance(): number;
  95699. /**
  95700. * Gets the hit normal/direction in the world
  95701. */
  95702. get hitNormalWorld(): Vector3;
  95703. /**
  95704. * Gets the hit point in the world
  95705. */
  95706. get hitPointWorld(): Vector3;
  95707. /**
  95708. * Gets the ray "start point" of the ray in the world
  95709. */
  95710. get rayFromWorld(): Vector3;
  95711. /**
  95712. * Gets the ray "end point" of the ray in the world
  95713. */
  95714. get rayToWorld(): Vector3;
  95715. /**
  95716. * Sets the hit data (normal & point in world space)
  95717. * @param hitNormalWorld defines the normal in world space
  95718. * @param hitPointWorld defines the point in world space
  95719. */
  95720. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  95721. /**
  95722. * Sets the distance from the start point to the hit point
  95723. * @param distance
  95724. */
  95725. setHitDistance(distance: number): void;
  95726. /**
  95727. * Calculates the distance manually
  95728. */
  95729. calculateHitDistance(): void;
  95730. /**
  95731. * Resets all the values to default
  95732. * @param from The from point on world space
  95733. * @param to The to point on world space
  95734. */
  95735. reset(from?: Vector3, to?: Vector3): void;
  95736. }
  95737. /**
  95738. * Interface for the size containing width and height
  95739. */
  95740. interface IXYZ {
  95741. /**
  95742. * X
  95743. */
  95744. x: number;
  95745. /**
  95746. * Y
  95747. */
  95748. y: number;
  95749. /**
  95750. * Z
  95751. */
  95752. z: number;
  95753. }
  95754. }
  95755. declare module BABYLON {
  95756. /**
  95757. * Interface used to describe a physics joint
  95758. */
  95759. export interface PhysicsImpostorJoint {
  95760. /** Defines the main impostor to which the joint is linked */
  95761. mainImpostor: PhysicsImpostor;
  95762. /** Defines the impostor that is connected to the main impostor using this joint */
  95763. connectedImpostor: PhysicsImpostor;
  95764. /** Defines the joint itself */
  95765. joint: PhysicsJoint;
  95766. }
  95767. /** @hidden */
  95768. export interface IPhysicsEnginePlugin {
  95769. world: any;
  95770. name: string;
  95771. setGravity(gravity: Vector3): void;
  95772. setTimeStep(timeStep: number): void;
  95773. getTimeStep(): number;
  95774. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  95775. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95776. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95777. generatePhysicsBody(impostor: PhysicsImpostor): void;
  95778. removePhysicsBody(impostor: PhysicsImpostor): void;
  95779. generateJoint(joint: PhysicsImpostorJoint): void;
  95780. removeJoint(joint: PhysicsImpostorJoint): void;
  95781. isSupported(): boolean;
  95782. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  95783. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  95784. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95785. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95786. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95787. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95788. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  95789. getBodyMass(impostor: PhysicsImpostor): number;
  95790. getBodyFriction(impostor: PhysicsImpostor): number;
  95791. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  95792. getBodyRestitution(impostor: PhysicsImpostor): number;
  95793. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  95794. getBodyPressure?(impostor: PhysicsImpostor): number;
  95795. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  95796. getBodyStiffness?(impostor: PhysicsImpostor): number;
  95797. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  95798. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  95799. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  95800. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  95801. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  95802. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95803. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95804. sleepBody(impostor: PhysicsImpostor): void;
  95805. wakeUpBody(impostor: PhysicsImpostor): void;
  95806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95807. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  95808. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  95809. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95810. getRadius(impostor: PhysicsImpostor): number;
  95811. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  95812. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  95813. dispose(): void;
  95814. }
  95815. /**
  95816. * Interface used to define a physics engine
  95817. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  95818. */
  95819. export interface IPhysicsEngine {
  95820. /**
  95821. * Gets the gravity vector used by the simulation
  95822. */
  95823. gravity: Vector3;
  95824. /**
  95825. * Sets the gravity vector used by the simulation
  95826. * @param gravity defines the gravity vector to use
  95827. */
  95828. setGravity(gravity: Vector3): void;
  95829. /**
  95830. * Set the time step of the physics engine.
  95831. * Default is 1/60.
  95832. * To slow it down, enter 1/600 for example.
  95833. * To speed it up, 1/30
  95834. * @param newTimeStep the new timestep to apply to this world.
  95835. */
  95836. setTimeStep(newTimeStep: number): void;
  95837. /**
  95838. * Get the time step of the physics engine.
  95839. * @returns the current time step
  95840. */
  95841. getTimeStep(): number;
  95842. /**
  95843. * Set the sub time step of the physics engine.
  95844. * Default is 0 meaning there is no sub steps
  95845. * To increase physics resolution precision, set a small value (like 1 ms)
  95846. * @param subTimeStep defines the new sub timestep used for physics resolution.
  95847. */
  95848. setSubTimeStep(subTimeStep: number): void;
  95849. /**
  95850. * Get the sub time step of the physics engine.
  95851. * @returns the current sub time step
  95852. */
  95853. getSubTimeStep(): number;
  95854. /**
  95855. * Release all resources
  95856. */
  95857. dispose(): void;
  95858. /**
  95859. * Gets the name of the current physics plugin
  95860. * @returns the name of the plugin
  95861. */
  95862. getPhysicsPluginName(): string;
  95863. /**
  95864. * Adding a new impostor for the impostor tracking.
  95865. * This will be done by the impostor itself.
  95866. * @param impostor the impostor to add
  95867. */
  95868. addImpostor(impostor: PhysicsImpostor): void;
  95869. /**
  95870. * Remove an impostor from the engine.
  95871. * This impostor and its mesh will not longer be updated by the physics engine.
  95872. * @param impostor the impostor to remove
  95873. */
  95874. removeImpostor(impostor: PhysicsImpostor): void;
  95875. /**
  95876. * Add a joint to the physics engine
  95877. * @param mainImpostor defines the main impostor to which the joint is added.
  95878. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  95879. * @param joint defines the joint that will connect both impostors.
  95880. */
  95881. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  95882. /**
  95883. * Removes a joint from the simulation
  95884. * @param mainImpostor defines the impostor used with the joint
  95885. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  95886. * @param joint defines the joint to remove
  95887. */
  95888. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  95889. /**
  95890. * Gets the current plugin used to run the simulation
  95891. * @returns current plugin
  95892. */
  95893. getPhysicsPlugin(): IPhysicsEnginePlugin;
  95894. /**
  95895. * Gets the list of physic impostors
  95896. * @returns an array of PhysicsImpostor
  95897. */
  95898. getImpostors(): Array<PhysicsImpostor>;
  95899. /**
  95900. * Gets the impostor for a physics enabled object
  95901. * @param object defines the object impersonated by the impostor
  95902. * @returns the PhysicsImpostor or null if not found
  95903. */
  95904. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  95905. /**
  95906. * Gets the impostor for a physics body object
  95907. * @param body defines physics body used by the impostor
  95908. * @returns the PhysicsImpostor or null if not found
  95909. */
  95910. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  95911. /**
  95912. * Does a raycast in the physics world
  95913. * @param from when should the ray start?
  95914. * @param to when should the ray end?
  95915. * @returns PhysicsRaycastResult
  95916. */
  95917. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95918. /**
  95919. * Called by the scene. No need to call it.
  95920. * @param delta defines the timespam between frames
  95921. */
  95922. _step(delta: number): void;
  95923. }
  95924. }
  95925. declare module BABYLON {
  95926. /**
  95927. * The interface for the physics imposter parameters
  95928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95929. */
  95930. export interface PhysicsImpostorParameters {
  95931. /**
  95932. * The mass of the physics imposter
  95933. */
  95934. mass: number;
  95935. /**
  95936. * The friction of the physics imposter
  95937. */
  95938. friction?: number;
  95939. /**
  95940. * The coefficient of restitution of the physics imposter
  95941. */
  95942. restitution?: number;
  95943. /**
  95944. * The native options of the physics imposter
  95945. */
  95946. nativeOptions?: any;
  95947. /**
  95948. * Specifies if the parent should be ignored
  95949. */
  95950. ignoreParent?: boolean;
  95951. /**
  95952. * Specifies if bi-directional transformations should be disabled
  95953. */
  95954. disableBidirectionalTransformation?: boolean;
  95955. /**
  95956. * The pressure inside the physics imposter, soft object only
  95957. */
  95958. pressure?: number;
  95959. /**
  95960. * The stiffness the physics imposter, soft object only
  95961. */
  95962. stiffness?: number;
  95963. /**
  95964. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  95965. */
  95966. velocityIterations?: number;
  95967. /**
  95968. * The number of iterations used in maintaining consistent vertex positions, soft object only
  95969. */
  95970. positionIterations?: number;
  95971. /**
  95972. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  95973. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  95974. * Add to fix multiple points
  95975. */
  95976. fixedPoints?: number;
  95977. /**
  95978. * The collision margin around a soft object
  95979. */
  95980. margin?: number;
  95981. /**
  95982. * The collision margin around a soft object
  95983. */
  95984. damping?: number;
  95985. /**
  95986. * The path for a rope based on an extrusion
  95987. */
  95988. path?: any;
  95989. /**
  95990. * The shape of an extrusion used for a rope based on an extrusion
  95991. */
  95992. shape?: any;
  95993. }
  95994. /**
  95995. * Interface for a physics-enabled object
  95996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95997. */
  95998. export interface IPhysicsEnabledObject {
  95999. /**
  96000. * The position of the physics-enabled object
  96001. */
  96002. position: Vector3;
  96003. /**
  96004. * The rotation of the physics-enabled object
  96005. */
  96006. rotationQuaternion: Nullable<Quaternion>;
  96007. /**
  96008. * The scale of the physics-enabled object
  96009. */
  96010. scaling: Vector3;
  96011. /**
  96012. * The rotation of the physics-enabled object
  96013. */
  96014. rotation?: Vector3;
  96015. /**
  96016. * The parent of the physics-enabled object
  96017. */
  96018. parent?: any;
  96019. /**
  96020. * The bounding info of the physics-enabled object
  96021. * @returns The bounding info of the physics-enabled object
  96022. */
  96023. getBoundingInfo(): BoundingInfo;
  96024. /**
  96025. * Computes the world matrix
  96026. * @param force Specifies if the world matrix should be computed by force
  96027. * @returns A world matrix
  96028. */
  96029. computeWorldMatrix(force: boolean): Matrix;
  96030. /**
  96031. * Gets the world matrix
  96032. * @returns A world matrix
  96033. */
  96034. getWorldMatrix?(): Matrix;
  96035. /**
  96036. * Gets the child meshes
  96037. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96038. * @returns An array of abstract meshes
  96039. */
  96040. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96041. /**
  96042. * Gets the vertex data
  96043. * @param kind The type of vertex data
  96044. * @returns A nullable array of numbers, or a float32 array
  96045. */
  96046. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96047. /**
  96048. * Gets the indices from the mesh
  96049. * @returns A nullable array of index arrays
  96050. */
  96051. getIndices?(): Nullable<IndicesArray>;
  96052. /**
  96053. * Gets the scene from the mesh
  96054. * @returns the indices array or null
  96055. */
  96056. getScene?(): Scene;
  96057. /**
  96058. * Gets the absolute position from the mesh
  96059. * @returns the absolute position
  96060. */
  96061. getAbsolutePosition(): Vector3;
  96062. /**
  96063. * Gets the absolute pivot point from the mesh
  96064. * @returns the absolute pivot point
  96065. */
  96066. getAbsolutePivotPoint(): Vector3;
  96067. /**
  96068. * Rotates the mesh
  96069. * @param axis The axis of rotation
  96070. * @param amount The amount of rotation
  96071. * @param space The space of the rotation
  96072. * @returns The rotation transform node
  96073. */
  96074. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96075. /**
  96076. * Translates the mesh
  96077. * @param axis The axis of translation
  96078. * @param distance The distance of translation
  96079. * @param space The space of the translation
  96080. * @returns The transform node
  96081. */
  96082. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96083. /**
  96084. * Sets the absolute position of the mesh
  96085. * @param absolutePosition The absolute position of the mesh
  96086. * @returns The transform node
  96087. */
  96088. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96089. /**
  96090. * Gets the class name of the mesh
  96091. * @returns The class name
  96092. */
  96093. getClassName(): string;
  96094. }
  96095. /**
  96096. * Represents a physics imposter
  96097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96098. */
  96099. export class PhysicsImpostor {
  96100. /**
  96101. * The physics-enabled object used as the physics imposter
  96102. */
  96103. object: IPhysicsEnabledObject;
  96104. /**
  96105. * The type of the physics imposter
  96106. */
  96107. type: number;
  96108. private _options;
  96109. private _scene?;
  96110. /**
  96111. * The default object size of the imposter
  96112. */
  96113. static DEFAULT_OBJECT_SIZE: Vector3;
  96114. /**
  96115. * The identity quaternion of the imposter
  96116. */
  96117. static IDENTITY_QUATERNION: Quaternion;
  96118. /** @hidden */
  96119. _pluginData: any;
  96120. private _physicsEngine;
  96121. private _physicsBody;
  96122. private _bodyUpdateRequired;
  96123. private _onBeforePhysicsStepCallbacks;
  96124. private _onAfterPhysicsStepCallbacks;
  96125. /** @hidden */
  96126. _onPhysicsCollideCallbacks: Array<{
  96127. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96128. otherImpostors: Array<PhysicsImpostor>;
  96129. }>;
  96130. private _deltaPosition;
  96131. private _deltaRotation;
  96132. private _deltaRotationConjugated;
  96133. /** @hidden */
  96134. _isFromLine: boolean;
  96135. private _parent;
  96136. private _isDisposed;
  96137. private static _tmpVecs;
  96138. private static _tmpQuat;
  96139. /**
  96140. * Specifies if the physics imposter is disposed
  96141. */
  96142. get isDisposed(): boolean;
  96143. /**
  96144. * Gets the mass of the physics imposter
  96145. */
  96146. get mass(): number;
  96147. set mass(value: number);
  96148. /**
  96149. * Gets the coefficient of friction
  96150. */
  96151. get friction(): number;
  96152. /**
  96153. * Sets the coefficient of friction
  96154. */
  96155. set friction(value: number);
  96156. /**
  96157. * Gets the coefficient of restitution
  96158. */
  96159. get restitution(): number;
  96160. /**
  96161. * Sets the coefficient of restitution
  96162. */
  96163. set restitution(value: number);
  96164. /**
  96165. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96166. */
  96167. get pressure(): number;
  96168. /**
  96169. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96170. */
  96171. set pressure(value: number);
  96172. /**
  96173. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96174. */
  96175. get stiffness(): number;
  96176. /**
  96177. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96178. */
  96179. set stiffness(value: number);
  96180. /**
  96181. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96182. */
  96183. get velocityIterations(): number;
  96184. /**
  96185. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96186. */
  96187. set velocityIterations(value: number);
  96188. /**
  96189. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96190. */
  96191. get positionIterations(): number;
  96192. /**
  96193. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96194. */
  96195. set positionIterations(value: number);
  96196. /**
  96197. * The unique id of the physics imposter
  96198. * set by the physics engine when adding this impostor to the array
  96199. */
  96200. uniqueId: number;
  96201. /**
  96202. * @hidden
  96203. */
  96204. soft: boolean;
  96205. /**
  96206. * @hidden
  96207. */
  96208. segments: number;
  96209. private _joints;
  96210. /**
  96211. * Initializes the physics imposter
  96212. * @param object The physics-enabled object used as the physics imposter
  96213. * @param type The type of the physics imposter
  96214. * @param _options The options for the physics imposter
  96215. * @param _scene The Babylon scene
  96216. */
  96217. constructor(
  96218. /**
  96219. * The physics-enabled object used as the physics imposter
  96220. */
  96221. object: IPhysicsEnabledObject,
  96222. /**
  96223. * The type of the physics imposter
  96224. */
  96225. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  96226. /**
  96227. * This function will completly initialize this impostor.
  96228. * It will create a new body - but only if this mesh has no parent.
  96229. * If it has, this impostor will not be used other than to define the impostor
  96230. * of the child mesh.
  96231. * @hidden
  96232. */
  96233. _init(): void;
  96234. private _getPhysicsParent;
  96235. /**
  96236. * Should a new body be generated.
  96237. * @returns boolean specifying if body initialization is required
  96238. */
  96239. isBodyInitRequired(): boolean;
  96240. /**
  96241. * Sets the updated scaling
  96242. * @param updated Specifies if the scaling is updated
  96243. */
  96244. setScalingUpdated(): void;
  96245. /**
  96246. * Force a regeneration of this or the parent's impostor's body.
  96247. * Use under cautious - This will remove all joints already implemented.
  96248. */
  96249. forceUpdate(): void;
  96250. /**
  96251. * Gets the body that holds this impostor. Either its own, or its parent.
  96252. */
  96253. get physicsBody(): any;
  96254. /**
  96255. * Get the parent of the physics imposter
  96256. * @returns Physics imposter or null
  96257. */
  96258. get parent(): Nullable<PhysicsImpostor>;
  96259. /**
  96260. * Sets the parent of the physics imposter
  96261. */
  96262. set parent(value: Nullable<PhysicsImpostor>);
  96263. /**
  96264. * Set the physics body. Used mainly by the physics engine/plugin
  96265. */
  96266. set physicsBody(physicsBody: any);
  96267. /**
  96268. * Resets the update flags
  96269. */
  96270. resetUpdateFlags(): void;
  96271. /**
  96272. * Gets the object extend size
  96273. * @returns the object extend size
  96274. */
  96275. getObjectExtendSize(): Vector3;
  96276. /**
  96277. * Gets the object center
  96278. * @returns The object center
  96279. */
  96280. getObjectCenter(): Vector3;
  96281. /**
  96282. * Get a specific parameter from the options parameters
  96283. * @param paramName The object parameter name
  96284. * @returns The object parameter
  96285. */
  96286. getParam(paramName: string): any;
  96287. /**
  96288. * Sets a specific parameter in the options given to the physics plugin
  96289. * @param paramName The parameter name
  96290. * @param value The value of the parameter
  96291. */
  96292. setParam(paramName: string, value: number): void;
  96293. /**
  96294. * Specifically change the body's mass option. Won't recreate the physics body object
  96295. * @param mass The mass of the physics imposter
  96296. */
  96297. setMass(mass: number): void;
  96298. /**
  96299. * Gets the linear velocity
  96300. * @returns linear velocity or null
  96301. */
  96302. getLinearVelocity(): Nullable<Vector3>;
  96303. /**
  96304. * Sets the linear velocity
  96305. * @param velocity linear velocity or null
  96306. */
  96307. setLinearVelocity(velocity: Nullable<Vector3>): void;
  96308. /**
  96309. * Gets the angular velocity
  96310. * @returns angular velocity or null
  96311. */
  96312. getAngularVelocity(): Nullable<Vector3>;
  96313. /**
  96314. * Sets the angular velocity
  96315. * @param velocity The velocity or null
  96316. */
  96317. setAngularVelocity(velocity: Nullable<Vector3>): void;
  96318. /**
  96319. * Execute a function with the physics plugin native code
  96320. * Provide a function the will have two variables - the world object and the physics body object
  96321. * @param func The function to execute with the physics plugin native code
  96322. */
  96323. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  96324. /**
  96325. * Register a function that will be executed before the physics world is stepping forward
  96326. * @param func The function to execute before the physics world is stepped forward
  96327. */
  96328. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96329. /**
  96330. * Unregister a function that will be executed before the physics world is stepping forward
  96331. * @param func The function to execute before the physics world is stepped forward
  96332. */
  96333. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96334. /**
  96335. * Register a function that will be executed after the physics step
  96336. * @param func The function to execute after physics step
  96337. */
  96338. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96339. /**
  96340. * Unregisters a function that will be executed after the physics step
  96341. * @param func The function to execute after physics step
  96342. */
  96343. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96344. /**
  96345. * register a function that will be executed when this impostor collides against a different body
  96346. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  96347. * @param func Callback that is executed on collision
  96348. */
  96349. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  96350. /**
  96351. * Unregisters the physics imposter on contact
  96352. * @param collideAgainst The physics object to collide against
  96353. * @param func Callback to execute on collision
  96354. */
  96355. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  96356. private _tmpQuat;
  96357. private _tmpQuat2;
  96358. /**
  96359. * Get the parent rotation
  96360. * @returns The parent rotation
  96361. */
  96362. getParentsRotation(): Quaternion;
  96363. /**
  96364. * this function is executed by the physics engine.
  96365. */
  96366. beforeStep: () => void;
  96367. /**
  96368. * this function is executed by the physics engine
  96369. */
  96370. afterStep: () => void;
  96371. /**
  96372. * Legacy collision detection event support
  96373. */
  96374. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  96375. /**
  96376. * event and body object due to cannon's event-based architecture.
  96377. */
  96378. onCollide: (e: {
  96379. body: any;
  96380. }) => void;
  96381. /**
  96382. * Apply a force
  96383. * @param force The force to apply
  96384. * @param contactPoint The contact point for the force
  96385. * @returns The physics imposter
  96386. */
  96387. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96388. /**
  96389. * Apply an impulse
  96390. * @param force The impulse force
  96391. * @param contactPoint The contact point for the impulse force
  96392. * @returns The physics imposter
  96393. */
  96394. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96395. /**
  96396. * A help function to create a joint
  96397. * @param otherImpostor A physics imposter used to create a joint
  96398. * @param jointType The type of joint
  96399. * @param jointData The data for the joint
  96400. * @returns The physics imposter
  96401. */
  96402. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  96403. /**
  96404. * Add a joint to this impostor with a different impostor
  96405. * @param otherImpostor A physics imposter used to add a joint
  96406. * @param joint The joint to add
  96407. * @returns The physics imposter
  96408. */
  96409. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  96410. /**
  96411. * Add an anchor to a cloth impostor
  96412. * @param otherImpostor rigid impostor to anchor to
  96413. * @param width ratio across width from 0 to 1
  96414. * @param height ratio up height from 0 to 1
  96415. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  96416. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  96417. * @returns impostor the soft imposter
  96418. */
  96419. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96420. /**
  96421. * Add a hook to a rope impostor
  96422. * @param otherImpostor rigid impostor to anchor to
  96423. * @param length ratio across rope from 0 to 1
  96424. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  96425. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  96426. * @returns impostor the rope imposter
  96427. */
  96428. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96429. /**
  96430. * Will keep this body still, in a sleep mode.
  96431. * @returns the physics imposter
  96432. */
  96433. sleep(): PhysicsImpostor;
  96434. /**
  96435. * Wake the body up.
  96436. * @returns The physics imposter
  96437. */
  96438. wakeUp(): PhysicsImpostor;
  96439. /**
  96440. * Clones the physics imposter
  96441. * @param newObject The physics imposter clones to this physics-enabled object
  96442. * @returns A nullable physics imposter
  96443. */
  96444. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96445. /**
  96446. * Disposes the physics imposter
  96447. */
  96448. dispose(): void;
  96449. /**
  96450. * Sets the delta position
  96451. * @param position The delta position amount
  96452. */
  96453. setDeltaPosition(position: Vector3): void;
  96454. /**
  96455. * Sets the delta rotation
  96456. * @param rotation The delta rotation amount
  96457. */
  96458. setDeltaRotation(rotation: Quaternion): void;
  96459. /**
  96460. * Gets the box size of the physics imposter and stores the result in the input parameter
  96461. * @param result Stores the box size
  96462. * @returns The physics imposter
  96463. */
  96464. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  96465. /**
  96466. * Gets the radius of the physics imposter
  96467. * @returns Radius of the physics imposter
  96468. */
  96469. getRadius(): number;
  96470. /**
  96471. * Sync a bone with this impostor
  96472. * @param bone The bone to sync to the impostor.
  96473. * @param boneMesh The mesh that the bone is influencing.
  96474. * @param jointPivot The pivot of the joint / bone in local space.
  96475. * @param distToJoint Optional distance from the impostor to the joint.
  96476. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96477. */
  96478. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  96479. /**
  96480. * Sync impostor to a bone
  96481. * @param bone The bone that the impostor will be synced to.
  96482. * @param boneMesh The mesh that the bone is influencing.
  96483. * @param jointPivot The pivot of the joint / bone in local space.
  96484. * @param distToJoint Optional distance from the impostor to the joint.
  96485. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96486. * @param boneAxis Optional vector3 axis the bone is aligned with
  96487. */
  96488. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  96489. /**
  96490. * No-Imposter type
  96491. */
  96492. static NoImpostor: number;
  96493. /**
  96494. * Sphere-Imposter type
  96495. */
  96496. static SphereImpostor: number;
  96497. /**
  96498. * Box-Imposter type
  96499. */
  96500. static BoxImpostor: number;
  96501. /**
  96502. * Plane-Imposter type
  96503. */
  96504. static PlaneImpostor: number;
  96505. /**
  96506. * Mesh-imposter type
  96507. */
  96508. static MeshImpostor: number;
  96509. /**
  96510. * Capsule-Impostor type (Ammo.js plugin only)
  96511. */
  96512. static CapsuleImpostor: number;
  96513. /**
  96514. * Cylinder-Imposter type
  96515. */
  96516. static CylinderImpostor: number;
  96517. /**
  96518. * Particle-Imposter type
  96519. */
  96520. static ParticleImpostor: number;
  96521. /**
  96522. * Heightmap-Imposter type
  96523. */
  96524. static HeightmapImpostor: number;
  96525. /**
  96526. * ConvexHull-Impostor type (Ammo.js plugin only)
  96527. */
  96528. static ConvexHullImpostor: number;
  96529. /**
  96530. * Custom-Imposter type (Ammo.js plugin only)
  96531. */
  96532. static CustomImpostor: number;
  96533. /**
  96534. * Rope-Imposter type
  96535. */
  96536. static RopeImpostor: number;
  96537. /**
  96538. * Cloth-Imposter type
  96539. */
  96540. static ClothImpostor: number;
  96541. /**
  96542. * Softbody-Imposter type
  96543. */
  96544. static SoftbodyImpostor: number;
  96545. }
  96546. }
  96547. declare module BABYLON {
  96548. /**
  96549. * @hidden
  96550. **/
  96551. export class _CreationDataStorage {
  96552. closePath?: boolean;
  96553. closeArray?: boolean;
  96554. idx: number[];
  96555. dashSize: number;
  96556. gapSize: number;
  96557. path3D: Path3D;
  96558. pathArray: Vector3[][];
  96559. arc: number;
  96560. radius: number;
  96561. cap: number;
  96562. tessellation: number;
  96563. }
  96564. /**
  96565. * @hidden
  96566. **/
  96567. class _InstanceDataStorage {
  96568. visibleInstances: any;
  96569. batchCache: _InstancesBatch;
  96570. instancesBufferSize: number;
  96571. instancesBuffer: Nullable<Buffer>;
  96572. instancesData: Float32Array;
  96573. overridenInstanceCount: number;
  96574. isFrozen: boolean;
  96575. previousBatch: Nullable<_InstancesBatch>;
  96576. hardwareInstancedRendering: boolean;
  96577. sideOrientation: number;
  96578. manualUpdate: boolean;
  96579. }
  96580. /**
  96581. * @hidden
  96582. **/
  96583. export class _InstancesBatch {
  96584. mustReturn: boolean;
  96585. visibleInstances: Nullable<InstancedMesh[]>[];
  96586. renderSelf: boolean[];
  96587. hardwareInstancedRendering: boolean[];
  96588. }
  96589. /**
  96590. * Class used to represent renderable models
  96591. */
  96592. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  96593. /**
  96594. * Mesh side orientation : usually the external or front surface
  96595. */
  96596. static readonly FRONTSIDE: number;
  96597. /**
  96598. * Mesh side orientation : usually the internal or back surface
  96599. */
  96600. static readonly BACKSIDE: number;
  96601. /**
  96602. * Mesh side orientation : both internal and external or front and back surfaces
  96603. */
  96604. static readonly DOUBLESIDE: number;
  96605. /**
  96606. * Mesh side orientation : by default, `FRONTSIDE`
  96607. */
  96608. static readonly DEFAULTSIDE: number;
  96609. /**
  96610. * Mesh cap setting : no cap
  96611. */
  96612. static readonly NO_CAP: number;
  96613. /**
  96614. * Mesh cap setting : one cap at the beginning of the mesh
  96615. */
  96616. static readonly CAP_START: number;
  96617. /**
  96618. * Mesh cap setting : one cap at the end of the mesh
  96619. */
  96620. static readonly CAP_END: number;
  96621. /**
  96622. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  96623. */
  96624. static readonly CAP_ALL: number;
  96625. /**
  96626. * Mesh pattern setting : no flip or rotate
  96627. */
  96628. static readonly NO_FLIP: number;
  96629. /**
  96630. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  96631. */
  96632. static readonly FLIP_TILE: number;
  96633. /**
  96634. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  96635. */
  96636. static readonly ROTATE_TILE: number;
  96637. /**
  96638. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  96639. */
  96640. static readonly FLIP_ROW: number;
  96641. /**
  96642. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  96643. */
  96644. static readonly ROTATE_ROW: number;
  96645. /**
  96646. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  96647. */
  96648. static readonly FLIP_N_ROTATE_TILE: number;
  96649. /**
  96650. * Mesh pattern setting : rotate pattern and rotate
  96651. */
  96652. static readonly FLIP_N_ROTATE_ROW: number;
  96653. /**
  96654. * Mesh tile positioning : part tiles same on left/right or top/bottom
  96655. */
  96656. static readonly CENTER: number;
  96657. /**
  96658. * Mesh tile positioning : part tiles on left
  96659. */
  96660. static readonly LEFT: number;
  96661. /**
  96662. * Mesh tile positioning : part tiles on right
  96663. */
  96664. static readonly RIGHT: number;
  96665. /**
  96666. * Mesh tile positioning : part tiles on top
  96667. */
  96668. static readonly TOP: number;
  96669. /**
  96670. * Mesh tile positioning : part tiles on bottom
  96671. */
  96672. static readonly BOTTOM: number;
  96673. /**
  96674. * Gets the default side orientation.
  96675. * @param orientation the orientation to value to attempt to get
  96676. * @returns the default orientation
  96677. * @hidden
  96678. */
  96679. static _GetDefaultSideOrientation(orientation?: number): number;
  96680. private _internalMeshDataInfo;
  96681. /**
  96682. * An event triggered before rendering the mesh
  96683. */
  96684. get onBeforeRenderObservable(): Observable<Mesh>;
  96685. /**
  96686. * An event triggered before binding the mesh
  96687. */
  96688. get onBeforeBindObservable(): Observable<Mesh>;
  96689. /**
  96690. * An event triggered after rendering the mesh
  96691. */
  96692. get onAfterRenderObservable(): Observable<Mesh>;
  96693. /**
  96694. * An event triggered before drawing the mesh
  96695. */
  96696. get onBeforeDrawObservable(): Observable<Mesh>;
  96697. private _onBeforeDrawObserver;
  96698. /**
  96699. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  96700. */
  96701. set onBeforeDraw(callback: () => void);
  96702. get hasInstances(): boolean;
  96703. /**
  96704. * Gets the delay loading state of the mesh (when delay loading is turned on)
  96705. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  96706. */
  96707. delayLoadState: number;
  96708. /**
  96709. * Gets the list of instances created from this mesh
  96710. * it is not supposed to be modified manually.
  96711. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  96712. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96713. */
  96714. instances: InstancedMesh[];
  96715. /**
  96716. * Gets the file containing delay loading data for this mesh
  96717. */
  96718. delayLoadingFile: string;
  96719. /** @hidden */
  96720. _binaryInfo: any;
  96721. /**
  96722. * User defined function used to change how LOD level selection is done
  96723. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96724. */
  96725. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  96726. /**
  96727. * Gets or sets the morph target manager
  96728. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96729. */
  96730. get morphTargetManager(): Nullable<MorphTargetManager>;
  96731. set morphTargetManager(value: Nullable<MorphTargetManager>);
  96732. /** @hidden */
  96733. _creationDataStorage: Nullable<_CreationDataStorage>;
  96734. /** @hidden */
  96735. _geometry: Nullable<Geometry>;
  96736. /** @hidden */
  96737. _delayInfo: Array<string>;
  96738. /** @hidden */
  96739. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  96740. /** @hidden */
  96741. _instanceDataStorage: _InstanceDataStorage;
  96742. private _effectiveMaterial;
  96743. /** @hidden */
  96744. _shouldGenerateFlatShading: boolean;
  96745. /** @hidden */
  96746. _originalBuilderSideOrientation: number;
  96747. /**
  96748. * Use this property to change the original side orientation defined at construction time
  96749. */
  96750. overrideMaterialSideOrientation: Nullable<number>;
  96751. /**
  96752. * Gets the source mesh (the one used to clone this one from)
  96753. */
  96754. get source(): Nullable<Mesh>;
  96755. /**
  96756. * Gets or sets a boolean indicating that this mesh does not use index buffer
  96757. */
  96758. get isUnIndexed(): boolean;
  96759. set isUnIndexed(value: boolean);
  96760. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  96761. get worldMatrixInstancedBuffer(): Float32Array;
  96762. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  96763. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  96764. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  96765. /**
  96766. * @constructor
  96767. * @param name The value used by scene.getMeshByName() to do a lookup.
  96768. * @param scene The scene to add this mesh to.
  96769. * @param parent The parent of this mesh, if it has one
  96770. * @param source An optional Mesh from which geometry is shared, cloned.
  96771. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96772. * When false, achieved by calling a clone(), also passing False.
  96773. * This will make creation of children, recursive.
  96774. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  96775. */
  96776. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  96777. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96778. doNotInstantiate: boolean;
  96779. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96780. /**
  96781. * Gets the class name
  96782. * @returns the string "Mesh".
  96783. */
  96784. getClassName(): string;
  96785. /** @hidden */
  96786. get _isMesh(): boolean;
  96787. /**
  96788. * Returns a description of this mesh
  96789. * @param fullDetails define if full details about this mesh must be used
  96790. * @returns a descriptive string representing this mesh
  96791. */
  96792. toString(fullDetails?: boolean): string;
  96793. /** @hidden */
  96794. _unBindEffect(): void;
  96795. /**
  96796. * Gets a boolean indicating if this mesh has LOD
  96797. */
  96798. get hasLODLevels(): boolean;
  96799. /**
  96800. * Gets the list of MeshLODLevel associated with the current mesh
  96801. * @returns an array of MeshLODLevel
  96802. */
  96803. getLODLevels(): MeshLODLevel[];
  96804. private _sortLODLevels;
  96805. /**
  96806. * Add a mesh as LOD level triggered at the given distance.
  96807. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96808. * @param distance The distance from the center of the object to show this level
  96809. * @param mesh The mesh to be added as LOD level (can be null)
  96810. * @return This mesh (for chaining)
  96811. */
  96812. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  96813. /**
  96814. * Returns the LOD level mesh at the passed distance or null if not found.
  96815. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96816. * @param distance The distance from the center of the object to show this level
  96817. * @returns a Mesh or `null`
  96818. */
  96819. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  96820. /**
  96821. * Remove a mesh from the LOD array
  96822. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96823. * @param mesh defines the mesh to be removed
  96824. * @return This mesh (for chaining)
  96825. */
  96826. removeLODLevel(mesh: Mesh): Mesh;
  96827. /**
  96828. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  96829. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96830. * @param camera defines the camera to use to compute distance
  96831. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  96832. * @return This mesh (for chaining)
  96833. */
  96834. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  96835. /**
  96836. * Gets the mesh internal Geometry object
  96837. */
  96838. get geometry(): Nullable<Geometry>;
  96839. /**
  96840. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  96841. * @returns the total number of vertices
  96842. */
  96843. getTotalVertices(): number;
  96844. /**
  96845. * Returns the content of an associated vertex buffer
  96846. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96847. * - VertexBuffer.PositionKind
  96848. * - VertexBuffer.UVKind
  96849. * - VertexBuffer.UV2Kind
  96850. * - VertexBuffer.UV3Kind
  96851. * - VertexBuffer.UV4Kind
  96852. * - VertexBuffer.UV5Kind
  96853. * - VertexBuffer.UV6Kind
  96854. * - VertexBuffer.ColorKind
  96855. * - VertexBuffer.MatricesIndicesKind
  96856. * - VertexBuffer.MatricesIndicesExtraKind
  96857. * - VertexBuffer.MatricesWeightsKind
  96858. * - VertexBuffer.MatricesWeightsExtraKind
  96859. * @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
  96860. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  96861. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  96862. */
  96863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96864. /**
  96865. * Returns the mesh VertexBuffer object from the requested `kind`
  96866. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96867. * - VertexBuffer.PositionKind
  96868. * - VertexBuffer.NormalKind
  96869. * - VertexBuffer.UVKind
  96870. * - VertexBuffer.UV2Kind
  96871. * - VertexBuffer.UV3Kind
  96872. * - VertexBuffer.UV4Kind
  96873. * - VertexBuffer.UV5Kind
  96874. * - VertexBuffer.UV6Kind
  96875. * - VertexBuffer.ColorKind
  96876. * - VertexBuffer.MatricesIndicesKind
  96877. * - VertexBuffer.MatricesIndicesExtraKind
  96878. * - VertexBuffer.MatricesWeightsKind
  96879. * - VertexBuffer.MatricesWeightsExtraKind
  96880. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  96881. */
  96882. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96883. /**
  96884. * Tests if a specific vertex buffer is associated with this mesh
  96885. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  96886. * - VertexBuffer.PositionKind
  96887. * - VertexBuffer.NormalKind
  96888. * - VertexBuffer.UVKind
  96889. * - VertexBuffer.UV2Kind
  96890. * - VertexBuffer.UV3Kind
  96891. * - VertexBuffer.UV4Kind
  96892. * - VertexBuffer.UV5Kind
  96893. * - VertexBuffer.UV6Kind
  96894. * - VertexBuffer.ColorKind
  96895. * - VertexBuffer.MatricesIndicesKind
  96896. * - VertexBuffer.MatricesIndicesExtraKind
  96897. * - VertexBuffer.MatricesWeightsKind
  96898. * - VertexBuffer.MatricesWeightsExtraKind
  96899. * @returns a boolean
  96900. */
  96901. isVerticesDataPresent(kind: string): boolean;
  96902. /**
  96903. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  96904. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  96905. * - VertexBuffer.PositionKind
  96906. * - VertexBuffer.UVKind
  96907. * - VertexBuffer.UV2Kind
  96908. * - VertexBuffer.UV3Kind
  96909. * - VertexBuffer.UV4Kind
  96910. * - VertexBuffer.UV5Kind
  96911. * - VertexBuffer.UV6Kind
  96912. * - VertexBuffer.ColorKind
  96913. * - VertexBuffer.MatricesIndicesKind
  96914. * - VertexBuffer.MatricesIndicesExtraKind
  96915. * - VertexBuffer.MatricesWeightsKind
  96916. * - VertexBuffer.MatricesWeightsExtraKind
  96917. * @returns a boolean
  96918. */
  96919. isVertexBufferUpdatable(kind: string): boolean;
  96920. /**
  96921. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  96922. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96923. * - VertexBuffer.PositionKind
  96924. * - VertexBuffer.NormalKind
  96925. * - VertexBuffer.UVKind
  96926. * - VertexBuffer.UV2Kind
  96927. * - VertexBuffer.UV3Kind
  96928. * - VertexBuffer.UV4Kind
  96929. * - VertexBuffer.UV5Kind
  96930. * - VertexBuffer.UV6Kind
  96931. * - VertexBuffer.ColorKind
  96932. * - VertexBuffer.MatricesIndicesKind
  96933. * - VertexBuffer.MatricesIndicesExtraKind
  96934. * - VertexBuffer.MatricesWeightsKind
  96935. * - VertexBuffer.MatricesWeightsExtraKind
  96936. * @returns an array of strings
  96937. */
  96938. getVerticesDataKinds(): string[];
  96939. /**
  96940. * Returns a positive integer : the total number of indices in this mesh geometry.
  96941. * @returns the numner of indices or zero if the mesh has no geometry.
  96942. */
  96943. getTotalIndices(): number;
  96944. /**
  96945. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96946. * @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.
  96947. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96948. * @returns the indices array or an empty array if the mesh has no geometry
  96949. */
  96950. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96951. get isBlocked(): boolean;
  96952. /**
  96953. * Determine if the current mesh is ready to be rendered
  96954. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96955. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  96956. * @returns true if all associated assets are ready (material, textures, shaders)
  96957. */
  96958. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  96959. /**
  96960. * 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.
  96961. */
  96962. get areNormalsFrozen(): boolean;
  96963. /**
  96964. * 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.
  96965. * @returns the current mesh
  96966. */
  96967. freezeNormals(): Mesh;
  96968. /**
  96969. * 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
  96970. * @returns the current mesh
  96971. */
  96972. unfreezeNormals(): Mesh;
  96973. /**
  96974. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  96975. */
  96976. set overridenInstanceCount(count: number);
  96977. /** @hidden */
  96978. _preActivate(): Mesh;
  96979. /** @hidden */
  96980. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96981. /** @hidden */
  96982. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  96983. /**
  96984. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96985. * This means the mesh underlying bounding box and sphere are recomputed.
  96986. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96987. * @returns the current mesh
  96988. */
  96989. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  96990. /** @hidden */
  96991. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  96992. /**
  96993. * This function will subdivide the mesh into multiple submeshes
  96994. * @param count defines the expected number of submeshes
  96995. */
  96996. subdivide(count: number): void;
  96997. /**
  96998. * Copy a FloatArray into a specific associated vertex buffer
  96999. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97000. * - VertexBuffer.PositionKind
  97001. * - VertexBuffer.UVKind
  97002. * - VertexBuffer.UV2Kind
  97003. * - VertexBuffer.UV3Kind
  97004. * - VertexBuffer.UV4Kind
  97005. * - VertexBuffer.UV5Kind
  97006. * - VertexBuffer.UV6Kind
  97007. * - VertexBuffer.ColorKind
  97008. * - VertexBuffer.MatricesIndicesKind
  97009. * - VertexBuffer.MatricesIndicesExtraKind
  97010. * - VertexBuffer.MatricesWeightsKind
  97011. * - VertexBuffer.MatricesWeightsExtraKind
  97012. * @param data defines the data source
  97013. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97014. * @param stride defines the data stride size (can be null)
  97015. * @returns the current mesh
  97016. */
  97017. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97018. /**
  97019. * Delete a vertex buffer associated with this mesh
  97020. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97021. * - VertexBuffer.PositionKind
  97022. * - VertexBuffer.UVKind
  97023. * - VertexBuffer.UV2Kind
  97024. * - VertexBuffer.UV3Kind
  97025. * - VertexBuffer.UV4Kind
  97026. * - VertexBuffer.UV5Kind
  97027. * - VertexBuffer.UV6Kind
  97028. * - VertexBuffer.ColorKind
  97029. * - VertexBuffer.MatricesIndicesKind
  97030. * - VertexBuffer.MatricesIndicesExtraKind
  97031. * - VertexBuffer.MatricesWeightsKind
  97032. * - VertexBuffer.MatricesWeightsExtraKind
  97033. */
  97034. removeVerticesData(kind: string): void;
  97035. /**
  97036. * Flags an associated vertex buffer as updatable
  97037. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97038. * - VertexBuffer.PositionKind
  97039. * - VertexBuffer.UVKind
  97040. * - VertexBuffer.UV2Kind
  97041. * - VertexBuffer.UV3Kind
  97042. * - VertexBuffer.UV4Kind
  97043. * - VertexBuffer.UV5Kind
  97044. * - VertexBuffer.UV6Kind
  97045. * - VertexBuffer.ColorKind
  97046. * - VertexBuffer.MatricesIndicesKind
  97047. * - VertexBuffer.MatricesIndicesExtraKind
  97048. * - VertexBuffer.MatricesWeightsKind
  97049. * - VertexBuffer.MatricesWeightsExtraKind
  97050. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97051. */
  97052. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97053. /**
  97054. * Sets the mesh global Vertex Buffer
  97055. * @param buffer defines the buffer to use
  97056. * @returns the current mesh
  97057. */
  97058. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97059. /**
  97060. * Update a specific associated vertex buffer
  97061. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97062. * - VertexBuffer.PositionKind
  97063. * - VertexBuffer.UVKind
  97064. * - VertexBuffer.UV2Kind
  97065. * - VertexBuffer.UV3Kind
  97066. * - VertexBuffer.UV4Kind
  97067. * - VertexBuffer.UV5Kind
  97068. * - VertexBuffer.UV6Kind
  97069. * - VertexBuffer.ColorKind
  97070. * - VertexBuffer.MatricesIndicesKind
  97071. * - VertexBuffer.MatricesIndicesExtraKind
  97072. * - VertexBuffer.MatricesWeightsKind
  97073. * - VertexBuffer.MatricesWeightsExtraKind
  97074. * @param data defines the data source
  97075. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97076. * @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)
  97077. * @returns the current mesh
  97078. */
  97079. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97080. /**
  97081. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97082. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97083. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97084. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97085. * @returns the current mesh
  97086. */
  97087. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97088. /**
  97089. * Creates a un-shared specific occurence of the geometry for the mesh.
  97090. * @returns the current mesh
  97091. */
  97092. makeGeometryUnique(): Mesh;
  97093. /**
  97094. * Set the index buffer of this mesh
  97095. * @param indices defines the source data
  97096. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97097. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97098. * @returns the current mesh
  97099. */
  97100. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97101. /**
  97102. * Update the current index buffer
  97103. * @param indices defines the source data
  97104. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97105. * @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)
  97106. * @returns the current mesh
  97107. */
  97108. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97109. /**
  97110. * Invert the geometry to move from a right handed system to a left handed one.
  97111. * @returns the current mesh
  97112. */
  97113. toLeftHanded(): Mesh;
  97114. /** @hidden */
  97115. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97116. /** @hidden */
  97117. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97118. /**
  97119. * Registers for this mesh a javascript function called just before the rendering process
  97120. * @param func defines the function to call before rendering this mesh
  97121. * @returns the current mesh
  97122. */
  97123. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97124. /**
  97125. * Disposes a previously registered javascript function called before the rendering
  97126. * @param func defines the function to remove
  97127. * @returns the current mesh
  97128. */
  97129. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97130. /**
  97131. * Registers for this mesh a javascript function called just after the rendering is complete
  97132. * @param func defines the function to call after rendering this mesh
  97133. * @returns the current mesh
  97134. */
  97135. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97136. /**
  97137. * Disposes a previously registered javascript function called after the rendering.
  97138. * @param func defines the function to remove
  97139. * @returns the current mesh
  97140. */
  97141. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97142. /** @hidden */
  97143. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97144. /** @hidden */
  97145. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97146. /** @hidden */
  97147. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97148. /** @hidden */
  97149. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97150. /** @hidden */
  97151. _rebuild(): void;
  97152. /** @hidden */
  97153. _freeze(): void;
  97154. /** @hidden */
  97155. _unFreeze(): void;
  97156. /**
  97157. * 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
  97158. * @param subMesh defines the subMesh to render
  97159. * @param enableAlphaMode defines if alpha mode can be changed
  97160. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97161. * @returns the current mesh
  97162. */
  97163. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97164. private _onBeforeDraw;
  97165. /**
  97166. * Renormalize the mesh and patch it up if there are no weights
  97167. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97168. * However in the case of zero weights then we set just a single influence to 1.
  97169. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97170. */
  97171. cleanMatrixWeights(): void;
  97172. private normalizeSkinFourWeights;
  97173. private normalizeSkinWeightsAndExtra;
  97174. /**
  97175. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  97176. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  97177. * the user know there was an issue with importing the mesh
  97178. * @returns a validation object with skinned, valid and report string
  97179. */
  97180. validateSkinning(): {
  97181. skinned: boolean;
  97182. valid: boolean;
  97183. report: string;
  97184. };
  97185. /** @hidden */
  97186. _checkDelayState(): Mesh;
  97187. private _queueLoad;
  97188. /**
  97189. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97190. * A mesh is in the frustum if its bounding box intersects the frustum
  97191. * @param frustumPlanes defines the frustum to test
  97192. * @returns true if the mesh is in the frustum planes
  97193. */
  97194. isInFrustum(frustumPlanes: Plane[]): boolean;
  97195. /**
  97196. * Sets the mesh material by the material or multiMaterial `id` property
  97197. * @param id is a string identifying the material or the multiMaterial
  97198. * @returns the current mesh
  97199. */
  97200. setMaterialByID(id: string): Mesh;
  97201. /**
  97202. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  97203. * @returns an array of IAnimatable
  97204. */
  97205. getAnimatables(): IAnimatable[];
  97206. /**
  97207. * Modifies the mesh geometry according to the passed transformation matrix.
  97208. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  97209. * The mesh normals are modified using the same transformation.
  97210. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97211. * @param transform defines the transform matrix to use
  97212. * @see http://doc.babylonjs.com/resources/baking_transformations
  97213. * @returns the current mesh
  97214. */
  97215. bakeTransformIntoVertices(transform: Matrix): Mesh;
  97216. /**
  97217. * Modifies the mesh geometry according to its own current World Matrix.
  97218. * The mesh World Matrix is then reset.
  97219. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  97220. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97221. * @see http://doc.babylonjs.com/resources/baking_transformations
  97222. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  97223. * @returns the current mesh
  97224. */
  97225. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  97226. /** @hidden */
  97227. get _positions(): Nullable<Vector3[]>;
  97228. /** @hidden */
  97229. _resetPointsArrayCache(): Mesh;
  97230. /** @hidden */
  97231. _generatePointsArray(): boolean;
  97232. /**
  97233. * Returns a new Mesh object generated from the current mesh properties.
  97234. * This method must not get confused with createInstance()
  97235. * @param name is a string, the name given to the new mesh
  97236. * @param newParent can be any Node object (default `null`)
  97237. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  97238. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  97239. * @returns a new mesh
  97240. */
  97241. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  97242. /**
  97243. * Releases resources associated with this mesh.
  97244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97246. */
  97247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97248. /** @hidden */
  97249. _disposeInstanceSpecificData(): void;
  97250. /**
  97251. * Modifies the mesh geometry according to a displacement map.
  97252. * 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.
  97253. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97254. * @param url is a string, the URL from the image file is to be downloaded.
  97255. * @param minHeight is the lower limit of the displacement.
  97256. * @param maxHeight is the upper limit of the displacement.
  97257. * @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.
  97258. * @param uvOffset is an optional vector2 used to offset UV.
  97259. * @param uvScale is an optional vector2 used to scale UV.
  97260. * @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.
  97261. * @returns the Mesh.
  97262. */
  97263. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97264. /**
  97265. * Modifies the mesh geometry according to a displacementMap buffer.
  97266. * 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.
  97267. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97268. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  97269. * @param heightMapWidth is the width of the buffer image.
  97270. * @param heightMapHeight is the height of the buffer image.
  97271. * @param minHeight is the lower limit of the displacement.
  97272. * @param maxHeight is the upper limit of the displacement.
  97273. * @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.
  97274. * @param uvOffset is an optional vector2 used to offset UV.
  97275. * @param uvScale is an optional vector2 used to scale UV.
  97276. * @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.
  97277. * @returns the Mesh.
  97278. */
  97279. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97280. /**
  97281. * Modify the mesh to get a flat shading rendering.
  97282. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  97283. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  97284. * @returns current mesh
  97285. */
  97286. convertToFlatShadedMesh(): Mesh;
  97287. /**
  97288. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  97289. * In other words, more vertices, no more indices and a single bigger VBO.
  97290. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  97291. * @returns current mesh
  97292. */
  97293. convertToUnIndexedMesh(): Mesh;
  97294. /**
  97295. * Inverses facet orientations.
  97296. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97297. * @param flipNormals will also inverts the normals
  97298. * @returns current mesh
  97299. */
  97300. flipFaces(flipNormals?: boolean): Mesh;
  97301. /**
  97302. * Increase the number of facets and hence vertices in a mesh
  97303. * Vertex normals are interpolated from existing vertex normals
  97304. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97305. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  97306. */
  97307. increaseVertices(numberPerEdge: number): void;
  97308. /**
  97309. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  97310. * This will undo any application of covertToFlatShadedMesh
  97311. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97312. */
  97313. forceSharedVertices(): void;
  97314. /** @hidden */
  97315. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  97316. /** @hidden */
  97317. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  97318. /**
  97319. * Creates a new InstancedMesh object from the mesh model.
  97320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97321. * @param name defines the name of the new instance
  97322. * @returns a new InstancedMesh
  97323. */
  97324. createInstance(name: string): InstancedMesh;
  97325. /**
  97326. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  97327. * After this call, all the mesh instances have the same submeshes than the current mesh.
  97328. * @returns the current mesh
  97329. */
  97330. synchronizeInstances(): Mesh;
  97331. /**
  97332. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  97333. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  97334. * This should be used together with the simplification to avoid disappearing triangles.
  97335. * @param successCallback an optional success callback to be called after the optimization finished.
  97336. * @returns the current mesh
  97337. */
  97338. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  97339. /**
  97340. * Serialize current mesh
  97341. * @param serializationObject defines the object which will receive the serialization data
  97342. */
  97343. serialize(serializationObject: any): void;
  97344. /** @hidden */
  97345. _syncGeometryWithMorphTargetManager(): void;
  97346. /** @hidden */
  97347. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  97348. /**
  97349. * Returns a new Mesh object parsed from the source provided.
  97350. * @param parsedMesh is the source
  97351. * @param scene defines the hosting scene
  97352. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  97353. * @returns a new Mesh
  97354. */
  97355. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  97356. /**
  97357. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  97358. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97359. * @param name defines the name of the mesh to create
  97360. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  97361. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  97362. * @param closePath creates a seam between the first and the last points of each path of the path array
  97363. * @param offset is taken in account only if the `pathArray` is containing a single path
  97364. * @param scene defines the hosting scene
  97365. * @param updatable defines if the mesh must be flagged as updatable
  97366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97367. * @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)
  97368. * @returns a new Mesh
  97369. */
  97370. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97371. /**
  97372. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  97373. * @param name defines the name of the mesh to create
  97374. * @param radius sets the radius size (float) of the polygon (default 0.5)
  97375. * @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
  97376. * @param scene defines the hosting scene
  97377. * @param updatable defines if the mesh must be flagged as updatable
  97378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97379. * @returns a new Mesh
  97380. */
  97381. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97382. /**
  97383. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  97384. * @param name defines the name of the mesh to create
  97385. * @param size sets the size (float) of each box side (default 1)
  97386. * @param scene defines the hosting scene
  97387. * @param updatable defines if the mesh must be flagged as updatable
  97388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97389. * @returns a new Mesh
  97390. */
  97391. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97392. /**
  97393. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  97394. * @param name defines the name of the mesh to create
  97395. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97396. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97397. * @param scene defines the hosting scene
  97398. * @param updatable defines if the mesh must be flagged as updatable
  97399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97400. * @returns a new Mesh
  97401. */
  97402. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97403. /**
  97404. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  97405. * @param name defines the name of the mesh to create
  97406. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97407. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97408. * @param scene defines the hosting scene
  97409. * @returns a new Mesh
  97410. */
  97411. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  97412. /**
  97413. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  97414. * @param name defines the name of the mesh to create
  97415. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  97416. * @param diameterTop set the top cap diameter (floats, default 1)
  97417. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  97418. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  97419. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  97420. * @param scene defines the hosting scene
  97421. * @param updatable defines if the mesh must be flagged as updatable
  97422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97423. * @returns a new Mesh
  97424. */
  97425. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  97426. /**
  97427. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  97428. * @param name defines the name of the mesh to create
  97429. * @param diameter sets the diameter size (float) of the torus (default 1)
  97430. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  97431. * @param tessellation sets the number of torus sides (postive integer, default 16)
  97432. * @param scene defines the hosting scene
  97433. * @param updatable defines if the mesh must be flagged as updatable
  97434. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97435. * @returns a new Mesh
  97436. */
  97437. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97438. /**
  97439. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  97440. * @param name defines the name of the mesh to create
  97441. * @param radius sets the global radius size (float) of the torus knot (default 2)
  97442. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  97443. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  97444. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  97445. * @param p the number of windings on X axis (positive integers, default 2)
  97446. * @param q the number of windings on Y axis (positive integers, default 3)
  97447. * @param scene defines the hosting scene
  97448. * @param updatable defines if the mesh must be flagged as updatable
  97449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97450. * @returns a new Mesh
  97451. */
  97452. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97453. /**
  97454. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  97455. * @param name defines the name of the mesh to create
  97456. * @param points is an array successive Vector3
  97457. * @param scene defines the hosting scene
  97458. * @param updatable defines if the mesh must be flagged as updatable
  97459. * @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).
  97460. * @returns a new Mesh
  97461. */
  97462. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  97463. /**
  97464. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  97465. * @param name defines the name of the mesh to create
  97466. * @param points is an array successive Vector3
  97467. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  97468. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97469. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  97470. * @param scene defines the hosting scene
  97471. * @param updatable defines if the mesh must be flagged as updatable
  97472. * @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)
  97473. * @returns a new Mesh
  97474. */
  97475. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  97476. /**
  97477. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  97478. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  97479. * 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.
  97480. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97481. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97482. * Remember you can only change the shape positions, not their number when updating a polygon.
  97483. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  97484. * @param name defines the name of the mesh to create
  97485. * @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
  97486. * @param scene defines the hosting scene
  97487. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97488. * @param updatable defines if the mesh must be flagged as updatable
  97489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97490. * @param earcutInjection can be used to inject your own earcut reference
  97491. * @returns a new Mesh
  97492. */
  97493. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97494. /**
  97495. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  97496. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  97497. * @param name defines the name of the mesh to create
  97498. * @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
  97499. * @param depth defines the height of extrusion
  97500. * @param scene defines the hosting scene
  97501. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97502. * @param updatable defines if the mesh must be flagged as updatable
  97503. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97504. * @param earcutInjection can be used to inject your own earcut reference
  97505. * @returns a new Mesh
  97506. */
  97507. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97508. /**
  97509. * Creates an extruded shape mesh.
  97510. * 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
  97511. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97512. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97513. * @param name defines the name of the mesh to create
  97514. * @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
  97515. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97516. * @param scale is the value to scale the shape
  97517. * @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
  97518. * @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
  97519. * @param scene defines the hosting scene
  97520. * @param updatable defines if the mesh must be flagged as updatable
  97521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97522. * @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)
  97523. * @returns a new Mesh
  97524. */
  97525. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97526. /**
  97527. * Creates an custom extruded shape mesh.
  97528. * The custom extrusion is a parametric shape.
  97529. * It has no predefined shape. Its final shape will depend on the input parameters.
  97530. * Please consider using the same method from the MeshBuilder class instead
  97531. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97532. * @param name defines the name of the mesh to create
  97533. * @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
  97534. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97535. * @param scaleFunction is a custom Javascript function called on each path point
  97536. * @param rotationFunction is a custom Javascript function called on each path point
  97537. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  97538. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  97539. * @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
  97540. * @param scene defines the hosting scene
  97541. * @param updatable defines if the mesh must be flagged as updatable
  97542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97543. * @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)
  97544. * @returns a new Mesh
  97545. */
  97546. 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;
  97547. /**
  97548. * Creates lathe mesh.
  97549. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  97550. * Please consider using the same method from the MeshBuilder class instead
  97551. * @param name defines the name of the mesh to create
  97552. * @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
  97553. * @param radius is the radius value of the lathe
  97554. * @param tessellation is the side number of the lathe.
  97555. * @param scene defines the hosting scene
  97556. * @param updatable defines if the mesh must be flagged as updatable
  97557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97558. * @returns a new Mesh
  97559. */
  97560. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97561. /**
  97562. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  97563. * @param name defines the name of the mesh to create
  97564. * @param size sets the size (float) of both sides of the plane at once (default 1)
  97565. * @param scene defines the hosting scene
  97566. * @param updatable defines if the mesh must be flagged as updatable
  97567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97568. * @returns a new Mesh
  97569. */
  97570. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97571. /**
  97572. * Creates a ground mesh.
  97573. * Please consider using the same method from the MeshBuilder class instead
  97574. * @param name defines the name of the mesh to create
  97575. * @param width set the width of the ground
  97576. * @param height set the height of the ground
  97577. * @param subdivisions sets the number of subdivisions per side
  97578. * @param scene defines the hosting scene
  97579. * @param updatable defines if the mesh must be flagged as updatable
  97580. * @returns a new Mesh
  97581. */
  97582. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  97583. /**
  97584. * Creates a tiled ground mesh.
  97585. * Please consider using the same method from the MeshBuilder class instead
  97586. * @param name defines the name of the mesh to create
  97587. * @param xmin set the ground minimum X coordinate
  97588. * @param zmin set the ground minimum Y coordinate
  97589. * @param xmax set the ground maximum X coordinate
  97590. * @param zmax set the ground maximum Z coordinate
  97591. * @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
  97592. * @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
  97593. * @param scene defines the hosting scene
  97594. * @param updatable defines if the mesh must be flagged as updatable
  97595. * @returns a new Mesh
  97596. */
  97597. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  97598. w: number;
  97599. h: number;
  97600. }, precision: {
  97601. w: number;
  97602. h: number;
  97603. }, scene: Scene, updatable?: boolean): Mesh;
  97604. /**
  97605. * Creates a ground mesh from a height map.
  97606. * Please consider using the same method from the MeshBuilder class instead
  97607. * @see http://doc.babylonjs.com/babylon101/height_map
  97608. * @param name defines the name of the mesh to create
  97609. * @param url sets the URL of the height map image resource
  97610. * @param width set the ground width size
  97611. * @param height set the ground height size
  97612. * @param subdivisions sets the number of subdivision per side
  97613. * @param minHeight is the minimum altitude on the ground
  97614. * @param maxHeight is the maximum altitude on the ground
  97615. * @param scene defines the hosting scene
  97616. * @param updatable defines if the mesh must be flagged as updatable
  97617. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  97618. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97619. * @returns a new Mesh
  97620. */
  97621. 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;
  97622. /**
  97623. * Creates a tube mesh.
  97624. * The tube is a parametric shape.
  97625. * It has no predefined shape. Its final shape will depend on the input parameters.
  97626. * Please consider using the same method from the MeshBuilder class instead
  97627. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97628. * @param name defines the name of the mesh to create
  97629. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  97630. * @param radius sets the tube radius size
  97631. * @param tessellation is the number of sides on the tubular surface
  97632. * @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
  97633. * @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
  97634. * @param scene defines the hosting scene
  97635. * @param updatable defines if the mesh must be flagged as updatable
  97636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97637. * @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)
  97638. * @returns a new Mesh
  97639. */
  97640. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  97641. (i: number, distance: number): number;
  97642. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97643. /**
  97644. * Creates a polyhedron mesh.
  97645. * Please consider using the same method from the MeshBuilder class instead.
  97646. * * 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
  97647. * * The parameter `size` (positive float, default 1) sets the polygon size
  97648. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97649. * * 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`
  97650. * * 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
  97651. * * 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)`)
  97652. * * 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
  97653. * * 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
  97654. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97655. * * If you create a double-sided mesh, you can choose what parts of 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
  97656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97657. * @param name defines the name of the mesh to create
  97658. * @param options defines the options used to create the mesh
  97659. * @param scene defines the hosting scene
  97660. * @returns a new Mesh
  97661. */
  97662. static CreatePolyhedron(name: string, options: {
  97663. type?: number;
  97664. size?: number;
  97665. sizeX?: number;
  97666. sizeY?: number;
  97667. sizeZ?: number;
  97668. custom?: any;
  97669. faceUV?: Vector4[];
  97670. faceColors?: Color4[];
  97671. updatable?: boolean;
  97672. sideOrientation?: number;
  97673. }, scene: Scene): Mesh;
  97674. /**
  97675. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  97676. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  97677. * * 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`)
  97678. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  97679. * * 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
  97680. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97681. * * If you create a double-sided mesh, you can choose what parts of 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
  97682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97683. * @param name defines the name of the mesh
  97684. * @param options defines the options used to create the mesh
  97685. * @param scene defines the hosting scene
  97686. * @returns a new Mesh
  97687. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  97688. */
  97689. static CreateIcoSphere(name: string, options: {
  97690. radius?: number;
  97691. flat?: boolean;
  97692. subdivisions?: number;
  97693. sideOrientation?: number;
  97694. updatable?: boolean;
  97695. }, scene: Scene): Mesh;
  97696. /**
  97697. * Creates a decal mesh.
  97698. * Please consider using the same method from the MeshBuilder class instead.
  97699. * A decal is a mesh usually applied as a model onto the surface of another mesh
  97700. * @param name defines the name of the mesh
  97701. * @param sourceMesh defines the mesh receiving the decal
  97702. * @param position sets the position of the decal in world coordinates
  97703. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  97704. * @param size sets the decal scaling
  97705. * @param angle sets the angle to rotate the decal
  97706. * @returns a new Mesh
  97707. */
  97708. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  97709. /**
  97710. * Prepare internal position array for software CPU skinning
  97711. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  97712. */
  97713. setPositionsForCPUSkinning(): Float32Array;
  97714. /**
  97715. * Prepare internal normal array for software CPU skinning
  97716. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  97717. */
  97718. setNormalsForCPUSkinning(): Float32Array;
  97719. /**
  97720. * Updates the vertex buffer by applying transformation from the bones
  97721. * @param skeleton defines the skeleton to apply to current mesh
  97722. * @returns the current mesh
  97723. */
  97724. applySkeleton(skeleton: Skeleton): Mesh;
  97725. /**
  97726. * 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
  97727. * @param meshes defines the list of meshes to scan
  97728. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  97729. */
  97730. static MinMax(meshes: AbstractMesh[]): {
  97731. min: Vector3;
  97732. max: Vector3;
  97733. };
  97734. /**
  97735. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  97736. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  97737. * @returns a vector3
  97738. */
  97739. static Center(meshesOrMinMaxVector: {
  97740. min: Vector3;
  97741. max: Vector3;
  97742. } | AbstractMesh[]): Vector3;
  97743. /**
  97744. * Merge the array of meshes into a single mesh for performance reasons.
  97745. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  97746. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  97747. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  97748. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  97749. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  97750. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  97751. * @returns a new mesh
  97752. */
  97753. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  97754. /** @hidden */
  97755. addInstance(instance: InstancedMesh): void;
  97756. /** @hidden */
  97757. removeInstance(instance: InstancedMesh): void;
  97758. }
  97759. }
  97760. declare module BABYLON {
  97761. /**
  97762. * This is the base class of all the camera used in the application.
  97763. * @see http://doc.babylonjs.com/features/cameras
  97764. */
  97765. export class Camera extends Node {
  97766. /** @hidden */
  97767. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  97768. /**
  97769. * This is the default projection mode used by the cameras.
  97770. * It helps recreating a feeling of perspective and better appreciate depth.
  97771. * This is the best way to simulate real life cameras.
  97772. */
  97773. static readonly PERSPECTIVE_CAMERA: number;
  97774. /**
  97775. * This helps creating camera with an orthographic mode.
  97776. * 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.
  97777. */
  97778. static readonly ORTHOGRAPHIC_CAMERA: number;
  97779. /**
  97780. * This is the default FOV mode for perspective cameras.
  97781. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  97782. */
  97783. static readonly FOVMODE_VERTICAL_FIXED: number;
  97784. /**
  97785. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  97786. */
  97787. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  97788. /**
  97789. * This specifies ther is no need for a camera rig.
  97790. * Basically only one eye is rendered corresponding to the camera.
  97791. */
  97792. static readonly RIG_MODE_NONE: number;
  97793. /**
  97794. * Simulates a camera Rig with one blue eye and one red eye.
  97795. * This can be use with 3d blue and red glasses.
  97796. */
  97797. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  97798. /**
  97799. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  97800. */
  97801. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  97802. /**
  97803. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  97804. */
  97805. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  97806. /**
  97807. * Defines that both eyes of the camera will be rendered over under each other.
  97808. */
  97809. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  97810. /**
  97811. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  97812. */
  97813. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  97814. /**
  97815. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  97816. */
  97817. static readonly RIG_MODE_VR: number;
  97818. /**
  97819. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  97820. */
  97821. static readonly RIG_MODE_WEBVR: number;
  97822. /**
  97823. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  97824. */
  97825. static readonly RIG_MODE_CUSTOM: number;
  97826. /**
  97827. * Defines if by default attaching controls should prevent the default javascript event to continue.
  97828. */
  97829. static ForceAttachControlToAlwaysPreventDefault: boolean;
  97830. /**
  97831. * Define the input manager associated with the camera.
  97832. */
  97833. inputs: CameraInputsManager<Camera>;
  97834. /** @hidden */
  97835. _position: Vector3;
  97836. /**
  97837. * Define the current local position of the camera in the scene
  97838. */
  97839. get position(): Vector3;
  97840. set position(newPosition: Vector3);
  97841. /**
  97842. * The vector the camera should consider as up.
  97843. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  97844. */
  97845. upVector: Vector3;
  97846. /**
  97847. * Define the current limit on the left side for an orthographic camera
  97848. * In scene unit
  97849. */
  97850. orthoLeft: Nullable<number>;
  97851. /**
  97852. * Define the current limit on the right side for an orthographic camera
  97853. * In scene unit
  97854. */
  97855. orthoRight: Nullable<number>;
  97856. /**
  97857. * Define the current limit on the bottom side for an orthographic camera
  97858. * In scene unit
  97859. */
  97860. orthoBottom: Nullable<number>;
  97861. /**
  97862. * Define the current limit on the top side for an orthographic camera
  97863. * In scene unit
  97864. */
  97865. orthoTop: Nullable<number>;
  97866. /**
  97867. * Field Of View is set in Radians. (default is 0.8)
  97868. */
  97869. fov: number;
  97870. /**
  97871. * Define the minimum distance the camera can see from.
  97872. * This is important to note that the depth buffer are not infinite and the closer it starts
  97873. * the more your scene might encounter depth fighting issue.
  97874. */
  97875. minZ: number;
  97876. /**
  97877. * Define the maximum distance the camera can see to.
  97878. * This is important to note that the depth buffer are not infinite and the further it end
  97879. * the more your scene might encounter depth fighting issue.
  97880. */
  97881. maxZ: number;
  97882. /**
  97883. * Define the default inertia of the camera.
  97884. * This helps giving a smooth feeling to the camera movement.
  97885. */
  97886. inertia: number;
  97887. /**
  97888. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  97889. */
  97890. mode: number;
  97891. /**
  97892. * Define wether the camera is intermediate.
  97893. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  97894. */
  97895. isIntermediate: boolean;
  97896. /**
  97897. * Define the viewport of the camera.
  97898. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  97899. */
  97900. viewport: Viewport;
  97901. /**
  97902. * Restricts the camera to viewing objects with the same layerMask.
  97903. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  97904. */
  97905. layerMask: number;
  97906. /**
  97907. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  97908. */
  97909. fovMode: number;
  97910. /**
  97911. * Rig mode of the camera.
  97912. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  97913. * This is normally controlled byt the camera themselves as internal use.
  97914. */
  97915. cameraRigMode: number;
  97916. /**
  97917. * Defines the distance between both "eyes" in case of a RIG
  97918. */
  97919. interaxialDistance: number;
  97920. /**
  97921. * Defines if stereoscopic rendering is done side by side or over under.
  97922. */
  97923. isStereoscopicSideBySide: boolean;
  97924. /**
  97925. * 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
  97926. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  97927. * else in the scene. (Eg. security camera)
  97928. *
  97929. * 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)
  97930. */
  97931. customRenderTargets: RenderTargetTexture[];
  97932. /**
  97933. * When set, the camera will render to this render target instead of the default canvas
  97934. *
  97935. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  97936. */
  97937. outputRenderTarget: Nullable<RenderTargetTexture>;
  97938. /**
  97939. * Observable triggered when the camera view matrix has changed.
  97940. */
  97941. onViewMatrixChangedObservable: Observable<Camera>;
  97942. /**
  97943. * Observable triggered when the camera Projection matrix has changed.
  97944. */
  97945. onProjectionMatrixChangedObservable: Observable<Camera>;
  97946. /**
  97947. * Observable triggered when the inputs have been processed.
  97948. */
  97949. onAfterCheckInputsObservable: Observable<Camera>;
  97950. /**
  97951. * Observable triggered when reset has been called and applied to the camera.
  97952. */
  97953. onRestoreStateObservable: Observable<Camera>;
  97954. /** @hidden */
  97955. _cameraRigParams: any;
  97956. /** @hidden */
  97957. _rigCameras: Camera[];
  97958. /** @hidden */
  97959. _rigPostProcess: Nullable<PostProcess>;
  97960. protected _webvrViewMatrix: Matrix;
  97961. /** @hidden */
  97962. _skipRendering: boolean;
  97963. /** @hidden */
  97964. _projectionMatrix: Matrix;
  97965. /** @hidden */
  97966. _postProcesses: Nullable<PostProcess>[];
  97967. /** @hidden */
  97968. _activeMeshes: SmartArray<AbstractMesh>;
  97969. protected _globalPosition: Vector3;
  97970. /** @hidden */
  97971. _computedViewMatrix: Matrix;
  97972. private _doNotComputeProjectionMatrix;
  97973. private _transformMatrix;
  97974. private _frustumPlanes;
  97975. private _refreshFrustumPlanes;
  97976. private _storedFov;
  97977. private _stateStored;
  97978. /**
  97979. * Instantiates a new camera object.
  97980. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  97981. * @see http://doc.babylonjs.com/features/cameras
  97982. * @param name Defines the name of the camera in the scene
  97983. * @param position Defines the position of the camera
  97984. * @param scene Defines the scene the camera belongs too
  97985. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  97986. */
  97987. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97988. /**
  97989. * Store current camera state (fov, position, etc..)
  97990. * @returns the camera
  97991. */
  97992. storeState(): Camera;
  97993. /**
  97994. * Restores the camera state values if it has been stored. You must call storeState() first
  97995. */
  97996. protected _restoreStateValues(): boolean;
  97997. /**
  97998. * Restored camera state. You must call storeState() first.
  97999. * @returns true if restored and false otherwise
  98000. */
  98001. restoreState(): boolean;
  98002. /**
  98003. * Gets the class name of the camera.
  98004. * @returns the class name
  98005. */
  98006. getClassName(): string;
  98007. /** @hidden */
  98008. readonly _isCamera: boolean;
  98009. /**
  98010. * Gets a string representation of the camera useful for debug purpose.
  98011. * @param fullDetails Defines that a more verboe level of logging is required
  98012. * @returns the string representation
  98013. */
  98014. toString(fullDetails?: boolean): string;
  98015. /**
  98016. * Gets the current world space position of the camera.
  98017. */
  98018. get globalPosition(): Vector3;
  98019. /**
  98020. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98021. * @returns the active meshe list
  98022. */
  98023. getActiveMeshes(): SmartArray<AbstractMesh>;
  98024. /**
  98025. * Check wether a mesh is part of the current active mesh list of the camera
  98026. * @param mesh Defines the mesh to check
  98027. * @returns true if active, false otherwise
  98028. */
  98029. isActiveMesh(mesh: Mesh): boolean;
  98030. /**
  98031. * Is this camera ready to be used/rendered
  98032. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98033. * @return true if the camera is ready
  98034. */
  98035. isReady(completeCheck?: boolean): boolean;
  98036. /** @hidden */
  98037. _initCache(): void;
  98038. /** @hidden */
  98039. _updateCache(ignoreParentClass?: boolean): void;
  98040. /** @hidden */
  98041. _isSynchronized(): boolean;
  98042. /** @hidden */
  98043. _isSynchronizedViewMatrix(): boolean;
  98044. /** @hidden */
  98045. _isSynchronizedProjectionMatrix(): boolean;
  98046. /**
  98047. * Attach the input controls to a specific dom element to get the input from.
  98048. * @param element Defines the element the controls should be listened from
  98049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98050. */
  98051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98052. /**
  98053. * Detach the current controls from the specified dom element.
  98054. * @param element Defines the element to stop listening the inputs from
  98055. */
  98056. detachControl(element: HTMLElement): void;
  98057. /**
  98058. * Update the camera state according to the different inputs gathered during the frame.
  98059. */
  98060. update(): void;
  98061. /** @hidden */
  98062. _checkInputs(): void;
  98063. /** @hidden */
  98064. get rigCameras(): Camera[];
  98065. /**
  98066. * Gets the post process used by the rig cameras
  98067. */
  98068. get rigPostProcess(): Nullable<PostProcess>;
  98069. /**
  98070. * Internal, gets the first post proces.
  98071. * @returns the first post process to be run on this camera.
  98072. */
  98073. _getFirstPostProcess(): Nullable<PostProcess>;
  98074. private _cascadePostProcessesToRigCams;
  98075. /**
  98076. * Attach a post process to the camera.
  98077. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98078. * @param postProcess The post process to attach to the camera
  98079. * @param insertAt The position of the post process in case several of them are in use in the scene
  98080. * @returns the position the post process has been inserted at
  98081. */
  98082. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98083. /**
  98084. * Detach a post process to the camera.
  98085. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98086. * @param postProcess The post process to detach from the camera
  98087. */
  98088. detachPostProcess(postProcess: PostProcess): void;
  98089. /**
  98090. * Gets the current world matrix of the camera
  98091. */
  98092. getWorldMatrix(): Matrix;
  98093. /** @hidden */
  98094. _getViewMatrix(): Matrix;
  98095. /**
  98096. * Gets the current view matrix of the camera.
  98097. * @param force forces the camera to recompute the matrix without looking at the cached state
  98098. * @returns the view matrix
  98099. */
  98100. getViewMatrix(force?: boolean): Matrix;
  98101. /**
  98102. * Freeze the projection matrix.
  98103. * It will prevent the cache check of the camera projection compute and can speed up perf
  98104. * if no parameter of the camera are meant to change
  98105. * @param projection Defines manually a projection if necessary
  98106. */
  98107. freezeProjectionMatrix(projection?: Matrix): void;
  98108. /**
  98109. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98110. */
  98111. unfreezeProjectionMatrix(): void;
  98112. /**
  98113. * Gets the current projection matrix of the camera.
  98114. * @param force forces the camera to recompute the matrix without looking at the cached state
  98115. * @returns the projection matrix
  98116. */
  98117. getProjectionMatrix(force?: boolean): Matrix;
  98118. /**
  98119. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98120. * @returns a Matrix
  98121. */
  98122. getTransformationMatrix(): Matrix;
  98123. private _updateFrustumPlanes;
  98124. /**
  98125. * Checks if a cullable object (mesh...) is in the camera frustum
  98126. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98127. * @param target The object to check
  98128. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98129. * @returns true if the object is in frustum otherwise false
  98130. */
  98131. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98132. /**
  98133. * Checks if a cullable object (mesh...) is in the camera frustum
  98134. * Unlike isInFrustum this cheks the full bounding box
  98135. * @param target The object to check
  98136. * @returns true if the object is in frustum otherwise false
  98137. */
  98138. isCompletelyInFrustum(target: ICullable): boolean;
  98139. /**
  98140. * Gets a ray in the forward direction from the camera.
  98141. * @param length Defines the length of the ray to create
  98142. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98143. * @param origin Defines the start point of the ray which defaults to the camera position
  98144. * @returns the forward ray
  98145. */
  98146. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98147. /**
  98148. * Releases resources associated with this node.
  98149. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98150. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98151. */
  98152. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98153. /** @hidden */
  98154. _isLeftCamera: boolean;
  98155. /**
  98156. * Gets the left camera of a rig setup in case of Rigged Camera
  98157. */
  98158. get isLeftCamera(): boolean;
  98159. /** @hidden */
  98160. _isRightCamera: boolean;
  98161. /**
  98162. * Gets the right camera of a rig setup in case of Rigged Camera
  98163. */
  98164. get isRightCamera(): boolean;
  98165. /**
  98166. * Gets the left camera of a rig setup in case of Rigged Camera
  98167. */
  98168. get leftCamera(): Nullable<FreeCamera>;
  98169. /**
  98170. * Gets the right camera of a rig setup in case of Rigged Camera
  98171. */
  98172. get rightCamera(): Nullable<FreeCamera>;
  98173. /**
  98174. * Gets the left camera target of a rig setup in case of Rigged Camera
  98175. * @returns the target position
  98176. */
  98177. getLeftTarget(): Nullable<Vector3>;
  98178. /**
  98179. * Gets the right camera target of a rig setup in case of Rigged Camera
  98180. * @returns the target position
  98181. */
  98182. getRightTarget(): Nullable<Vector3>;
  98183. /**
  98184. * @hidden
  98185. */
  98186. setCameraRigMode(mode: number, rigParams: any): void;
  98187. /** @hidden */
  98188. static _setStereoscopicRigMode(camera: Camera): void;
  98189. /** @hidden */
  98190. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  98191. /** @hidden */
  98192. static _setVRRigMode(camera: Camera, rigParams: any): void;
  98193. /** @hidden */
  98194. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  98195. /** @hidden */
  98196. _getVRProjectionMatrix(): Matrix;
  98197. protected _updateCameraRotationMatrix(): void;
  98198. protected _updateWebVRCameraRotationMatrix(): void;
  98199. /**
  98200. * This function MUST be overwritten by the different WebVR cameras available.
  98201. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98202. * @hidden
  98203. */
  98204. _getWebVRProjectionMatrix(): Matrix;
  98205. /**
  98206. * This function MUST be overwritten by the different WebVR cameras available.
  98207. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98208. * @hidden
  98209. */
  98210. _getWebVRViewMatrix(): Matrix;
  98211. /** @hidden */
  98212. setCameraRigParameter(name: string, value: any): void;
  98213. /**
  98214. * needs to be overridden by children so sub has required properties to be copied
  98215. * @hidden
  98216. */
  98217. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98218. /**
  98219. * May need to be overridden by children
  98220. * @hidden
  98221. */
  98222. _updateRigCameras(): void;
  98223. /** @hidden */
  98224. _setupInputs(): void;
  98225. /**
  98226. * Serialiaze the camera setup to a json represention
  98227. * @returns the JSON representation
  98228. */
  98229. serialize(): any;
  98230. /**
  98231. * Clones the current camera.
  98232. * @param name The cloned camera name
  98233. * @returns the cloned camera
  98234. */
  98235. clone(name: string): Camera;
  98236. /**
  98237. * Gets the direction of the camera relative to a given local axis.
  98238. * @param localAxis Defines the reference axis to provide a relative direction.
  98239. * @return the direction
  98240. */
  98241. getDirection(localAxis: Vector3): Vector3;
  98242. /**
  98243. * Returns the current camera absolute rotation
  98244. */
  98245. get absoluteRotation(): Quaternion;
  98246. /**
  98247. * Gets the direction of the camera relative to a given local axis into a passed vector.
  98248. * @param localAxis Defines the reference axis to provide a relative direction.
  98249. * @param result Defines the vector to store the result in
  98250. */
  98251. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  98252. /**
  98253. * Gets a camera constructor for a given camera type
  98254. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  98255. * @param name The name of the camera the result will be able to instantiate
  98256. * @param scene The scene the result will construct the camera in
  98257. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  98258. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  98259. * @returns a factory method to construc the camera
  98260. */
  98261. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  98262. /**
  98263. * Compute the world matrix of the camera.
  98264. * @returns the camera world matrix
  98265. */
  98266. computeWorldMatrix(): Matrix;
  98267. /**
  98268. * Parse a JSON and creates the camera from the parsed information
  98269. * @param parsedCamera The JSON to parse
  98270. * @param scene The scene to instantiate the camera in
  98271. * @returns the newly constructed camera
  98272. */
  98273. static Parse(parsedCamera: any, scene: Scene): Camera;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. /**
  98278. * Class containing static functions to help procedurally build meshes
  98279. */
  98280. export class DiscBuilder {
  98281. /**
  98282. * Creates a plane polygonal mesh. By default, this is a disc
  98283. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  98284. * * 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
  98285. * * 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
  98286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98289. * @param name defines the name of the mesh
  98290. * @param options defines the options used to create the mesh
  98291. * @param scene defines the hosting scene
  98292. * @returns the plane polygonal mesh
  98293. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  98294. */
  98295. static CreateDisc(name: string, options: {
  98296. radius?: number;
  98297. tessellation?: number;
  98298. arc?: number;
  98299. updatable?: boolean;
  98300. sideOrientation?: number;
  98301. frontUVs?: Vector4;
  98302. backUVs?: Vector4;
  98303. }, scene?: Nullable<Scene>): Mesh;
  98304. }
  98305. }
  98306. declare module BABYLON {
  98307. /**
  98308. * This represents all the required information to add a fresnel effect on a material:
  98309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98310. */
  98311. export class FresnelParameters {
  98312. private _isEnabled;
  98313. /**
  98314. * Define if the fresnel effect is enable or not.
  98315. */
  98316. get isEnabled(): boolean;
  98317. set isEnabled(value: boolean);
  98318. /**
  98319. * Define the color used on edges (grazing angle)
  98320. */
  98321. leftColor: Color3;
  98322. /**
  98323. * Define the color used on center
  98324. */
  98325. rightColor: Color3;
  98326. /**
  98327. * Define bias applied to computed fresnel term
  98328. */
  98329. bias: number;
  98330. /**
  98331. * Defined the power exponent applied to fresnel term
  98332. */
  98333. power: number;
  98334. /**
  98335. * Clones the current fresnel and its valuues
  98336. * @returns a clone fresnel configuration
  98337. */
  98338. clone(): FresnelParameters;
  98339. /**
  98340. * Serializes the current fresnel parameters to a JSON representation.
  98341. * @return the JSON serialization
  98342. */
  98343. serialize(): any;
  98344. /**
  98345. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  98346. * @param parsedFresnelParameters Define the JSON representation
  98347. * @returns the parsed parameters
  98348. */
  98349. static Parse(parsedFresnelParameters: any): FresnelParameters;
  98350. }
  98351. }
  98352. declare module BABYLON {
  98353. /**
  98354. * Base class of materials working in push mode in babylon JS
  98355. * @hidden
  98356. */
  98357. export class PushMaterial extends Material {
  98358. protected _activeEffect: Effect;
  98359. protected _normalMatrix: Matrix;
  98360. /**
  98361. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98362. * This means that the material can keep using a previous shader while a new one is being compiled.
  98363. * This is mostly used when shader parallel compilation is supported (true by default)
  98364. */
  98365. allowShaderHotSwapping: boolean;
  98366. constructor(name: string, scene: Scene);
  98367. getEffect(): Effect;
  98368. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98369. /**
  98370. * Binds the given world matrix to the active effect
  98371. *
  98372. * @param world the matrix to bind
  98373. */
  98374. bindOnlyWorldMatrix(world: Matrix): void;
  98375. /**
  98376. * Binds the given normal matrix to the active effect
  98377. *
  98378. * @param normalMatrix the matrix to bind
  98379. */
  98380. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98381. bind(world: Matrix, mesh?: Mesh): void;
  98382. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98383. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98384. }
  98385. }
  98386. declare module BABYLON {
  98387. /**
  98388. * This groups all the flags used to control the materials channel.
  98389. */
  98390. export class MaterialFlags {
  98391. private static _DiffuseTextureEnabled;
  98392. /**
  98393. * Are diffuse textures enabled in the application.
  98394. */
  98395. static get DiffuseTextureEnabled(): boolean;
  98396. static set DiffuseTextureEnabled(value: boolean);
  98397. private static _AmbientTextureEnabled;
  98398. /**
  98399. * Are ambient textures enabled in the application.
  98400. */
  98401. static get AmbientTextureEnabled(): boolean;
  98402. static set AmbientTextureEnabled(value: boolean);
  98403. private static _OpacityTextureEnabled;
  98404. /**
  98405. * Are opacity textures enabled in the application.
  98406. */
  98407. static get OpacityTextureEnabled(): boolean;
  98408. static set OpacityTextureEnabled(value: boolean);
  98409. private static _ReflectionTextureEnabled;
  98410. /**
  98411. * Are reflection textures enabled in the application.
  98412. */
  98413. static get ReflectionTextureEnabled(): boolean;
  98414. static set ReflectionTextureEnabled(value: boolean);
  98415. private static _EmissiveTextureEnabled;
  98416. /**
  98417. * Are emissive textures enabled in the application.
  98418. */
  98419. static get EmissiveTextureEnabled(): boolean;
  98420. static set EmissiveTextureEnabled(value: boolean);
  98421. private static _SpecularTextureEnabled;
  98422. /**
  98423. * Are specular textures enabled in the application.
  98424. */
  98425. static get SpecularTextureEnabled(): boolean;
  98426. static set SpecularTextureEnabled(value: boolean);
  98427. private static _BumpTextureEnabled;
  98428. /**
  98429. * Are bump textures enabled in the application.
  98430. */
  98431. static get BumpTextureEnabled(): boolean;
  98432. static set BumpTextureEnabled(value: boolean);
  98433. private static _LightmapTextureEnabled;
  98434. /**
  98435. * Are lightmap textures enabled in the application.
  98436. */
  98437. static get LightmapTextureEnabled(): boolean;
  98438. static set LightmapTextureEnabled(value: boolean);
  98439. private static _RefractionTextureEnabled;
  98440. /**
  98441. * Are refraction textures enabled in the application.
  98442. */
  98443. static get RefractionTextureEnabled(): boolean;
  98444. static set RefractionTextureEnabled(value: boolean);
  98445. private static _ColorGradingTextureEnabled;
  98446. /**
  98447. * Are color grading textures enabled in the application.
  98448. */
  98449. static get ColorGradingTextureEnabled(): boolean;
  98450. static set ColorGradingTextureEnabled(value: boolean);
  98451. private static _FresnelEnabled;
  98452. /**
  98453. * Are fresnels enabled in the application.
  98454. */
  98455. static get FresnelEnabled(): boolean;
  98456. static set FresnelEnabled(value: boolean);
  98457. private static _ClearCoatTextureEnabled;
  98458. /**
  98459. * Are clear coat textures enabled in the application.
  98460. */
  98461. static get ClearCoatTextureEnabled(): boolean;
  98462. static set ClearCoatTextureEnabled(value: boolean);
  98463. private static _ClearCoatBumpTextureEnabled;
  98464. /**
  98465. * Are clear coat bump textures enabled in the application.
  98466. */
  98467. static get ClearCoatBumpTextureEnabled(): boolean;
  98468. static set ClearCoatBumpTextureEnabled(value: boolean);
  98469. private static _ClearCoatTintTextureEnabled;
  98470. /**
  98471. * Are clear coat tint textures enabled in the application.
  98472. */
  98473. static get ClearCoatTintTextureEnabled(): boolean;
  98474. static set ClearCoatTintTextureEnabled(value: boolean);
  98475. private static _SheenTextureEnabled;
  98476. /**
  98477. * Are sheen textures enabled in the application.
  98478. */
  98479. static get SheenTextureEnabled(): boolean;
  98480. static set SheenTextureEnabled(value: boolean);
  98481. private static _AnisotropicTextureEnabled;
  98482. /**
  98483. * Are anisotropic textures enabled in the application.
  98484. */
  98485. static get AnisotropicTextureEnabled(): boolean;
  98486. static set AnisotropicTextureEnabled(value: boolean);
  98487. private static _ThicknessTextureEnabled;
  98488. /**
  98489. * Are thickness textures enabled in the application.
  98490. */
  98491. static get ThicknessTextureEnabled(): boolean;
  98492. static set ThicknessTextureEnabled(value: boolean);
  98493. }
  98494. }
  98495. declare module BABYLON {
  98496. /** @hidden */
  98497. export var defaultFragmentDeclaration: {
  98498. name: string;
  98499. shader: string;
  98500. };
  98501. }
  98502. declare module BABYLON {
  98503. /** @hidden */
  98504. export var defaultUboDeclaration: {
  98505. name: string;
  98506. shader: string;
  98507. };
  98508. }
  98509. declare module BABYLON {
  98510. /** @hidden */
  98511. export var lightFragmentDeclaration: {
  98512. name: string;
  98513. shader: string;
  98514. };
  98515. }
  98516. declare module BABYLON {
  98517. /** @hidden */
  98518. export var lightUboDeclaration: {
  98519. name: string;
  98520. shader: string;
  98521. };
  98522. }
  98523. declare module BABYLON {
  98524. /** @hidden */
  98525. export var lightsFragmentFunctions: {
  98526. name: string;
  98527. shader: string;
  98528. };
  98529. }
  98530. declare module BABYLON {
  98531. /** @hidden */
  98532. export var shadowsFragmentFunctions: {
  98533. name: string;
  98534. shader: string;
  98535. };
  98536. }
  98537. declare module BABYLON {
  98538. /** @hidden */
  98539. export var fresnelFunction: {
  98540. name: string;
  98541. shader: string;
  98542. };
  98543. }
  98544. declare module BABYLON {
  98545. /** @hidden */
  98546. export var reflectionFunction: {
  98547. name: string;
  98548. shader: string;
  98549. };
  98550. }
  98551. declare module BABYLON {
  98552. /** @hidden */
  98553. export var bumpFragmentFunctions: {
  98554. name: string;
  98555. shader: string;
  98556. };
  98557. }
  98558. declare module BABYLON {
  98559. /** @hidden */
  98560. export var logDepthDeclaration: {
  98561. name: string;
  98562. shader: string;
  98563. };
  98564. }
  98565. declare module BABYLON {
  98566. /** @hidden */
  98567. export var bumpFragment: {
  98568. name: string;
  98569. shader: string;
  98570. };
  98571. }
  98572. declare module BABYLON {
  98573. /** @hidden */
  98574. export var depthPrePass: {
  98575. name: string;
  98576. shader: string;
  98577. };
  98578. }
  98579. declare module BABYLON {
  98580. /** @hidden */
  98581. export var lightFragment: {
  98582. name: string;
  98583. shader: string;
  98584. };
  98585. }
  98586. declare module BABYLON {
  98587. /** @hidden */
  98588. export var logDepthFragment: {
  98589. name: string;
  98590. shader: string;
  98591. };
  98592. }
  98593. declare module BABYLON {
  98594. /** @hidden */
  98595. export var defaultPixelShader: {
  98596. name: string;
  98597. shader: string;
  98598. };
  98599. }
  98600. declare module BABYLON {
  98601. /** @hidden */
  98602. export var defaultVertexDeclaration: {
  98603. name: string;
  98604. shader: string;
  98605. };
  98606. }
  98607. declare module BABYLON {
  98608. /** @hidden */
  98609. export var bumpVertexDeclaration: {
  98610. name: string;
  98611. shader: string;
  98612. };
  98613. }
  98614. declare module BABYLON {
  98615. /** @hidden */
  98616. export var bumpVertex: {
  98617. name: string;
  98618. shader: string;
  98619. };
  98620. }
  98621. declare module BABYLON {
  98622. /** @hidden */
  98623. export var fogVertex: {
  98624. name: string;
  98625. shader: string;
  98626. };
  98627. }
  98628. declare module BABYLON {
  98629. /** @hidden */
  98630. export var shadowsVertex: {
  98631. name: string;
  98632. shader: string;
  98633. };
  98634. }
  98635. declare module BABYLON {
  98636. /** @hidden */
  98637. export var pointCloudVertex: {
  98638. name: string;
  98639. shader: string;
  98640. };
  98641. }
  98642. declare module BABYLON {
  98643. /** @hidden */
  98644. export var logDepthVertex: {
  98645. name: string;
  98646. shader: string;
  98647. };
  98648. }
  98649. declare module BABYLON {
  98650. /** @hidden */
  98651. export var defaultVertexShader: {
  98652. name: string;
  98653. shader: string;
  98654. };
  98655. }
  98656. declare module BABYLON {
  98657. /** @hidden */
  98658. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98659. MAINUV1: boolean;
  98660. MAINUV2: boolean;
  98661. DIFFUSE: boolean;
  98662. DIFFUSEDIRECTUV: number;
  98663. AMBIENT: boolean;
  98664. AMBIENTDIRECTUV: number;
  98665. OPACITY: boolean;
  98666. OPACITYDIRECTUV: number;
  98667. OPACITYRGB: boolean;
  98668. REFLECTION: boolean;
  98669. EMISSIVE: boolean;
  98670. EMISSIVEDIRECTUV: number;
  98671. SPECULAR: boolean;
  98672. SPECULARDIRECTUV: number;
  98673. BUMP: boolean;
  98674. BUMPDIRECTUV: number;
  98675. PARALLAX: boolean;
  98676. PARALLAXOCCLUSION: boolean;
  98677. SPECULAROVERALPHA: boolean;
  98678. CLIPPLANE: boolean;
  98679. CLIPPLANE2: boolean;
  98680. CLIPPLANE3: boolean;
  98681. CLIPPLANE4: boolean;
  98682. CLIPPLANE5: boolean;
  98683. CLIPPLANE6: boolean;
  98684. ALPHATEST: boolean;
  98685. DEPTHPREPASS: boolean;
  98686. ALPHAFROMDIFFUSE: boolean;
  98687. POINTSIZE: boolean;
  98688. FOG: boolean;
  98689. SPECULARTERM: boolean;
  98690. DIFFUSEFRESNEL: boolean;
  98691. OPACITYFRESNEL: boolean;
  98692. REFLECTIONFRESNEL: boolean;
  98693. REFRACTIONFRESNEL: boolean;
  98694. EMISSIVEFRESNEL: boolean;
  98695. FRESNEL: boolean;
  98696. NORMAL: boolean;
  98697. UV1: boolean;
  98698. UV2: boolean;
  98699. VERTEXCOLOR: boolean;
  98700. VERTEXALPHA: boolean;
  98701. NUM_BONE_INFLUENCERS: number;
  98702. BonesPerMesh: number;
  98703. BONETEXTURE: boolean;
  98704. INSTANCES: boolean;
  98705. GLOSSINESS: boolean;
  98706. ROUGHNESS: boolean;
  98707. EMISSIVEASILLUMINATION: boolean;
  98708. LINKEMISSIVEWITHDIFFUSE: boolean;
  98709. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98710. LIGHTMAP: boolean;
  98711. LIGHTMAPDIRECTUV: number;
  98712. OBJECTSPACE_NORMALMAP: boolean;
  98713. USELIGHTMAPASSHADOWMAP: boolean;
  98714. REFLECTIONMAP_3D: boolean;
  98715. REFLECTIONMAP_SPHERICAL: boolean;
  98716. REFLECTIONMAP_PLANAR: boolean;
  98717. REFLECTIONMAP_CUBIC: boolean;
  98718. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98719. REFLECTIONMAP_PROJECTION: boolean;
  98720. REFLECTIONMAP_SKYBOX: boolean;
  98721. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98722. REFLECTIONMAP_EXPLICIT: boolean;
  98723. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98724. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98725. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98726. INVERTCUBICMAP: boolean;
  98727. LOGARITHMICDEPTH: boolean;
  98728. REFRACTION: boolean;
  98729. REFRACTIONMAP_3D: boolean;
  98730. REFLECTIONOVERALPHA: boolean;
  98731. TWOSIDEDLIGHTING: boolean;
  98732. SHADOWFLOAT: boolean;
  98733. MORPHTARGETS: boolean;
  98734. MORPHTARGETS_NORMAL: boolean;
  98735. MORPHTARGETS_TANGENT: boolean;
  98736. MORPHTARGETS_UV: boolean;
  98737. NUM_MORPH_INFLUENCERS: number;
  98738. NONUNIFORMSCALING: boolean;
  98739. PREMULTIPLYALPHA: boolean;
  98740. IMAGEPROCESSING: boolean;
  98741. VIGNETTE: boolean;
  98742. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98743. VIGNETTEBLENDMODEOPAQUE: boolean;
  98744. TONEMAPPING: boolean;
  98745. TONEMAPPING_ACES: boolean;
  98746. CONTRAST: boolean;
  98747. COLORCURVES: boolean;
  98748. COLORGRADING: boolean;
  98749. COLORGRADING3D: boolean;
  98750. SAMPLER3DGREENDEPTH: boolean;
  98751. SAMPLER3DBGRMAP: boolean;
  98752. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98753. MULTIVIEW: boolean;
  98754. /**
  98755. * If the reflection texture on this material is in linear color space
  98756. * @hidden
  98757. */
  98758. IS_REFLECTION_LINEAR: boolean;
  98759. /**
  98760. * If the refraction texture on this material is in linear color space
  98761. * @hidden
  98762. */
  98763. IS_REFRACTION_LINEAR: boolean;
  98764. EXPOSURE: boolean;
  98765. constructor();
  98766. setReflectionMode(modeToEnable: string): void;
  98767. }
  98768. /**
  98769. * This is the default material used in Babylon. It is the best trade off between quality
  98770. * and performances.
  98771. * @see http://doc.babylonjs.com/babylon101/materials
  98772. */
  98773. export class StandardMaterial extends PushMaterial {
  98774. private _diffuseTexture;
  98775. /**
  98776. * The basic texture of the material as viewed under a light.
  98777. */
  98778. diffuseTexture: Nullable<BaseTexture>;
  98779. private _ambientTexture;
  98780. /**
  98781. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98782. */
  98783. ambientTexture: Nullable<BaseTexture>;
  98784. private _opacityTexture;
  98785. /**
  98786. * Define the transparency of the material from a texture.
  98787. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98788. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98789. */
  98790. opacityTexture: Nullable<BaseTexture>;
  98791. private _reflectionTexture;
  98792. /**
  98793. * Define the texture used to display the reflection.
  98794. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98795. */
  98796. reflectionTexture: Nullable<BaseTexture>;
  98797. private _emissiveTexture;
  98798. /**
  98799. * Define texture of the material as if self lit.
  98800. * This will be mixed in the final result even in the absence of light.
  98801. */
  98802. emissiveTexture: Nullable<BaseTexture>;
  98803. private _specularTexture;
  98804. /**
  98805. * Define how the color and intensity of the highlight given by the light in the material.
  98806. */
  98807. specularTexture: Nullable<BaseTexture>;
  98808. private _bumpTexture;
  98809. /**
  98810. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98811. * 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.
  98812. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98813. */
  98814. bumpTexture: Nullable<BaseTexture>;
  98815. private _lightmapTexture;
  98816. /**
  98817. * Complex lighting can be computationally expensive to compute at runtime.
  98818. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98819. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98820. */
  98821. lightmapTexture: Nullable<BaseTexture>;
  98822. private _refractionTexture;
  98823. /**
  98824. * Define the texture used to display the refraction.
  98825. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98826. */
  98827. refractionTexture: Nullable<BaseTexture>;
  98828. /**
  98829. * The color of the material lit by the environmental background lighting.
  98830. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98831. */
  98832. ambientColor: Color3;
  98833. /**
  98834. * The basic color of the material as viewed under a light.
  98835. */
  98836. diffuseColor: Color3;
  98837. /**
  98838. * Define how the color and intensity of the highlight given by the light in the material.
  98839. */
  98840. specularColor: Color3;
  98841. /**
  98842. * Define the color of the material as if self lit.
  98843. * This will be mixed in the final result even in the absence of light.
  98844. */
  98845. emissiveColor: Color3;
  98846. /**
  98847. * Defines how sharp are the highlights in the material.
  98848. * The bigger the value the sharper giving a more glossy feeling to the result.
  98849. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98850. */
  98851. specularPower: number;
  98852. private _useAlphaFromDiffuseTexture;
  98853. /**
  98854. * Does the transparency come from the diffuse texture alpha channel.
  98855. */
  98856. useAlphaFromDiffuseTexture: boolean;
  98857. private _useEmissiveAsIllumination;
  98858. /**
  98859. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98860. */
  98861. useEmissiveAsIllumination: boolean;
  98862. private _linkEmissiveWithDiffuse;
  98863. /**
  98864. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98865. * the emissive level when the final color is close to one.
  98866. */
  98867. linkEmissiveWithDiffuse: boolean;
  98868. private _useSpecularOverAlpha;
  98869. /**
  98870. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98871. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98872. */
  98873. useSpecularOverAlpha: boolean;
  98874. private _useReflectionOverAlpha;
  98875. /**
  98876. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98877. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98878. */
  98879. useReflectionOverAlpha: boolean;
  98880. private _disableLighting;
  98881. /**
  98882. * Does lights from the scene impacts this material.
  98883. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98884. */
  98885. disableLighting: boolean;
  98886. private _useObjectSpaceNormalMap;
  98887. /**
  98888. * Allows using an object space normal map (instead of tangent space).
  98889. */
  98890. useObjectSpaceNormalMap: boolean;
  98891. private _useParallax;
  98892. /**
  98893. * Is parallax enabled or not.
  98894. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98895. */
  98896. useParallax: boolean;
  98897. private _useParallaxOcclusion;
  98898. /**
  98899. * Is parallax occlusion enabled or not.
  98900. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98901. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98902. */
  98903. useParallaxOcclusion: boolean;
  98904. /**
  98905. * 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.
  98906. */
  98907. parallaxScaleBias: number;
  98908. private _roughness;
  98909. /**
  98910. * Helps to define how blurry the reflections should appears in the material.
  98911. */
  98912. roughness: number;
  98913. /**
  98914. * In case of refraction, define the value of the index of refraction.
  98915. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98916. */
  98917. indexOfRefraction: number;
  98918. /**
  98919. * Invert the refraction texture alongside the y axis.
  98920. * It can be useful with procedural textures or probe for instance.
  98921. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98922. */
  98923. invertRefractionY: boolean;
  98924. /**
  98925. * Defines the alpha limits in alpha test mode.
  98926. */
  98927. alphaCutOff: number;
  98928. private _useLightmapAsShadowmap;
  98929. /**
  98930. * In case of light mapping, define whether the map contains light or shadow informations.
  98931. */
  98932. useLightmapAsShadowmap: boolean;
  98933. private _diffuseFresnelParameters;
  98934. /**
  98935. * Define the diffuse fresnel parameters of the material.
  98936. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98937. */
  98938. diffuseFresnelParameters: FresnelParameters;
  98939. private _opacityFresnelParameters;
  98940. /**
  98941. * Define the opacity fresnel parameters of the material.
  98942. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98943. */
  98944. opacityFresnelParameters: FresnelParameters;
  98945. private _reflectionFresnelParameters;
  98946. /**
  98947. * Define the reflection fresnel parameters of the material.
  98948. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98949. */
  98950. reflectionFresnelParameters: FresnelParameters;
  98951. private _refractionFresnelParameters;
  98952. /**
  98953. * Define the refraction fresnel parameters of the material.
  98954. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98955. */
  98956. refractionFresnelParameters: FresnelParameters;
  98957. private _emissiveFresnelParameters;
  98958. /**
  98959. * Define the emissive fresnel parameters of the material.
  98960. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98961. */
  98962. emissiveFresnelParameters: FresnelParameters;
  98963. private _useReflectionFresnelFromSpecular;
  98964. /**
  98965. * If true automatically deducts the fresnels values from the material specularity.
  98966. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98967. */
  98968. useReflectionFresnelFromSpecular: boolean;
  98969. private _useGlossinessFromSpecularMapAlpha;
  98970. /**
  98971. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98972. */
  98973. useGlossinessFromSpecularMapAlpha: boolean;
  98974. private _maxSimultaneousLights;
  98975. /**
  98976. * Defines the maximum number of lights that can be used in the material
  98977. */
  98978. maxSimultaneousLights: number;
  98979. private _invertNormalMapX;
  98980. /**
  98981. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98982. */
  98983. invertNormalMapX: boolean;
  98984. private _invertNormalMapY;
  98985. /**
  98986. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98987. */
  98988. invertNormalMapY: boolean;
  98989. private _twoSidedLighting;
  98990. /**
  98991. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98992. */
  98993. twoSidedLighting: boolean;
  98994. /**
  98995. * Default configuration related to image processing available in the standard Material.
  98996. */
  98997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98998. /**
  98999. * Gets the image processing configuration used either in this material.
  99000. */
  99001. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99002. /**
  99003. * Sets the Default image processing configuration used either in the this material.
  99004. *
  99005. * If sets to null, the scene one is in use.
  99006. */
  99007. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99008. /**
  99009. * Keep track of the image processing observer to allow dispose and replace.
  99010. */
  99011. private _imageProcessingObserver;
  99012. /**
  99013. * Attaches a new image processing configuration to the Standard Material.
  99014. * @param configuration
  99015. */
  99016. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99017. /**
  99018. * Gets wether the color curves effect is enabled.
  99019. */
  99020. get cameraColorCurvesEnabled(): boolean;
  99021. /**
  99022. * Sets wether the color curves effect is enabled.
  99023. */
  99024. set cameraColorCurvesEnabled(value: boolean);
  99025. /**
  99026. * Gets wether the color grading effect is enabled.
  99027. */
  99028. get cameraColorGradingEnabled(): boolean;
  99029. /**
  99030. * Gets wether the color grading effect is enabled.
  99031. */
  99032. set cameraColorGradingEnabled(value: boolean);
  99033. /**
  99034. * Gets wether tonemapping is enabled or not.
  99035. */
  99036. get cameraToneMappingEnabled(): boolean;
  99037. /**
  99038. * Sets wether tonemapping is enabled or not
  99039. */
  99040. set cameraToneMappingEnabled(value: boolean);
  99041. /**
  99042. * The camera exposure used on this material.
  99043. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99044. * This corresponds to a photographic exposure.
  99045. */
  99046. get cameraExposure(): number;
  99047. /**
  99048. * The camera exposure used on this material.
  99049. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99050. * This corresponds to a photographic exposure.
  99051. */
  99052. set cameraExposure(value: number);
  99053. /**
  99054. * Gets The camera contrast used on this material.
  99055. */
  99056. get cameraContrast(): number;
  99057. /**
  99058. * Sets The camera contrast used on this material.
  99059. */
  99060. set cameraContrast(value: number);
  99061. /**
  99062. * Gets the Color Grading 2D Lookup Texture.
  99063. */
  99064. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99065. /**
  99066. * Sets the Color Grading 2D Lookup Texture.
  99067. */
  99068. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99069. /**
  99070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99072. * 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;
  99073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99074. */
  99075. get cameraColorCurves(): Nullable<ColorCurves>;
  99076. /**
  99077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99079. * 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;
  99080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99081. */
  99082. set cameraColorCurves(value: Nullable<ColorCurves>);
  99083. /**
  99084. * Custom callback helping to override the default shader used in the material.
  99085. */
  99086. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99087. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99088. protected _worldViewProjectionMatrix: Matrix;
  99089. protected _globalAmbientColor: Color3;
  99090. protected _useLogarithmicDepth: boolean;
  99091. protected _rebuildInParallel: boolean;
  99092. /**
  99093. * Instantiates a new standard material.
  99094. * This is the default material used in Babylon. It is the best trade off between quality
  99095. * and performances.
  99096. * @see http://doc.babylonjs.com/babylon101/materials
  99097. * @param name Define the name of the material in the scene
  99098. * @param scene Define the scene the material belong to
  99099. */
  99100. constructor(name: string, scene: Scene);
  99101. /**
  99102. * Gets a boolean indicating that current material needs to register RTT
  99103. */
  99104. get hasRenderTargetTextures(): boolean;
  99105. /**
  99106. * Gets the current class name of the material e.g. "StandardMaterial"
  99107. * Mainly use in serialization.
  99108. * @returns the class name
  99109. */
  99110. getClassName(): string;
  99111. /**
  99112. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99113. * You can try switching to logarithmic depth.
  99114. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99115. */
  99116. get useLogarithmicDepth(): boolean;
  99117. set useLogarithmicDepth(value: boolean);
  99118. /**
  99119. * Specifies if the material will require alpha blending
  99120. * @returns a boolean specifying if alpha blending is needed
  99121. */
  99122. needAlphaBlending(): boolean;
  99123. /**
  99124. * Specifies if this material should be rendered in alpha test mode
  99125. * @returns a boolean specifying if an alpha test is needed.
  99126. */
  99127. needAlphaTesting(): boolean;
  99128. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99129. /**
  99130. * Get the texture used for alpha test purpose.
  99131. * @returns the diffuse texture in case of the standard material.
  99132. */
  99133. getAlphaTestTexture(): Nullable<BaseTexture>;
  99134. /**
  99135. * Get if the submesh is ready to be used and all its information available.
  99136. * Child classes can use it to update shaders
  99137. * @param mesh defines the mesh to check
  99138. * @param subMesh defines which submesh to check
  99139. * @param useInstances specifies that instances should be used
  99140. * @returns a boolean indicating that the submesh is ready or not
  99141. */
  99142. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99143. /**
  99144. * Builds the material UBO layouts.
  99145. * Used internally during the effect preparation.
  99146. */
  99147. buildUniformLayout(): void;
  99148. /**
  99149. * Unbinds the material from the mesh
  99150. */
  99151. unbind(): void;
  99152. /**
  99153. * Binds the submesh to this material by preparing the effect and shader to draw
  99154. * @param world defines the world transformation matrix
  99155. * @param mesh defines the mesh containing the submesh
  99156. * @param subMesh defines the submesh to bind the material to
  99157. */
  99158. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99159. /**
  99160. * Get the list of animatables in the material.
  99161. * @returns the list of animatables object used in the material
  99162. */
  99163. getAnimatables(): IAnimatable[];
  99164. /**
  99165. * Gets the active textures from the material
  99166. * @returns an array of textures
  99167. */
  99168. getActiveTextures(): BaseTexture[];
  99169. /**
  99170. * Specifies if the material uses a texture
  99171. * @param texture defines the texture to check against the material
  99172. * @returns a boolean specifying if the material uses the texture
  99173. */
  99174. hasTexture(texture: BaseTexture): boolean;
  99175. /**
  99176. * Disposes the material
  99177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99179. */
  99180. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99181. /**
  99182. * Makes a duplicate of the material, and gives it a new name
  99183. * @param name defines the new name for the duplicated material
  99184. * @returns the cloned material
  99185. */
  99186. clone(name: string): StandardMaterial;
  99187. /**
  99188. * Serializes this material in a JSON representation
  99189. * @returns the serialized material object
  99190. */
  99191. serialize(): any;
  99192. /**
  99193. * Creates a standard material from parsed material data
  99194. * @param source defines the JSON representation of the material
  99195. * @param scene defines the hosting scene
  99196. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99197. * @returns a new standard material
  99198. */
  99199. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99200. /**
  99201. * Are diffuse textures enabled in the application.
  99202. */
  99203. static get DiffuseTextureEnabled(): boolean;
  99204. static set DiffuseTextureEnabled(value: boolean);
  99205. /**
  99206. * Are ambient textures enabled in the application.
  99207. */
  99208. static get AmbientTextureEnabled(): boolean;
  99209. static set AmbientTextureEnabled(value: boolean);
  99210. /**
  99211. * Are opacity textures enabled in the application.
  99212. */
  99213. static get OpacityTextureEnabled(): boolean;
  99214. static set OpacityTextureEnabled(value: boolean);
  99215. /**
  99216. * Are reflection textures enabled in the application.
  99217. */
  99218. static get ReflectionTextureEnabled(): boolean;
  99219. static set ReflectionTextureEnabled(value: boolean);
  99220. /**
  99221. * Are emissive textures enabled in the application.
  99222. */
  99223. static get EmissiveTextureEnabled(): boolean;
  99224. static set EmissiveTextureEnabled(value: boolean);
  99225. /**
  99226. * Are specular textures enabled in the application.
  99227. */
  99228. static get SpecularTextureEnabled(): boolean;
  99229. static set SpecularTextureEnabled(value: boolean);
  99230. /**
  99231. * Are bump textures enabled in the application.
  99232. */
  99233. static get BumpTextureEnabled(): boolean;
  99234. static set BumpTextureEnabled(value: boolean);
  99235. /**
  99236. * Are lightmap textures enabled in the application.
  99237. */
  99238. static get LightmapTextureEnabled(): boolean;
  99239. static set LightmapTextureEnabled(value: boolean);
  99240. /**
  99241. * Are refraction textures enabled in the application.
  99242. */
  99243. static get RefractionTextureEnabled(): boolean;
  99244. static set RefractionTextureEnabled(value: boolean);
  99245. /**
  99246. * Are color grading textures enabled in the application.
  99247. */
  99248. static get ColorGradingTextureEnabled(): boolean;
  99249. static set ColorGradingTextureEnabled(value: boolean);
  99250. /**
  99251. * Are fresnels enabled in the application.
  99252. */
  99253. static get FresnelEnabled(): boolean;
  99254. static set FresnelEnabled(value: boolean);
  99255. }
  99256. }
  99257. declare module BABYLON {
  99258. /**
  99259. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  99260. *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.
  99261. * The SPS is also a particle system. It provides some methods to manage the particles.
  99262. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  99263. *
  99264. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  99265. */
  99266. export class SolidParticleSystem implements IDisposable {
  99267. /**
  99268. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  99269. * Example : var p = SPS.particles[i];
  99270. */
  99271. particles: SolidParticle[];
  99272. /**
  99273. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  99274. */
  99275. nbParticles: number;
  99276. /**
  99277. * If the particles must ever face the camera (default false). Useful for planar particles.
  99278. */
  99279. billboard: boolean;
  99280. /**
  99281. * Recompute normals when adding a shape
  99282. */
  99283. recomputeNormals: boolean;
  99284. /**
  99285. * This a counter ofr your own usage. It's not set by any SPS functions.
  99286. */
  99287. counter: number;
  99288. /**
  99289. * The SPS name. This name is also given to the underlying mesh.
  99290. */
  99291. name: string;
  99292. /**
  99293. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  99294. */
  99295. mesh: Mesh;
  99296. /**
  99297. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  99298. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  99299. */
  99300. vars: any;
  99301. /**
  99302. * This array is populated when the SPS is set as 'pickable'.
  99303. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  99304. * Each element of this array is an object `{idx: int, faceId: int}`.
  99305. * `idx` is the picked particle index in the `SPS.particles` array
  99306. * `faceId` is the picked face index counted within this particle.
  99307. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  99308. */
  99309. pickedParticles: {
  99310. idx: number;
  99311. faceId: number;
  99312. }[];
  99313. /**
  99314. * This array is populated when `enableDepthSort` is set to true.
  99315. * Each element of this array is an instance of the class DepthSortedParticle.
  99316. */
  99317. depthSortedParticles: DepthSortedParticle[];
  99318. /**
  99319. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  99320. * @hidden
  99321. */
  99322. _bSphereOnly: boolean;
  99323. /**
  99324. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  99325. * @hidden
  99326. */
  99327. _bSphereRadiusFactor: number;
  99328. private _scene;
  99329. private _positions;
  99330. private _indices;
  99331. private _normals;
  99332. private _colors;
  99333. private _uvs;
  99334. private _indices32;
  99335. private _positions32;
  99336. private _normals32;
  99337. private _fixedNormal32;
  99338. private _colors32;
  99339. private _uvs32;
  99340. private _index;
  99341. private _updatable;
  99342. private _pickable;
  99343. private _isVisibilityBoxLocked;
  99344. private _alwaysVisible;
  99345. private _depthSort;
  99346. private _expandable;
  99347. private _shapeCounter;
  99348. private _copy;
  99349. private _color;
  99350. private _computeParticleColor;
  99351. private _computeParticleTexture;
  99352. private _computeParticleRotation;
  99353. private _computeParticleVertex;
  99354. private _computeBoundingBox;
  99355. private _depthSortParticles;
  99356. private _camera;
  99357. private _mustUnrotateFixedNormals;
  99358. private _particlesIntersect;
  99359. private _needs32Bits;
  99360. private _isNotBuilt;
  99361. private _lastParticleId;
  99362. private _idxOfId;
  99363. private _multimaterialEnabled;
  99364. private _useModelMaterial;
  99365. private _indicesByMaterial;
  99366. private _materialIndexes;
  99367. private _depthSortFunction;
  99368. private _materialSortFunction;
  99369. private _materials;
  99370. private _multimaterial;
  99371. private _materialIndexesById;
  99372. private _defaultMaterial;
  99373. private _autoUpdateSubMeshes;
  99374. /**
  99375. * Creates a SPS (Solid Particle System) object.
  99376. * @param name (String) is the SPS name, this will be the underlying mesh name.
  99377. * @param scene (Scene) is the scene in which the SPS is added.
  99378. * @param options defines the options of the sps e.g.
  99379. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  99380. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  99381. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  99382. * * 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.
  99383. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  99384. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  99385. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  99386. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  99387. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  99388. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  99389. */
  99390. constructor(name: string, scene: Scene, options?: {
  99391. updatable?: boolean;
  99392. isPickable?: boolean;
  99393. enableDepthSort?: boolean;
  99394. particleIntersection?: boolean;
  99395. boundingSphereOnly?: boolean;
  99396. bSphereRadiusFactor?: number;
  99397. expandable?: boolean;
  99398. useModelMaterial?: boolean;
  99399. enableMultiMaterial?: boolean;
  99400. });
  99401. /**
  99402. * Builds the SPS underlying mesh. Returns a standard Mesh.
  99403. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  99404. * @returns the created mesh
  99405. */
  99406. buildMesh(): Mesh;
  99407. /**
  99408. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  99409. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  99410. * Thus the particles generated from `digest()` have their property `position` set yet.
  99411. * @param mesh ( Mesh ) is the mesh to be digested
  99412. * @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
  99413. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  99414. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  99415. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99416. * @returns the current SPS
  99417. */
  99418. digest(mesh: Mesh, options?: {
  99419. facetNb?: number;
  99420. number?: number;
  99421. delta?: number;
  99422. storage?: [];
  99423. }): SolidParticleSystem;
  99424. /**
  99425. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  99426. * @hidden
  99427. */
  99428. private _unrotateFixedNormals;
  99429. /**
  99430. * Resets the temporary working copy particle
  99431. * @hidden
  99432. */
  99433. private _resetCopy;
  99434. /**
  99435. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  99436. * @param p the current index in the positions array to be updated
  99437. * @param ind the current index in the indices array
  99438. * @param shape a Vector3 array, the shape geometry
  99439. * @param positions the positions array to be updated
  99440. * @param meshInd the shape indices array
  99441. * @param indices the indices array to be updated
  99442. * @param meshUV the shape uv array
  99443. * @param uvs the uv array to be updated
  99444. * @param meshCol the shape color array
  99445. * @param colors the color array to be updated
  99446. * @param meshNor the shape normals array
  99447. * @param normals the normals array to be updated
  99448. * @param idx the particle index
  99449. * @param idxInShape the particle index in its shape
  99450. * @param options the addShape() method passed options
  99451. * @model the particle model
  99452. * @hidden
  99453. */
  99454. private _meshBuilder;
  99455. /**
  99456. * Returns a shape Vector3 array from positions float array
  99457. * @param positions float array
  99458. * @returns a vector3 array
  99459. * @hidden
  99460. */
  99461. private _posToShape;
  99462. /**
  99463. * Returns a shapeUV array from a float uvs (array deep copy)
  99464. * @param uvs as a float array
  99465. * @returns a shapeUV array
  99466. * @hidden
  99467. */
  99468. private _uvsToShapeUV;
  99469. /**
  99470. * Adds a new particle object in the particles array
  99471. * @param idx particle index in particles array
  99472. * @param id particle id
  99473. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  99474. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  99475. * @param model particle ModelShape object
  99476. * @param shapeId model shape identifier
  99477. * @param idxInShape index of the particle in the current model
  99478. * @param bInfo model bounding info object
  99479. * @param storage target storage array, if any
  99480. * @hidden
  99481. */
  99482. private _addParticle;
  99483. /**
  99484. * Adds some particles to the SPS from the model shape. Returns the shape id.
  99485. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  99486. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  99487. * @param nb (positive integer) the number of particles to be created from this model
  99488. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  99489. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  99490. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99491. * @returns the number of shapes in the system
  99492. */
  99493. addShape(mesh: Mesh, nb: number, options?: {
  99494. positionFunction?: any;
  99495. vertexFunction?: any;
  99496. storage?: [];
  99497. }): number;
  99498. /**
  99499. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  99500. * @hidden
  99501. */
  99502. private _rebuildParticle;
  99503. /**
  99504. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  99505. * @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.
  99506. * @returns the SPS.
  99507. */
  99508. rebuildMesh(reset?: boolean): SolidParticleSystem;
  99509. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  99510. * Returns an array with the removed particles.
  99511. * 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.
  99512. * The SPS can't be empty so at least one particle needs to remain in place.
  99513. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  99514. * @param start index of the first particle to remove
  99515. * @param end index of the last particle to remove (included)
  99516. * @returns an array populated with the removed particles
  99517. */
  99518. removeParticles(start: number, end: number): SolidParticle[];
  99519. /**
  99520. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  99521. * @param solidParticleArray an array populated with Solid Particles objects
  99522. * @returns the SPS
  99523. */
  99524. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  99525. /**
  99526. * Creates a new particle and modifies the SPS mesh geometry :
  99527. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  99528. * - calls _addParticle() to populate the particle array
  99529. * factorized code from addShape() and insertParticlesFromArray()
  99530. * @param idx particle index in the particles array
  99531. * @param i particle index in its shape
  99532. * @param modelShape particle ModelShape object
  99533. * @param shape shape vertex array
  99534. * @param meshInd shape indices array
  99535. * @param meshUV shape uv array
  99536. * @param meshCol shape color array
  99537. * @param meshNor shape normals array
  99538. * @param bbInfo shape bounding info
  99539. * @param storage target particle storage
  99540. * @options addShape() passed options
  99541. * @hidden
  99542. */
  99543. private _insertNewParticle;
  99544. /**
  99545. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  99546. * This method calls `updateParticle()` for each particle of the SPS.
  99547. * For an animated SPS, it is usually called within the render loop.
  99548. * 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.
  99549. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  99550. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  99551. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  99552. * @returns the SPS.
  99553. */
  99554. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  99555. /**
  99556. * Disposes the SPS.
  99557. */
  99558. dispose(): void;
  99559. /**
  99560. * Returns a SolidParticle object from its identifier : particle.id
  99561. * @param id (integer) the particle Id
  99562. * @returns the searched particle or null if not found in the SPS.
  99563. */
  99564. getParticleById(id: number): Nullable<SolidParticle>;
  99565. /**
  99566. * Returns a new array populated with the particles having the passed shapeId.
  99567. * @param shapeId (integer) the shape identifier
  99568. * @returns a new solid particle array
  99569. */
  99570. getParticlesByShapeId(shapeId: number): SolidParticle[];
  99571. /**
  99572. * Populates the passed array "ref" with the particles having the passed shapeId.
  99573. * @param shapeId the shape identifier
  99574. * @returns the SPS
  99575. * @param ref
  99576. */
  99577. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  99578. /**
  99579. * Computes the required SubMeshes according the materials assigned to the particles.
  99580. * @returns the solid particle system.
  99581. * Does nothing if called before the SPS mesh is built.
  99582. */
  99583. computeSubMeshes(): SolidParticleSystem;
  99584. /**
  99585. * Sorts the solid particles by material when MultiMaterial is enabled.
  99586. * Updates the indices32 array.
  99587. * Updates the indicesByMaterial array.
  99588. * Updates the mesh indices array.
  99589. * @returns the SPS
  99590. * @hidden
  99591. */
  99592. private _sortParticlesByMaterial;
  99593. /**
  99594. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  99595. * @hidden
  99596. */
  99597. private _setMaterialIndexesById;
  99598. /**
  99599. * Returns an array with unique values of Materials from the passed array
  99600. * @param array the material array to be checked and filtered
  99601. * @hidden
  99602. */
  99603. private _filterUniqueMaterialId;
  99604. /**
  99605. * Sets a new Standard Material as _defaultMaterial if not already set.
  99606. * @hidden
  99607. */
  99608. private _setDefaultMaterial;
  99609. /**
  99610. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  99611. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99612. * @returns the SPS.
  99613. */
  99614. refreshVisibleSize(): SolidParticleSystem;
  99615. /**
  99616. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  99617. * @param size the size (float) of the visibility box
  99618. * note : this doesn't lock the SPS mesh bounding box.
  99619. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99620. */
  99621. setVisibilityBox(size: number): void;
  99622. /**
  99623. * Gets whether the SPS as always visible or not
  99624. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99625. */
  99626. get isAlwaysVisible(): boolean;
  99627. /**
  99628. * Sets the SPS as always visible or not
  99629. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99630. */
  99631. set isAlwaysVisible(val: boolean);
  99632. /**
  99633. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99635. */
  99636. set isVisibilityBoxLocked(val: boolean);
  99637. /**
  99638. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99640. */
  99641. get isVisibilityBoxLocked(): boolean;
  99642. /**
  99643. * Tells to `setParticles()` to compute the particle rotations or not.
  99644. * Default value : true. The SPS is faster when it's set to false.
  99645. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99646. */
  99647. set computeParticleRotation(val: boolean);
  99648. /**
  99649. * Tells to `setParticles()` to compute the particle colors or not.
  99650. * Default value : true. The SPS is faster when it's set to false.
  99651. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99652. */
  99653. set computeParticleColor(val: boolean);
  99654. set computeParticleTexture(val: boolean);
  99655. /**
  99656. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  99657. * Default value : false. The SPS is faster when it's set to false.
  99658. * Note : the particle custom vertex positions aren't stored values.
  99659. */
  99660. set computeParticleVertex(val: boolean);
  99661. /**
  99662. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  99663. */
  99664. set computeBoundingBox(val: boolean);
  99665. /**
  99666. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  99667. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99668. * Default : `true`
  99669. */
  99670. set depthSortParticles(val: boolean);
  99671. /**
  99672. * Gets if `setParticles()` computes the particle rotations or not.
  99673. * Default value : true. The SPS is faster when it's set to false.
  99674. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99675. */
  99676. get computeParticleRotation(): boolean;
  99677. /**
  99678. * Gets if `setParticles()` computes the particle colors or not.
  99679. * Default value : true. The SPS is faster when it's set to false.
  99680. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99681. */
  99682. get computeParticleColor(): boolean;
  99683. /**
  99684. * Gets if `setParticles()` computes the particle textures or not.
  99685. * Default value : true. The SPS is faster when it's set to false.
  99686. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  99687. */
  99688. get computeParticleTexture(): boolean;
  99689. /**
  99690. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  99691. * Default value : false. The SPS is faster when it's set to false.
  99692. * Note : the particle custom vertex positions aren't stored values.
  99693. */
  99694. get computeParticleVertex(): boolean;
  99695. /**
  99696. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  99697. */
  99698. get computeBoundingBox(): boolean;
  99699. /**
  99700. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  99701. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99702. * Default : `true`
  99703. */
  99704. get depthSortParticles(): boolean;
  99705. /**
  99706. * Gets if the SPS is created as expandable at construction time.
  99707. * Default : `false`
  99708. */
  99709. get expandable(): boolean;
  99710. /**
  99711. * Gets if the SPS supports the Multi Materials
  99712. */
  99713. get multimaterialEnabled(): boolean;
  99714. /**
  99715. * Gets if the SPS uses the model materials for its own multimaterial.
  99716. */
  99717. get useModelMaterial(): boolean;
  99718. /**
  99719. * The SPS used material array.
  99720. */
  99721. get materials(): Material[];
  99722. /**
  99723. * Sets the SPS MultiMaterial from the passed materials.
  99724. * Note : the passed array is internally copied and not used then by reference.
  99725. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  99726. */
  99727. setMultiMaterial(materials: Material[]): void;
  99728. /**
  99729. * The SPS computed multimaterial object
  99730. */
  99731. get multimaterial(): MultiMaterial;
  99732. set multimaterial(mm: MultiMaterial);
  99733. /**
  99734. * If the subMeshes must be updated on the next call to setParticles()
  99735. */
  99736. get autoUpdateSubMeshes(): boolean;
  99737. set autoUpdateSubMeshes(val: boolean);
  99738. /**
  99739. * This function does nothing. It may be overwritten to set all the particle first values.
  99740. * The SPS doesn't call this function, you may have to call it by your own.
  99741. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99742. */
  99743. initParticles(): void;
  99744. /**
  99745. * This function does nothing. It may be overwritten to recycle a particle.
  99746. * The SPS doesn't call this function, you may have to call it by your own.
  99747. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99748. * @param particle The particle to recycle
  99749. * @returns the recycled particle
  99750. */
  99751. recycleParticle(particle: SolidParticle): SolidParticle;
  99752. /**
  99753. * Updates a particle : this function should be overwritten by the user.
  99754. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  99755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99756. * @example : just set a particle position or velocity and recycle conditions
  99757. * @param particle The particle to update
  99758. * @returns the updated particle
  99759. */
  99760. updateParticle(particle: SolidParticle): SolidParticle;
  99761. /**
  99762. * Updates a vertex of a particle : it can be overwritten by the user.
  99763. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  99764. * @param particle the current particle
  99765. * @param vertex the current index of the current particle
  99766. * @param pt the index of the current vertex in the particle shape
  99767. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  99768. * @example : just set a vertex particle position
  99769. * @returns the updated vertex
  99770. */
  99771. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  99772. /**
  99773. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  99774. * This does nothing and may be overwritten by the user.
  99775. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99776. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99777. * @param update the boolean update value actually passed to setParticles()
  99778. */
  99779. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99780. /**
  99781. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  99782. * This will be passed three parameters.
  99783. * This does nothing and may be overwritten by the user.
  99784. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99785. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99786. * @param update the boolean update value actually passed to setParticles()
  99787. */
  99788. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99789. }
  99790. }
  99791. declare module BABYLON {
  99792. /**
  99793. * Represents one particle of a solid particle system.
  99794. */
  99795. export class SolidParticle {
  99796. /**
  99797. * particle global index
  99798. */
  99799. idx: number;
  99800. /**
  99801. * particle identifier
  99802. */
  99803. id: number;
  99804. /**
  99805. * The color of the particle
  99806. */
  99807. color: Nullable<Color4>;
  99808. /**
  99809. * The world space position of the particle.
  99810. */
  99811. position: Vector3;
  99812. /**
  99813. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  99814. */
  99815. rotation: Vector3;
  99816. /**
  99817. * The world space rotation quaternion of the particle.
  99818. */
  99819. rotationQuaternion: Nullable<Quaternion>;
  99820. /**
  99821. * The scaling of the particle.
  99822. */
  99823. scaling: Vector3;
  99824. /**
  99825. * The uvs of the particle.
  99826. */
  99827. uvs: Vector4;
  99828. /**
  99829. * The current speed of the particle.
  99830. */
  99831. velocity: Vector3;
  99832. /**
  99833. * The pivot point in the particle local space.
  99834. */
  99835. pivot: Vector3;
  99836. /**
  99837. * Must the particle be translated from its pivot point in its local space ?
  99838. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  99839. * Default : false
  99840. */
  99841. translateFromPivot: boolean;
  99842. /**
  99843. * Is the particle active or not ?
  99844. */
  99845. alive: boolean;
  99846. /**
  99847. * Is the particle visible or not ?
  99848. */
  99849. isVisible: boolean;
  99850. /**
  99851. * Index of this particle in the global "positions" array (Internal use)
  99852. * @hidden
  99853. */
  99854. _pos: number;
  99855. /**
  99856. * @hidden Index of this particle in the global "indices" array (Internal use)
  99857. */
  99858. _ind: number;
  99859. /**
  99860. * @hidden ModelShape of this particle (Internal use)
  99861. */
  99862. _model: ModelShape;
  99863. /**
  99864. * ModelShape id of this particle
  99865. */
  99866. shapeId: number;
  99867. /**
  99868. * Index of the particle in its shape id
  99869. */
  99870. idxInShape: number;
  99871. /**
  99872. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  99873. */
  99874. _modelBoundingInfo: BoundingInfo;
  99875. /**
  99876. * @hidden Particle BoundingInfo object (Internal use)
  99877. */
  99878. _boundingInfo: BoundingInfo;
  99879. /**
  99880. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  99881. */
  99882. _sps: SolidParticleSystem;
  99883. /**
  99884. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  99885. */
  99886. _stillInvisible: boolean;
  99887. /**
  99888. * @hidden Last computed particle rotation matrix
  99889. */
  99890. _rotationMatrix: number[];
  99891. /**
  99892. * Parent particle Id, if any.
  99893. * Default null.
  99894. */
  99895. parentId: Nullable<number>;
  99896. /**
  99897. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  99898. */
  99899. materialIndex: Nullable<number>;
  99900. /**
  99901. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  99902. * The possible values are :
  99903. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  99904. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99905. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  99906. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  99907. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99908. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  99909. * */
  99910. cullingStrategy: number;
  99911. /**
  99912. * @hidden Internal global position in the SPS.
  99913. */
  99914. _globalPosition: Vector3;
  99915. /**
  99916. * Creates a Solid Particle object.
  99917. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  99918. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  99919. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  99920. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  99921. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  99922. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  99923. * @param shapeId (integer) is the model shape identifier in the SPS.
  99924. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  99925. * @param sps defines the sps it is associated to
  99926. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  99927. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  99928. */
  99929. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  99930. /**
  99931. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  99932. * @param target the particle target
  99933. * @returns the current particle
  99934. */
  99935. copyToRef(target: SolidParticle): SolidParticle;
  99936. /**
  99937. * Legacy support, changed scale to scaling
  99938. */
  99939. get scale(): Vector3;
  99940. /**
  99941. * Legacy support, changed scale to scaling
  99942. */
  99943. set scale(scale: Vector3);
  99944. /**
  99945. * Legacy support, changed quaternion to rotationQuaternion
  99946. */
  99947. get quaternion(): Nullable<Quaternion>;
  99948. /**
  99949. * Legacy support, changed quaternion to rotationQuaternion
  99950. */
  99951. set quaternion(q: Nullable<Quaternion>);
  99952. /**
  99953. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  99954. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  99955. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  99956. * @returns true if it intersects
  99957. */
  99958. intersectsMesh(target: Mesh | SolidParticle): boolean;
  99959. /**
  99960. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  99961. * A particle is in the frustum if its bounding box intersects the frustum
  99962. * @param frustumPlanes defines the frustum to test
  99963. * @returns true if the particle is in the frustum planes
  99964. */
  99965. isInFrustum(frustumPlanes: Plane[]): boolean;
  99966. /**
  99967. * get the rotation matrix of the particle
  99968. * @hidden
  99969. */
  99970. getRotationMatrix(m: Matrix): void;
  99971. }
  99972. /**
  99973. * Represents the shape of the model used by one particle of a solid particle system.
  99974. * SPS internal tool, don't use it manually.
  99975. */
  99976. export class ModelShape {
  99977. /**
  99978. * The shape id
  99979. * @hidden
  99980. */
  99981. shapeID: number;
  99982. /**
  99983. * flat array of model positions (internal use)
  99984. * @hidden
  99985. */
  99986. _shape: Vector3[];
  99987. /**
  99988. * flat array of model UVs (internal use)
  99989. * @hidden
  99990. */
  99991. _shapeUV: number[];
  99992. /**
  99993. * color array of the model
  99994. * @hidden
  99995. */
  99996. _shapeColors: number[];
  99997. /**
  99998. * indices array of the model
  99999. * @hidden
  100000. */
  100001. _indices: number[];
  100002. /**
  100003. * normals array of the model
  100004. * @hidden
  100005. */
  100006. _normals: number[];
  100007. /**
  100008. * length of the shape in the model indices array (internal use)
  100009. * @hidden
  100010. */
  100011. _indicesLength: number;
  100012. /**
  100013. * Custom position function (internal use)
  100014. * @hidden
  100015. */
  100016. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100017. /**
  100018. * Custom vertex function (internal use)
  100019. * @hidden
  100020. */
  100021. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100022. /**
  100023. * Model material (internal use)
  100024. * @hidden
  100025. */
  100026. _material: Nullable<Material>;
  100027. /**
  100028. * 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.
  100029. * SPS internal tool, don't use it manually.
  100030. * @hidden
  100031. */
  100032. 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>);
  100033. }
  100034. /**
  100035. * Represents a Depth Sorted Particle in the solid particle system.
  100036. * @hidden
  100037. */
  100038. export class DepthSortedParticle {
  100039. /**
  100040. * Index of the particle in the "indices" array
  100041. */
  100042. ind: number;
  100043. /**
  100044. * Length of the particle shape in the "indices" array
  100045. */
  100046. indicesLength: number;
  100047. /**
  100048. * Squared distance from the particle to the camera
  100049. */
  100050. sqDistance: number;
  100051. /**
  100052. * Material index when used with MultiMaterials
  100053. */
  100054. materialIndex: number;
  100055. /**
  100056. * Creates a new sorted particle
  100057. * @param materialIndex
  100058. */
  100059. constructor(ind: number, indLength: number, materialIndex: number);
  100060. }
  100061. }
  100062. declare module BABYLON {
  100063. /**
  100064. * @hidden
  100065. */
  100066. export class _MeshCollisionData {
  100067. _checkCollisions: boolean;
  100068. _collisionMask: number;
  100069. _collisionGroup: number;
  100070. _collider: Nullable<Collider>;
  100071. _oldPositionForCollisions: Vector3;
  100072. _diffPositionForCollisions: Vector3;
  100073. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100074. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100075. }
  100076. }
  100077. declare module BABYLON {
  100078. /** @hidden */
  100079. class _FacetDataStorage {
  100080. facetPositions: Vector3[];
  100081. facetNormals: Vector3[];
  100082. facetPartitioning: number[][];
  100083. facetNb: number;
  100084. partitioningSubdivisions: number;
  100085. partitioningBBoxRatio: number;
  100086. facetDataEnabled: boolean;
  100087. facetParameters: any;
  100088. bbSize: Vector3;
  100089. subDiv: {
  100090. max: number;
  100091. X: number;
  100092. Y: number;
  100093. Z: number;
  100094. };
  100095. facetDepthSort: boolean;
  100096. facetDepthSortEnabled: boolean;
  100097. depthSortedIndices: IndicesArray;
  100098. depthSortedFacets: {
  100099. ind: number;
  100100. sqDistance: number;
  100101. }[];
  100102. facetDepthSortFunction: (f1: {
  100103. ind: number;
  100104. sqDistance: number;
  100105. }, f2: {
  100106. ind: number;
  100107. sqDistance: number;
  100108. }) => number;
  100109. facetDepthSortFrom: Vector3;
  100110. facetDepthSortOrigin: Vector3;
  100111. invertedMatrix: Matrix;
  100112. }
  100113. /**
  100114. * @hidden
  100115. **/
  100116. class _InternalAbstractMeshDataInfo {
  100117. _hasVertexAlpha: boolean;
  100118. _useVertexColors: boolean;
  100119. _numBoneInfluencers: number;
  100120. _applyFog: boolean;
  100121. _receiveShadows: boolean;
  100122. _facetData: _FacetDataStorage;
  100123. _visibility: number;
  100124. _skeleton: Nullable<Skeleton>;
  100125. _layerMask: number;
  100126. _computeBonesUsingShaders: boolean;
  100127. _isActive: boolean;
  100128. _onlyForInstances: boolean;
  100129. _isActiveIntermediate: boolean;
  100130. _onlyForInstancesIntermediate: boolean;
  100131. _actAsRegularMesh: boolean;
  100132. }
  100133. /**
  100134. * Class used to store all common mesh properties
  100135. */
  100136. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100137. /** No occlusion */
  100138. static OCCLUSION_TYPE_NONE: number;
  100139. /** Occlusion set to optimisitic */
  100140. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100141. /** Occlusion set to strict */
  100142. static OCCLUSION_TYPE_STRICT: number;
  100143. /** Use an accurante occlusion algorithm */
  100144. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100145. /** Use a conservative occlusion algorithm */
  100146. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100147. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100148. * Test order :
  100149. * Is the bounding sphere outside the frustum ?
  100150. * If not, are the bounding box vertices outside the frustum ?
  100151. * It not, then the cullable object is in the frustum.
  100152. */
  100153. static readonly CULLINGSTRATEGY_STANDARD: number;
  100154. /** Culling strategy : Bounding Sphere Only.
  100155. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100156. * It's also less accurate than the standard because some not visible objects can still be selected.
  100157. * Test : is the bounding sphere outside the frustum ?
  100158. * If not, then the cullable object is in the frustum.
  100159. */
  100160. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100161. /** Culling strategy : Optimistic Inclusion.
  100162. * This in an inclusion test first, then the standard exclusion test.
  100163. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100164. * 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.
  100165. * Anyway, it's as accurate as the standard strategy.
  100166. * Test :
  100167. * Is the cullable object bounding sphere center in the frustum ?
  100168. * If not, apply the default culling strategy.
  100169. */
  100170. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  100171. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  100172. * This in an inclusion test first, then the bounding sphere only exclusion test.
  100173. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  100174. * 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.
  100175. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  100176. * Test :
  100177. * Is the cullable object bounding sphere center in the frustum ?
  100178. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  100179. */
  100180. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  100181. /**
  100182. * No billboard
  100183. */
  100184. static get BILLBOARDMODE_NONE(): number;
  100185. /** Billboard on X axis */
  100186. static get BILLBOARDMODE_X(): number;
  100187. /** Billboard on Y axis */
  100188. static get BILLBOARDMODE_Y(): number;
  100189. /** Billboard on Z axis */
  100190. static get BILLBOARDMODE_Z(): number;
  100191. /** Billboard on all axes */
  100192. static get BILLBOARDMODE_ALL(): number;
  100193. /** Billboard on using position instead of orientation */
  100194. static get BILLBOARDMODE_USE_POSITION(): number;
  100195. /** @hidden */
  100196. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  100197. /**
  100198. * The culling strategy to use to check whether the mesh must be rendered or not.
  100199. * This value can be changed at any time and will be used on the next render mesh selection.
  100200. * The possible values are :
  100201. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100202. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100203. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100204. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100205. * Please read each static variable documentation to get details about the culling process.
  100206. * */
  100207. cullingStrategy: number;
  100208. /**
  100209. * Gets the number of facets in the mesh
  100210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100211. */
  100212. get facetNb(): number;
  100213. /**
  100214. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  100215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100216. */
  100217. get partitioningSubdivisions(): number;
  100218. set partitioningSubdivisions(nb: number);
  100219. /**
  100220. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  100221. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  100222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100223. */
  100224. get partitioningBBoxRatio(): number;
  100225. set partitioningBBoxRatio(ratio: number);
  100226. /**
  100227. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  100228. * Works only for updatable meshes.
  100229. * Doesn't work with multi-materials
  100230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100231. */
  100232. get mustDepthSortFacets(): boolean;
  100233. set mustDepthSortFacets(sort: boolean);
  100234. /**
  100235. * The location (Vector3) where the facet depth sort must be computed from.
  100236. * By default, the active camera position.
  100237. * Used only when facet depth sort is enabled
  100238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100239. */
  100240. get facetDepthSortFrom(): Vector3;
  100241. set facetDepthSortFrom(location: Vector3);
  100242. /**
  100243. * gets a boolean indicating if facetData is enabled
  100244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100245. */
  100246. get isFacetDataEnabled(): boolean;
  100247. /** @hidden */
  100248. _updateNonUniformScalingState(value: boolean): boolean;
  100249. /**
  100250. * An event triggered when this mesh collides with another one
  100251. */
  100252. onCollideObservable: Observable<AbstractMesh>;
  100253. /** Set a function to call when this mesh collides with another one */
  100254. set onCollide(callback: () => void);
  100255. /**
  100256. * An event triggered when the collision's position changes
  100257. */
  100258. onCollisionPositionChangeObservable: Observable<Vector3>;
  100259. /** Set a function to call when the collision's position changes */
  100260. set onCollisionPositionChange(callback: () => void);
  100261. /**
  100262. * An event triggered when material is changed
  100263. */
  100264. onMaterialChangedObservable: Observable<AbstractMesh>;
  100265. /**
  100266. * Gets or sets the orientation for POV movement & rotation
  100267. */
  100268. definedFacingForward: boolean;
  100269. /** @hidden */
  100270. _occlusionQuery: Nullable<WebGLQuery>;
  100271. /** @hidden */
  100272. _renderingGroup: Nullable<RenderingGroup>;
  100273. /**
  100274. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100275. */
  100276. get visibility(): number;
  100277. /**
  100278. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100279. */
  100280. set visibility(value: number);
  100281. /** Gets or sets the alpha index used to sort transparent meshes
  100282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  100283. */
  100284. alphaIndex: number;
  100285. /**
  100286. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  100287. */
  100288. isVisible: boolean;
  100289. /**
  100290. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  100291. */
  100292. isPickable: boolean;
  100293. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  100294. showSubMeshesBoundingBox: boolean;
  100295. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  100296. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100297. */
  100298. isBlocker: boolean;
  100299. /**
  100300. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  100301. */
  100302. enablePointerMoveEvents: boolean;
  100303. /**
  100304. * Specifies the rendering group id for this mesh (0 by default)
  100305. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  100306. */
  100307. renderingGroupId: number;
  100308. private _material;
  100309. /** Gets or sets current material */
  100310. get material(): Nullable<Material>;
  100311. set material(value: Nullable<Material>);
  100312. /**
  100313. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  100314. * @see http://doc.babylonjs.com/babylon101/shadows
  100315. */
  100316. get receiveShadows(): boolean;
  100317. set receiveShadows(value: boolean);
  100318. /** Defines color to use when rendering outline */
  100319. outlineColor: Color3;
  100320. /** Define width to use when rendering outline */
  100321. outlineWidth: number;
  100322. /** Defines color to use when rendering overlay */
  100323. overlayColor: Color3;
  100324. /** Defines alpha to use when rendering overlay */
  100325. overlayAlpha: number;
  100326. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  100327. get hasVertexAlpha(): boolean;
  100328. set hasVertexAlpha(value: boolean);
  100329. /** 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) */
  100330. get useVertexColors(): boolean;
  100331. set useVertexColors(value: boolean);
  100332. /**
  100333. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  100334. */
  100335. get computeBonesUsingShaders(): boolean;
  100336. set computeBonesUsingShaders(value: boolean);
  100337. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  100338. get numBoneInfluencers(): number;
  100339. set numBoneInfluencers(value: number);
  100340. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  100341. get applyFog(): boolean;
  100342. set applyFog(value: boolean);
  100343. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  100344. useOctreeForRenderingSelection: boolean;
  100345. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  100346. useOctreeForPicking: boolean;
  100347. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  100348. useOctreeForCollisions: boolean;
  100349. /**
  100350. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  100351. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  100352. */
  100353. get layerMask(): number;
  100354. set layerMask(value: number);
  100355. /**
  100356. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  100357. */
  100358. alwaysSelectAsActiveMesh: boolean;
  100359. /**
  100360. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  100361. */
  100362. doNotSyncBoundingInfo: boolean;
  100363. /**
  100364. * Gets or sets the current action manager
  100365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100366. */
  100367. actionManager: Nullable<AbstractActionManager>;
  100368. private _meshCollisionData;
  100369. /**
  100370. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  100371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100372. */
  100373. ellipsoid: Vector3;
  100374. /**
  100375. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  100376. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100377. */
  100378. ellipsoidOffset: Vector3;
  100379. /**
  100380. * Gets or sets a collision mask used to mask collisions (default is -1).
  100381. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100382. */
  100383. get collisionMask(): number;
  100384. set collisionMask(mask: number);
  100385. /**
  100386. * Gets or sets the current collision group mask (-1 by default).
  100387. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100388. */
  100389. get collisionGroup(): number;
  100390. set collisionGroup(mask: number);
  100391. /**
  100392. * Defines edge width used when edgesRenderer is enabled
  100393. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100394. */
  100395. edgesWidth: number;
  100396. /**
  100397. * Defines edge color used when edgesRenderer is enabled
  100398. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100399. */
  100400. edgesColor: Color4;
  100401. /** @hidden */
  100402. _edgesRenderer: Nullable<IEdgesRenderer>;
  100403. /** @hidden */
  100404. _masterMesh: Nullable<AbstractMesh>;
  100405. /** @hidden */
  100406. _boundingInfo: Nullable<BoundingInfo>;
  100407. /** @hidden */
  100408. _renderId: number;
  100409. /**
  100410. * Gets or sets the list of subMeshes
  100411. * @see http://doc.babylonjs.com/how_to/multi_materials
  100412. */
  100413. subMeshes: SubMesh[];
  100414. /** @hidden */
  100415. _intersectionsInProgress: AbstractMesh[];
  100416. /** @hidden */
  100417. _unIndexed: boolean;
  100418. /** @hidden */
  100419. _lightSources: Light[];
  100420. /** Gets the list of lights affecting that mesh */
  100421. get lightSources(): Light[];
  100422. /** @hidden */
  100423. get _positions(): Nullable<Vector3[]>;
  100424. /** @hidden */
  100425. _waitingData: {
  100426. lods: Nullable<any>;
  100427. actions: Nullable<any>;
  100428. freezeWorldMatrix: Nullable<boolean>;
  100429. };
  100430. /** @hidden */
  100431. _bonesTransformMatrices: Nullable<Float32Array>;
  100432. /** @hidden */
  100433. _transformMatrixTexture: Nullable<RawTexture>;
  100434. /**
  100435. * Gets or sets a skeleton to apply skining transformations
  100436. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100437. */
  100438. set skeleton(value: Nullable<Skeleton>);
  100439. get skeleton(): Nullable<Skeleton>;
  100440. /**
  100441. * An event triggered when the mesh is rebuilt.
  100442. */
  100443. onRebuildObservable: Observable<AbstractMesh>;
  100444. /**
  100445. * Creates a new AbstractMesh
  100446. * @param name defines the name of the mesh
  100447. * @param scene defines the hosting scene
  100448. */
  100449. constructor(name: string, scene?: Nullable<Scene>);
  100450. /**
  100451. * Returns the string "AbstractMesh"
  100452. * @returns "AbstractMesh"
  100453. */
  100454. getClassName(): string;
  100455. /**
  100456. * Gets a string representation of the current mesh
  100457. * @param fullDetails defines a boolean indicating if full details must be included
  100458. * @returns a string representation of the current mesh
  100459. */
  100460. toString(fullDetails?: boolean): string;
  100461. /**
  100462. * @hidden
  100463. */
  100464. protected _getEffectiveParent(): Nullable<Node>;
  100465. /** @hidden */
  100466. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100467. /** @hidden */
  100468. _rebuild(): void;
  100469. /** @hidden */
  100470. _resyncLightSources(): void;
  100471. /** @hidden */
  100472. _resyncLightSource(light: Light): void;
  100473. /** @hidden */
  100474. _unBindEffect(): void;
  100475. /** @hidden */
  100476. _removeLightSource(light: Light, dispose: boolean): void;
  100477. private _markSubMeshesAsDirty;
  100478. /** @hidden */
  100479. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  100480. /** @hidden */
  100481. _markSubMeshesAsAttributesDirty(): void;
  100482. /** @hidden */
  100483. _markSubMeshesAsMiscDirty(): void;
  100484. /**
  100485. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  100486. */
  100487. get scaling(): Vector3;
  100488. set scaling(newScaling: Vector3);
  100489. /**
  100490. * Returns true if the mesh is blocked. Implemented by child classes
  100491. */
  100492. get isBlocked(): boolean;
  100493. /**
  100494. * Returns the mesh itself by default. Implemented by child classes
  100495. * @param camera defines the camera to use to pick the right LOD level
  100496. * @returns the currentAbstractMesh
  100497. */
  100498. getLOD(camera: Camera): Nullable<AbstractMesh>;
  100499. /**
  100500. * Returns 0 by default. Implemented by child classes
  100501. * @returns an integer
  100502. */
  100503. getTotalVertices(): number;
  100504. /**
  100505. * Returns a positive integer : the total number of indices in this mesh geometry.
  100506. * @returns the numner of indices or zero if the mesh has no geometry.
  100507. */
  100508. getTotalIndices(): number;
  100509. /**
  100510. * Returns null by default. Implemented by child classes
  100511. * @returns null
  100512. */
  100513. getIndices(): Nullable<IndicesArray>;
  100514. /**
  100515. * Returns the array of the requested vertex data kind. Implemented by child classes
  100516. * @param kind defines the vertex data kind to use
  100517. * @returns null
  100518. */
  100519. getVerticesData(kind: string): Nullable<FloatArray>;
  100520. /**
  100521. * Sets the vertex data of the mesh geometry for the requested `kind`.
  100522. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  100523. * Note that a new underlying VertexBuffer object is created each call.
  100524. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  100525. * @param kind defines vertex data kind:
  100526. * * VertexBuffer.PositionKind
  100527. * * VertexBuffer.UVKind
  100528. * * VertexBuffer.UV2Kind
  100529. * * VertexBuffer.UV3Kind
  100530. * * VertexBuffer.UV4Kind
  100531. * * VertexBuffer.UV5Kind
  100532. * * VertexBuffer.UV6Kind
  100533. * * VertexBuffer.ColorKind
  100534. * * VertexBuffer.MatricesIndicesKind
  100535. * * VertexBuffer.MatricesIndicesExtraKind
  100536. * * VertexBuffer.MatricesWeightsKind
  100537. * * VertexBuffer.MatricesWeightsExtraKind
  100538. * @param data defines the data source
  100539. * @param updatable defines if the data must be flagged as updatable (or static)
  100540. * @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
  100541. * @returns the current mesh
  100542. */
  100543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100544. /**
  100545. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  100546. * If the mesh has no geometry, it is simply returned as it is.
  100547. * @param kind defines vertex data kind:
  100548. * * VertexBuffer.PositionKind
  100549. * * VertexBuffer.UVKind
  100550. * * VertexBuffer.UV2Kind
  100551. * * VertexBuffer.UV3Kind
  100552. * * VertexBuffer.UV4Kind
  100553. * * VertexBuffer.UV5Kind
  100554. * * VertexBuffer.UV6Kind
  100555. * * VertexBuffer.ColorKind
  100556. * * VertexBuffer.MatricesIndicesKind
  100557. * * VertexBuffer.MatricesIndicesExtraKind
  100558. * * VertexBuffer.MatricesWeightsKind
  100559. * * VertexBuffer.MatricesWeightsExtraKind
  100560. * @param data defines the data source
  100561. * @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
  100562. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  100563. * @returns the current mesh
  100564. */
  100565. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100566. /**
  100567. * Sets the mesh indices,
  100568. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  100569. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  100570. * @param totalVertices Defines the total number of vertices
  100571. * @returns the current mesh
  100572. */
  100573. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  100574. /**
  100575. * Gets a boolean indicating if specific vertex data is present
  100576. * @param kind defines the vertex data kind to use
  100577. * @returns true is data kind is present
  100578. */
  100579. isVerticesDataPresent(kind: string): boolean;
  100580. /**
  100581. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  100582. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  100583. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  100584. * @returns a BoundingInfo
  100585. */
  100586. getBoundingInfo(): BoundingInfo;
  100587. /**
  100588. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  100589. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  100590. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  100591. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  100592. * @returns the current mesh
  100593. */
  100594. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  100595. /**
  100596. * Overwrite the current bounding info
  100597. * @param boundingInfo defines the new bounding info
  100598. * @returns the current mesh
  100599. */
  100600. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  100601. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  100602. get useBones(): boolean;
  100603. /** @hidden */
  100604. _preActivate(): void;
  100605. /** @hidden */
  100606. _preActivateForIntermediateRendering(renderId: number): void;
  100607. /** @hidden */
  100608. _activate(renderId: number, intermediateRendering: boolean): boolean;
  100609. /** @hidden */
  100610. _postActivate(): void;
  100611. /** @hidden */
  100612. _freeze(): void;
  100613. /** @hidden */
  100614. _unFreeze(): void;
  100615. /**
  100616. * Gets the current world matrix
  100617. * @returns a Matrix
  100618. */
  100619. getWorldMatrix(): Matrix;
  100620. /** @hidden */
  100621. _getWorldMatrixDeterminant(): number;
  100622. /**
  100623. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  100624. */
  100625. get isAnInstance(): boolean;
  100626. /**
  100627. * Gets a boolean indicating if this mesh has instances
  100628. */
  100629. get hasInstances(): boolean;
  100630. /**
  100631. * Perform relative position change from the point of view of behind the front of the mesh.
  100632. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100633. * Supports definition of mesh facing forward or backward
  100634. * @param amountRight defines the distance on the right axis
  100635. * @param amountUp defines the distance on the up axis
  100636. * @param amountForward defines the distance on the forward axis
  100637. * @returns the current mesh
  100638. */
  100639. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  100640. /**
  100641. * Calculate relative position change from the point of view of behind the front of the mesh.
  100642. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100643. * Supports definition of mesh facing forward or backward
  100644. * @param amountRight defines the distance on the right axis
  100645. * @param amountUp defines the distance on the up axis
  100646. * @param amountForward defines the distance on the forward axis
  100647. * @returns the new displacement vector
  100648. */
  100649. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  100650. /**
  100651. * Perform relative rotation change from the point of view of behind the front of the mesh.
  100652. * Supports definition of mesh facing forward or backward
  100653. * @param flipBack defines the flip
  100654. * @param twirlClockwise defines the twirl
  100655. * @param tiltRight defines the tilt
  100656. * @returns the current mesh
  100657. */
  100658. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  100659. /**
  100660. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  100661. * Supports definition of mesh facing forward or backward.
  100662. * @param flipBack defines the flip
  100663. * @param twirlClockwise defines the twirl
  100664. * @param tiltRight defines the tilt
  100665. * @returns the new rotation vector
  100666. */
  100667. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  100668. /**
  100669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100670. * This means the mesh underlying bounding box and sphere are recomputed.
  100671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100672. * @returns the current mesh
  100673. */
  100674. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  100675. /** @hidden */
  100676. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  100677. /** @hidden */
  100678. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  100679. /** @hidden */
  100680. _updateBoundingInfo(): AbstractMesh;
  100681. /** @hidden */
  100682. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  100683. /** @hidden */
  100684. protected _afterComputeWorldMatrix(): void;
  100685. /** @hidden */
  100686. get _effectiveMesh(): AbstractMesh;
  100687. /**
  100688. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  100689. * A mesh is in the frustum if its bounding box intersects the frustum
  100690. * @param frustumPlanes defines the frustum to test
  100691. * @returns true if the mesh is in the frustum planes
  100692. */
  100693. isInFrustum(frustumPlanes: Plane[]): boolean;
  100694. /**
  100695. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  100696. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  100697. * @param frustumPlanes defines the frustum to test
  100698. * @returns true if the mesh is completely in the frustum planes
  100699. */
  100700. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  100701. /**
  100702. * True if the mesh intersects another mesh or a SolidParticle object
  100703. * @param mesh defines a target mesh or SolidParticle to test
  100704. * @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)
  100705. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  100706. * @returns true if there is an intersection
  100707. */
  100708. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  100709. /**
  100710. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  100711. * @param point defines the point to test
  100712. * @returns true if there is an intersection
  100713. */
  100714. intersectsPoint(point: Vector3): boolean;
  100715. /**
  100716. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  100717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100718. */
  100719. get checkCollisions(): boolean;
  100720. set checkCollisions(collisionEnabled: boolean);
  100721. /**
  100722. * Gets Collider object used to compute collisions (not physics)
  100723. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100724. */
  100725. get collider(): Nullable<Collider>;
  100726. /**
  100727. * Move the mesh using collision engine
  100728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100729. * @param displacement defines the requested displacement vector
  100730. * @returns the current mesh
  100731. */
  100732. moveWithCollisions(displacement: Vector3): AbstractMesh;
  100733. private _onCollisionPositionChange;
  100734. /** @hidden */
  100735. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  100736. /** @hidden */
  100737. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  100738. /** @hidden */
  100739. _checkCollision(collider: Collider): AbstractMesh;
  100740. /** @hidden */
  100741. _generatePointsArray(): boolean;
  100742. /**
  100743. * Checks if the passed Ray intersects with the mesh
  100744. * @param ray defines the ray to use
  100745. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  100746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100747. * @returns the picking info
  100748. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  100749. */
  100750. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  100751. /**
  100752. * Clones the current mesh
  100753. * @param name defines the mesh name
  100754. * @param newParent defines the new mesh parent
  100755. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  100756. * @returns the new mesh
  100757. */
  100758. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  100759. /**
  100760. * Disposes all the submeshes of the current meshnp
  100761. * @returns the current mesh
  100762. */
  100763. releaseSubMeshes(): AbstractMesh;
  100764. /**
  100765. * Releases resources associated with this abstract mesh.
  100766. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100767. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100768. */
  100769. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100770. /**
  100771. * Adds the passed mesh as a child to the current mesh
  100772. * @param mesh defines the child mesh
  100773. * @returns the current mesh
  100774. */
  100775. addChild(mesh: AbstractMesh): AbstractMesh;
  100776. /**
  100777. * Removes the passed mesh from the current mesh children list
  100778. * @param mesh defines the child mesh
  100779. * @returns the current mesh
  100780. */
  100781. removeChild(mesh: AbstractMesh): AbstractMesh;
  100782. /** @hidden */
  100783. private _initFacetData;
  100784. /**
  100785. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  100786. * This method can be called within the render loop.
  100787. * 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
  100788. * @returns the current mesh
  100789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100790. */
  100791. updateFacetData(): AbstractMesh;
  100792. /**
  100793. * Returns the facetLocalNormals array.
  100794. * The normals are expressed in the mesh local spac
  100795. * @returns an array of Vector3
  100796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100797. */
  100798. getFacetLocalNormals(): Vector3[];
  100799. /**
  100800. * Returns the facetLocalPositions array.
  100801. * The facet positions are expressed in the mesh local space
  100802. * @returns an array of Vector3
  100803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100804. */
  100805. getFacetLocalPositions(): Vector3[];
  100806. /**
  100807. * Returns the facetLocalPartioning array
  100808. * @returns an array of array of numbers
  100809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100810. */
  100811. getFacetLocalPartitioning(): number[][];
  100812. /**
  100813. * Returns the i-th facet position in the world system.
  100814. * This method allocates a new Vector3 per call
  100815. * @param i defines the facet index
  100816. * @returns a new Vector3
  100817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100818. */
  100819. getFacetPosition(i: number): Vector3;
  100820. /**
  100821. * Sets the reference Vector3 with the i-th facet position in the world system
  100822. * @param i defines the facet index
  100823. * @param ref defines the target vector
  100824. * @returns the current mesh
  100825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100826. */
  100827. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  100828. /**
  100829. * Returns the i-th facet normal in the world system.
  100830. * This method allocates a new Vector3 per call
  100831. * @param i defines the facet index
  100832. * @returns a new Vector3
  100833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100834. */
  100835. getFacetNormal(i: number): Vector3;
  100836. /**
  100837. * Sets the reference Vector3 with the i-th facet normal in the world system
  100838. * @param i defines the facet index
  100839. * @param ref defines the target vector
  100840. * @returns the current mesh
  100841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100842. */
  100843. getFacetNormalToRef(i: number, ref: Vector3): this;
  100844. /**
  100845. * 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)
  100846. * @param x defines x coordinate
  100847. * @param y defines y coordinate
  100848. * @param z defines z coordinate
  100849. * @returns the array of facet indexes
  100850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100851. */
  100852. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  100853. /**
  100854. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  100855. * @param projected sets as the (x,y,z) world projection on the facet
  100856. * @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
  100857. * @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
  100858. * @param x defines x coordinate
  100859. * @param y defines y coordinate
  100860. * @param z defines z coordinate
  100861. * @returns the face index if found (or null instead)
  100862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100863. */
  100864. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  100865. /**
  100866. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  100867. * @param projected sets as the (x,y,z) local projection on the facet
  100868. * @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
  100869. * @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
  100870. * @param x defines x coordinate
  100871. * @param y defines y coordinate
  100872. * @param z defines z coordinate
  100873. * @returns the face index if found (or null instead)
  100874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100875. */
  100876. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  100877. /**
  100878. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  100879. * @returns the parameters
  100880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100881. */
  100882. getFacetDataParameters(): any;
  100883. /**
  100884. * Disables the feature FacetData and frees the related memory
  100885. * @returns the current mesh
  100886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100887. */
  100888. disableFacetData(): AbstractMesh;
  100889. /**
  100890. * Updates the AbstractMesh indices array
  100891. * @param indices defines the data source
  100892. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  100893. * @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)
  100894. * @returns the current mesh
  100895. */
  100896. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  100897. /**
  100898. * Creates new normals data for the mesh
  100899. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  100900. * @returns the current mesh
  100901. */
  100902. createNormals(updatable: boolean): AbstractMesh;
  100903. /**
  100904. * Align the mesh with a normal
  100905. * @param normal defines the normal to use
  100906. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  100907. * @returns the current mesh
  100908. */
  100909. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  100910. /** @hidden */
  100911. _checkOcclusionQuery(): boolean;
  100912. /**
  100913. * Disables the mesh edge rendering mode
  100914. * @returns the currentAbstractMesh
  100915. */
  100916. disableEdgesRendering(): AbstractMesh;
  100917. /**
  100918. * Enables the edge rendering mode on the mesh.
  100919. * This mode makes the mesh edges visible
  100920. * @param epsilon defines the maximal distance between two angles to detect a face
  100921. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  100922. * @returns the currentAbstractMesh
  100923. * @see https://www.babylonjs-playground.com/#19O9TU#0
  100924. */
  100925. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  100926. }
  100927. }
  100928. declare module BABYLON {
  100929. /**
  100930. * Interface used to define ActionEvent
  100931. */
  100932. export interface IActionEvent {
  100933. /** The mesh or sprite that triggered the action */
  100934. source: any;
  100935. /** The X mouse cursor position at the time of the event */
  100936. pointerX: number;
  100937. /** The Y mouse cursor position at the time of the event */
  100938. pointerY: number;
  100939. /** The mesh that is currently pointed at (can be null) */
  100940. meshUnderPointer: Nullable<AbstractMesh>;
  100941. /** the original (browser) event that triggered the ActionEvent */
  100942. sourceEvent?: any;
  100943. /** additional data for the event */
  100944. additionalData?: any;
  100945. }
  100946. /**
  100947. * ActionEvent is the event being sent when an action is triggered.
  100948. */
  100949. export class ActionEvent implements IActionEvent {
  100950. /** The mesh or sprite that triggered the action */
  100951. source: any;
  100952. /** The X mouse cursor position at the time of the event */
  100953. pointerX: number;
  100954. /** The Y mouse cursor position at the time of the event */
  100955. pointerY: number;
  100956. /** The mesh that is currently pointed at (can be null) */
  100957. meshUnderPointer: Nullable<AbstractMesh>;
  100958. /** the original (browser) event that triggered the ActionEvent */
  100959. sourceEvent?: any;
  100960. /** additional data for the event */
  100961. additionalData?: any;
  100962. /**
  100963. * Creates a new ActionEvent
  100964. * @param source The mesh or sprite that triggered the action
  100965. * @param pointerX The X mouse cursor position at the time of the event
  100966. * @param pointerY The Y mouse cursor position at the time of the event
  100967. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  100968. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  100969. * @param additionalData additional data for the event
  100970. */
  100971. constructor(
  100972. /** The mesh or sprite that triggered the action */
  100973. source: any,
  100974. /** The X mouse cursor position at the time of the event */
  100975. pointerX: number,
  100976. /** The Y mouse cursor position at the time of the event */
  100977. pointerY: number,
  100978. /** The mesh that is currently pointed at (can be null) */
  100979. meshUnderPointer: Nullable<AbstractMesh>,
  100980. /** the original (browser) event that triggered the ActionEvent */
  100981. sourceEvent?: any,
  100982. /** additional data for the event */
  100983. additionalData?: any);
  100984. /**
  100985. * Helper function to auto-create an ActionEvent from a source mesh.
  100986. * @param source The source mesh that triggered the event
  100987. * @param evt The original (browser) event
  100988. * @param additionalData additional data for the event
  100989. * @returns the new ActionEvent
  100990. */
  100991. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  100992. /**
  100993. * Helper function to auto-create an ActionEvent from a source sprite
  100994. * @param source The source sprite that triggered the event
  100995. * @param scene Scene associated with the sprite
  100996. * @param evt The original (browser) event
  100997. * @param additionalData additional data for the event
  100998. * @returns the new ActionEvent
  100999. */
  101000. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101001. /**
  101002. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101003. * @param scene the scene where the event occurred
  101004. * @param evt The original (browser) event
  101005. * @returns the new ActionEvent
  101006. */
  101007. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101008. /**
  101009. * Helper function to auto-create an ActionEvent from a primitive
  101010. * @param prim defines the target primitive
  101011. * @param pointerPos defines the pointer position
  101012. * @param evt The original (browser) event
  101013. * @param additionalData additional data for the event
  101014. * @returns the new ActionEvent
  101015. */
  101016. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101017. }
  101018. }
  101019. declare module BABYLON {
  101020. /**
  101021. * Abstract class used to decouple action Manager from scene and meshes.
  101022. * Do not instantiate.
  101023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101024. */
  101025. export abstract class AbstractActionManager implements IDisposable {
  101026. /** Gets the list of active triggers */
  101027. static Triggers: {
  101028. [key: string]: number;
  101029. };
  101030. /** Gets the cursor to use when hovering items */
  101031. hoverCursor: string;
  101032. /** Gets the list of actions */
  101033. actions: IAction[];
  101034. /**
  101035. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101036. */
  101037. isRecursive: boolean;
  101038. /**
  101039. * Releases all associated resources
  101040. */
  101041. abstract dispose(): void;
  101042. /**
  101043. * Does this action manager has pointer triggers
  101044. */
  101045. abstract get hasPointerTriggers(): boolean;
  101046. /**
  101047. * Does this action manager has pick triggers
  101048. */
  101049. abstract get hasPickTriggers(): boolean;
  101050. /**
  101051. * Process a specific trigger
  101052. * @param trigger defines the trigger to process
  101053. * @param evt defines the event details to be processed
  101054. */
  101055. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101056. /**
  101057. * Does this action manager handles actions of any of the given triggers
  101058. * @param triggers defines the triggers to be tested
  101059. * @return a boolean indicating whether one (or more) of the triggers is handled
  101060. */
  101061. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101062. /**
  101063. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101064. * speed.
  101065. * @param triggerA defines the trigger to be tested
  101066. * @param triggerB defines the trigger to be tested
  101067. * @return a boolean indicating whether one (or more) of the triggers is handled
  101068. */
  101069. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101070. /**
  101071. * Does this action manager handles actions of a given trigger
  101072. * @param trigger defines the trigger to be tested
  101073. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101074. * @return whether the trigger is handled
  101075. */
  101076. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101077. /**
  101078. * Serialize this manager to a JSON object
  101079. * @param name defines the property name to store this manager
  101080. * @returns a JSON representation of this manager
  101081. */
  101082. abstract serialize(name: string): any;
  101083. /**
  101084. * Registers an action to this action manager
  101085. * @param action defines the action to be registered
  101086. * @return the action amended (prepared) after registration
  101087. */
  101088. abstract registerAction(action: IAction): Nullable<IAction>;
  101089. /**
  101090. * Unregisters an action to this action manager
  101091. * @param action defines the action to be unregistered
  101092. * @return a boolean indicating whether the action has been unregistered
  101093. */
  101094. abstract unregisterAction(action: IAction): Boolean;
  101095. /**
  101096. * Does exist one action manager with at least one trigger
  101097. **/
  101098. static get HasTriggers(): boolean;
  101099. /**
  101100. * Does exist one action manager with at least one pick trigger
  101101. **/
  101102. static get HasPickTriggers(): boolean;
  101103. /**
  101104. * Does exist one action manager that handles actions of a given trigger
  101105. * @param trigger defines the trigger to be tested
  101106. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101107. **/
  101108. static HasSpecificTrigger(trigger: number): boolean;
  101109. }
  101110. }
  101111. declare module BABYLON {
  101112. /**
  101113. * Defines how a node can be built from a string name.
  101114. */
  101115. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101116. /**
  101117. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101118. */
  101119. export class Node implements IBehaviorAware<Node> {
  101120. /** @hidden */
  101121. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101122. private static _NodeConstructors;
  101123. /**
  101124. * Add a new node constructor
  101125. * @param type defines the type name of the node to construct
  101126. * @param constructorFunc defines the constructor function
  101127. */
  101128. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101129. /**
  101130. * Returns a node constructor based on type name
  101131. * @param type defines the type name
  101132. * @param name defines the new node name
  101133. * @param scene defines the hosting scene
  101134. * @param options defines optional options to transmit to constructors
  101135. * @returns the new constructor or null
  101136. */
  101137. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101138. /**
  101139. * Gets or sets the name of the node
  101140. */
  101141. name: string;
  101142. /**
  101143. * Gets or sets the id of the node
  101144. */
  101145. id: string;
  101146. /**
  101147. * Gets or sets the unique id of the node
  101148. */
  101149. uniqueId: number;
  101150. /**
  101151. * Gets or sets a string used to store user defined state for the node
  101152. */
  101153. state: string;
  101154. /**
  101155. * Gets or sets an object used to store user defined information for the node
  101156. */
  101157. metadata: any;
  101158. /**
  101159. * For internal use only. Please do not use.
  101160. */
  101161. reservedDataStore: any;
  101162. /**
  101163. * List of inspectable custom properties (used by the Inspector)
  101164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101165. */
  101166. inspectableCustomProperties: IInspectable[];
  101167. private _doNotSerialize;
  101168. /**
  101169. * Gets or sets a boolean used to define if the node must be serialized
  101170. */
  101171. get doNotSerialize(): boolean;
  101172. set doNotSerialize(value: boolean);
  101173. /** @hidden */
  101174. _isDisposed: boolean;
  101175. /**
  101176. * Gets a list of Animations associated with the node
  101177. */
  101178. animations: Animation[];
  101179. protected _ranges: {
  101180. [name: string]: Nullable<AnimationRange>;
  101181. };
  101182. /**
  101183. * Callback raised when the node is ready to be used
  101184. */
  101185. onReady: Nullable<(node: Node) => void>;
  101186. private _isEnabled;
  101187. private _isParentEnabled;
  101188. private _isReady;
  101189. /** @hidden */
  101190. _currentRenderId: number;
  101191. private _parentUpdateId;
  101192. /** @hidden */
  101193. _childUpdateId: number;
  101194. /** @hidden */
  101195. _waitingParentId: Nullable<string>;
  101196. /** @hidden */
  101197. _scene: Scene;
  101198. /** @hidden */
  101199. _cache: any;
  101200. private _parentNode;
  101201. private _children;
  101202. /** @hidden */
  101203. _worldMatrix: Matrix;
  101204. /** @hidden */
  101205. _worldMatrixDeterminant: number;
  101206. /** @hidden */
  101207. _worldMatrixDeterminantIsDirty: boolean;
  101208. /** @hidden */
  101209. private _sceneRootNodesIndex;
  101210. /**
  101211. * Gets a boolean indicating if the node has been disposed
  101212. * @returns true if the node was disposed
  101213. */
  101214. isDisposed(): boolean;
  101215. /**
  101216. * Gets or sets the parent of the node (without keeping the current position in the scene)
  101217. * @see https://doc.babylonjs.com/how_to/parenting
  101218. */
  101219. set parent(parent: Nullable<Node>);
  101220. get parent(): Nullable<Node>;
  101221. /** @hidden */
  101222. _addToSceneRootNodes(): void;
  101223. /** @hidden */
  101224. _removeFromSceneRootNodes(): void;
  101225. private _animationPropertiesOverride;
  101226. /**
  101227. * Gets or sets the animation properties override
  101228. */
  101229. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  101230. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  101231. /**
  101232. * Gets a string idenfifying the name of the class
  101233. * @returns "Node" string
  101234. */
  101235. getClassName(): string;
  101236. /** @hidden */
  101237. readonly _isNode: boolean;
  101238. /**
  101239. * An event triggered when the mesh is disposed
  101240. */
  101241. onDisposeObservable: Observable<Node>;
  101242. private _onDisposeObserver;
  101243. /**
  101244. * Sets a callback that will be raised when the node will be disposed
  101245. */
  101246. set onDispose(callback: () => void);
  101247. /**
  101248. * Creates a new Node
  101249. * @param name the name and id to be given to this node
  101250. * @param scene the scene this node will be added to
  101251. */
  101252. constructor(name: string, scene?: Nullable<Scene>);
  101253. /**
  101254. * Gets the scene of the node
  101255. * @returns a scene
  101256. */
  101257. getScene(): Scene;
  101258. /**
  101259. * Gets the engine of the node
  101260. * @returns a Engine
  101261. */
  101262. getEngine(): Engine;
  101263. private _behaviors;
  101264. /**
  101265. * Attach a behavior to the node
  101266. * @see http://doc.babylonjs.com/features/behaviour
  101267. * @param behavior defines the behavior to attach
  101268. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  101269. * @returns the current Node
  101270. */
  101271. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  101272. /**
  101273. * Remove an attached behavior
  101274. * @see http://doc.babylonjs.com/features/behaviour
  101275. * @param behavior defines the behavior to attach
  101276. * @returns the current Node
  101277. */
  101278. removeBehavior(behavior: Behavior<Node>): Node;
  101279. /**
  101280. * Gets the list of attached behaviors
  101281. * @see http://doc.babylonjs.com/features/behaviour
  101282. */
  101283. get behaviors(): Behavior<Node>[];
  101284. /**
  101285. * Gets an attached behavior by name
  101286. * @param name defines the name of the behavior to look for
  101287. * @see http://doc.babylonjs.com/features/behaviour
  101288. * @returns null if behavior was not found else the requested behavior
  101289. */
  101290. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  101291. /**
  101292. * Returns the latest update of the World matrix
  101293. * @returns a Matrix
  101294. */
  101295. getWorldMatrix(): Matrix;
  101296. /** @hidden */
  101297. _getWorldMatrixDeterminant(): number;
  101298. /**
  101299. * Returns directly the latest state of the mesh World matrix.
  101300. * A Matrix is returned.
  101301. */
  101302. get worldMatrixFromCache(): Matrix;
  101303. /** @hidden */
  101304. _initCache(): void;
  101305. /** @hidden */
  101306. updateCache(force?: boolean): void;
  101307. /** @hidden */
  101308. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101309. /** @hidden */
  101310. _updateCache(ignoreParentClass?: boolean): void;
  101311. /** @hidden */
  101312. _isSynchronized(): boolean;
  101313. /** @hidden */
  101314. _markSyncedWithParent(): void;
  101315. /** @hidden */
  101316. isSynchronizedWithParent(): boolean;
  101317. /** @hidden */
  101318. isSynchronized(): boolean;
  101319. /**
  101320. * Is this node ready to be used/rendered
  101321. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101322. * @return true if the node is ready
  101323. */
  101324. isReady(completeCheck?: boolean): boolean;
  101325. /**
  101326. * Is this node enabled?
  101327. * 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
  101328. * @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
  101329. * @return whether this node (and its parent) is enabled
  101330. */
  101331. isEnabled(checkAncestors?: boolean): boolean;
  101332. /** @hidden */
  101333. protected _syncParentEnabledState(): void;
  101334. /**
  101335. * Set the enabled state of this node
  101336. * @param value defines the new enabled state
  101337. */
  101338. setEnabled(value: boolean): void;
  101339. /**
  101340. * Is this node a descendant of the given node?
  101341. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  101342. * @param ancestor defines the parent node to inspect
  101343. * @returns a boolean indicating if this node is a descendant of the given node
  101344. */
  101345. isDescendantOf(ancestor: Node): boolean;
  101346. /** @hidden */
  101347. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  101348. /**
  101349. * Will return all nodes that have this node as ascendant
  101350. * @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
  101351. * @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
  101352. * @return all children nodes of all types
  101353. */
  101354. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  101355. /**
  101356. * Get all child-meshes of this node
  101357. * @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)
  101358. * @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
  101359. * @returns an array of AbstractMesh
  101360. */
  101361. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  101362. /**
  101363. * Get all direct children of this node
  101364. * @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
  101365. * @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)
  101366. * @returns an array of Node
  101367. */
  101368. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  101369. /** @hidden */
  101370. _setReady(state: boolean): void;
  101371. /**
  101372. * Get an animation by name
  101373. * @param name defines the name of the animation to look for
  101374. * @returns null if not found else the requested animation
  101375. */
  101376. getAnimationByName(name: string): Nullable<Animation>;
  101377. /**
  101378. * Creates an animation range for this node
  101379. * @param name defines the name of the range
  101380. * @param from defines the starting key
  101381. * @param to defines the end key
  101382. */
  101383. createAnimationRange(name: string, from: number, to: number): void;
  101384. /**
  101385. * Delete a specific animation range
  101386. * @param name defines the name of the range to delete
  101387. * @param deleteFrames defines if animation frames from the range must be deleted as well
  101388. */
  101389. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  101390. /**
  101391. * Get an animation range by name
  101392. * @param name defines the name of the animation range to look for
  101393. * @returns null if not found else the requested animation range
  101394. */
  101395. getAnimationRange(name: string): Nullable<AnimationRange>;
  101396. /**
  101397. * Gets the list of all animation ranges defined on this node
  101398. * @returns an array
  101399. */
  101400. getAnimationRanges(): Nullable<AnimationRange>[];
  101401. /**
  101402. * Will start the animation sequence
  101403. * @param name defines the range frames for animation sequence
  101404. * @param loop defines if the animation should loop (false by default)
  101405. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  101406. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  101407. * @returns the object created for this animation. If range does not exist, it will return null
  101408. */
  101409. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  101410. /**
  101411. * Serialize animation ranges into a JSON compatible object
  101412. * @returns serialization object
  101413. */
  101414. serializeAnimationRanges(): any;
  101415. /**
  101416. * Computes the world matrix of the node
  101417. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101418. * @returns the world matrix
  101419. */
  101420. computeWorldMatrix(force?: boolean): Matrix;
  101421. /**
  101422. * Releases resources associated with this node.
  101423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101425. */
  101426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101427. /**
  101428. * Parse animation range data from a serialization object and store them into a given node
  101429. * @param node defines where to store the animation ranges
  101430. * @param parsedNode defines the serialization object to read data from
  101431. * @param scene defines the hosting scene
  101432. */
  101433. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  101434. /**
  101435. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  101436. * @param includeDescendants Include bounding info from descendants as well (true by default)
  101437. * @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
  101438. * @returns the new bounding vectors
  101439. */
  101440. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  101441. min: Vector3;
  101442. max: Vector3;
  101443. };
  101444. }
  101445. }
  101446. declare module BABYLON {
  101447. /**
  101448. * @hidden
  101449. */
  101450. export class _IAnimationState {
  101451. key: number;
  101452. repeatCount: number;
  101453. workValue?: any;
  101454. loopMode?: number;
  101455. offsetValue?: any;
  101456. highLimitValue?: any;
  101457. }
  101458. /**
  101459. * Class used to store any kind of animation
  101460. */
  101461. export class Animation {
  101462. /**Name of the animation */
  101463. name: string;
  101464. /**Property to animate */
  101465. targetProperty: string;
  101466. /**The frames per second of the animation */
  101467. framePerSecond: number;
  101468. /**The data type of the animation */
  101469. dataType: number;
  101470. /**The loop mode of the animation */
  101471. loopMode?: number | undefined;
  101472. /**Specifies if blending should be enabled */
  101473. enableBlending?: boolean | undefined;
  101474. /**
  101475. * Use matrix interpolation instead of using direct key value when animating matrices
  101476. */
  101477. static AllowMatricesInterpolation: boolean;
  101478. /**
  101479. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  101480. */
  101481. static AllowMatrixDecomposeForInterpolation: boolean;
  101482. /**
  101483. * Stores the key frames of the animation
  101484. */
  101485. private _keys;
  101486. /**
  101487. * Stores the easing function of the animation
  101488. */
  101489. private _easingFunction;
  101490. /**
  101491. * @hidden Internal use only
  101492. */
  101493. _runtimeAnimations: RuntimeAnimation[];
  101494. /**
  101495. * The set of event that will be linked to this animation
  101496. */
  101497. private _events;
  101498. /**
  101499. * Stores an array of target property paths
  101500. */
  101501. targetPropertyPath: string[];
  101502. /**
  101503. * Stores the blending speed of the animation
  101504. */
  101505. blendingSpeed: number;
  101506. /**
  101507. * Stores the animation ranges for the animation
  101508. */
  101509. private _ranges;
  101510. /**
  101511. * @hidden Internal use
  101512. */
  101513. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  101514. /**
  101515. * Sets up an animation
  101516. * @param property The property to animate
  101517. * @param animationType The animation type to apply
  101518. * @param framePerSecond The frames per second of the animation
  101519. * @param easingFunction The easing function used in the animation
  101520. * @returns The created animation
  101521. */
  101522. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  101523. /**
  101524. * Create and start an animation on a node
  101525. * @param name defines the name of the global animation that will be run on all nodes
  101526. * @param node defines the root node where the animation will take place
  101527. * @param targetProperty defines property to animate
  101528. * @param framePerSecond defines the number of frame per second yo use
  101529. * @param totalFrame defines the number of frames in total
  101530. * @param from defines the initial value
  101531. * @param to defines the final value
  101532. * @param loopMode defines which loop mode you want to use (off by default)
  101533. * @param easingFunction defines the easing function to use (linear by default)
  101534. * @param onAnimationEnd defines the callback to call when animation end
  101535. * @returns the animatable created for this animation
  101536. */
  101537. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101538. /**
  101539. * Create and start an animation on a node and its descendants
  101540. * @param name defines the name of the global animation that will be run on all nodes
  101541. * @param node defines the root node where the animation will take place
  101542. * @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
  101543. * @param targetProperty defines property to animate
  101544. * @param framePerSecond defines the number of frame per second to use
  101545. * @param totalFrame defines the number of frames in total
  101546. * @param from defines the initial value
  101547. * @param to defines the final value
  101548. * @param loopMode defines which loop mode you want to use (off by default)
  101549. * @param easingFunction defines the easing function to use (linear by default)
  101550. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  101551. * @returns the list of animatables created for all nodes
  101552. * @example https://www.babylonjs-playground.com/#MH0VLI
  101553. */
  101554. 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[]>;
  101555. /**
  101556. * Creates a new animation, merges it with the existing animations and starts it
  101557. * @param name Name of the animation
  101558. * @param node Node which contains the scene that begins the animations
  101559. * @param targetProperty Specifies which property to animate
  101560. * @param framePerSecond The frames per second of the animation
  101561. * @param totalFrame The total number of frames
  101562. * @param from The frame at the beginning of the animation
  101563. * @param to The frame at the end of the animation
  101564. * @param loopMode Specifies the loop mode of the animation
  101565. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  101566. * @param onAnimationEnd Callback to run once the animation is complete
  101567. * @returns Nullable animation
  101568. */
  101569. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101570. /**
  101571. * Transition property of an host to the target Value
  101572. * @param property The property to transition
  101573. * @param targetValue The target Value of the property
  101574. * @param host The object where the property to animate belongs
  101575. * @param scene Scene used to run the animation
  101576. * @param frameRate Framerate (in frame/s) to use
  101577. * @param transition The transition type we want to use
  101578. * @param duration The duration of the animation, in milliseconds
  101579. * @param onAnimationEnd Callback trigger at the end of the animation
  101580. * @returns Nullable animation
  101581. */
  101582. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  101583. /**
  101584. * Return the array of runtime animations currently using this animation
  101585. */
  101586. get runtimeAnimations(): RuntimeAnimation[];
  101587. /**
  101588. * Specifies if any of the runtime animations are currently running
  101589. */
  101590. get hasRunningRuntimeAnimations(): boolean;
  101591. /**
  101592. * Initializes the animation
  101593. * @param name Name of the animation
  101594. * @param targetProperty Property to animate
  101595. * @param framePerSecond The frames per second of the animation
  101596. * @param dataType The data type of the animation
  101597. * @param loopMode The loop mode of the animation
  101598. * @param enableBlending Specifies if blending should be enabled
  101599. */
  101600. constructor(
  101601. /**Name of the animation */
  101602. name: string,
  101603. /**Property to animate */
  101604. targetProperty: string,
  101605. /**The frames per second of the animation */
  101606. framePerSecond: number,
  101607. /**The data type of the animation */
  101608. dataType: number,
  101609. /**The loop mode of the animation */
  101610. loopMode?: number | undefined,
  101611. /**Specifies if blending should be enabled */
  101612. enableBlending?: boolean | undefined);
  101613. /**
  101614. * Converts the animation to a string
  101615. * @param fullDetails support for multiple levels of logging within scene loading
  101616. * @returns String form of the animation
  101617. */
  101618. toString(fullDetails?: boolean): string;
  101619. /**
  101620. * Add an event to this animation
  101621. * @param event Event to add
  101622. */
  101623. addEvent(event: AnimationEvent): void;
  101624. /**
  101625. * Remove all events found at the given frame
  101626. * @param frame The frame to remove events from
  101627. */
  101628. removeEvents(frame: number): void;
  101629. /**
  101630. * Retrieves all the events from the animation
  101631. * @returns Events from the animation
  101632. */
  101633. getEvents(): AnimationEvent[];
  101634. /**
  101635. * Creates an animation range
  101636. * @param name Name of the animation range
  101637. * @param from Starting frame of the animation range
  101638. * @param to Ending frame of the animation
  101639. */
  101640. createRange(name: string, from: number, to: number): void;
  101641. /**
  101642. * Deletes an animation range by name
  101643. * @param name Name of the animation range to delete
  101644. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  101645. */
  101646. deleteRange(name: string, deleteFrames?: boolean): void;
  101647. /**
  101648. * Gets the animation range by name, or null if not defined
  101649. * @param name Name of the animation range
  101650. * @returns Nullable animation range
  101651. */
  101652. getRange(name: string): Nullable<AnimationRange>;
  101653. /**
  101654. * Gets the key frames from the animation
  101655. * @returns The key frames of the animation
  101656. */
  101657. getKeys(): Array<IAnimationKey>;
  101658. /**
  101659. * Gets the highest frame rate of the animation
  101660. * @returns Highest frame rate of the animation
  101661. */
  101662. getHighestFrame(): number;
  101663. /**
  101664. * Gets the easing function of the animation
  101665. * @returns Easing function of the animation
  101666. */
  101667. getEasingFunction(): IEasingFunction;
  101668. /**
  101669. * Sets the easing function of the animation
  101670. * @param easingFunction A custom mathematical formula for animation
  101671. */
  101672. setEasingFunction(easingFunction: EasingFunction): void;
  101673. /**
  101674. * Interpolates a scalar linearly
  101675. * @param startValue Start value of the animation curve
  101676. * @param endValue End value of the animation curve
  101677. * @param gradient Scalar amount to interpolate
  101678. * @returns Interpolated scalar value
  101679. */
  101680. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  101681. /**
  101682. * Interpolates a scalar cubically
  101683. * @param startValue Start value of the animation curve
  101684. * @param outTangent End tangent of the animation
  101685. * @param endValue End value of the animation curve
  101686. * @param inTangent Start tangent of the animation curve
  101687. * @param gradient Scalar amount to interpolate
  101688. * @returns Interpolated scalar value
  101689. */
  101690. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  101691. /**
  101692. * Interpolates a quaternion using a spherical linear interpolation
  101693. * @param startValue Start value of the animation curve
  101694. * @param endValue End value of the animation curve
  101695. * @param gradient Scalar amount to interpolate
  101696. * @returns Interpolated quaternion value
  101697. */
  101698. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  101699. /**
  101700. * Interpolates a quaternion cubically
  101701. * @param startValue Start value of the animation curve
  101702. * @param outTangent End tangent of the animation curve
  101703. * @param endValue End value of the animation curve
  101704. * @param inTangent Start tangent of the animation curve
  101705. * @param gradient Scalar amount to interpolate
  101706. * @returns Interpolated quaternion value
  101707. */
  101708. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  101709. /**
  101710. * Interpolates a Vector3 linearl
  101711. * @param startValue Start value of the animation curve
  101712. * @param endValue End value of the animation curve
  101713. * @param gradient Scalar amount to interpolate
  101714. * @returns Interpolated scalar value
  101715. */
  101716. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  101717. /**
  101718. * Interpolates a Vector3 cubically
  101719. * @param startValue Start value of the animation curve
  101720. * @param outTangent End tangent of the animation
  101721. * @param endValue End value of the animation curve
  101722. * @param inTangent Start tangent of the animation curve
  101723. * @param gradient Scalar amount to interpolate
  101724. * @returns InterpolatedVector3 value
  101725. */
  101726. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  101727. /**
  101728. * Interpolates a Vector2 linearly
  101729. * @param startValue Start value of the animation curve
  101730. * @param endValue End value of the animation curve
  101731. * @param gradient Scalar amount to interpolate
  101732. * @returns Interpolated Vector2 value
  101733. */
  101734. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  101735. /**
  101736. * Interpolates a Vector2 cubically
  101737. * @param startValue Start value of the animation curve
  101738. * @param outTangent End tangent of the animation
  101739. * @param endValue End value of the animation curve
  101740. * @param inTangent Start tangent of the animation curve
  101741. * @param gradient Scalar amount to interpolate
  101742. * @returns Interpolated Vector2 value
  101743. */
  101744. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  101745. /**
  101746. * Interpolates a size linearly
  101747. * @param startValue Start value of the animation curve
  101748. * @param endValue End value of the animation curve
  101749. * @param gradient Scalar amount to interpolate
  101750. * @returns Interpolated Size value
  101751. */
  101752. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  101753. /**
  101754. * Interpolates a Color3 linearly
  101755. * @param startValue Start value of the animation curve
  101756. * @param endValue End value of the animation curve
  101757. * @param gradient Scalar amount to interpolate
  101758. * @returns Interpolated Color3 value
  101759. */
  101760. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  101761. /**
  101762. * Interpolates a Color4 linearly
  101763. * @param startValue Start value of the animation curve
  101764. * @param endValue End value of the animation curve
  101765. * @param gradient Scalar amount to interpolate
  101766. * @returns Interpolated Color3 value
  101767. */
  101768. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  101769. /**
  101770. * @hidden Internal use only
  101771. */
  101772. _getKeyValue(value: any): any;
  101773. /**
  101774. * @hidden Internal use only
  101775. */
  101776. _interpolate(currentFrame: number, state: _IAnimationState): any;
  101777. /**
  101778. * Defines the function to use to interpolate matrices
  101779. * @param startValue defines the start matrix
  101780. * @param endValue defines the end matrix
  101781. * @param gradient defines the gradient between both matrices
  101782. * @param result defines an optional target matrix where to store the interpolation
  101783. * @returns the interpolated matrix
  101784. */
  101785. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  101786. /**
  101787. * Makes a copy of the animation
  101788. * @returns Cloned animation
  101789. */
  101790. clone(): Animation;
  101791. /**
  101792. * Sets the key frames of the animation
  101793. * @param values The animation key frames to set
  101794. */
  101795. setKeys(values: Array<IAnimationKey>): void;
  101796. /**
  101797. * Serializes the animation to an object
  101798. * @returns Serialized object
  101799. */
  101800. serialize(): any;
  101801. /**
  101802. * Float animation type
  101803. */
  101804. static readonly ANIMATIONTYPE_FLOAT: number;
  101805. /**
  101806. * Vector3 animation type
  101807. */
  101808. static readonly ANIMATIONTYPE_VECTOR3: number;
  101809. /**
  101810. * Quaternion animation type
  101811. */
  101812. static readonly ANIMATIONTYPE_QUATERNION: number;
  101813. /**
  101814. * Matrix animation type
  101815. */
  101816. static readonly ANIMATIONTYPE_MATRIX: number;
  101817. /**
  101818. * Color3 animation type
  101819. */
  101820. static readonly ANIMATIONTYPE_COLOR3: number;
  101821. /**
  101822. * Color3 animation type
  101823. */
  101824. static readonly ANIMATIONTYPE_COLOR4: number;
  101825. /**
  101826. * Vector2 animation type
  101827. */
  101828. static readonly ANIMATIONTYPE_VECTOR2: number;
  101829. /**
  101830. * Size animation type
  101831. */
  101832. static readonly ANIMATIONTYPE_SIZE: number;
  101833. /**
  101834. * Relative Loop Mode
  101835. */
  101836. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  101837. /**
  101838. * Cycle Loop Mode
  101839. */
  101840. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  101841. /**
  101842. * Constant Loop Mode
  101843. */
  101844. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  101845. /** @hidden */
  101846. static _UniversalLerp(left: any, right: any, amount: number): any;
  101847. /**
  101848. * Parses an animation object and creates an animation
  101849. * @param parsedAnimation Parsed animation object
  101850. * @returns Animation object
  101851. */
  101852. static Parse(parsedAnimation: any): Animation;
  101853. /**
  101854. * Appends the serialized animations from the source animations
  101855. * @param source Source containing the animations
  101856. * @param destination Target to store the animations
  101857. */
  101858. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  101859. }
  101860. }
  101861. declare module BABYLON {
  101862. /**
  101863. * Interface containing an array of animations
  101864. */
  101865. export interface IAnimatable {
  101866. /**
  101867. * Array of animations
  101868. */
  101869. animations: Nullable<Array<Animation>>;
  101870. }
  101871. }
  101872. declare module BABYLON {
  101873. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  101874. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101875. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101876. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101877. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101878. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101879. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101880. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101881. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101882. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101883. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101884. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101885. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101886. /**
  101887. * Decorator used to define property that can be serialized as reference to a camera
  101888. * @param sourceName defines the name of the property to decorate
  101889. */
  101890. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101891. /**
  101892. * Class used to help serialization objects
  101893. */
  101894. export class SerializationHelper {
  101895. /** @hidden */
  101896. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  101897. /** @hidden */
  101898. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  101899. /** @hidden */
  101900. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  101901. /** @hidden */
  101902. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  101903. /**
  101904. * Appends the serialized animations from the source animations
  101905. * @param source Source containing the animations
  101906. * @param destination Target to store the animations
  101907. */
  101908. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  101909. /**
  101910. * Static function used to serialized a specific entity
  101911. * @param entity defines the entity to serialize
  101912. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  101913. * @returns a JSON compatible object representing the serialization of the entity
  101914. */
  101915. static Serialize<T>(entity: T, serializationObject?: any): any;
  101916. /**
  101917. * Creates a new entity from a serialization data object
  101918. * @param creationFunction defines a function used to instanciated the new entity
  101919. * @param source defines the source serialization data
  101920. * @param scene defines the hosting scene
  101921. * @param rootUrl defines the root url for resources
  101922. * @returns a new entity
  101923. */
  101924. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  101925. /**
  101926. * Clones an object
  101927. * @param creationFunction defines the function used to instanciate the new object
  101928. * @param source defines the source object
  101929. * @returns the cloned object
  101930. */
  101931. static Clone<T>(creationFunction: () => T, source: T): T;
  101932. /**
  101933. * Instanciates a new object based on a source one (some data will be shared between both object)
  101934. * @param creationFunction defines the function used to instanciate the new object
  101935. * @param source defines the source object
  101936. * @returns the new object
  101937. */
  101938. static Instanciate<T>(creationFunction: () => T, source: T): T;
  101939. }
  101940. }
  101941. declare module BABYLON {
  101942. /**
  101943. * Class used to manipulate GUIDs
  101944. */
  101945. export class GUID {
  101946. /**
  101947. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101948. * Be aware Math.random() could cause collisions, but:
  101949. * "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"
  101950. * @returns a pseudo random id
  101951. */
  101952. static RandomId(): string;
  101953. }
  101954. }
  101955. declare module BABYLON {
  101956. /**
  101957. * Base class of all the textures in babylon.
  101958. * It groups all the common properties the materials, post process, lights... might need
  101959. * in order to make a correct use of the texture.
  101960. */
  101961. export class BaseTexture implements IAnimatable {
  101962. /**
  101963. * Default anisotropic filtering level for the application.
  101964. * It is set to 4 as a good tradeoff between perf and quality.
  101965. */
  101966. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  101967. /**
  101968. * Gets or sets the unique id of the texture
  101969. */
  101970. uniqueId: number;
  101971. /**
  101972. * Define the name of the texture.
  101973. */
  101974. name: string;
  101975. /**
  101976. * Gets or sets an object used to store user defined information.
  101977. */
  101978. metadata: any;
  101979. /**
  101980. * For internal use only. Please do not use.
  101981. */
  101982. reservedDataStore: any;
  101983. private _hasAlpha;
  101984. /**
  101985. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  101986. */
  101987. set hasAlpha(value: boolean);
  101988. get hasAlpha(): boolean;
  101989. /**
  101990. * Defines if the alpha value should be determined via the rgb values.
  101991. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  101992. */
  101993. getAlphaFromRGB: boolean;
  101994. /**
  101995. * Intensity or strength of the texture.
  101996. * It is commonly used by materials to fine tune the intensity of the texture
  101997. */
  101998. level: number;
  101999. /**
  102000. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102001. * This is part of the texture as textures usually maps to one uv set.
  102002. */
  102003. coordinatesIndex: number;
  102004. private _coordinatesMode;
  102005. /**
  102006. * How a texture is mapped.
  102007. *
  102008. * | Value | Type | Description |
  102009. * | ----- | ----------------------------------- | ----------- |
  102010. * | 0 | EXPLICIT_MODE | |
  102011. * | 1 | SPHERICAL_MODE | |
  102012. * | 2 | PLANAR_MODE | |
  102013. * | 3 | CUBIC_MODE | |
  102014. * | 4 | PROJECTION_MODE | |
  102015. * | 5 | SKYBOX_MODE | |
  102016. * | 6 | INVCUBIC_MODE | |
  102017. * | 7 | EQUIRECTANGULAR_MODE | |
  102018. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102019. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102020. */
  102021. set coordinatesMode(value: number);
  102022. get coordinatesMode(): number;
  102023. /**
  102024. * | Value | Type | Description |
  102025. * | ----- | ------------------ | ----------- |
  102026. * | 0 | CLAMP_ADDRESSMODE | |
  102027. * | 1 | WRAP_ADDRESSMODE | |
  102028. * | 2 | MIRROR_ADDRESSMODE | |
  102029. */
  102030. wrapU: number;
  102031. /**
  102032. * | Value | Type | Description |
  102033. * | ----- | ------------------ | ----------- |
  102034. * | 0 | CLAMP_ADDRESSMODE | |
  102035. * | 1 | WRAP_ADDRESSMODE | |
  102036. * | 2 | MIRROR_ADDRESSMODE | |
  102037. */
  102038. wrapV: number;
  102039. /**
  102040. * | Value | Type | Description |
  102041. * | ----- | ------------------ | ----------- |
  102042. * | 0 | CLAMP_ADDRESSMODE | |
  102043. * | 1 | WRAP_ADDRESSMODE | |
  102044. * | 2 | MIRROR_ADDRESSMODE | |
  102045. */
  102046. wrapR: number;
  102047. /**
  102048. * With compliant hardware and browser (supporting anisotropic filtering)
  102049. * this defines the level of anisotropic filtering in the texture.
  102050. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102051. */
  102052. anisotropicFilteringLevel: number;
  102053. /**
  102054. * Define if the texture is a cube texture or if false a 2d texture.
  102055. */
  102056. get isCube(): boolean;
  102057. set isCube(value: boolean);
  102058. /**
  102059. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102060. */
  102061. get is3D(): boolean;
  102062. set is3D(value: boolean);
  102063. /**
  102064. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102065. */
  102066. get is2DArray(): boolean;
  102067. set is2DArray(value: boolean);
  102068. /**
  102069. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102070. * HDR texture are usually stored in linear space.
  102071. * This only impacts the PBR and Background materials
  102072. */
  102073. gammaSpace: boolean;
  102074. /**
  102075. * Gets or sets whether or not the texture contains RGBD data.
  102076. */
  102077. get isRGBD(): boolean;
  102078. set isRGBD(value: boolean);
  102079. /**
  102080. * Is Z inverted in the texture (useful in a cube texture).
  102081. */
  102082. invertZ: boolean;
  102083. /**
  102084. * Are mip maps generated for this texture or not.
  102085. */
  102086. get noMipmap(): boolean;
  102087. /**
  102088. * @hidden
  102089. */
  102090. lodLevelInAlpha: boolean;
  102091. /**
  102092. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102093. */
  102094. get lodGenerationOffset(): number;
  102095. set lodGenerationOffset(value: number);
  102096. /**
  102097. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102098. */
  102099. get lodGenerationScale(): number;
  102100. set lodGenerationScale(value: number);
  102101. /**
  102102. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102103. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102104. * average roughness values.
  102105. */
  102106. get linearSpecularLOD(): boolean;
  102107. set linearSpecularLOD(value: boolean);
  102108. /**
  102109. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102110. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102111. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102112. */
  102113. get irradianceTexture(): Nullable<BaseTexture>;
  102114. set irradianceTexture(value: Nullable<BaseTexture>);
  102115. /**
  102116. * Define if the texture is a render target.
  102117. */
  102118. isRenderTarget: boolean;
  102119. /**
  102120. * Define the unique id of the texture in the scene.
  102121. */
  102122. get uid(): string;
  102123. /**
  102124. * Return a string representation of the texture.
  102125. * @returns the texture as a string
  102126. */
  102127. toString(): string;
  102128. /**
  102129. * Get the class name of the texture.
  102130. * @returns "BaseTexture"
  102131. */
  102132. getClassName(): string;
  102133. /**
  102134. * Define the list of animation attached to the texture.
  102135. */
  102136. animations: Animation[];
  102137. /**
  102138. * An event triggered when the texture is disposed.
  102139. */
  102140. onDisposeObservable: Observable<BaseTexture>;
  102141. private _onDisposeObserver;
  102142. /**
  102143. * Callback triggered when the texture has been disposed.
  102144. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102145. */
  102146. set onDispose(callback: () => void);
  102147. /**
  102148. * Define the current state of the loading sequence when in delayed load mode.
  102149. */
  102150. delayLoadState: number;
  102151. private _scene;
  102152. /** @hidden */
  102153. _texture: Nullable<InternalTexture>;
  102154. private _uid;
  102155. /**
  102156. * Define if the texture is preventinga material to render or not.
  102157. * If not and the texture is not ready, the engine will use a default black texture instead.
  102158. */
  102159. get isBlocking(): boolean;
  102160. /**
  102161. * Instantiates a new BaseTexture.
  102162. * Base class of all the textures in babylon.
  102163. * It groups all the common properties the materials, post process, lights... might need
  102164. * in order to make a correct use of the texture.
  102165. * @param scene Define the scene the texture blongs to
  102166. */
  102167. constructor(scene: Nullable<Scene>);
  102168. /**
  102169. * Get the scene the texture belongs to.
  102170. * @returns the scene or null if undefined
  102171. */
  102172. getScene(): Nullable<Scene>;
  102173. /**
  102174. * Get the texture transform matrix used to offset tile the texture for istance.
  102175. * @returns the transformation matrix
  102176. */
  102177. getTextureMatrix(): Matrix;
  102178. /**
  102179. * Get the texture reflection matrix used to rotate/transform the reflection.
  102180. * @returns the reflection matrix
  102181. */
  102182. getReflectionTextureMatrix(): Matrix;
  102183. /**
  102184. * Get the underlying lower level texture from Babylon.
  102185. * @returns the insternal texture
  102186. */
  102187. getInternalTexture(): Nullable<InternalTexture>;
  102188. /**
  102189. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  102190. * @returns true if ready or not blocking
  102191. */
  102192. isReadyOrNotBlocking(): boolean;
  102193. /**
  102194. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  102195. * @returns true if fully ready
  102196. */
  102197. isReady(): boolean;
  102198. private _cachedSize;
  102199. /**
  102200. * Get the size of the texture.
  102201. * @returns the texture size.
  102202. */
  102203. getSize(): ISize;
  102204. /**
  102205. * Get the base size of the texture.
  102206. * It can be different from the size if the texture has been resized for POT for instance
  102207. * @returns the base size
  102208. */
  102209. getBaseSize(): ISize;
  102210. /**
  102211. * Update the sampling mode of the texture.
  102212. * Default is Trilinear mode.
  102213. *
  102214. * | Value | Type | Description |
  102215. * | ----- | ------------------ | ----------- |
  102216. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  102217. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  102218. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  102219. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  102220. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  102221. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  102222. * | 7 | NEAREST_LINEAR | |
  102223. * | 8 | NEAREST_NEAREST | |
  102224. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  102225. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  102226. * | 11 | LINEAR_LINEAR | |
  102227. * | 12 | LINEAR_NEAREST | |
  102228. *
  102229. * > _mag_: magnification filter (close to the viewer)
  102230. * > _min_: minification filter (far from the viewer)
  102231. * > _mip_: filter used between mip map levels
  102232. *@param samplingMode Define the new sampling mode of the texture
  102233. */
  102234. updateSamplingMode(samplingMode: number): void;
  102235. /**
  102236. * Scales the texture if is `canRescale()`
  102237. * @param ratio the resize factor we want to use to rescale
  102238. */
  102239. scale(ratio: number): void;
  102240. /**
  102241. * Get if the texture can rescale.
  102242. */
  102243. get canRescale(): boolean;
  102244. /** @hidden */
  102245. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  102246. /** @hidden */
  102247. _rebuild(): void;
  102248. /**
  102249. * Triggers the load sequence in delayed load mode.
  102250. */
  102251. delayLoad(): void;
  102252. /**
  102253. * Clones the texture.
  102254. * @returns the cloned texture
  102255. */
  102256. clone(): Nullable<BaseTexture>;
  102257. /**
  102258. * Get the texture underlying type (INT, FLOAT...)
  102259. */
  102260. get textureType(): number;
  102261. /**
  102262. * Get the texture underlying format (RGB, RGBA...)
  102263. */
  102264. get textureFormat(): number;
  102265. /**
  102266. * Indicates that textures need to be re-calculated for all materials
  102267. */
  102268. protected _markAllSubMeshesAsTexturesDirty(): void;
  102269. /**
  102270. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  102271. * This will returns an RGBA array buffer containing either in values (0-255) or
  102272. * float values (0-1) depending of the underlying buffer type.
  102273. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  102274. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  102275. * @param buffer defines a user defined buffer to fill with data (can be null)
  102276. * @returns The Array buffer containing the pixels data.
  102277. */
  102278. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  102279. /**
  102280. * Release and destroy the underlying lower level texture aka internalTexture.
  102281. */
  102282. releaseInternalTexture(): void;
  102283. /** @hidden */
  102284. get _lodTextureHigh(): Nullable<BaseTexture>;
  102285. /** @hidden */
  102286. get _lodTextureMid(): Nullable<BaseTexture>;
  102287. /** @hidden */
  102288. get _lodTextureLow(): Nullable<BaseTexture>;
  102289. /**
  102290. * Dispose the texture and release its associated resources.
  102291. */
  102292. dispose(): void;
  102293. /**
  102294. * Serialize the texture into a JSON representation that can be parsed later on.
  102295. * @returns the JSON representation of the texture
  102296. */
  102297. serialize(): any;
  102298. /**
  102299. * Helper function to be called back once a list of texture contains only ready textures.
  102300. * @param textures Define the list of textures to wait for
  102301. * @param callback Define the callback triggered once the entire list will be ready
  102302. */
  102303. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  102304. }
  102305. }
  102306. declare module BABYLON {
  102307. /**
  102308. * Options to be used when creating an effect.
  102309. */
  102310. export interface IEffectCreationOptions {
  102311. /**
  102312. * Atrributes that will be used in the shader.
  102313. */
  102314. attributes: string[];
  102315. /**
  102316. * Uniform varible names that will be set in the shader.
  102317. */
  102318. uniformsNames: string[];
  102319. /**
  102320. * Uniform buffer variable names that will be set in the shader.
  102321. */
  102322. uniformBuffersNames: string[];
  102323. /**
  102324. * Sampler texture variable names that will be set in the shader.
  102325. */
  102326. samplers: string[];
  102327. /**
  102328. * Define statements that will be set in the shader.
  102329. */
  102330. defines: any;
  102331. /**
  102332. * Possible fallbacks for this effect to improve performance when needed.
  102333. */
  102334. fallbacks: Nullable<IEffectFallbacks>;
  102335. /**
  102336. * Callback that will be called when the shader is compiled.
  102337. */
  102338. onCompiled: Nullable<(effect: Effect) => void>;
  102339. /**
  102340. * Callback that will be called if an error occurs during shader compilation.
  102341. */
  102342. onError: Nullable<(effect: Effect, errors: string) => void>;
  102343. /**
  102344. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102345. */
  102346. indexParameters?: any;
  102347. /**
  102348. * Max number of lights that can be used in the shader.
  102349. */
  102350. maxSimultaneousLights?: number;
  102351. /**
  102352. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  102353. */
  102354. transformFeedbackVaryings?: Nullable<string[]>;
  102355. }
  102356. /**
  102357. * Effect containing vertex and fragment shader that can be executed on an object.
  102358. */
  102359. export class Effect implements IDisposable {
  102360. /**
  102361. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102362. */
  102363. static ShadersRepository: string;
  102364. /**
  102365. * Name of the effect.
  102366. */
  102367. name: any;
  102368. /**
  102369. * String container all the define statements that should be set on the shader.
  102370. */
  102371. defines: string;
  102372. /**
  102373. * Callback that will be called when the shader is compiled.
  102374. */
  102375. onCompiled: Nullable<(effect: Effect) => void>;
  102376. /**
  102377. * Callback that will be called if an error occurs during shader compilation.
  102378. */
  102379. onError: Nullable<(effect: Effect, errors: string) => void>;
  102380. /**
  102381. * Callback that will be called when effect is bound.
  102382. */
  102383. onBind: Nullable<(effect: Effect) => void>;
  102384. /**
  102385. * Unique ID of the effect.
  102386. */
  102387. uniqueId: number;
  102388. /**
  102389. * Observable that will be called when the shader is compiled.
  102390. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  102391. */
  102392. onCompileObservable: Observable<Effect>;
  102393. /**
  102394. * Observable that will be called if an error occurs during shader compilation.
  102395. */
  102396. onErrorObservable: Observable<Effect>;
  102397. /** @hidden */
  102398. _onBindObservable: Nullable<Observable<Effect>>;
  102399. /**
  102400. * @hidden
  102401. * Specifies if the effect was previously ready
  102402. */
  102403. _wasPreviouslyReady: boolean;
  102404. /**
  102405. * Observable that will be called when effect is bound.
  102406. */
  102407. get onBindObservable(): Observable<Effect>;
  102408. /** @hidden */
  102409. _bonesComputationForcedToCPU: boolean;
  102410. private static _uniqueIdSeed;
  102411. private _engine;
  102412. private _uniformBuffersNames;
  102413. private _uniformsNames;
  102414. private _samplerList;
  102415. private _samplers;
  102416. private _isReady;
  102417. private _compilationError;
  102418. private _allFallbacksProcessed;
  102419. private _attributesNames;
  102420. private _attributes;
  102421. private _attributeLocationByName;
  102422. private _uniforms;
  102423. /**
  102424. * Key for the effect.
  102425. * @hidden
  102426. */
  102427. _key: string;
  102428. private _indexParameters;
  102429. private _fallbacks;
  102430. private _vertexSourceCode;
  102431. private _fragmentSourceCode;
  102432. private _vertexSourceCodeOverride;
  102433. private _fragmentSourceCodeOverride;
  102434. private _transformFeedbackVaryings;
  102435. /**
  102436. * Compiled shader to webGL program.
  102437. * @hidden
  102438. */
  102439. _pipelineContext: Nullable<IPipelineContext>;
  102440. private _valueCache;
  102441. private static _baseCache;
  102442. /**
  102443. * Instantiates an effect.
  102444. * An effect can be used to create/manage/execute vertex and fragment shaders.
  102445. * @param baseName Name of the effect.
  102446. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  102447. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  102448. * @param samplers List of sampler variables that will be passed to the shader.
  102449. * @param engine Engine to be used to render the effect
  102450. * @param defines Define statements to be added to the shader.
  102451. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  102452. * @param onCompiled Callback that will be called when the shader is compiled.
  102453. * @param onError Callback that will be called if an error occurs during shader compilation.
  102454. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102455. */
  102456. 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);
  102457. private _useFinalCode;
  102458. /**
  102459. * Unique key for this effect
  102460. */
  102461. get key(): string;
  102462. /**
  102463. * If the effect has been compiled and prepared.
  102464. * @returns if the effect is compiled and prepared.
  102465. */
  102466. isReady(): boolean;
  102467. private _isReadyInternal;
  102468. /**
  102469. * The engine the effect was initialized with.
  102470. * @returns the engine.
  102471. */
  102472. getEngine(): Engine;
  102473. /**
  102474. * The pipeline context for this effect
  102475. * @returns the associated pipeline context
  102476. */
  102477. getPipelineContext(): Nullable<IPipelineContext>;
  102478. /**
  102479. * The set of names of attribute variables for the shader.
  102480. * @returns An array of attribute names.
  102481. */
  102482. getAttributesNames(): string[];
  102483. /**
  102484. * Returns the attribute at the given index.
  102485. * @param index The index of the attribute.
  102486. * @returns The location of the attribute.
  102487. */
  102488. getAttributeLocation(index: number): number;
  102489. /**
  102490. * Returns the attribute based on the name of the variable.
  102491. * @param name of the attribute to look up.
  102492. * @returns the attribute location.
  102493. */
  102494. getAttributeLocationByName(name: string): number;
  102495. /**
  102496. * The number of attributes.
  102497. * @returns the numnber of attributes.
  102498. */
  102499. getAttributesCount(): number;
  102500. /**
  102501. * Gets the index of a uniform variable.
  102502. * @param uniformName of the uniform to look up.
  102503. * @returns the index.
  102504. */
  102505. getUniformIndex(uniformName: string): number;
  102506. /**
  102507. * Returns the attribute based on the name of the variable.
  102508. * @param uniformName of the uniform to look up.
  102509. * @returns the location of the uniform.
  102510. */
  102511. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  102512. /**
  102513. * Returns an array of sampler variable names
  102514. * @returns The array of sampler variable neames.
  102515. */
  102516. getSamplers(): string[];
  102517. /**
  102518. * The error from the last compilation.
  102519. * @returns the error string.
  102520. */
  102521. getCompilationError(): string;
  102522. /**
  102523. * Gets a boolean indicating that all fallbacks were used during compilation
  102524. * @returns true if all fallbacks were used
  102525. */
  102526. allFallbacksProcessed(): boolean;
  102527. /**
  102528. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  102529. * @param func The callback to be used.
  102530. */
  102531. executeWhenCompiled(func: (effect: Effect) => void): void;
  102532. private _checkIsReady;
  102533. private _loadShader;
  102534. /**
  102535. * Recompiles the webGL program
  102536. * @param vertexSourceCode The source code for the vertex shader.
  102537. * @param fragmentSourceCode The source code for the fragment shader.
  102538. * @param onCompiled Callback called when completed.
  102539. * @param onError Callback called on error.
  102540. * @hidden
  102541. */
  102542. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  102543. /**
  102544. * Prepares the effect
  102545. * @hidden
  102546. */
  102547. _prepareEffect(): void;
  102548. private _processCompilationErrors;
  102549. /**
  102550. * Checks if the effect is supported. (Must be called after compilation)
  102551. */
  102552. get isSupported(): boolean;
  102553. /**
  102554. * Binds a texture to the engine to be used as output of the shader.
  102555. * @param channel Name of the output variable.
  102556. * @param texture Texture to bind.
  102557. * @hidden
  102558. */
  102559. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  102560. /**
  102561. * Sets a texture on the engine to be used in the shader.
  102562. * @param channel Name of the sampler variable.
  102563. * @param texture Texture to set.
  102564. */
  102565. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  102566. /**
  102567. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  102568. * @param channel Name of the sampler variable.
  102569. * @param texture Texture to set.
  102570. */
  102571. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  102572. /**
  102573. * Sets an array of textures on the engine to be used in the shader.
  102574. * @param channel Name of the variable.
  102575. * @param textures Textures to set.
  102576. */
  102577. setTextureArray(channel: string, textures: BaseTexture[]): void;
  102578. /**
  102579. * 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)
  102580. * @param channel Name of the sampler variable.
  102581. * @param postProcess Post process to get the input texture from.
  102582. */
  102583. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  102584. /**
  102585. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  102586. * 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)
  102587. * @param channel Name of the sampler variable.
  102588. * @param postProcess Post process to get the output texture from.
  102589. */
  102590. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  102591. /** @hidden */
  102592. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  102593. /** @hidden */
  102594. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  102595. /** @hidden */
  102596. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  102597. /** @hidden */
  102598. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  102599. /**
  102600. * Binds a buffer to a uniform.
  102601. * @param buffer Buffer to bind.
  102602. * @param name Name of the uniform variable to bind to.
  102603. */
  102604. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  102605. /**
  102606. * Binds block to a uniform.
  102607. * @param blockName Name of the block to bind.
  102608. * @param index Index to bind.
  102609. */
  102610. bindUniformBlock(blockName: string, index: number): void;
  102611. /**
  102612. * Sets an interger value on a uniform variable.
  102613. * @param uniformName Name of the variable.
  102614. * @param value Value to be set.
  102615. * @returns this effect.
  102616. */
  102617. setInt(uniformName: string, value: number): Effect;
  102618. /**
  102619. * Sets an int array on a uniform variable.
  102620. * @param uniformName Name of the variable.
  102621. * @param array array to be set.
  102622. * @returns this effect.
  102623. */
  102624. setIntArray(uniformName: string, array: Int32Array): Effect;
  102625. /**
  102626. * 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)
  102627. * @param uniformName Name of the variable.
  102628. * @param array array to be set.
  102629. * @returns this effect.
  102630. */
  102631. setIntArray2(uniformName: string, array: Int32Array): Effect;
  102632. /**
  102633. * 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)
  102634. * @param uniformName Name of the variable.
  102635. * @param array array to be set.
  102636. * @returns this effect.
  102637. */
  102638. setIntArray3(uniformName: string, array: Int32Array): Effect;
  102639. /**
  102640. * 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)
  102641. * @param uniformName Name of the variable.
  102642. * @param array array to be set.
  102643. * @returns this effect.
  102644. */
  102645. setIntArray4(uniformName: string, array: Int32Array): Effect;
  102646. /**
  102647. * Sets an float array on a uniform variable.
  102648. * @param uniformName Name of the variable.
  102649. * @param array array to be set.
  102650. * @returns this effect.
  102651. */
  102652. setFloatArray(uniformName: string, array: Float32Array): Effect;
  102653. /**
  102654. * 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)
  102655. * @param uniformName Name of the variable.
  102656. * @param array array to be set.
  102657. * @returns this effect.
  102658. */
  102659. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  102660. /**
  102661. * 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)
  102662. * @param uniformName Name of the variable.
  102663. * @param array array to be set.
  102664. * @returns this effect.
  102665. */
  102666. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  102667. /**
  102668. * 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)
  102669. * @param uniformName Name of the variable.
  102670. * @param array array to be set.
  102671. * @returns this effect.
  102672. */
  102673. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  102674. /**
  102675. * Sets an array on a uniform variable.
  102676. * @param uniformName Name of the variable.
  102677. * @param array array to be set.
  102678. * @returns this effect.
  102679. */
  102680. setArray(uniformName: string, array: number[]): Effect;
  102681. /**
  102682. * 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)
  102683. * @param uniformName Name of the variable.
  102684. * @param array array to be set.
  102685. * @returns this effect.
  102686. */
  102687. setArray2(uniformName: string, array: number[]): Effect;
  102688. /**
  102689. * 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)
  102690. * @param uniformName Name of the variable.
  102691. * @param array array to be set.
  102692. * @returns this effect.
  102693. */
  102694. setArray3(uniformName: string, array: number[]): Effect;
  102695. /**
  102696. * 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)
  102697. * @param uniformName Name of the variable.
  102698. * @param array array to be set.
  102699. * @returns this effect.
  102700. */
  102701. setArray4(uniformName: string, array: number[]): Effect;
  102702. /**
  102703. * Sets matrices on a uniform variable.
  102704. * @param uniformName Name of the variable.
  102705. * @param matrices matrices to be set.
  102706. * @returns this effect.
  102707. */
  102708. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  102709. /**
  102710. * Sets matrix on a uniform variable.
  102711. * @param uniformName Name of the variable.
  102712. * @param matrix matrix to be set.
  102713. * @returns this effect.
  102714. */
  102715. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  102716. /**
  102717. * 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)
  102718. * @param uniformName Name of the variable.
  102719. * @param matrix matrix to be set.
  102720. * @returns this effect.
  102721. */
  102722. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  102723. /**
  102724. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  102725. * @param uniformName Name of the variable.
  102726. * @param matrix matrix to be set.
  102727. * @returns this effect.
  102728. */
  102729. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  102730. /**
  102731. * Sets a float on a uniform variable.
  102732. * @param uniformName Name of the variable.
  102733. * @param value value to be set.
  102734. * @returns this effect.
  102735. */
  102736. setFloat(uniformName: string, value: number): Effect;
  102737. /**
  102738. * Sets a boolean on a uniform variable.
  102739. * @param uniformName Name of the variable.
  102740. * @param bool value to be set.
  102741. * @returns this effect.
  102742. */
  102743. setBool(uniformName: string, bool: boolean): Effect;
  102744. /**
  102745. * Sets a Vector2 on a uniform variable.
  102746. * @param uniformName Name of the variable.
  102747. * @param vector2 vector2 to be set.
  102748. * @returns this effect.
  102749. */
  102750. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  102751. /**
  102752. * Sets a float2 on a uniform variable.
  102753. * @param uniformName Name of the variable.
  102754. * @param x First float in float2.
  102755. * @param y Second float in float2.
  102756. * @returns this effect.
  102757. */
  102758. setFloat2(uniformName: string, x: number, y: number): Effect;
  102759. /**
  102760. * Sets a Vector3 on a uniform variable.
  102761. * @param uniformName Name of the variable.
  102762. * @param vector3 Value to be set.
  102763. * @returns this effect.
  102764. */
  102765. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  102766. /**
  102767. * Sets a float3 on a uniform variable.
  102768. * @param uniformName Name of the variable.
  102769. * @param x First float in float3.
  102770. * @param y Second float in float3.
  102771. * @param z Third float in float3.
  102772. * @returns this effect.
  102773. */
  102774. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  102775. /**
  102776. * Sets a Vector4 on a uniform variable.
  102777. * @param uniformName Name of the variable.
  102778. * @param vector4 Value to be set.
  102779. * @returns this effect.
  102780. */
  102781. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  102782. /**
  102783. * Sets a float4 on a uniform variable.
  102784. * @param uniformName Name of the variable.
  102785. * @param x First float in float4.
  102786. * @param y Second float in float4.
  102787. * @param z Third float in float4.
  102788. * @param w Fourth float in float4.
  102789. * @returns this effect.
  102790. */
  102791. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  102792. /**
  102793. * Sets a Color3 on a uniform variable.
  102794. * @param uniformName Name of the variable.
  102795. * @param color3 Value to be set.
  102796. * @returns this effect.
  102797. */
  102798. setColor3(uniformName: string, color3: IColor3Like): Effect;
  102799. /**
  102800. * Sets a Color4 on a uniform variable.
  102801. * @param uniformName Name of the variable.
  102802. * @param color3 Value to be set.
  102803. * @param alpha Alpha value to be set.
  102804. * @returns this effect.
  102805. */
  102806. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  102807. /**
  102808. * Sets a Color4 on a uniform variable
  102809. * @param uniformName defines the name of the variable
  102810. * @param color4 defines the value to be set
  102811. * @returns this effect.
  102812. */
  102813. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  102814. /** Release all associated resources */
  102815. dispose(): void;
  102816. /**
  102817. * This function will add a new shader to the shader store
  102818. * @param name the name of the shader
  102819. * @param pixelShader optional pixel shader content
  102820. * @param vertexShader optional vertex shader content
  102821. */
  102822. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  102823. /**
  102824. * Store of each shader (The can be looked up using effect.key)
  102825. */
  102826. static ShadersStore: {
  102827. [key: string]: string;
  102828. };
  102829. /**
  102830. * Store of each included file for a shader (The can be looked up using effect.key)
  102831. */
  102832. static IncludesShadersStore: {
  102833. [key: string]: string;
  102834. };
  102835. /**
  102836. * Resets the cache of effects.
  102837. */
  102838. static ResetCache(): void;
  102839. }
  102840. }
  102841. declare module BABYLON {
  102842. /**
  102843. * Interface used to describe the capabilities of the engine relatively to the current browser
  102844. */
  102845. export interface EngineCapabilities {
  102846. /** Maximum textures units per fragment shader */
  102847. maxTexturesImageUnits: number;
  102848. /** Maximum texture units per vertex shader */
  102849. maxVertexTextureImageUnits: number;
  102850. /** Maximum textures units in the entire pipeline */
  102851. maxCombinedTexturesImageUnits: number;
  102852. /** Maximum texture size */
  102853. maxTextureSize: number;
  102854. /** Maximum texture samples */
  102855. maxSamples?: number;
  102856. /** Maximum cube texture size */
  102857. maxCubemapTextureSize: number;
  102858. /** Maximum render texture size */
  102859. maxRenderTextureSize: number;
  102860. /** Maximum number of vertex attributes */
  102861. maxVertexAttribs: number;
  102862. /** Maximum number of varyings */
  102863. maxVaryingVectors: number;
  102864. /** Maximum number of uniforms per vertex shader */
  102865. maxVertexUniformVectors: number;
  102866. /** Maximum number of uniforms per fragment shader */
  102867. maxFragmentUniformVectors: number;
  102868. /** Defines if standard derivates (dx/dy) are supported */
  102869. standardDerivatives: boolean;
  102870. /** Defines if s3tc texture compression is supported */
  102871. s3tc?: WEBGL_compressed_texture_s3tc;
  102872. /** Defines if pvrtc texture compression is supported */
  102873. pvrtc: any;
  102874. /** Defines if etc1 texture compression is supported */
  102875. etc1: any;
  102876. /** Defines if etc2 texture compression is supported */
  102877. etc2: any;
  102878. /** Defines if astc texture compression is supported */
  102879. astc: any;
  102880. /** Defines if float textures are supported */
  102881. textureFloat: boolean;
  102882. /** Defines if vertex array objects are supported */
  102883. vertexArrayObject: boolean;
  102884. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  102885. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  102886. /** Gets the maximum level of anisotropy supported */
  102887. maxAnisotropy: number;
  102888. /** Defines if instancing is supported */
  102889. instancedArrays: boolean;
  102890. /** Defines if 32 bits indices are supported */
  102891. uintIndices: boolean;
  102892. /** Defines if high precision shaders are supported */
  102893. highPrecisionShaderSupported: boolean;
  102894. /** Defines if depth reading in the fragment shader is supported */
  102895. fragmentDepthSupported: boolean;
  102896. /** Defines if float texture linear filtering is supported*/
  102897. textureFloatLinearFiltering: boolean;
  102898. /** Defines if rendering to float textures is supported */
  102899. textureFloatRender: boolean;
  102900. /** Defines if half float textures are supported*/
  102901. textureHalfFloat: boolean;
  102902. /** Defines if half float texture linear filtering is supported*/
  102903. textureHalfFloatLinearFiltering: boolean;
  102904. /** Defines if rendering to half float textures is supported */
  102905. textureHalfFloatRender: boolean;
  102906. /** Defines if textureLOD shader command is supported */
  102907. textureLOD: boolean;
  102908. /** Defines if draw buffers extension is supported */
  102909. drawBuffersExtension: boolean;
  102910. /** Defines if depth textures are supported */
  102911. depthTextureExtension: boolean;
  102912. /** Defines if float color buffer are supported */
  102913. colorBufferFloat: boolean;
  102914. /** Gets disjoint timer query extension (null if not supported) */
  102915. timerQuery?: EXT_disjoint_timer_query;
  102916. /** Defines if timestamp can be used with timer query */
  102917. canUseTimestampForTimerQuery: boolean;
  102918. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  102919. multiview?: any;
  102920. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  102921. oculusMultiview?: any;
  102922. /** Function used to let the system compiles shaders in background */
  102923. parallelShaderCompile?: {
  102924. COMPLETION_STATUS_KHR: number;
  102925. };
  102926. /** Max number of texture samples for MSAA */
  102927. maxMSAASamples: number;
  102928. /** Defines if the blend min max extension is supported */
  102929. blendMinMax: boolean;
  102930. }
  102931. }
  102932. declare module BABYLON {
  102933. /**
  102934. * @hidden
  102935. **/
  102936. export class DepthCullingState {
  102937. private _isDepthTestDirty;
  102938. private _isDepthMaskDirty;
  102939. private _isDepthFuncDirty;
  102940. private _isCullFaceDirty;
  102941. private _isCullDirty;
  102942. private _isZOffsetDirty;
  102943. private _isFrontFaceDirty;
  102944. private _depthTest;
  102945. private _depthMask;
  102946. private _depthFunc;
  102947. private _cull;
  102948. private _cullFace;
  102949. private _zOffset;
  102950. private _frontFace;
  102951. /**
  102952. * Initializes the state.
  102953. */
  102954. constructor();
  102955. get isDirty(): boolean;
  102956. get zOffset(): number;
  102957. set zOffset(value: number);
  102958. get cullFace(): Nullable<number>;
  102959. set cullFace(value: Nullable<number>);
  102960. get cull(): Nullable<boolean>;
  102961. set cull(value: Nullable<boolean>);
  102962. get depthFunc(): Nullable<number>;
  102963. set depthFunc(value: Nullable<number>);
  102964. get depthMask(): boolean;
  102965. set depthMask(value: boolean);
  102966. get depthTest(): boolean;
  102967. set depthTest(value: boolean);
  102968. get frontFace(): Nullable<number>;
  102969. set frontFace(value: Nullable<number>);
  102970. reset(): void;
  102971. apply(gl: WebGLRenderingContext): void;
  102972. }
  102973. }
  102974. declare module BABYLON {
  102975. /**
  102976. * @hidden
  102977. **/
  102978. export class StencilState {
  102979. /** 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 */
  102980. static readonly ALWAYS: number;
  102981. /** Passed to stencilOperation to specify that stencil value must be kept */
  102982. static readonly KEEP: number;
  102983. /** Passed to stencilOperation to specify that stencil value must be replaced */
  102984. static readonly REPLACE: number;
  102985. private _isStencilTestDirty;
  102986. private _isStencilMaskDirty;
  102987. private _isStencilFuncDirty;
  102988. private _isStencilOpDirty;
  102989. private _stencilTest;
  102990. private _stencilMask;
  102991. private _stencilFunc;
  102992. private _stencilFuncRef;
  102993. private _stencilFuncMask;
  102994. private _stencilOpStencilFail;
  102995. private _stencilOpDepthFail;
  102996. private _stencilOpStencilDepthPass;
  102997. get isDirty(): boolean;
  102998. get stencilFunc(): number;
  102999. set stencilFunc(value: number);
  103000. get stencilFuncRef(): number;
  103001. set stencilFuncRef(value: number);
  103002. get stencilFuncMask(): number;
  103003. set stencilFuncMask(value: number);
  103004. get stencilOpStencilFail(): number;
  103005. set stencilOpStencilFail(value: number);
  103006. get stencilOpDepthFail(): number;
  103007. set stencilOpDepthFail(value: number);
  103008. get stencilOpStencilDepthPass(): number;
  103009. set stencilOpStencilDepthPass(value: number);
  103010. get stencilMask(): number;
  103011. set stencilMask(value: number);
  103012. get stencilTest(): boolean;
  103013. set stencilTest(value: boolean);
  103014. constructor();
  103015. reset(): void;
  103016. apply(gl: WebGLRenderingContext): void;
  103017. }
  103018. }
  103019. declare module BABYLON {
  103020. /**
  103021. * @hidden
  103022. **/
  103023. export class AlphaState {
  103024. private _isAlphaBlendDirty;
  103025. private _isBlendFunctionParametersDirty;
  103026. private _isBlendEquationParametersDirty;
  103027. private _isBlendConstantsDirty;
  103028. private _alphaBlend;
  103029. private _blendFunctionParameters;
  103030. private _blendEquationParameters;
  103031. private _blendConstants;
  103032. /**
  103033. * Initializes the state.
  103034. */
  103035. constructor();
  103036. get isDirty(): boolean;
  103037. get alphaBlend(): boolean;
  103038. set alphaBlend(value: boolean);
  103039. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103040. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103041. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103042. reset(): void;
  103043. apply(gl: WebGLRenderingContext): void;
  103044. }
  103045. }
  103046. declare module BABYLON {
  103047. /** @hidden */
  103048. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103049. attributeProcessor(attribute: string): string;
  103050. varyingProcessor(varying: string, isFragment: boolean): string;
  103051. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103052. }
  103053. }
  103054. declare module BABYLON {
  103055. /**
  103056. * Interface for attribute information associated with buffer instanciation
  103057. */
  103058. export interface InstancingAttributeInfo {
  103059. /**
  103060. * Name of the GLSL attribute
  103061. * if attribute index is not specified, this is used to retrieve the index from the effect
  103062. */
  103063. attributeName: string;
  103064. /**
  103065. * Index/offset of the attribute in the vertex shader
  103066. * if not specified, this will be computes from the name.
  103067. */
  103068. index?: number;
  103069. /**
  103070. * size of the attribute, 1, 2, 3 or 4
  103071. */
  103072. attributeSize: number;
  103073. /**
  103074. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103075. */
  103076. offset: number;
  103077. /**
  103078. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103079. * default to 1
  103080. */
  103081. divisor?: number;
  103082. /**
  103083. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103084. * default is FLOAT
  103085. */
  103086. attributeType?: number;
  103087. /**
  103088. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103089. */
  103090. normalized?: boolean;
  103091. }
  103092. }
  103093. declare module BABYLON {
  103094. interface ThinEngine {
  103095. /**
  103096. * Update a video texture
  103097. * @param texture defines the texture to update
  103098. * @param video defines the video element to use
  103099. * @param invertY defines if data must be stored with Y axis inverted
  103100. */
  103101. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103102. }
  103103. }
  103104. declare module BABYLON {
  103105. /**
  103106. * Settings for finer control over video usage
  103107. */
  103108. export interface VideoTextureSettings {
  103109. /**
  103110. * Applies `autoplay` to video, if specified
  103111. */
  103112. autoPlay?: boolean;
  103113. /**
  103114. * Applies `loop` to video, if specified
  103115. */
  103116. loop?: boolean;
  103117. /**
  103118. * Automatically updates internal texture from video at every frame in the render loop
  103119. */
  103120. autoUpdateTexture: boolean;
  103121. /**
  103122. * Image src displayed during the video loading or until the user interacts with the video.
  103123. */
  103124. poster?: string;
  103125. }
  103126. /**
  103127. * If you want to display a video in your scene, this is the special texture for that.
  103128. * This special texture works similar to other textures, with the exception of a few parameters.
  103129. * @see https://doc.babylonjs.com/how_to/video_texture
  103130. */
  103131. export class VideoTexture extends Texture {
  103132. /**
  103133. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103134. */
  103135. readonly autoUpdateTexture: boolean;
  103136. /**
  103137. * The video instance used by the texture internally
  103138. */
  103139. readonly video: HTMLVideoElement;
  103140. private _onUserActionRequestedObservable;
  103141. /**
  103142. * Event triggerd when a dom action is required by the user to play the video.
  103143. * This happens due to recent changes in browser policies preventing video to auto start.
  103144. */
  103145. get onUserActionRequestedObservable(): Observable<Texture>;
  103146. private _generateMipMaps;
  103147. private _engine;
  103148. private _stillImageCaptured;
  103149. private _displayingPosterTexture;
  103150. private _settings;
  103151. private _createInternalTextureOnEvent;
  103152. private _frameId;
  103153. private _currentSrc;
  103154. /**
  103155. * Creates a video texture.
  103156. * If you want to display a video in your scene, this is the special texture for that.
  103157. * This special texture works similar to other textures, with the exception of a few parameters.
  103158. * @see https://doc.babylonjs.com/how_to/video_texture
  103159. * @param name optional name, will detect from video source, if not defined
  103160. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103161. * @param scene is obviously the current scene.
  103162. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103163. * @param invertY is false by default but can be used to invert video on Y axis
  103164. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103165. * @param settings allows finer control over video usage
  103166. */
  103167. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  103168. private _getName;
  103169. private _getVideo;
  103170. private _createInternalTexture;
  103171. private reset;
  103172. /**
  103173. * @hidden Internal method to initiate `update`.
  103174. */
  103175. _rebuild(): void;
  103176. /**
  103177. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  103178. */
  103179. update(): void;
  103180. /**
  103181. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  103182. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  103183. */
  103184. updateTexture(isVisible: boolean): void;
  103185. protected _updateInternalTexture: () => void;
  103186. /**
  103187. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  103188. * @param url New url.
  103189. */
  103190. updateURL(url: string): void;
  103191. /**
  103192. * Clones the texture.
  103193. * @returns the cloned texture
  103194. */
  103195. clone(): VideoTexture;
  103196. /**
  103197. * Dispose the texture and release its associated resources.
  103198. */
  103199. dispose(): void;
  103200. /**
  103201. * Creates a video texture straight from a stream.
  103202. * @param scene Define the scene the texture should be created in
  103203. * @param stream Define the stream the texture should be created from
  103204. * @returns The created video texture as a promise
  103205. */
  103206. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  103207. /**
  103208. * Creates a video texture straight from your WebCam video feed.
  103209. * @param scene Define the scene the texture should be created in
  103210. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103211. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103212. * @returns The created video texture as a promise
  103213. */
  103214. static CreateFromWebCamAsync(scene: Scene, constraints: {
  103215. minWidth: number;
  103216. maxWidth: number;
  103217. minHeight: number;
  103218. maxHeight: number;
  103219. deviceId: string;
  103220. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  103221. /**
  103222. * Creates a video texture straight from your WebCam video feed.
  103223. * @param scene Define the scene the texture should be created in
  103224. * @param onReady Define a callback to triggered once the texture will be ready
  103225. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103226. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103227. */
  103228. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  103229. minWidth: number;
  103230. maxWidth: number;
  103231. minHeight: number;
  103232. maxHeight: number;
  103233. deviceId: string;
  103234. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  103235. }
  103236. }
  103237. declare module BABYLON {
  103238. /**
  103239. * Defines the interface used by objects working like Scene
  103240. * @hidden
  103241. */
  103242. interface ISceneLike {
  103243. _addPendingData(data: any): void;
  103244. _removePendingData(data: any): void;
  103245. offlineProvider: IOfflineProvider;
  103246. }
  103247. /** Interface defining initialization parameters for Engine class */
  103248. export interface EngineOptions extends WebGLContextAttributes {
  103249. /**
  103250. * Defines if the engine should no exceed a specified device ratio
  103251. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  103252. */
  103253. limitDeviceRatio?: number;
  103254. /**
  103255. * Defines if webvr should be enabled automatically
  103256. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103257. */
  103258. autoEnableWebVR?: boolean;
  103259. /**
  103260. * Defines if webgl2 should be turned off even if supported
  103261. * @see http://doc.babylonjs.com/features/webgl2
  103262. */
  103263. disableWebGL2Support?: boolean;
  103264. /**
  103265. * Defines if webaudio should be initialized as well
  103266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103267. */
  103268. audioEngine?: boolean;
  103269. /**
  103270. * Defines if animations should run using a deterministic lock step
  103271. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103272. */
  103273. deterministicLockstep?: boolean;
  103274. /** Defines the maximum steps to use with deterministic lock step mode */
  103275. lockstepMaxSteps?: number;
  103276. /** Defines the seconds between each deterministic lock step */
  103277. timeStep?: number;
  103278. /**
  103279. * Defines that engine should ignore context lost events
  103280. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  103281. */
  103282. doNotHandleContextLost?: boolean;
  103283. /**
  103284. * Defines that engine should ignore modifying touch action attribute and style
  103285. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  103286. */
  103287. doNotHandleTouchAction?: boolean;
  103288. /**
  103289. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  103290. */
  103291. useHighPrecisionFloats?: boolean;
  103292. }
  103293. /**
  103294. * The base engine class (root of all engines)
  103295. */
  103296. export class ThinEngine {
  103297. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  103298. static ExceptionList: ({
  103299. key: string;
  103300. capture: string;
  103301. captureConstraint: number;
  103302. targets: string[];
  103303. } | {
  103304. key: string;
  103305. capture: null;
  103306. captureConstraint: null;
  103307. targets: string[];
  103308. })[];
  103309. /** @hidden */
  103310. static _TextureLoaders: IInternalTextureLoader[];
  103311. /**
  103312. * Returns the current npm package of the sdk
  103313. */
  103314. static get NpmPackage(): string;
  103315. /**
  103316. * Returns the current version of the framework
  103317. */
  103318. static get Version(): string;
  103319. /**
  103320. * Returns a string describing the current engine
  103321. */
  103322. get description(): string;
  103323. /**
  103324. * Gets or sets the epsilon value used by collision engine
  103325. */
  103326. static CollisionsEpsilon: number;
  103327. /**
  103328. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103329. */
  103330. static get ShadersRepository(): string;
  103331. static set ShadersRepository(value: string);
  103332. /**
  103333. * Gets or sets the textures that the engine should not attempt to load as compressed
  103334. */
  103335. protected _excludedCompressedTextures: string[];
  103336. /**
  103337. * Filters the compressed texture formats to only include
  103338. * files that are not included in the skippable list
  103339. *
  103340. * @param url the current extension
  103341. * @param textureFormatInUse the current compressed texture format
  103342. * @returns "format" string
  103343. */
  103344. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  103345. /** @hidden */
  103346. _shaderProcessor: IShaderProcessor;
  103347. /**
  103348. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  103349. */
  103350. forcePOTTextures: boolean;
  103351. /**
  103352. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  103353. */
  103354. isFullscreen: boolean;
  103355. /**
  103356. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  103357. */
  103358. cullBackFaces: boolean;
  103359. /**
  103360. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  103361. */
  103362. renderEvenInBackground: boolean;
  103363. /**
  103364. * Gets or sets a boolean indicating that cache can be kept between frames
  103365. */
  103366. preventCacheWipeBetweenFrames: boolean;
  103367. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  103368. validateShaderPrograms: boolean;
  103369. /**
  103370. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  103371. * This can provide greater z depth for distant objects.
  103372. */
  103373. useReverseDepthBuffer: boolean;
  103374. /**
  103375. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  103376. */
  103377. disableUniformBuffers: boolean;
  103378. /** @hidden */
  103379. _uniformBuffers: UniformBuffer[];
  103380. /**
  103381. * Gets a boolean indicating that the engine supports uniform buffers
  103382. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  103383. */
  103384. get supportsUniformBuffers(): boolean;
  103385. /** @hidden */
  103386. _gl: WebGLRenderingContext;
  103387. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  103388. protected _windowIsBackground: boolean;
  103389. protected _webGLVersion: number;
  103390. protected _creationOptions: EngineOptions;
  103391. protected _highPrecisionShadersAllowed: boolean;
  103392. /** @hidden */
  103393. get _shouldUseHighPrecisionShader(): boolean;
  103394. /**
  103395. * Gets a boolean indicating that only power of 2 textures are supported
  103396. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  103397. */
  103398. get needPOTTextures(): boolean;
  103399. /** @hidden */
  103400. _badOS: boolean;
  103401. /** @hidden */
  103402. _badDesktopOS: boolean;
  103403. private _hardwareScalingLevel;
  103404. /** @hidden */
  103405. _caps: EngineCapabilities;
  103406. private _isStencilEnable;
  103407. private _glVersion;
  103408. private _glRenderer;
  103409. private _glVendor;
  103410. /** @hidden */
  103411. _videoTextureSupported: boolean;
  103412. protected _renderingQueueLaunched: boolean;
  103413. protected _activeRenderLoops: (() => void)[];
  103414. /**
  103415. * Observable signaled when a context lost event is raised
  103416. */
  103417. onContextLostObservable: Observable<ThinEngine>;
  103418. /**
  103419. * Observable signaled when a context restored event is raised
  103420. */
  103421. onContextRestoredObservable: Observable<ThinEngine>;
  103422. private _onContextLost;
  103423. private _onContextRestored;
  103424. protected _contextWasLost: boolean;
  103425. /** @hidden */
  103426. _doNotHandleContextLost: boolean;
  103427. /**
  103428. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  103429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  103430. */
  103431. get doNotHandleContextLost(): boolean;
  103432. set doNotHandleContextLost(value: boolean);
  103433. /**
  103434. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  103435. */
  103436. disableVertexArrayObjects: boolean;
  103437. /** @hidden */
  103438. protected _colorWrite: boolean;
  103439. /** @hidden */
  103440. protected _colorWriteChanged: boolean;
  103441. /** @hidden */
  103442. protected _depthCullingState: DepthCullingState;
  103443. /** @hidden */
  103444. protected _stencilState: StencilState;
  103445. /** @hidden */
  103446. _alphaState: AlphaState;
  103447. /** @hidden */
  103448. _alphaMode: number;
  103449. /** @hidden */
  103450. _alphaEquation: number;
  103451. /** @hidden */
  103452. _internalTexturesCache: InternalTexture[];
  103453. /** @hidden */
  103454. protected _activeChannel: number;
  103455. private _currentTextureChannel;
  103456. /** @hidden */
  103457. protected _boundTexturesCache: {
  103458. [key: string]: Nullable<InternalTexture>;
  103459. };
  103460. /** @hidden */
  103461. protected _currentEffect: Nullable<Effect>;
  103462. /** @hidden */
  103463. protected _currentProgram: Nullable<WebGLProgram>;
  103464. private _compiledEffects;
  103465. private _vertexAttribArraysEnabled;
  103466. /** @hidden */
  103467. protected _cachedViewport: Nullable<IViewportLike>;
  103468. private _cachedVertexArrayObject;
  103469. /** @hidden */
  103470. protected _cachedVertexBuffers: any;
  103471. /** @hidden */
  103472. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  103473. /** @hidden */
  103474. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  103475. /** @hidden */
  103476. _currentRenderTarget: Nullable<InternalTexture>;
  103477. private _uintIndicesCurrentlySet;
  103478. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  103479. /** @hidden */
  103480. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  103481. private _currentBufferPointers;
  103482. private _currentInstanceLocations;
  103483. private _currentInstanceBuffers;
  103484. private _textureUnits;
  103485. /** @hidden */
  103486. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103487. /** @hidden */
  103488. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103489. /** @hidden */
  103490. _boundRenderFunction: any;
  103491. private _vaoRecordInProgress;
  103492. private _mustWipeVertexAttributes;
  103493. private _emptyTexture;
  103494. private _emptyCubeTexture;
  103495. private _emptyTexture3D;
  103496. private _emptyTexture2DArray;
  103497. /** @hidden */
  103498. _frameHandler: number;
  103499. private _nextFreeTextureSlots;
  103500. private _maxSimultaneousTextures;
  103501. private _activeRequests;
  103502. protected _texturesSupported: string[];
  103503. /** @hidden */
  103504. _textureFormatInUse: Nullable<string>;
  103505. protected get _supportsHardwareTextureRescaling(): boolean;
  103506. /**
  103507. * Gets the list of texture formats supported
  103508. */
  103509. get texturesSupported(): Array<string>;
  103510. /**
  103511. * Gets the list of texture formats in use
  103512. */
  103513. get textureFormatInUse(): Nullable<string>;
  103514. /**
  103515. * Gets the current viewport
  103516. */
  103517. get currentViewport(): Nullable<IViewportLike>;
  103518. /**
  103519. * Gets the default empty texture
  103520. */
  103521. get emptyTexture(): InternalTexture;
  103522. /**
  103523. * Gets the default empty 3D texture
  103524. */
  103525. get emptyTexture3D(): InternalTexture;
  103526. /**
  103527. * Gets the default empty 2D array texture
  103528. */
  103529. get emptyTexture2DArray(): InternalTexture;
  103530. /**
  103531. * Gets the default empty cube texture
  103532. */
  103533. get emptyCubeTexture(): InternalTexture;
  103534. /**
  103535. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  103536. */
  103537. readonly premultipliedAlpha: boolean;
  103538. /**
  103539. * Observable event triggered before each texture is initialized
  103540. */
  103541. onBeforeTextureInitObservable: Observable<Texture>;
  103542. /**
  103543. * Creates a new engine
  103544. * @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
  103545. * @param antialias defines enable antialiasing (default: false)
  103546. * @param options defines further options to be sent to the getContext() function
  103547. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103548. */
  103549. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103550. private _rebuildInternalTextures;
  103551. private _rebuildEffects;
  103552. /**
  103553. * Gets a boolean indicating if all created effects are ready
  103554. * @returns true if all effects are ready
  103555. */
  103556. areAllEffectsReady(): boolean;
  103557. protected _rebuildBuffers(): void;
  103558. private _initGLContext;
  103559. /**
  103560. * Gets version of the current webGL context
  103561. */
  103562. get webGLVersion(): number;
  103563. /**
  103564. * Gets a string idenfifying the name of the class
  103565. * @returns "Engine" string
  103566. */
  103567. getClassName(): string;
  103568. /**
  103569. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  103570. */
  103571. get isStencilEnable(): boolean;
  103572. /** @hidden */
  103573. _prepareWorkingCanvas(): void;
  103574. /**
  103575. * Reset the texture cache to empty state
  103576. */
  103577. resetTextureCache(): void;
  103578. /**
  103579. * Gets an object containing information about the current webGL context
  103580. * @returns an object containing the vender, the renderer and the version of the current webGL context
  103581. */
  103582. getGlInfo(): {
  103583. vendor: string;
  103584. renderer: string;
  103585. version: string;
  103586. };
  103587. /**
  103588. * Defines the hardware scaling level.
  103589. * By default the hardware scaling level is computed from the window device ratio.
  103590. * 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.
  103591. * @param level defines the level to use
  103592. */
  103593. setHardwareScalingLevel(level: number): void;
  103594. /**
  103595. * Gets the current hardware scaling level.
  103596. * By default the hardware scaling level is computed from the window device ratio.
  103597. * 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.
  103598. * @returns a number indicating the current hardware scaling level
  103599. */
  103600. getHardwareScalingLevel(): number;
  103601. /**
  103602. * Gets the list of loaded textures
  103603. * @returns an array containing all loaded textures
  103604. */
  103605. getLoadedTexturesCache(): InternalTexture[];
  103606. /**
  103607. * Gets the object containing all engine capabilities
  103608. * @returns the EngineCapabilities object
  103609. */
  103610. getCaps(): EngineCapabilities;
  103611. /**
  103612. * stop executing a render loop function and remove it from the execution array
  103613. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  103614. */
  103615. stopRenderLoop(renderFunction?: () => void): void;
  103616. /** @hidden */
  103617. _renderLoop(): void;
  103618. /**
  103619. * Gets the HTML canvas attached with the current webGL context
  103620. * @returns a HTML canvas
  103621. */
  103622. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  103623. /**
  103624. * Gets host window
  103625. * @returns the host window object
  103626. */
  103627. getHostWindow(): Nullable<Window>;
  103628. /**
  103629. * Gets the current render width
  103630. * @param useScreen defines if screen size must be used (or the current render target if any)
  103631. * @returns a number defining the current render width
  103632. */
  103633. getRenderWidth(useScreen?: boolean): number;
  103634. /**
  103635. * Gets the current render height
  103636. * @param useScreen defines if screen size must be used (or the current render target if any)
  103637. * @returns a number defining the current render height
  103638. */
  103639. getRenderHeight(useScreen?: boolean): number;
  103640. /**
  103641. * Can be used to override the current requestAnimationFrame requester.
  103642. * @hidden
  103643. */
  103644. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  103645. /**
  103646. * Register and execute a render loop. The engine can have more than one render function
  103647. * @param renderFunction defines the function to continuously execute
  103648. */
  103649. runRenderLoop(renderFunction: () => void): void;
  103650. /**
  103651. * Clear the current render buffer or the current render target (if any is set up)
  103652. * @param color defines the color to use
  103653. * @param backBuffer defines if the back buffer must be cleared
  103654. * @param depth defines if the depth buffer must be cleared
  103655. * @param stencil defines if the stencil buffer must be cleared
  103656. */
  103657. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  103658. private _viewportCached;
  103659. /** @hidden */
  103660. _viewport(x: number, y: number, width: number, height: number): void;
  103661. /**
  103662. * Set the WebGL's viewport
  103663. * @param viewport defines the viewport element to be used
  103664. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  103665. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  103666. */
  103667. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  103668. /**
  103669. * Begin a new frame
  103670. */
  103671. beginFrame(): void;
  103672. /**
  103673. * Enf the current frame
  103674. */
  103675. endFrame(): void;
  103676. /**
  103677. * Resize the view according to the canvas' size
  103678. */
  103679. resize(): void;
  103680. /**
  103681. * Force a specific size of the canvas
  103682. * @param width defines the new canvas' width
  103683. * @param height defines the new canvas' height
  103684. */
  103685. setSize(width: number, height: number): void;
  103686. /**
  103687. * Binds the frame buffer to the specified texture.
  103688. * @param texture The texture to render to or null for the default canvas
  103689. * @param faceIndex The face of the texture to render to in case of cube texture
  103690. * @param requiredWidth The width of the target to render to
  103691. * @param requiredHeight The height of the target to render to
  103692. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  103693. * @param lodLevel defines the lod level to bind to the frame buffer
  103694. * @param layer defines the 2d array index to bind to frame buffer to
  103695. */
  103696. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  103697. /** @hidden */
  103698. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  103699. /**
  103700. * Unbind the current render target texture from the webGL context
  103701. * @param texture defines the render target texture to unbind
  103702. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103703. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103704. */
  103705. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  103706. /**
  103707. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  103708. */
  103709. flushFramebuffer(): void;
  103710. /**
  103711. * Unbind the current render target and bind the default framebuffer
  103712. */
  103713. restoreDefaultFramebuffer(): void;
  103714. /** @hidden */
  103715. protected _resetVertexBufferBinding(): void;
  103716. /**
  103717. * Creates a vertex buffer
  103718. * @param data the data for the vertex buffer
  103719. * @returns the new WebGL static buffer
  103720. */
  103721. createVertexBuffer(data: DataArray): DataBuffer;
  103722. private _createVertexBuffer;
  103723. /**
  103724. * Creates a dynamic vertex buffer
  103725. * @param data the data for the dynamic vertex buffer
  103726. * @returns the new WebGL dynamic buffer
  103727. */
  103728. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  103729. protected _resetIndexBufferBinding(): void;
  103730. /**
  103731. * Creates a new index buffer
  103732. * @param indices defines the content of the index buffer
  103733. * @param updatable defines if the index buffer must be updatable
  103734. * @returns a new webGL buffer
  103735. */
  103736. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  103737. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  103738. /**
  103739. * Bind a webGL buffer to the webGL context
  103740. * @param buffer defines the buffer to bind
  103741. */
  103742. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  103743. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  103744. private bindBuffer;
  103745. /**
  103746. * update the bound buffer with the given data
  103747. * @param data defines the data to update
  103748. */
  103749. updateArrayBuffer(data: Float32Array): void;
  103750. private _vertexAttribPointer;
  103751. /** @hidden */
  103752. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  103753. private _bindVertexBuffersAttributes;
  103754. /**
  103755. * Records a vertex array object
  103756. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103757. * @param vertexBuffers defines the list of vertex buffers to store
  103758. * @param indexBuffer defines the index buffer to store
  103759. * @param effect defines the effect to store
  103760. * @returns the new vertex array object
  103761. */
  103762. recordVertexArrayObject(vertexBuffers: {
  103763. [key: string]: VertexBuffer;
  103764. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  103765. /**
  103766. * Bind a specific vertex array object
  103767. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103768. * @param vertexArrayObject defines the vertex array object to bind
  103769. * @param indexBuffer defines the index buffer to bind
  103770. */
  103771. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  103772. /**
  103773. * Bind webGl buffers directly to the webGL context
  103774. * @param vertexBuffer defines the vertex buffer to bind
  103775. * @param indexBuffer defines the index buffer to bind
  103776. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  103777. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  103778. * @param effect defines the effect associated with the vertex buffer
  103779. */
  103780. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  103781. private _unbindVertexArrayObject;
  103782. /**
  103783. * Bind a list of vertex buffers to the webGL context
  103784. * @param vertexBuffers defines the list of vertex buffers to bind
  103785. * @param indexBuffer defines the index buffer to bind
  103786. * @param effect defines the effect associated with the vertex buffers
  103787. */
  103788. bindBuffers(vertexBuffers: {
  103789. [key: string]: Nullable<VertexBuffer>;
  103790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  103791. /**
  103792. * Unbind all instance attributes
  103793. */
  103794. unbindInstanceAttributes(): void;
  103795. /**
  103796. * Release and free the memory of a vertex array object
  103797. * @param vao defines the vertex array object to delete
  103798. */
  103799. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  103800. /** @hidden */
  103801. _releaseBuffer(buffer: DataBuffer): boolean;
  103802. protected _deleteBuffer(buffer: DataBuffer): void;
  103803. /**
  103804. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  103805. * @param instancesBuffer defines the webGL buffer to update and bind
  103806. * @param data defines the data to store in the buffer
  103807. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  103808. */
  103809. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  103810. /**
  103811. * Bind the content of a webGL buffer used with instanciation
  103812. * @param instancesBuffer defines the webGL buffer to bind
  103813. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  103814. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  103815. */
  103816. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  103817. /**
  103818. * Disable the instance attribute corresponding to the name in parameter
  103819. * @param name defines the name of the attribute to disable
  103820. */
  103821. disableInstanceAttributeByName(name: string): void;
  103822. /**
  103823. * Disable the instance attribute corresponding to the location in parameter
  103824. * @param attributeLocation defines the attribute location of the attribute to disable
  103825. */
  103826. disableInstanceAttribute(attributeLocation: number): void;
  103827. /**
  103828. * Disable the attribute corresponding to the location in parameter
  103829. * @param attributeLocation defines the attribute location of the attribute to disable
  103830. */
  103831. disableAttributeByIndex(attributeLocation: number): void;
  103832. /**
  103833. * Send a draw order
  103834. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103835. * @param indexStart defines the starting index
  103836. * @param indexCount defines the number of index to draw
  103837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103838. */
  103839. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  103840. /**
  103841. * Draw a list of points
  103842. * @param verticesStart defines the index of first vertex to draw
  103843. * @param verticesCount defines the count of vertices to draw
  103844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103845. */
  103846. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103847. /**
  103848. * Draw a list of unindexed primitives
  103849. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103850. * @param verticesStart defines the index of first vertex to draw
  103851. * @param verticesCount defines the count of vertices to draw
  103852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103853. */
  103854. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103855. /**
  103856. * Draw a list of indexed primitives
  103857. * @param fillMode defines the primitive to use
  103858. * @param indexStart defines the starting index
  103859. * @param indexCount defines the number of index to draw
  103860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103861. */
  103862. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  103863. /**
  103864. * Draw a list of unindexed primitives
  103865. * @param fillMode defines the primitive to use
  103866. * @param verticesStart defines the index of first vertex to draw
  103867. * @param verticesCount defines the count of vertices to draw
  103868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103869. */
  103870. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103871. private _drawMode;
  103872. /** @hidden */
  103873. protected _reportDrawCall(): void;
  103874. /** @hidden */
  103875. _releaseEffect(effect: Effect): void;
  103876. /** @hidden */
  103877. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  103878. /**
  103879. * Create a new effect (used to store vertex/fragment shaders)
  103880. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  103881. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  103882. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  103883. * @param samplers defines an array of string used to represent textures
  103884. * @param defines defines the string containing the defines to use to compile the shaders
  103885. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  103886. * @param onCompiled defines a function to call when the effect creation is successful
  103887. * @param onError defines a function to call when the effect creation has failed
  103888. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  103889. * @returns the new Effect
  103890. */
  103891. 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;
  103892. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  103893. private _compileShader;
  103894. private _compileRawShader;
  103895. /**
  103896. * Directly creates a webGL program
  103897. * @param pipelineContext defines the pipeline context to attach to
  103898. * @param vertexCode defines the vertex shader code to use
  103899. * @param fragmentCode defines the fragment shader code to use
  103900. * @param context defines the webGL context to use (if not set, the current one will be used)
  103901. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  103902. * @returns the new webGL program
  103903. */
  103904. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103905. /**
  103906. * Creates a webGL program
  103907. * @param pipelineContext defines the pipeline context to attach to
  103908. * @param vertexCode defines the vertex shader code to use
  103909. * @param fragmentCode defines the fragment shader code to use
  103910. * @param defines defines the string containing the defines to use to compile the shaders
  103911. * @param context defines the webGL context to use (if not set, the current one will be used)
  103912. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  103913. * @returns the new webGL program
  103914. */
  103915. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103916. /**
  103917. * Creates a new pipeline context
  103918. * @returns the new pipeline
  103919. */
  103920. createPipelineContext(): IPipelineContext;
  103921. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103922. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  103923. /** @hidden */
  103924. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  103925. /** @hidden */
  103926. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  103927. /** @hidden */
  103928. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  103929. /**
  103930. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  103931. * @param pipelineContext defines the pipeline context to use
  103932. * @param uniformsNames defines the list of uniform names
  103933. * @returns an array of webGL uniform locations
  103934. */
  103935. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  103936. /**
  103937. * Gets the lsit of active attributes for a given webGL program
  103938. * @param pipelineContext defines the pipeline context to use
  103939. * @param attributesNames defines the list of attribute names to get
  103940. * @returns an array of indices indicating the offset of each attribute
  103941. */
  103942. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  103943. /**
  103944. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  103945. * @param effect defines the effect to activate
  103946. */
  103947. enableEffect(effect: Nullable<Effect>): void;
  103948. /**
  103949. * Set the value of an uniform to a number (int)
  103950. * @param uniform defines the webGL uniform location where to store the value
  103951. * @param value defines the int number to store
  103952. */
  103953. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  103954. /**
  103955. * Set the value of an uniform to an array of int32
  103956. * @param uniform defines the webGL uniform location where to store the value
  103957. * @param array defines the array of int32 to store
  103958. */
  103959. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103960. /**
  103961. * Set the value of an uniform to an array of int32 (stored as vec2)
  103962. * @param uniform defines the webGL uniform location where to store the value
  103963. * @param array defines the array of int32 to store
  103964. */
  103965. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103966. /**
  103967. * Set the value of an uniform to an array of int32 (stored as vec3)
  103968. * @param uniform defines the webGL uniform location where to store the value
  103969. * @param array defines the array of int32 to store
  103970. */
  103971. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103972. /**
  103973. * Set the value of an uniform to an array of int32 (stored as vec4)
  103974. * @param uniform defines the webGL uniform location where to store the value
  103975. * @param array defines the array of int32 to store
  103976. */
  103977. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103978. /**
  103979. * Set the value of an uniform to an array of number
  103980. * @param uniform defines the webGL uniform location where to store the value
  103981. * @param array defines the array of number to store
  103982. */
  103983. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103984. /**
  103985. * Set the value of an uniform to an array of number (stored as vec2)
  103986. * @param uniform defines the webGL uniform location where to store the value
  103987. * @param array defines the array of number to store
  103988. */
  103989. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103990. /**
  103991. * Set the value of an uniform to an array of number (stored as vec3)
  103992. * @param uniform defines the webGL uniform location where to store the value
  103993. * @param array defines the array of number to store
  103994. */
  103995. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103996. /**
  103997. * Set the value of an uniform to an array of number (stored as vec4)
  103998. * @param uniform defines the webGL uniform location where to store the value
  103999. * @param array defines the array of number to store
  104000. */
  104001. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104002. /**
  104003. * Set the value of an uniform to an array of float32 (stored as matrices)
  104004. * @param uniform defines the webGL uniform location where to store the value
  104005. * @param matrices defines the array of float32 to store
  104006. */
  104007. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104008. /**
  104009. * Set the value of an uniform to a matrix (3x3)
  104010. * @param uniform defines the webGL uniform location where to store the value
  104011. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104012. */
  104013. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104014. /**
  104015. * Set the value of an uniform to a matrix (2x2)
  104016. * @param uniform defines the webGL uniform location where to store the value
  104017. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104018. */
  104019. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104020. /**
  104021. * Set the value of an uniform to a number (float)
  104022. * @param uniform defines the webGL uniform location where to store the value
  104023. * @param value defines the float number to store
  104024. */
  104025. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104026. /**
  104027. * Set the value of an uniform to a vec2
  104028. * @param uniform defines the webGL uniform location where to store the value
  104029. * @param x defines the 1st component of the value
  104030. * @param y defines the 2nd component of the value
  104031. */
  104032. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104033. /**
  104034. * Set the value of an uniform to a vec3
  104035. * @param uniform defines the webGL uniform location where to store the value
  104036. * @param x defines the 1st component of the value
  104037. * @param y defines the 2nd component of the value
  104038. * @param z defines the 3rd component of the value
  104039. */
  104040. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104041. /**
  104042. * Set the value of an uniform to a vec4
  104043. * @param uniform defines the webGL uniform location where to store the value
  104044. * @param x defines the 1st component of the value
  104045. * @param y defines the 2nd component of the value
  104046. * @param z defines the 3rd component of the value
  104047. * @param w defines the 4th component of the value
  104048. */
  104049. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104050. /**
  104051. * Apply all cached states (depth, culling, stencil and alpha)
  104052. */
  104053. applyStates(): void;
  104054. /**
  104055. * Enable or disable color writing
  104056. * @param enable defines the state to set
  104057. */
  104058. setColorWrite(enable: boolean): void;
  104059. /**
  104060. * Gets a boolean indicating if color writing is enabled
  104061. * @returns the current color writing state
  104062. */
  104063. getColorWrite(): boolean;
  104064. /**
  104065. * Gets the depth culling state manager
  104066. */
  104067. get depthCullingState(): DepthCullingState;
  104068. /**
  104069. * Gets the alpha state manager
  104070. */
  104071. get alphaState(): AlphaState;
  104072. /**
  104073. * Gets the stencil state manager
  104074. */
  104075. get stencilState(): StencilState;
  104076. /**
  104077. * Clears the list of texture accessible through engine.
  104078. * This can help preventing texture load conflict due to name collision.
  104079. */
  104080. clearInternalTexturesCache(): void;
  104081. /**
  104082. * Force the entire cache to be cleared
  104083. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104084. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104085. */
  104086. wipeCaches(bruteForce?: boolean): void;
  104087. /** @hidden */
  104088. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104089. min: number;
  104090. mag: number;
  104091. };
  104092. /** @hidden */
  104093. _createTexture(): WebGLTexture;
  104094. /**
  104095. * Usually called from Texture.ts.
  104096. * Passed information to create a WebGLTexture
  104097. * @param urlArg defines a value which contains one of the following:
  104098. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104099. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104100. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104101. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104102. * @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)
  104103. * @param scene needed for loading to the correct scene
  104104. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104105. * @param onLoad optional callback to be called upon successful completion
  104106. * @param onError optional callback to be called upon failure
  104107. * @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
  104108. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104109. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104110. * @param forcedExtension defines the extension to use to pick the right loader
  104111. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104112. * @param mimeType defines an optional mime type
  104113. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104114. */
  104115. 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;
  104116. /**
  104117. * Loads an image as an HTMLImageElement.
  104118. * @param input url string, ArrayBuffer, or Blob to load
  104119. * @param onLoad callback called when the image successfully loads
  104120. * @param onError callback called when the image fails to load
  104121. * @param offlineProvider offline provider for caching
  104122. * @param mimeType optional mime type
  104123. * @returns the HTMLImageElement of the loaded image
  104124. * @hidden
  104125. */
  104126. 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>;
  104127. /**
  104128. * @hidden
  104129. */
  104130. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104131. /**
  104132. * Creates a raw texture
  104133. * @param data defines the data to store in the texture
  104134. * @param width defines the width of the texture
  104135. * @param height defines the height of the texture
  104136. * @param format defines the format of the data
  104137. * @param generateMipMaps defines if the engine should generate the mip levels
  104138. * @param invertY defines if data must be stored with Y axis inverted
  104139. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104140. * @param compression defines the compression used (null by default)
  104141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104142. * @returns the raw texture inside an InternalTexture
  104143. */
  104144. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104145. /**
  104146. * Creates a new raw cube texture
  104147. * @param data defines the array of data to use to create each face
  104148. * @param size defines the size of the textures
  104149. * @param format defines the format of the data
  104150. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104151. * @param generateMipMaps defines if the engine should generate the mip levels
  104152. * @param invertY defines if data must be stored with Y axis inverted
  104153. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104154. * @param compression defines the compression used (null by default)
  104155. * @returns the cube texture as an InternalTexture
  104156. */
  104157. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104158. /**
  104159. * Creates a new raw 3D texture
  104160. * @param data defines the data used to create the texture
  104161. * @param width defines the width of the texture
  104162. * @param height defines the height of the texture
  104163. * @param depth defines the depth of the texture
  104164. * @param format defines the format of the texture
  104165. * @param generateMipMaps defines if the engine must generate mip levels
  104166. * @param invertY defines if data must be stored with Y axis inverted
  104167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104168. * @param compression defines the compressed used (can be null)
  104169. * @param textureType defines the compressed used (can be null)
  104170. * @returns a new raw 3D texture (stored in an InternalTexture)
  104171. */
  104172. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104173. /**
  104174. * Creates a new raw 2D array texture
  104175. * @param data defines the data used to create the texture
  104176. * @param width defines the width of the texture
  104177. * @param height defines the height of the texture
  104178. * @param depth defines the number of layers of the texture
  104179. * @param format defines the format of the texture
  104180. * @param generateMipMaps defines if the engine must generate mip levels
  104181. * @param invertY defines if data must be stored with Y axis inverted
  104182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104183. * @param compression defines the compressed used (can be null)
  104184. * @param textureType defines the compressed used (can be null)
  104185. * @returns a new raw 2D array texture (stored in an InternalTexture)
  104186. */
  104187. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104188. private _unpackFlipYCached;
  104189. /**
  104190. * In case you are sharing the context with other applications, it might
  104191. * be interested to not cache the unpack flip y state to ensure a consistent
  104192. * value would be set.
  104193. */
  104194. enableUnpackFlipYCached: boolean;
  104195. /** @hidden */
  104196. _unpackFlipY(value: boolean): void;
  104197. /** @hidden */
  104198. _getUnpackAlignement(): number;
  104199. private _getTextureTarget;
  104200. /**
  104201. * Update the sampling mode of a given texture
  104202. * @param samplingMode defines the required sampling mode
  104203. * @param texture defines the texture to update
  104204. * @param generateMipMaps defines whether to generate mipmaps for the texture
  104205. */
  104206. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  104207. /**
  104208. * Update the sampling mode of a given texture
  104209. * @param texture defines the texture to update
  104210. * @param wrapU defines the texture wrap mode of the u coordinates
  104211. * @param wrapV defines the texture wrap mode of the v coordinates
  104212. * @param wrapR defines the texture wrap mode of the r coordinates
  104213. */
  104214. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  104215. /** @hidden */
  104216. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  104217. width: number;
  104218. height: number;
  104219. layers?: number;
  104220. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  104221. /** @hidden */
  104222. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104223. /** @hidden */
  104224. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  104225. /**
  104226. * Update a portion of an internal texture
  104227. * @param texture defines the texture to update
  104228. * @param imageData defines the data to store into the texture
  104229. * @param xOffset defines the x coordinates of the update rectangle
  104230. * @param yOffset defines the y coordinates of the update rectangle
  104231. * @param width defines the width of the update rectangle
  104232. * @param height defines the height of the update rectangle
  104233. * @param faceIndex defines the face index if texture is a cube (0 by default)
  104234. * @param lod defines the lod level to update (0 by default)
  104235. */
  104236. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  104237. /** @hidden */
  104238. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104239. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  104240. private _prepareWebGLTexture;
  104241. /** @hidden */
  104242. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  104243. private _getDepthStencilBuffer;
  104244. /** @hidden */
  104245. _releaseFramebufferObjects(texture: InternalTexture): void;
  104246. /** @hidden */
  104247. _releaseTexture(texture: InternalTexture): void;
  104248. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  104249. protected _setProgram(program: WebGLProgram): void;
  104250. protected _boundUniforms: {
  104251. [key: number]: WebGLUniformLocation;
  104252. };
  104253. /**
  104254. * Binds an effect to the webGL context
  104255. * @param effect defines the effect to bind
  104256. */
  104257. bindSamplers(effect: Effect): void;
  104258. private _activateCurrentTexture;
  104259. /** @hidden */
  104260. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  104261. /** @hidden */
  104262. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  104263. /**
  104264. * Unbind all textures from the webGL context
  104265. */
  104266. unbindAllTextures(): void;
  104267. /**
  104268. * Sets a texture to the according uniform.
  104269. * @param channel The texture channel
  104270. * @param uniform The uniform to set
  104271. * @param texture The texture to apply
  104272. */
  104273. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  104274. private _bindSamplerUniformToChannel;
  104275. private _getTextureWrapMode;
  104276. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  104277. /**
  104278. * Sets an array of texture to the webGL context
  104279. * @param channel defines the channel where the texture array must be set
  104280. * @param uniform defines the associated uniform location
  104281. * @param textures defines the array of textures to bind
  104282. */
  104283. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  104284. /** @hidden */
  104285. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  104286. private _setTextureParameterFloat;
  104287. private _setTextureParameterInteger;
  104288. /**
  104289. * Unbind all vertex attributes from the webGL context
  104290. */
  104291. unbindAllAttributes(): void;
  104292. /**
  104293. * 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
  104294. */
  104295. releaseEffects(): void;
  104296. /**
  104297. * Dispose and release all associated resources
  104298. */
  104299. dispose(): void;
  104300. /**
  104301. * Attach a new callback raised when context lost event is fired
  104302. * @param callback defines the callback to call
  104303. */
  104304. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104305. /**
  104306. * Attach a new callback raised when context restored event is fired
  104307. * @param callback defines the callback to call
  104308. */
  104309. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104310. /**
  104311. * Get the current error code of the webGL context
  104312. * @returns the error code
  104313. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104314. */
  104315. getError(): number;
  104316. private _canRenderToFloatFramebuffer;
  104317. private _canRenderToHalfFloatFramebuffer;
  104318. private _canRenderToFramebuffer;
  104319. /** @hidden */
  104320. _getWebGLTextureType(type: number): number;
  104321. /** @hidden */
  104322. _getInternalFormat(format: number): number;
  104323. /** @hidden */
  104324. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  104325. /** @hidden */
  104326. _getRGBAMultiSampleBufferFormat(type: number): number;
  104327. /** @hidden */
  104328. _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;
  104329. /**
  104330. * Loads a file from a url
  104331. * @param url url to load
  104332. * @param onSuccess callback called when the file successfully loads
  104333. * @param onProgress callback called while file is loading (if the server supports this mode)
  104334. * @param offlineProvider defines the offline provider for caching
  104335. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104336. * @param onError callback called when the file fails to load
  104337. * @returns a file request object
  104338. * @hidden
  104339. */
  104340. 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;
  104341. /**
  104342. * Reads pixels from the current frame buffer. Please note that this function can be slow
  104343. * @param x defines the x coordinate of the rectangle where pixels must be read
  104344. * @param y defines the y coordinate of the rectangle where pixels must be read
  104345. * @param width defines the width of the rectangle where pixels must be read
  104346. * @param height defines the height of the rectangle where pixels must be read
  104347. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  104348. * @returns a Uint8Array containing RGBA colors
  104349. */
  104350. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  104351. private static _isSupported;
  104352. /**
  104353. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  104354. * @returns true if the engine can be created
  104355. * @ignorenaming
  104356. */
  104357. static isSupported(): boolean;
  104358. /**
  104359. * Find the next highest power of two.
  104360. * @param x Number to start search from.
  104361. * @return Next highest power of two.
  104362. */
  104363. static CeilingPOT(x: number): number;
  104364. /**
  104365. * Find the next lowest power of two.
  104366. * @param x Number to start search from.
  104367. * @return Next lowest power of two.
  104368. */
  104369. static FloorPOT(x: number): number;
  104370. /**
  104371. * Find the nearest power of two.
  104372. * @param x Number to start search from.
  104373. * @return Next nearest power of two.
  104374. */
  104375. static NearestPOT(x: number): number;
  104376. /**
  104377. * Get the closest exponent of two
  104378. * @param value defines the value to approximate
  104379. * @param max defines the maximum value to return
  104380. * @param mode defines how to define the closest value
  104381. * @returns closest exponent of two of the given value
  104382. */
  104383. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  104384. /**
  104385. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  104386. * @param func - the function to be called
  104387. * @param requester - the object that will request the next frame. Falls back to window.
  104388. * @returns frame number
  104389. */
  104390. static QueueNewFrame(func: () => void, requester?: any): number;
  104391. /**
  104392. * Gets host document
  104393. * @returns the host document object
  104394. */
  104395. getHostDocument(): Nullable<Document>;
  104396. }
  104397. }
  104398. declare module BABYLON {
  104399. /**
  104400. * Class representing spherical harmonics coefficients to the 3rd degree
  104401. */
  104402. export class SphericalHarmonics {
  104403. /**
  104404. * Defines whether or not the harmonics have been prescaled for rendering.
  104405. */
  104406. preScaled: boolean;
  104407. /**
  104408. * The l0,0 coefficients of the spherical harmonics
  104409. */
  104410. l00: Vector3;
  104411. /**
  104412. * The l1,-1 coefficients of the spherical harmonics
  104413. */
  104414. l1_1: Vector3;
  104415. /**
  104416. * The l1,0 coefficients of the spherical harmonics
  104417. */
  104418. l10: Vector3;
  104419. /**
  104420. * The l1,1 coefficients of the spherical harmonics
  104421. */
  104422. l11: Vector3;
  104423. /**
  104424. * The l2,-2 coefficients of the spherical harmonics
  104425. */
  104426. l2_2: Vector3;
  104427. /**
  104428. * The l2,-1 coefficients of the spherical harmonics
  104429. */
  104430. l2_1: Vector3;
  104431. /**
  104432. * The l2,0 coefficients of the spherical harmonics
  104433. */
  104434. l20: Vector3;
  104435. /**
  104436. * The l2,1 coefficients of the spherical harmonics
  104437. */
  104438. l21: Vector3;
  104439. /**
  104440. * The l2,2 coefficients of the spherical harmonics
  104441. */
  104442. l22: Vector3;
  104443. /**
  104444. * Adds a light to the spherical harmonics
  104445. * @param direction the direction of the light
  104446. * @param color the color of the light
  104447. * @param deltaSolidAngle the delta solid angle of the light
  104448. */
  104449. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  104450. /**
  104451. * Scales the spherical harmonics by the given amount
  104452. * @param scale the amount to scale
  104453. */
  104454. scaleInPlace(scale: number): void;
  104455. /**
  104456. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  104457. *
  104458. * ```
  104459. * E_lm = A_l * L_lm
  104460. * ```
  104461. *
  104462. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  104463. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  104464. * the scaling factors are given in equation 9.
  104465. */
  104466. convertIncidentRadianceToIrradiance(): void;
  104467. /**
  104468. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  104469. *
  104470. * ```
  104471. * L = (1/pi) * E * rho
  104472. * ```
  104473. *
  104474. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  104475. */
  104476. convertIrradianceToLambertianRadiance(): void;
  104477. /**
  104478. * Integrates the reconstruction coefficients directly in to the SH preventing further
  104479. * required operations at run time.
  104480. *
  104481. * This is simply done by scaling back the SH with Ylm constants parameter.
  104482. * The trigonometric part being applied by the shader at run time.
  104483. */
  104484. preScaleForRendering(): void;
  104485. /**
  104486. * Constructs a spherical harmonics from an array.
  104487. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104488. * @returns the spherical harmonics
  104489. */
  104490. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  104491. /**
  104492. * Gets the spherical harmonics from polynomial
  104493. * @param polynomial the spherical polynomial
  104494. * @returns the spherical harmonics
  104495. */
  104496. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  104497. }
  104498. /**
  104499. * Class representing spherical polynomial coefficients to the 3rd degree
  104500. */
  104501. export class SphericalPolynomial {
  104502. private _harmonics;
  104503. /**
  104504. * The spherical harmonics used to create the polynomials.
  104505. */
  104506. get preScaledHarmonics(): SphericalHarmonics;
  104507. /**
  104508. * The x coefficients of the spherical polynomial
  104509. */
  104510. x: Vector3;
  104511. /**
  104512. * The y coefficients of the spherical polynomial
  104513. */
  104514. y: Vector3;
  104515. /**
  104516. * The z coefficients of the spherical polynomial
  104517. */
  104518. z: Vector3;
  104519. /**
  104520. * The xx coefficients of the spherical polynomial
  104521. */
  104522. xx: Vector3;
  104523. /**
  104524. * The yy coefficients of the spherical polynomial
  104525. */
  104526. yy: Vector3;
  104527. /**
  104528. * The zz coefficients of the spherical polynomial
  104529. */
  104530. zz: Vector3;
  104531. /**
  104532. * The xy coefficients of the spherical polynomial
  104533. */
  104534. xy: Vector3;
  104535. /**
  104536. * The yz coefficients of the spherical polynomial
  104537. */
  104538. yz: Vector3;
  104539. /**
  104540. * The zx coefficients of the spherical polynomial
  104541. */
  104542. zx: Vector3;
  104543. /**
  104544. * Adds an ambient color to the spherical polynomial
  104545. * @param color the color to add
  104546. */
  104547. addAmbient(color: Color3): void;
  104548. /**
  104549. * Scales the spherical polynomial by the given amount
  104550. * @param scale the amount to scale
  104551. */
  104552. scaleInPlace(scale: number): void;
  104553. /**
  104554. * Gets the spherical polynomial from harmonics
  104555. * @param harmonics the spherical harmonics
  104556. * @returns the spherical polynomial
  104557. */
  104558. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  104559. /**
  104560. * Constructs a spherical polynomial from an array.
  104561. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  104562. * @returns the spherical polynomial
  104563. */
  104564. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  104565. }
  104566. }
  104567. declare module BABYLON {
  104568. /**
  104569. * Defines the source of the internal texture
  104570. */
  104571. export enum InternalTextureSource {
  104572. /**
  104573. * The source of the texture data is unknown
  104574. */
  104575. Unknown = 0,
  104576. /**
  104577. * Texture data comes from an URL
  104578. */
  104579. Url = 1,
  104580. /**
  104581. * Texture data is only used for temporary storage
  104582. */
  104583. Temp = 2,
  104584. /**
  104585. * Texture data comes from raw data (ArrayBuffer)
  104586. */
  104587. Raw = 3,
  104588. /**
  104589. * Texture content is dynamic (video or dynamic texture)
  104590. */
  104591. Dynamic = 4,
  104592. /**
  104593. * Texture content is generated by rendering to it
  104594. */
  104595. RenderTarget = 5,
  104596. /**
  104597. * Texture content is part of a multi render target process
  104598. */
  104599. MultiRenderTarget = 6,
  104600. /**
  104601. * Texture data comes from a cube data file
  104602. */
  104603. Cube = 7,
  104604. /**
  104605. * Texture data comes from a raw cube data
  104606. */
  104607. CubeRaw = 8,
  104608. /**
  104609. * Texture data come from a prefiltered cube data file
  104610. */
  104611. CubePrefiltered = 9,
  104612. /**
  104613. * Texture content is raw 3D data
  104614. */
  104615. Raw3D = 10,
  104616. /**
  104617. * Texture content is raw 2D array data
  104618. */
  104619. Raw2DArray = 11,
  104620. /**
  104621. * Texture content is a depth texture
  104622. */
  104623. Depth = 12,
  104624. /**
  104625. * Texture data comes from a raw cube data encoded with RGBD
  104626. */
  104627. CubeRawRGBD = 13
  104628. }
  104629. /**
  104630. * Class used to store data associated with WebGL texture data for the engine
  104631. * This class should not be used directly
  104632. */
  104633. export class InternalTexture {
  104634. /** @hidden */
  104635. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  104636. /**
  104637. * Defines if the texture is ready
  104638. */
  104639. isReady: boolean;
  104640. /**
  104641. * Defines if the texture is a cube texture
  104642. */
  104643. isCube: boolean;
  104644. /**
  104645. * Defines if the texture contains 3D data
  104646. */
  104647. is3D: boolean;
  104648. /**
  104649. * Defines if the texture contains 2D array data
  104650. */
  104651. is2DArray: boolean;
  104652. /**
  104653. * Defines if the texture contains multiview data
  104654. */
  104655. isMultiview: boolean;
  104656. /**
  104657. * Gets the URL used to load this texture
  104658. */
  104659. url: string;
  104660. /**
  104661. * Gets the sampling mode of the texture
  104662. */
  104663. samplingMode: number;
  104664. /**
  104665. * Gets a boolean indicating if the texture needs mipmaps generation
  104666. */
  104667. generateMipMaps: boolean;
  104668. /**
  104669. * Gets the number of samples used by the texture (WebGL2+ only)
  104670. */
  104671. samples: number;
  104672. /**
  104673. * Gets the type of the texture (int, float...)
  104674. */
  104675. type: number;
  104676. /**
  104677. * Gets the format of the texture (RGB, RGBA...)
  104678. */
  104679. format: number;
  104680. /**
  104681. * Observable called when the texture is loaded
  104682. */
  104683. onLoadedObservable: Observable<InternalTexture>;
  104684. /**
  104685. * Gets the width of the texture
  104686. */
  104687. width: number;
  104688. /**
  104689. * Gets the height of the texture
  104690. */
  104691. height: number;
  104692. /**
  104693. * Gets the depth of the texture
  104694. */
  104695. depth: number;
  104696. /**
  104697. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  104698. */
  104699. baseWidth: number;
  104700. /**
  104701. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  104702. */
  104703. baseHeight: number;
  104704. /**
  104705. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  104706. */
  104707. baseDepth: number;
  104708. /**
  104709. * Gets a boolean indicating if the texture is inverted on Y axis
  104710. */
  104711. invertY: boolean;
  104712. /** @hidden */
  104713. _invertVScale: boolean;
  104714. /** @hidden */
  104715. _associatedChannel: number;
  104716. /** @hidden */
  104717. _source: InternalTextureSource;
  104718. /** @hidden */
  104719. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104720. /** @hidden */
  104721. _bufferView: Nullable<ArrayBufferView>;
  104722. /** @hidden */
  104723. _bufferViewArray: Nullable<ArrayBufferView[]>;
  104724. /** @hidden */
  104725. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  104726. /** @hidden */
  104727. _size: number;
  104728. /** @hidden */
  104729. _extension: string;
  104730. /** @hidden */
  104731. _files: Nullable<string[]>;
  104732. /** @hidden */
  104733. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104734. /** @hidden */
  104735. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104736. /** @hidden */
  104737. _framebuffer: Nullable<WebGLFramebuffer>;
  104738. /** @hidden */
  104739. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  104740. /** @hidden */
  104741. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  104742. /** @hidden */
  104743. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  104744. /** @hidden */
  104745. _attachments: Nullable<number[]>;
  104746. /** @hidden */
  104747. _cachedCoordinatesMode: Nullable<number>;
  104748. /** @hidden */
  104749. _cachedWrapU: Nullable<number>;
  104750. /** @hidden */
  104751. _cachedWrapV: Nullable<number>;
  104752. /** @hidden */
  104753. _cachedWrapR: Nullable<number>;
  104754. /** @hidden */
  104755. _cachedAnisotropicFilteringLevel: Nullable<number>;
  104756. /** @hidden */
  104757. _isDisabled: boolean;
  104758. /** @hidden */
  104759. _compression: Nullable<string>;
  104760. /** @hidden */
  104761. _generateStencilBuffer: boolean;
  104762. /** @hidden */
  104763. _generateDepthBuffer: boolean;
  104764. /** @hidden */
  104765. _comparisonFunction: number;
  104766. /** @hidden */
  104767. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  104768. /** @hidden */
  104769. _lodGenerationScale: number;
  104770. /** @hidden */
  104771. _lodGenerationOffset: number;
  104772. /** @hidden */
  104773. _depthStencilTexture: Nullable<InternalTexture>;
  104774. /** @hidden */
  104775. _colorTextureArray: Nullable<WebGLTexture>;
  104776. /** @hidden */
  104777. _depthStencilTextureArray: Nullable<WebGLTexture>;
  104778. /** @hidden */
  104779. _lodTextureHigh: Nullable<BaseTexture>;
  104780. /** @hidden */
  104781. _lodTextureMid: Nullable<BaseTexture>;
  104782. /** @hidden */
  104783. _lodTextureLow: Nullable<BaseTexture>;
  104784. /** @hidden */
  104785. _isRGBD: boolean;
  104786. /** @hidden */
  104787. _linearSpecularLOD: boolean;
  104788. /** @hidden */
  104789. _irradianceTexture: Nullable<BaseTexture>;
  104790. /** @hidden */
  104791. _webGLTexture: Nullable<WebGLTexture>;
  104792. /** @hidden */
  104793. _references: number;
  104794. private _engine;
  104795. /**
  104796. * Gets the Engine the texture belongs to.
  104797. * @returns The babylon engine
  104798. */
  104799. getEngine(): ThinEngine;
  104800. /**
  104801. * Gets the data source type of the texture
  104802. */
  104803. get source(): InternalTextureSource;
  104804. /**
  104805. * Creates a new InternalTexture
  104806. * @param engine defines the engine to use
  104807. * @param source defines the type of data that will be used
  104808. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104809. */
  104810. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  104811. /**
  104812. * Increments the number of references (ie. the number of Texture that point to it)
  104813. */
  104814. incrementReferences(): void;
  104815. /**
  104816. * Change the size of the texture (not the size of the content)
  104817. * @param width defines the new width
  104818. * @param height defines the new height
  104819. * @param depth defines the new depth (1 by default)
  104820. */
  104821. updateSize(width: int, height: int, depth?: int): void;
  104822. /** @hidden */
  104823. _rebuild(): void;
  104824. /** @hidden */
  104825. _swapAndDie(target: InternalTexture): void;
  104826. /**
  104827. * Dispose the current allocated resources
  104828. */
  104829. dispose(): void;
  104830. }
  104831. }
  104832. declare module BABYLON {
  104833. /**
  104834. * Class used to work with sound analyzer using fast fourier transform (FFT)
  104835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104836. */
  104837. export class Analyser {
  104838. /**
  104839. * Gets or sets the smoothing
  104840. * @ignorenaming
  104841. */
  104842. SMOOTHING: number;
  104843. /**
  104844. * Gets or sets the FFT table size
  104845. * @ignorenaming
  104846. */
  104847. FFT_SIZE: number;
  104848. /**
  104849. * Gets or sets the bar graph amplitude
  104850. * @ignorenaming
  104851. */
  104852. BARGRAPHAMPLITUDE: number;
  104853. /**
  104854. * Gets or sets the position of the debug canvas
  104855. * @ignorenaming
  104856. */
  104857. DEBUGCANVASPOS: {
  104858. x: number;
  104859. y: number;
  104860. };
  104861. /**
  104862. * Gets or sets the debug canvas size
  104863. * @ignorenaming
  104864. */
  104865. DEBUGCANVASSIZE: {
  104866. width: number;
  104867. height: number;
  104868. };
  104869. private _byteFreqs;
  104870. private _byteTime;
  104871. private _floatFreqs;
  104872. private _webAudioAnalyser;
  104873. private _debugCanvas;
  104874. private _debugCanvasContext;
  104875. private _scene;
  104876. private _registerFunc;
  104877. private _audioEngine;
  104878. /**
  104879. * Creates a new analyser
  104880. * @param scene defines hosting scene
  104881. */
  104882. constructor(scene: Scene);
  104883. /**
  104884. * Get the number of data values you will have to play with for the visualization
  104885. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  104886. * @returns a number
  104887. */
  104888. getFrequencyBinCount(): number;
  104889. /**
  104890. * Gets the current frequency data as a byte array
  104891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  104892. * @returns a Uint8Array
  104893. */
  104894. getByteFrequencyData(): Uint8Array;
  104895. /**
  104896. * Gets the current waveform as a byte array
  104897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  104898. * @returns a Uint8Array
  104899. */
  104900. getByteTimeDomainData(): Uint8Array;
  104901. /**
  104902. * Gets the current frequency data as a float array
  104903. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  104904. * @returns a Float32Array
  104905. */
  104906. getFloatFrequencyData(): Float32Array;
  104907. /**
  104908. * Renders the debug canvas
  104909. */
  104910. drawDebugCanvas(): void;
  104911. /**
  104912. * Stops rendering the debug canvas and removes it
  104913. */
  104914. stopDebugCanvas(): void;
  104915. /**
  104916. * Connects two audio nodes
  104917. * @param inputAudioNode defines first node to connect
  104918. * @param outputAudioNode defines second node to connect
  104919. */
  104920. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  104921. /**
  104922. * Releases all associated resources
  104923. */
  104924. dispose(): void;
  104925. }
  104926. }
  104927. declare module BABYLON {
  104928. /**
  104929. * This represents an audio engine and it is responsible
  104930. * to play, synchronize and analyse sounds throughout the application.
  104931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104932. */
  104933. export interface IAudioEngine extends IDisposable {
  104934. /**
  104935. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  104936. */
  104937. readonly canUseWebAudio: boolean;
  104938. /**
  104939. * Gets the current AudioContext if available.
  104940. */
  104941. readonly audioContext: Nullable<AudioContext>;
  104942. /**
  104943. * The master gain node defines the global audio volume of your audio engine.
  104944. */
  104945. readonly masterGain: GainNode;
  104946. /**
  104947. * Gets whether or not mp3 are supported by your browser.
  104948. */
  104949. readonly isMP3supported: boolean;
  104950. /**
  104951. * Gets whether or not ogg are supported by your browser.
  104952. */
  104953. readonly isOGGsupported: boolean;
  104954. /**
  104955. * Defines if Babylon should emit a warning if WebAudio is not supported.
  104956. * @ignoreNaming
  104957. */
  104958. WarnedWebAudioUnsupported: boolean;
  104959. /**
  104960. * Defines if the audio engine relies on a custom unlocked button.
  104961. * In this case, the embedded button will not be displayed.
  104962. */
  104963. useCustomUnlockedButton: boolean;
  104964. /**
  104965. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  104966. */
  104967. readonly unlocked: boolean;
  104968. /**
  104969. * Event raised when audio has been unlocked on the browser.
  104970. */
  104971. onAudioUnlockedObservable: Observable<AudioEngine>;
  104972. /**
  104973. * Event raised when audio has been locked on the browser.
  104974. */
  104975. onAudioLockedObservable: Observable<AudioEngine>;
  104976. /**
  104977. * Flags the audio engine in Locked state.
  104978. * This happens due to new browser policies preventing audio to autoplay.
  104979. */
  104980. lock(): void;
  104981. /**
  104982. * Unlocks the audio engine once a user action has been done on the dom.
  104983. * This is helpful to resume play once browser policies have been satisfied.
  104984. */
  104985. unlock(): void;
  104986. }
  104987. /**
  104988. * This represents the default audio engine used in babylon.
  104989. * It is responsible to play, synchronize and analyse sounds throughout the application.
  104990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104991. */
  104992. export class AudioEngine implements IAudioEngine {
  104993. private _audioContext;
  104994. private _audioContextInitialized;
  104995. private _muteButton;
  104996. private _hostElement;
  104997. /**
  104998. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  104999. */
  105000. canUseWebAudio: boolean;
  105001. /**
  105002. * The master gain node defines the global audio volume of your audio engine.
  105003. */
  105004. masterGain: GainNode;
  105005. /**
  105006. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105007. * @ignoreNaming
  105008. */
  105009. WarnedWebAudioUnsupported: boolean;
  105010. /**
  105011. * Gets whether or not mp3 are supported by your browser.
  105012. */
  105013. isMP3supported: boolean;
  105014. /**
  105015. * Gets whether or not ogg are supported by your browser.
  105016. */
  105017. isOGGsupported: boolean;
  105018. /**
  105019. * Gets whether audio has been unlocked on the device.
  105020. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105021. * a user interaction has happened.
  105022. */
  105023. unlocked: boolean;
  105024. /**
  105025. * Defines if the audio engine relies on a custom unlocked button.
  105026. * In this case, the embedded button will not be displayed.
  105027. */
  105028. useCustomUnlockedButton: boolean;
  105029. /**
  105030. * Event raised when audio has been unlocked on the browser.
  105031. */
  105032. onAudioUnlockedObservable: Observable<AudioEngine>;
  105033. /**
  105034. * Event raised when audio has been locked on the browser.
  105035. */
  105036. onAudioLockedObservable: Observable<AudioEngine>;
  105037. /**
  105038. * Gets the current AudioContext if available.
  105039. */
  105040. get audioContext(): Nullable<AudioContext>;
  105041. private _connectedAnalyser;
  105042. /**
  105043. * Instantiates a new audio engine.
  105044. *
  105045. * There should be only one per page as some browsers restrict the number
  105046. * of audio contexts you can create.
  105047. * @param hostElement defines the host element where to display the mute icon if necessary
  105048. */
  105049. constructor(hostElement?: Nullable<HTMLElement>);
  105050. /**
  105051. * Flags the audio engine in Locked state.
  105052. * This happens due to new browser policies preventing audio to autoplay.
  105053. */
  105054. lock(): void;
  105055. /**
  105056. * Unlocks the audio engine once a user action has been done on the dom.
  105057. * This is helpful to resume play once browser policies have been satisfied.
  105058. */
  105059. unlock(): void;
  105060. private _resumeAudioContext;
  105061. private _initializeAudioContext;
  105062. private _tryToRun;
  105063. private _triggerRunningState;
  105064. private _triggerSuspendedState;
  105065. private _displayMuteButton;
  105066. private _moveButtonToTopLeft;
  105067. private _onResize;
  105068. private _hideMuteButton;
  105069. /**
  105070. * Destroy and release the resources associated with the audio ccontext.
  105071. */
  105072. dispose(): void;
  105073. /**
  105074. * Gets the global volume sets on the master gain.
  105075. * @returns the global volume if set or -1 otherwise
  105076. */
  105077. getGlobalVolume(): number;
  105078. /**
  105079. * Sets the global volume of your experience (sets on the master gain).
  105080. * @param newVolume Defines the new global volume of the application
  105081. */
  105082. setGlobalVolume(newVolume: number): void;
  105083. /**
  105084. * Connect the audio engine to an audio analyser allowing some amazing
  105085. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105087. * @param analyser The analyser to connect to the engine
  105088. */
  105089. connectToAnalyser(analyser: Analyser): void;
  105090. }
  105091. }
  105092. declare module BABYLON {
  105093. /**
  105094. * Interface used to present a loading screen while loading a scene
  105095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105096. */
  105097. export interface ILoadingScreen {
  105098. /**
  105099. * Function called to display the loading screen
  105100. */
  105101. displayLoadingUI: () => void;
  105102. /**
  105103. * Function called to hide the loading screen
  105104. */
  105105. hideLoadingUI: () => void;
  105106. /**
  105107. * Gets or sets the color to use for the background
  105108. */
  105109. loadingUIBackgroundColor: string;
  105110. /**
  105111. * Gets or sets the text to display while loading
  105112. */
  105113. loadingUIText: string;
  105114. }
  105115. /**
  105116. * Class used for the default loading screen
  105117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105118. */
  105119. export class DefaultLoadingScreen implements ILoadingScreen {
  105120. private _renderingCanvas;
  105121. private _loadingText;
  105122. private _loadingDivBackgroundColor;
  105123. private _loadingDiv;
  105124. private _loadingTextDiv;
  105125. /** Gets or sets the logo url to use for the default loading screen */
  105126. static DefaultLogoUrl: string;
  105127. /** Gets or sets the spinner url to use for the default loading screen */
  105128. static DefaultSpinnerUrl: string;
  105129. /**
  105130. * Creates a new default loading screen
  105131. * @param _renderingCanvas defines the canvas used to render the scene
  105132. * @param _loadingText defines the default text to display
  105133. * @param _loadingDivBackgroundColor defines the default background color
  105134. */
  105135. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105136. /**
  105137. * Function called to display the loading screen
  105138. */
  105139. displayLoadingUI(): void;
  105140. /**
  105141. * Function called to hide the loading screen
  105142. */
  105143. hideLoadingUI(): void;
  105144. /**
  105145. * Gets or sets the text to display while loading
  105146. */
  105147. set loadingUIText(text: string);
  105148. get loadingUIText(): string;
  105149. /**
  105150. * Gets or sets the color to use for the background
  105151. */
  105152. get loadingUIBackgroundColor(): string;
  105153. set loadingUIBackgroundColor(color: string);
  105154. private _resizeLoadingUI;
  105155. }
  105156. }
  105157. declare module BABYLON {
  105158. /**
  105159. * Interface for any object that can request an animation frame
  105160. */
  105161. export interface ICustomAnimationFrameRequester {
  105162. /**
  105163. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105164. */
  105165. renderFunction?: Function;
  105166. /**
  105167. * Called to request the next frame to render to
  105168. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105169. */
  105170. requestAnimationFrame: Function;
  105171. /**
  105172. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105173. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105174. */
  105175. requestID?: number;
  105176. }
  105177. }
  105178. declare module BABYLON {
  105179. /**
  105180. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  105181. */
  105182. export class PerformanceMonitor {
  105183. private _enabled;
  105184. private _rollingFrameTime;
  105185. private _lastFrameTimeMs;
  105186. /**
  105187. * constructor
  105188. * @param frameSampleSize The number of samples required to saturate the sliding window
  105189. */
  105190. constructor(frameSampleSize?: number);
  105191. /**
  105192. * Samples current frame
  105193. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  105194. */
  105195. sampleFrame(timeMs?: number): void;
  105196. /**
  105197. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105198. */
  105199. get averageFrameTime(): number;
  105200. /**
  105201. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105202. */
  105203. get averageFrameTimeVariance(): number;
  105204. /**
  105205. * Returns the frame time of the most recent frame
  105206. */
  105207. get instantaneousFrameTime(): number;
  105208. /**
  105209. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  105210. */
  105211. get averageFPS(): number;
  105212. /**
  105213. * Returns the average framerate in frames per second using the most recent frame time
  105214. */
  105215. get instantaneousFPS(): number;
  105216. /**
  105217. * Returns true if enough samples have been taken to completely fill the sliding window
  105218. */
  105219. get isSaturated(): boolean;
  105220. /**
  105221. * Enables contributions to the sliding window sample set
  105222. */
  105223. enable(): void;
  105224. /**
  105225. * Disables contributions to the sliding window sample set
  105226. * Samples will not be interpolated over the disabled period
  105227. */
  105228. disable(): void;
  105229. /**
  105230. * Returns true if sampling is enabled
  105231. */
  105232. get isEnabled(): boolean;
  105233. /**
  105234. * Resets performance monitor
  105235. */
  105236. reset(): void;
  105237. }
  105238. /**
  105239. * RollingAverage
  105240. *
  105241. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  105242. */
  105243. export class RollingAverage {
  105244. /**
  105245. * Current average
  105246. */
  105247. average: number;
  105248. /**
  105249. * Current variance
  105250. */
  105251. variance: number;
  105252. protected _samples: Array<number>;
  105253. protected _sampleCount: number;
  105254. protected _pos: number;
  105255. protected _m2: number;
  105256. /**
  105257. * constructor
  105258. * @param length The number of samples required to saturate the sliding window
  105259. */
  105260. constructor(length: number);
  105261. /**
  105262. * Adds a sample to the sample set
  105263. * @param v The sample value
  105264. */
  105265. add(v: number): void;
  105266. /**
  105267. * Returns previously added values or null if outside of history or outside the sliding window domain
  105268. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  105269. * @return Value previously recorded with add() or null if outside of range
  105270. */
  105271. history(i: number): number;
  105272. /**
  105273. * Returns true if enough samples have been taken to completely fill the sliding window
  105274. * @return true if sample-set saturated
  105275. */
  105276. isSaturated(): boolean;
  105277. /**
  105278. * Resets the rolling average (equivalent to 0 samples taken so far)
  105279. */
  105280. reset(): void;
  105281. /**
  105282. * Wraps a value around the sample range boundaries
  105283. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  105284. * @return Wrapped position in sample range
  105285. */
  105286. protected _wrapPosition(i: number): number;
  105287. }
  105288. }
  105289. declare module BABYLON {
  105290. /**
  105291. * This class is used to track a performance counter which is number based.
  105292. * The user has access to many properties which give statistics of different nature.
  105293. *
  105294. * The implementer can track two kinds of Performance Counter: time and count.
  105295. * 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.
  105296. * 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.
  105297. */
  105298. export class PerfCounter {
  105299. /**
  105300. * Gets or sets a global boolean to turn on and off all the counters
  105301. */
  105302. static Enabled: boolean;
  105303. /**
  105304. * Returns the smallest value ever
  105305. */
  105306. get min(): number;
  105307. /**
  105308. * Returns the biggest value ever
  105309. */
  105310. get max(): number;
  105311. /**
  105312. * Returns the average value since the performance counter is running
  105313. */
  105314. get average(): number;
  105315. /**
  105316. * Returns the average value of the last second the counter was monitored
  105317. */
  105318. get lastSecAverage(): number;
  105319. /**
  105320. * Returns the current value
  105321. */
  105322. get current(): number;
  105323. /**
  105324. * Gets the accumulated total
  105325. */
  105326. get total(): number;
  105327. /**
  105328. * Gets the total value count
  105329. */
  105330. get count(): number;
  105331. /**
  105332. * Creates a new counter
  105333. */
  105334. constructor();
  105335. /**
  105336. * Call this method to start monitoring a new frame.
  105337. * 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.
  105338. */
  105339. fetchNewFrame(): void;
  105340. /**
  105341. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  105342. * @param newCount the count value to add to the monitored count
  105343. * @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.
  105344. */
  105345. addCount(newCount: number, fetchResult: boolean): void;
  105346. /**
  105347. * Start monitoring this performance counter
  105348. */
  105349. beginMonitoring(): void;
  105350. /**
  105351. * Compute the time lapsed since the previous beginMonitoring() call.
  105352. * @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
  105353. */
  105354. endMonitoring(newFrame?: boolean): void;
  105355. private _fetchResult;
  105356. private _startMonitoringTime;
  105357. private _min;
  105358. private _max;
  105359. private _average;
  105360. private _current;
  105361. private _totalValueCount;
  105362. private _totalAccumulated;
  105363. private _lastSecAverage;
  105364. private _lastSecAccumulated;
  105365. private _lastSecTime;
  105366. private _lastSecValueCount;
  105367. }
  105368. }
  105369. declare module BABYLON {
  105370. interface ThinEngine {
  105371. /**
  105372. * Sets alpha constants used by some alpha blending modes
  105373. * @param r defines the red component
  105374. * @param g defines the green component
  105375. * @param b defines the blue component
  105376. * @param a defines the alpha component
  105377. */
  105378. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  105379. /**
  105380. * Sets the current alpha mode
  105381. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  105382. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  105383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105384. */
  105385. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105386. /**
  105387. * Gets the current alpha mode
  105388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105389. * @returns the current alpha mode
  105390. */
  105391. getAlphaMode(): number;
  105392. /**
  105393. * Sets the current alpha equation
  105394. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  105395. */
  105396. setAlphaEquation(equation: number): void;
  105397. /**
  105398. * Gets the current alpha equation.
  105399. * @returns the current alpha equation
  105400. */
  105401. getAlphaEquation(): number;
  105402. }
  105403. }
  105404. declare module BABYLON {
  105405. /**
  105406. * Defines the interface used by display changed events
  105407. */
  105408. export interface IDisplayChangedEventArgs {
  105409. /** Gets the vrDisplay object (if any) */
  105410. vrDisplay: Nullable<any>;
  105411. /** Gets a boolean indicating if webVR is supported */
  105412. vrSupported: boolean;
  105413. }
  105414. /**
  105415. * Defines the interface used by objects containing a viewport (like a camera)
  105416. */
  105417. interface IViewportOwnerLike {
  105418. /**
  105419. * Gets or sets the viewport
  105420. */
  105421. viewport: IViewportLike;
  105422. }
  105423. /**
  105424. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  105425. */
  105426. export class Engine extends ThinEngine {
  105427. /** Defines that alpha blending is disabled */
  105428. static readonly ALPHA_DISABLE: number;
  105429. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  105430. static readonly ALPHA_ADD: number;
  105431. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  105432. static readonly ALPHA_COMBINE: number;
  105433. /** Defines that alpha blending to DEST - SRC * DEST */
  105434. static readonly ALPHA_SUBTRACT: number;
  105435. /** Defines that alpha blending to SRC * DEST */
  105436. static readonly ALPHA_MULTIPLY: number;
  105437. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  105438. static readonly ALPHA_MAXIMIZED: number;
  105439. /** Defines that alpha blending to SRC + DEST */
  105440. static readonly ALPHA_ONEONE: number;
  105441. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  105442. static readonly ALPHA_PREMULTIPLIED: number;
  105443. /**
  105444. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  105445. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  105446. */
  105447. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  105448. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  105449. static readonly ALPHA_INTERPOLATE: number;
  105450. /**
  105451. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  105452. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  105453. */
  105454. static readonly ALPHA_SCREENMODE: number;
  105455. /** Defines that the ressource is not delayed*/
  105456. static readonly DELAYLOADSTATE_NONE: number;
  105457. /** Defines that the ressource was successfully delay loaded */
  105458. static readonly DELAYLOADSTATE_LOADED: number;
  105459. /** Defines that the ressource is currently delay loading */
  105460. static readonly DELAYLOADSTATE_LOADING: number;
  105461. /** Defines that the ressource is delayed and has not started loading */
  105462. static readonly DELAYLOADSTATE_NOTLOADED: number;
  105463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  105464. static readonly NEVER: number;
  105465. /** 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 */
  105466. static readonly ALWAYS: number;
  105467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  105468. static readonly LESS: number;
  105469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  105470. static readonly EQUAL: number;
  105471. /** 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 */
  105472. static readonly LEQUAL: number;
  105473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  105474. static readonly GREATER: number;
  105475. /** 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 */
  105476. static readonly GEQUAL: number;
  105477. /** 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 */
  105478. static readonly NOTEQUAL: number;
  105479. /** Passed to stencilOperation to specify that stencil value must be kept */
  105480. static readonly KEEP: number;
  105481. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105482. static readonly REPLACE: number;
  105483. /** Passed to stencilOperation to specify that stencil value must be incremented */
  105484. static readonly INCR: number;
  105485. /** Passed to stencilOperation to specify that stencil value must be decremented */
  105486. static readonly DECR: number;
  105487. /** Passed to stencilOperation to specify that stencil value must be inverted */
  105488. static readonly INVERT: number;
  105489. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  105490. static readonly INCR_WRAP: number;
  105491. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  105492. static readonly DECR_WRAP: number;
  105493. /** Texture is not repeating outside of 0..1 UVs */
  105494. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  105495. /** Texture is repeating outside of 0..1 UVs */
  105496. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  105497. /** Texture is repeating and mirrored */
  105498. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  105499. /** ALPHA */
  105500. static readonly TEXTUREFORMAT_ALPHA: number;
  105501. /** LUMINANCE */
  105502. static readonly TEXTUREFORMAT_LUMINANCE: number;
  105503. /** LUMINANCE_ALPHA */
  105504. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  105505. /** RGB */
  105506. static readonly TEXTUREFORMAT_RGB: number;
  105507. /** RGBA */
  105508. static readonly TEXTUREFORMAT_RGBA: number;
  105509. /** RED */
  105510. static readonly TEXTUREFORMAT_RED: number;
  105511. /** RED (2nd reference) */
  105512. static readonly TEXTUREFORMAT_R: number;
  105513. /** RG */
  105514. static readonly TEXTUREFORMAT_RG: number;
  105515. /** RED_INTEGER */
  105516. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  105517. /** RED_INTEGER (2nd reference) */
  105518. static readonly TEXTUREFORMAT_R_INTEGER: number;
  105519. /** RG_INTEGER */
  105520. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  105521. /** RGB_INTEGER */
  105522. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  105523. /** RGBA_INTEGER */
  105524. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  105525. /** UNSIGNED_BYTE */
  105526. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  105527. /** UNSIGNED_BYTE (2nd reference) */
  105528. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  105529. /** FLOAT */
  105530. static readonly TEXTURETYPE_FLOAT: number;
  105531. /** HALF_FLOAT */
  105532. static readonly TEXTURETYPE_HALF_FLOAT: number;
  105533. /** BYTE */
  105534. static readonly TEXTURETYPE_BYTE: number;
  105535. /** SHORT */
  105536. static readonly TEXTURETYPE_SHORT: number;
  105537. /** UNSIGNED_SHORT */
  105538. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  105539. /** INT */
  105540. static readonly TEXTURETYPE_INT: number;
  105541. /** UNSIGNED_INT */
  105542. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  105543. /** UNSIGNED_SHORT_4_4_4_4 */
  105544. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  105545. /** UNSIGNED_SHORT_5_5_5_1 */
  105546. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  105547. /** UNSIGNED_SHORT_5_6_5 */
  105548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  105549. /** UNSIGNED_INT_2_10_10_10_REV */
  105550. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  105551. /** UNSIGNED_INT_24_8 */
  105552. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  105553. /** UNSIGNED_INT_10F_11F_11F_REV */
  105554. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  105555. /** UNSIGNED_INT_5_9_9_9_REV */
  105556. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  105557. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  105558. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  105559. /** nearest is mag = nearest and min = nearest and mip = linear */
  105560. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  105561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105562. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  105563. /** Trilinear is mag = linear and min = linear and mip = linear */
  105564. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  105565. /** nearest is mag = nearest and min = nearest and mip = linear */
  105566. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  105567. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105568. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  105569. /** Trilinear is mag = linear and min = linear and mip = linear */
  105570. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  105571. /** mag = nearest and min = nearest and mip = nearest */
  105572. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  105573. /** mag = nearest and min = linear and mip = nearest */
  105574. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  105575. /** mag = nearest and min = linear and mip = linear */
  105576. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  105577. /** mag = nearest and min = linear and mip = none */
  105578. static readonly TEXTURE_NEAREST_LINEAR: number;
  105579. /** mag = nearest and min = nearest and mip = none */
  105580. static readonly TEXTURE_NEAREST_NEAREST: number;
  105581. /** mag = linear and min = nearest and mip = nearest */
  105582. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  105583. /** mag = linear and min = nearest and mip = linear */
  105584. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  105585. /** mag = linear and min = linear and mip = none */
  105586. static readonly TEXTURE_LINEAR_LINEAR: number;
  105587. /** mag = linear and min = nearest and mip = none */
  105588. static readonly TEXTURE_LINEAR_NEAREST: number;
  105589. /** Explicit coordinates mode */
  105590. static readonly TEXTURE_EXPLICIT_MODE: number;
  105591. /** Spherical coordinates mode */
  105592. static readonly TEXTURE_SPHERICAL_MODE: number;
  105593. /** Planar coordinates mode */
  105594. static readonly TEXTURE_PLANAR_MODE: number;
  105595. /** Cubic coordinates mode */
  105596. static readonly TEXTURE_CUBIC_MODE: number;
  105597. /** Projection coordinates mode */
  105598. static readonly TEXTURE_PROJECTION_MODE: number;
  105599. /** Skybox coordinates mode */
  105600. static readonly TEXTURE_SKYBOX_MODE: number;
  105601. /** Inverse Cubic coordinates mode */
  105602. static readonly TEXTURE_INVCUBIC_MODE: number;
  105603. /** Equirectangular coordinates mode */
  105604. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  105605. /** Equirectangular Fixed coordinates mode */
  105606. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  105607. /** Equirectangular Fixed Mirrored coordinates mode */
  105608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  105609. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  105610. static readonly SCALEMODE_FLOOR: number;
  105611. /** Defines that texture rescaling will look for the nearest power of 2 size */
  105612. static readonly SCALEMODE_NEAREST: number;
  105613. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  105614. static readonly SCALEMODE_CEILING: number;
  105615. /**
  105616. * Returns the current npm package of the sdk
  105617. */
  105618. static get NpmPackage(): string;
  105619. /**
  105620. * Returns the current version of the framework
  105621. */
  105622. static get Version(): string;
  105623. /** Gets the list of created engines */
  105624. static get Instances(): Engine[];
  105625. /**
  105626. * Gets the latest created engine
  105627. */
  105628. static get LastCreatedEngine(): Nullable<Engine>;
  105629. /**
  105630. * Gets the latest created scene
  105631. */
  105632. static get LastCreatedScene(): Nullable<Scene>;
  105633. /**
  105634. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  105635. * @param flag defines which part of the materials must be marked as dirty
  105636. * @param predicate defines a predicate used to filter which materials should be affected
  105637. */
  105638. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105639. /**
  105640. * Method called to create the default loading screen.
  105641. * This can be overriden in your own app.
  105642. * @param canvas The rendering canvas element
  105643. * @returns The loading screen
  105644. */
  105645. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  105646. /**
  105647. * Method called to create the default rescale post process on each engine.
  105648. */
  105649. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  105650. /**
  105651. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  105652. **/
  105653. enableOfflineSupport: boolean;
  105654. /**
  105655. * 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)
  105656. **/
  105657. disableManifestCheck: boolean;
  105658. /**
  105659. * Gets the list of created scenes
  105660. */
  105661. scenes: Scene[];
  105662. /**
  105663. * Event raised when a new scene is created
  105664. */
  105665. onNewSceneAddedObservable: Observable<Scene>;
  105666. /**
  105667. * Gets the list of created postprocesses
  105668. */
  105669. postProcesses: PostProcess[];
  105670. /**
  105671. * Gets a boolean indicating if the pointer is currently locked
  105672. */
  105673. isPointerLock: boolean;
  105674. /**
  105675. * Observable event triggered each time the rendering canvas is resized
  105676. */
  105677. onResizeObservable: Observable<Engine>;
  105678. /**
  105679. * Observable event triggered each time the canvas loses focus
  105680. */
  105681. onCanvasBlurObservable: Observable<Engine>;
  105682. /**
  105683. * Observable event triggered each time the canvas gains focus
  105684. */
  105685. onCanvasFocusObservable: Observable<Engine>;
  105686. /**
  105687. * Observable event triggered each time the canvas receives pointerout event
  105688. */
  105689. onCanvasPointerOutObservable: Observable<PointerEvent>;
  105690. /**
  105691. * Observable raised when the engine begins a new frame
  105692. */
  105693. onBeginFrameObservable: Observable<Engine>;
  105694. /**
  105695. * If set, will be used to request the next animation frame for the render loop
  105696. */
  105697. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  105698. /**
  105699. * Observable raised when the engine ends the current frame
  105700. */
  105701. onEndFrameObservable: Observable<Engine>;
  105702. /**
  105703. * Observable raised when the engine is about to compile a shader
  105704. */
  105705. onBeforeShaderCompilationObservable: Observable<Engine>;
  105706. /**
  105707. * Observable raised when the engine has jsut compiled a shader
  105708. */
  105709. onAfterShaderCompilationObservable: Observable<Engine>;
  105710. /**
  105711. * Gets the audio engine
  105712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105713. * @ignorenaming
  105714. */
  105715. static audioEngine: IAudioEngine;
  105716. /**
  105717. * Default AudioEngine factory responsible of creating the Audio Engine.
  105718. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  105719. */
  105720. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  105721. /**
  105722. * Default offline support factory responsible of creating a tool used to store data locally.
  105723. * By default, this will create a Database object if the workload has been embedded.
  105724. */
  105725. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  105726. private _loadingScreen;
  105727. private _pointerLockRequested;
  105728. private _dummyFramebuffer;
  105729. private _rescalePostProcess;
  105730. private _deterministicLockstep;
  105731. private _lockstepMaxSteps;
  105732. private _timeStep;
  105733. protected get _supportsHardwareTextureRescaling(): boolean;
  105734. private _fps;
  105735. private _deltaTime;
  105736. /** @hidden */
  105737. _drawCalls: PerfCounter;
  105738. /** 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 */
  105739. canvasTabIndex: number;
  105740. /**
  105741. * Turn this value on if you want to pause FPS computation when in background
  105742. */
  105743. disablePerformanceMonitorInBackground: boolean;
  105744. private _performanceMonitor;
  105745. /**
  105746. * Gets the performance monitor attached to this engine
  105747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105748. */
  105749. get performanceMonitor(): PerformanceMonitor;
  105750. private _onFocus;
  105751. private _onBlur;
  105752. private _onCanvasPointerOut;
  105753. private _onCanvasBlur;
  105754. private _onCanvasFocus;
  105755. private _onFullscreenChange;
  105756. private _onPointerLockChange;
  105757. /**
  105758. * Gets the HTML element used to attach event listeners
  105759. * @returns a HTML element
  105760. */
  105761. getInputElement(): Nullable<HTMLElement>;
  105762. /**
  105763. * Creates a new engine
  105764. * @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
  105765. * @param antialias defines enable antialiasing (default: false)
  105766. * @param options defines further options to be sent to the getContext() function
  105767. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105768. */
  105769. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105770. /**
  105771. * Gets current aspect ratio
  105772. * @param viewportOwner defines the camera to use to get the aspect ratio
  105773. * @param useScreen defines if screen size must be used (or the current render target if any)
  105774. * @returns a number defining the aspect ratio
  105775. */
  105776. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  105777. /**
  105778. * Gets current screen aspect ratio
  105779. * @returns a number defining the aspect ratio
  105780. */
  105781. getScreenAspectRatio(): number;
  105782. /**
  105783. * Gets the client rect of the HTML canvas attached with the current webGL context
  105784. * @returns a client rectanglee
  105785. */
  105786. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  105787. /**
  105788. * Gets the client rect of the HTML element used for events
  105789. * @returns a client rectanglee
  105790. */
  105791. getInputElementClientRect(): Nullable<ClientRect>;
  105792. /**
  105793. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  105794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105795. * @returns true if engine is in deterministic lock step mode
  105796. */
  105797. isDeterministicLockStep(): boolean;
  105798. /**
  105799. * Gets the max steps when engine is running in deterministic lock step
  105800. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105801. * @returns the max steps
  105802. */
  105803. getLockstepMaxSteps(): number;
  105804. /**
  105805. * Returns the time in ms between steps when using deterministic lock step.
  105806. * @returns time step in (ms)
  105807. */
  105808. getTimeStep(): number;
  105809. /**
  105810. * Force the mipmap generation for the given render target texture
  105811. * @param texture defines the render target texture to use
  105812. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  105813. */
  105814. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  105815. /** States */
  105816. /**
  105817. * Set various states to the webGL context
  105818. * @param culling defines backface culling state
  105819. * @param zOffset defines the value to apply to zOffset (0 by default)
  105820. * @param force defines if states must be applied even if cache is up to date
  105821. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  105822. */
  105823. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  105824. /**
  105825. * Set the z offset to apply to current rendering
  105826. * @param value defines the offset to apply
  105827. */
  105828. setZOffset(value: number): void;
  105829. /**
  105830. * Gets the current value of the zOffset
  105831. * @returns the current zOffset state
  105832. */
  105833. getZOffset(): number;
  105834. /**
  105835. * Enable or disable depth buffering
  105836. * @param enable defines the state to set
  105837. */
  105838. setDepthBuffer(enable: boolean): void;
  105839. /**
  105840. * Gets a boolean indicating if depth writing is enabled
  105841. * @returns the current depth writing state
  105842. */
  105843. getDepthWrite(): boolean;
  105844. /**
  105845. * Enable or disable depth writing
  105846. * @param enable defines the state to set
  105847. */
  105848. setDepthWrite(enable: boolean): void;
  105849. /**
  105850. * Gets a boolean indicating if stencil buffer is enabled
  105851. * @returns the current stencil buffer state
  105852. */
  105853. getStencilBuffer(): boolean;
  105854. /**
  105855. * Enable or disable the stencil buffer
  105856. * @param enable defines if the stencil buffer must be enabled or disabled
  105857. */
  105858. setStencilBuffer(enable: boolean): void;
  105859. /**
  105860. * Gets the current stencil mask
  105861. * @returns a number defining the new stencil mask to use
  105862. */
  105863. getStencilMask(): number;
  105864. /**
  105865. * Sets the current stencil mask
  105866. * @param mask defines the new stencil mask to use
  105867. */
  105868. setStencilMask(mask: number): void;
  105869. /**
  105870. * Gets the current stencil function
  105871. * @returns a number defining the stencil function to use
  105872. */
  105873. getStencilFunction(): number;
  105874. /**
  105875. * Gets the current stencil reference value
  105876. * @returns a number defining the stencil reference value to use
  105877. */
  105878. getStencilFunctionReference(): number;
  105879. /**
  105880. * Gets the current stencil mask
  105881. * @returns a number defining the stencil mask to use
  105882. */
  105883. getStencilFunctionMask(): number;
  105884. /**
  105885. * Sets the current stencil function
  105886. * @param stencilFunc defines the new stencil function to use
  105887. */
  105888. setStencilFunction(stencilFunc: number): void;
  105889. /**
  105890. * Sets the current stencil reference
  105891. * @param reference defines the new stencil reference to use
  105892. */
  105893. setStencilFunctionReference(reference: number): void;
  105894. /**
  105895. * Sets the current stencil mask
  105896. * @param mask defines the new stencil mask to use
  105897. */
  105898. setStencilFunctionMask(mask: number): void;
  105899. /**
  105900. * Gets the current stencil operation when stencil fails
  105901. * @returns a number defining stencil operation to use when stencil fails
  105902. */
  105903. getStencilOperationFail(): number;
  105904. /**
  105905. * Gets the current stencil operation when depth fails
  105906. * @returns a number defining stencil operation to use when depth fails
  105907. */
  105908. getStencilOperationDepthFail(): number;
  105909. /**
  105910. * Gets the current stencil operation when stencil passes
  105911. * @returns a number defining stencil operation to use when stencil passes
  105912. */
  105913. getStencilOperationPass(): number;
  105914. /**
  105915. * Sets the stencil operation to use when stencil fails
  105916. * @param operation defines the stencil operation to use when stencil fails
  105917. */
  105918. setStencilOperationFail(operation: number): void;
  105919. /**
  105920. * Sets the stencil operation to use when depth fails
  105921. * @param operation defines the stencil operation to use when depth fails
  105922. */
  105923. setStencilOperationDepthFail(operation: number): void;
  105924. /**
  105925. * Sets the stencil operation to use when stencil passes
  105926. * @param operation defines the stencil operation to use when stencil passes
  105927. */
  105928. setStencilOperationPass(operation: number): void;
  105929. /**
  105930. * Sets a boolean indicating if the dithering state is enabled or disabled
  105931. * @param value defines the dithering state
  105932. */
  105933. setDitheringState(value: boolean): void;
  105934. /**
  105935. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  105936. * @param value defines the rasterizer state
  105937. */
  105938. setRasterizerState(value: boolean): void;
  105939. /**
  105940. * Gets the current depth function
  105941. * @returns a number defining the depth function
  105942. */
  105943. getDepthFunction(): Nullable<number>;
  105944. /**
  105945. * Sets the current depth function
  105946. * @param depthFunc defines the function to use
  105947. */
  105948. setDepthFunction(depthFunc: number): void;
  105949. /**
  105950. * Sets the current depth function to GREATER
  105951. */
  105952. setDepthFunctionToGreater(): void;
  105953. /**
  105954. * Sets the current depth function to GEQUAL
  105955. */
  105956. setDepthFunctionToGreaterOrEqual(): void;
  105957. /**
  105958. * Sets the current depth function to LESS
  105959. */
  105960. setDepthFunctionToLess(): void;
  105961. /**
  105962. * Sets the current depth function to LEQUAL
  105963. */
  105964. setDepthFunctionToLessOrEqual(): void;
  105965. private _cachedStencilBuffer;
  105966. private _cachedStencilFunction;
  105967. private _cachedStencilMask;
  105968. private _cachedStencilOperationPass;
  105969. private _cachedStencilOperationFail;
  105970. private _cachedStencilOperationDepthFail;
  105971. private _cachedStencilReference;
  105972. /**
  105973. * Caches the the state of the stencil buffer
  105974. */
  105975. cacheStencilState(): void;
  105976. /**
  105977. * Restores the state of the stencil buffer
  105978. */
  105979. restoreStencilState(): void;
  105980. /**
  105981. * Directly set the WebGL Viewport
  105982. * @param x defines the x coordinate of the viewport (in screen space)
  105983. * @param y defines the y coordinate of the viewport (in screen space)
  105984. * @param width defines the width of the viewport (in screen space)
  105985. * @param height defines the height of the viewport (in screen space)
  105986. * @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
  105987. */
  105988. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  105989. /**
  105990. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  105991. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  105992. * @param y defines the y-coordinate of the corner of the clear rectangle
  105993. * @param width defines the width of the clear rectangle
  105994. * @param height defines the height of the clear rectangle
  105995. * @param clearColor defines the clear color
  105996. */
  105997. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  105998. /**
  105999. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106000. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106001. * @param y defines the y-coordinate of the corner of the clear rectangle
  106002. * @param width defines the width of the clear rectangle
  106003. * @param height defines the height of the clear rectangle
  106004. */
  106005. enableScissor(x: number, y: number, width: number, height: number): void;
  106006. /**
  106007. * Disable previously set scissor test rectangle
  106008. */
  106009. disableScissor(): void;
  106010. protected _reportDrawCall(): void;
  106011. /**
  106012. * Initializes a webVR display and starts listening to display change events
  106013. * The onVRDisplayChangedObservable will be notified upon these changes
  106014. * @returns The onVRDisplayChangedObservable
  106015. */
  106016. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106017. /** @hidden */
  106018. _prepareVRComponent(): void;
  106019. /** @hidden */
  106020. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106021. /** @hidden */
  106022. _submitVRFrame(): void;
  106023. /**
  106024. * Call this function to leave webVR mode
  106025. * Will do nothing if webVR is not supported or if there is no webVR device
  106026. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106027. */
  106028. disableVR(): void;
  106029. /**
  106030. * Gets a boolean indicating that the system is in VR mode and is presenting
  106031. * @returns true if VR mode is engaged
  106032. */
  106033. isVRPresenting(): boolean;
  106034. /** @hidden */
  106035. _requestVRFrame(): void;
  106036. /** @hidden */
  106037. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106038. /**
  106039. * Gets the source code of the vertex shader associated with a specific webGL program
  106040. * @param program defines the program to use
  106041. * @returns a string containing the source code of the vertex shader associated with the program
  106042. */
  106043. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106044. /**
  106045. * Gets the source code of the fragment shader associated with a specific webGL program
  106046. * @param program defines the program to use
  106047. * @returns a string containing the source code of the fragment shader associated with the program
  106048. */
  106049. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106050. /**
  106051. * Sets a depth stencil texture from a render target to the according uniform.
  106052. * @param channel The texture channel
  106053. * @param uniform The uniform to set
  106054. * @param texture The render target texture containing the depth stencil texture to apply
  106055. */
  106056. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106057. /**
  106058. * Sets a texture to the webGL context from a postprocess
  106059. * @param channel defines the channel to use
  106060. * @param postProcess defines the source postprocess
  106061. */
  106062. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106063. /**
  106064. * Binds the output of the passed in post process to the texture channel specified
  106065. * @param channel The channel the texture should be bound to
  106066. * @param postProcess The post process which's output should be bound
  106067. */
  106068. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106069. /** @hidden */
  106070. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106071. protected _rebuildBuffers(): void;
  106072. /** @hidden */
  106073. _renderFrame(): void;
  106074. _renderLoop(): void;
  106075. /** @hidden */
  106076. _renderViews(): boolean;
  106077. /**
  106078. * Toggle full screen mode
  106079. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106080. */
  106081. switchFullscreen(requestPointerLock: boolean): void;
  106082. /**
  106083. * Enters full screen mode
  106084. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106085. */
  106086. enterFullscreen(requestPointerLock: boolean): void;
  106087. /**
  106088. * Exits full screen mode
  106089. */
  106090. exitFullscreen(): void;
  106091. /**
  106092. * Enters Pointerlock mode
  106093. */
  106094. enterPointerlock(): void;
  106095. /**
  106096. * Exits Pointerlock mode
  106097. */
  106098. exitPointerlock(): void;
  106099. /**
  106100. * Begin a new frame
  106101. */
  106102. beginFrame(): void;
  106103. /**
  106104. * Enf the current frame
  106105. */
  106106. endFrame(): void;
  106107. resize(): void;
  106108. /**
  106109. * Set the compressed texture format to use, based on the formats you have, and the formats
  106110. * supported by the hardware / browser.
  106111. *
  106112. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106113. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106114. * to API arguments needed to compressed textures. This puts the burden on the container
  106115. * generator to house the arcane code for determining these for current & future formats.
  106116. *
  106117. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106118. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106119. *
  106120. * Note: The result of this call is not taken into account when a texture is base64.
  106121. *
  106122. * @param formatsAvailable defines the list of those format families you have created
  106123. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106124. *
  106125. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106126. * @returns The extension selected.
  106127. */
  106128. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106129. /**
  106130. * Set the compressed texture extensions or file names to skip.
  106131. *
  106132. * @param skippedFiles defines the list of those texture files you want to skip
  106133. * Example: [".dds", ".env", "myfile.png"]
  106134. */
  106135. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106136. /**
  106137. * Force a specific size of the canvas
  106138. * @param width defines the new canvas' width
  106139. * @param height defines the new canvas' height
  106140. */
  106141. setSize(width: number, height: number): void;
  106142. /**
  106143. * Updates a dynamic vertex buffer.
  106144. * @param vertexBuffer the vertex buffer to update
  106145. * @param data the data used to update the vertex buffer
  106146. * @param byteOffset the byte offset of the data
  106147. * @param byteLength the byte length of the data
  106148. */
  106149. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106150. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106151. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106152. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106153. _releaseTexture(texture: InternalTexture): void;
  106154. /**
  106155. * @hidden
  106156. * Rescales a texture
  106157. * @param source input texutre
  106158. * @param destination destination texture
  106159. * @param scene scene to use to render the resize
  106160. * @param internalFormat format to use when resizing
  106161. * @param onComplete callback to be called when resize has completed
  106162. */
  106163. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106164. /**
  106165. * Gets the current framerate
  106166. * @returns a number representing the framerate
  106167. */
  106168. getFps(): number;
  106169. /**
  106170. * Gets the time spent between current and previous frame
  106171. * @returns a number representing the delta time in ms
  106172. */
  106173. getDeltaTime(): number;
  106174. private _measureFps;
  106175. /** @hidden */
  106176. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106177. /**
  106178. * Update a dynamic index buffer
  106179. * @param indexBuffer defines the target index buffer
  106180. * @param indices defines the data to update
  106181. * @param offset defines the offset in the target index buffer where update should start
  106182. */
  106183. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106184. /**
  106185. * Updates the sample count of a render target texture
  106186. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106187. * @param texture defines the texture to update
  106188. * @param samples defines the sample count to set
  106189. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106190. */
  106191. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106192. /**
  106193. * Updates a depth texture Comparison Mode and Function.
  106194. * If the comparison Function is equal to 0, the mode will be set to none.
  106195. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106196. * @param texture The texture to set the comparison function for
  106197. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106198. */
  106199. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106200. /**
  106201. * Creates a webGL buffer to use with instanciation
  106202. * @param capacity defines the size of the buffer
  106203. * @returns the webGL buffer
  106204. */
  106205. createInstancesBuffer(capacity: number): DataBuffer;
  106206. /**
  106207. * Delete a webGL buffer used with instanciation
  106208. * @param buffer defines the webGL buffer to delete
  106209. */
  106210. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  106211. /** @hidden */
  106212. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  106213. dispose(): void;
  106214. private _disableTouchAction;
  106215. /**
  106216. * Display the loading screen
  106217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106218. */
  106219. displayLoadingUI(): void;
  106220. /**
  106221. * Hide the loading screen
  106222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106223. */
  106224. hideLoadingUI(): void;
  106225. /**
  106226. * Gets the current loading screen object
  106227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106228. */
  106229. get loadingScreen(): ILoadingScreen;
  106230. /**
  106231. * Sets the current loading screen object
  106232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106233. */
  106234. set loadingScreen(loadingScreen: ILoadingScreen);
  106235. /**
  106236. * Sets the current loading screen text
  106237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106238. */
  106239. set loadingUIText(text: string);
  106240. /**
  106241. * Sets the current loading screen background color
  106242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106243. */
  106244. set loadingUIBackgroundColor(color: string);
  106245. /** Pointerlock and fullscreen */
  106246. /**
  106247. * Ask the browser to promote the current element to pointerlock mode
  106248. * @param element defines the DOM element to promote
  106249. */
  106250. static _RequestPointerlock(element: HTMLElement): void;
  106251. /**
  106252. * Asks the browser to exit pointerlock mode
  106253. */
  106254. static _ExitPointerlock(): void;
  106255. /**
  106256. * Ask the browser to promote the current element to fullscreen rendering mode
  106257. * @param element defines the DOM element to promote
  106258. */
  106259. static _RequestFullscreen(element: HTMLElement): void;
  106260. /**
  106261. * Asks the browser to exit fullscreen mode
  106262. */
  106263. static _ExitFullscreen(): void;
  106264. }
  106265. }
  106266. declare module BABYLON {
  106267. /**
  106268. * The engine store class is responsible to hold all the instances of Engine and Scene created
  106269. * during the life time of the application.
  106270. */
  106271. export class EngineStore {
  106272. /** Gets the list of created engines */
  106273. static Instances: Engine[];
  106274. /** @hidden */
  106275. static _LastCreatedScene: Nullable<Scene>;
  106276. /**
  106277. * Gets the latest created engine
  106278. */
  106279. static get LastCreatedEngine(): Nullable<Engine>;
  106280. /**
  106281. * Gets the latest created scene
  106282. */
  106283. static get LastCreatedScene(): Nullable<Scene>;
  106284. /**
  106285. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106286. * @ignorenaming
  106287. */
  106288. static UseFallbackTexture: boolean;
  106289. /**
  106290. * Texture content used if a texture cannot loaded
  106291. * @ignorenaming
  106292. */
  106293. static FallbackTexture: string;
  106294. }
  106295. }
  106296. declare module BABYLON {
  106297. /**
  106298. * Helper class that provides a small promise polyfill
  106299. */
  106300. export class PromisePolyfill {
  106301. /**
  106302. * Static function used to check if the polyfill is required
  106303. * If this is the case then the function will inject the polyfill to window.Promise
  106304. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  106305. */
  106306. static Apply(force?: boolean): void;
  106307. }
  106308. }
  106309. declare module BABYLON {
  106310. /**
  106311. * Interface for screenshot methods with describe argument called `size` as object with options
  106312. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  106313. */
  106314. export interface IScreenshotSize {
  106315. /**
  106316. * number in pixels for canvas height
  106317. */
  106318. height?: number;
  106319. /**
  106320. * multiplier allowing render at a higher or lower resolution
  106321. * If value is defined then height and width will be ignored and taken from camera
  106322. */
  106323. precision?: number;
  106324. /**
  106325. * number in pixels for canvas width
  106326. */
  106327. width?: number;
  106328. }
  106329. }
  106330. declare module BABYLON {
  106331. interface IColor4Like {
  106332. r: float;
  106333. g: float;
  106334. b: float;
  106335. a: float;
  106336. }
  106337. /**
  106338. * Class containing a set of static utilities functions
  106339. */
  106340. export class Tools {
  106341. /**
  106342. * Gets or sets the base URL to use to load assets
  106343. */
  106344. static get BaseUrl(): string;
  106345. static set BaseUrl(value: string);
  106346. /**
  106347. * Enable/Disable Custom HTTP Request Headers globally.
  106348. * default = false
  106349. * @see CustomRequestHeaders
  106350. */
  106351. static UseCustomRequestHeaders: boolean;
  106352. /**
  106353. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106354. * i.e. when loading files, where the server/service expects an Authorization header
  106355. */
  106356. static CustomRequestHeaders: {
  106357. [key: string]: string;
  106358. };
  106359. /**
  106360. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106361. */
  106362. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  106363. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  106364. /**
  106365. * Default behaviour for cors in the application.
  106366. * It can be a string if the expected behavior is identical in the entire app.
  106367. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106368. */
  106369. static CorsBehavior: string | ((url: string | string[]) => string);
  106370. /**
  106371. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106372. * @ignorenaming
  106373. */
  106374. static get UseFallbackTexture(): boolean;
  106375. static set UseFallbackTexture(value: boolean);
  106376. /**
  106377. * Use this object to register external classes like custom textures or material
  106378. * to allow the laoders to instantiate them
  106379. */
  106380. static get RegisteredExternalClasses(): {
  106381. [key: string]: Object;
  106382. };
  106383. static set RegisteredExternalClasses(classes: {
  106384. [key: string]: Object;
  106385. });
  106386. /**
  106387. * Texture content used if a texture cannot loaded
  106388. * @ignorenaming
  106389. */
  106390. static get fallbackTexture(): string;
  106391. static set fallbackTexture(value: string);
  106392. /**
  106393. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  106394. * @param u defines the coordinate on X axis
  106395. * @param v defines the coordinate on Y axis
  106396. * @param width defines the width of the source data
  106397. * @param height defines the height of the source data
  106398. * @param pixels defines the source byte array
  106399. * @param color defines the output color
  106400. */
  106401. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  106402. /**
  106403. * Interpolates between a and b via alpha
  106404. * @param a The lower value (returned when alpha = 0)
  106405. * @param b The upper value (returned when alpha = 1)
  106406. * @param alpha The interpolation-factor
  106407. * @return The mixed value
  106408. */
  106409. static Mix(a: number, b: number, alpha: number): number;
  106410. /**
  106411. * Tries to instantiate a new object from a given class name
  106412. * @param className defines the class name to instantiate
  106413. * @returns the new object or null if the system was not able to do the instantiation
  106414. */
  106415. static Instantiate(className: string): any;
  106416. /**
  106417. * Provides a slice function that will work even on IE
  106418. * @param data defines the array to slice
  106419. * @param start defines the start of the data (optional)
  106420. * @param end defines the end of the data (optional)
  106421. * @returns the new sliced array
  106422. */
  106423. static Slice<T>(data: T, start?: number, end?: number): T;
  106424. /**
  106425. * Polyfill for setImmediate
  106426. * @param action defines the action to execute after the current execution block
  106427. */
  106428. static SetImmediate(action: () => void): void;
  106429. /**
  106430. * Function indicating if a number is an exponent of 2
  106431. * @param value defines the value to test
  106432. * @returns true if the value is an exponent of 2
  106433. */
  106434. static IsExponentOfTwo(value: number): boolean;
  106435. private static _tmpFloatArray;
  106436. /**
  106437. * Returns the nearest 32-bit single precision float representation of a Number
  106438. * @param value A Number. If the parameter is of a different type, it will get converted
  106439. * to a number or to NaN if it cannot be converted
  106440. * @returns number
  106441. */
  106442. static FloatRound(value: number): number;
  106443. /**
  106444. * Extracts the filename from a path
  106445. * @param path defines the path to use
  106446. * @returns the filename
  106447. */
  106448. static GetFilename(path: string): string;
  106449. /**
  106450. * Extracts the "folder" part of a path (everything before the filename).
  106451. * @param uri The URI to extract the info from
  106452. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  106453. * @returns The "folder" part of the path
  106454. */
  106455. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  106456. /**
  106457. * Extracts text content from a DOM element hierarchy
  106458. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106459. */
  106460. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  106461. /**
  106462. * Convert an angle in radians to degrees
  106463. * @param angle defines the angle to convert
  106464. * @returns the angle in degrees
  106465. */
  106466. static ToDegrees(angle: number): number;
  106467. /**
  106468. * Convert an angle in degrees to radians
  106469. * @param angle defines the angle to convert
  106470. * @returns the angle in radians
  106471. */
  106472. static ToRadians(angle: number): number;
  106473. /**
  106474. * Returns an array if obj is not an array
  106475. * @param obj defines the object to evaluate as an array
  106476. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  106477. * @returns either obj directly if obj is an array or a new array containing obj
  106478. */
  106479. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  106480. /**
  106481. * Gets the pointer prefix to use
  106482. * @returns "pointer" if touch is enabled. Else returns "mouse"
  106483. */
  106484. static GetPointerPrefix(): string;
  106485. /**
  106486. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  106487. * @param url define the url we are trying
  106488. * @param element define the dom element where to configure the cors policy
  106489. */
  106490. static SetCorsBehavior(url: string | string[], element: {
  106491. crossOrigin: string | null;
  106492. }): void;
  106493. /**
  106494. * Removes unwanted characters from an url
  106495. * @param url defines the url to clean
  106496. * @returns the cleaned url
  106497. */
  106498. static CleanUrl(url: string): string;
  106499. /**
  106500. * Gets or sets a function used to pre-process url before using them to load assets
  106501. */
  106502. static get PreprocessUrl(): (url: string) => string;
  106503. static set PreprocessUrl(processor: (url: string) => string);
  106504. /**
  106505. * Loads an image as an HTMLImageElement.
  106506. * @param input url string, ArrayBuffer, or Blob to load
  106507. * @param onLoad callback called when the image successfully loads
  106508. * @param onError callback called when the image fails to load
  106509. * @param offlineProvider offline provider for caching
  106510. * @param mimeType optional mime type
  106511. * @returns the HTMLImageElement of the loaded image
  106512. */
  106513. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106514. /**
  106515. * Loads a file from a url
  106516. * @param url url string, ArrayBuffer, or Blob to load
  106517. * @param onSuccess callback called when the file successfully loads
  106518. * @param onProgress callback called while file is loading (if the server supports this mode)
  106519. * @param offlineProvider defines the offline provider for caching
  106520. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106521. * @param onError callback called when the file fails to load
  106522. * @returns a file request object
  106523. */
  106524. 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;
  106525. /**
  106526. * Loads a file from a url
  106527. * @param url the file url to load
  106528. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  106529. */
  106530. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  106531. /**
  106532. * Load a script (identified by an url). When the url returns, the
  106533. * content of this file is added into a new script element, attached to the DOM (body element)
  106534. * @param scriptUrl defines the url of the script to laod
  106535. * @param onSuccess defines the callback called when the script is loaded
  106536. * @param onError defines the callback to call if an error occurs
  106537. * @param scriptId defines the id of the script element
  106538. */
  106539. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  106540. /**
  106541. * Load an asynchronous script (identified by an url). When the url returns, the
  106542. * content of this file is added into a new script element, attached to the DOM (body element)
  106543. * @param scriptUrl defines the url of the script to laod
  106544. * @param scriptId defines the id of the script element
  106545. * @returns a promise request object
  106546. */
  106547. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  106548. /**
  106549. * Loads a file from a blob
  106550. * @param fileToLoad defines the blob to use
  106551. * @param callback defines the callback to call when data is loaded
  106552. * @param progressCallback defines the callback to call during loading process
  106553. * @returns a file request object
  106554. */
  106555. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  106556. /**
  106557. * Reads a file from a File object
  106558. * @param file defines the file to load
  106559. * @param onSuccess defines the callback to call when data is loaded
  106560. * @param onProgress defines the callback to call during loading process
  106561. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  106562. * @param onError defines the callback to call when an error occurs
  106563. * @returns a file request object
  106564. */
  106565. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106566. /**
  106567. * Creates a data url from a given string content
  106568. * @param content defines the content to convert
  106569. * @returns the new data url link
  106570. */
  106571. static FileAsURL(content: string): string;
  106572. /**
  106573. * Format the given number to a specific decimal format
  106574. * @param value defines the number to format
  106575. * @param decimals defines the number of decimals to use
  106576. * @returns the formatted string
  106577. */
  106578. static Format(value: number, decimals?: number): string;
  106579. /**
  106580. * Tries to copy an object by duplicating every property
  106581. * @param source defines the source object
  106582. * @param destination defines the target object
  106583. * @param doNotCopyList defines a list of properties to avoid
  106584. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  106585. */
  106586. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  106587. /**
  106588. * Gets a boolean indicating if the given object has no own property
  106589. * @param obj defines the object to test
  106590. * @returns true if object has no own property
  106591. */
  106592. static IsEmpty(obj: any): boolean;
  106593. /**
  106594. * Function used to register events at window level
  106595. * @param windowElement defines the Window object to use
  106596. * @param events defines the events to register
  106597. */
  106598. static RegisterTopRootEvents(windowElement: Window, events: {
  106599. name: string;
  106600. handler: Nullable<(e: FocusEvent) => any>;
  106601. }[]): void;
  106602. /**
  106603. * Function used to unregister events from window level
  106604. * @param windowElement defines the Window object to use
  106605. * @param events defines the events to unregister
  106606. */
  106607. static UnregisterTopRootEvents(windowElement: Window, events: {
  106608. name: string;
  106609. handler: Nullable<(e: FocusEvent) => any>;
  106610. }[]): void;
  106611. /**
  106612. * @ignore
  106613. */
  106614. static _ScreenshotCanvas: HTMLCanvasElement;
  106615. /**
  106616. * Dumps the current bound framebuffer
  106617. * @param width defines the rendering width
  106618. * @param height defines the rendering height
  106619. * @param engine defines the hosting engine
  106620. * @param successCallback defines the callback triggered once the data are available
  106621. * @param mimeType defines the mime type of the result
  106622. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  106623. */
  106624. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106625. /**
  106626. * Converts the canvas data to blob.
  106627. * This acts as a polyfill for browsers not supporting the to blob function.
  106628. * @param canvas Defines the canvas to extract the data from
  106629. * @param successCallback Defines the callback triggered once the data are available
  106630. * @param mimeType Defines the mime type of the result
  106631. */
  106632. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  106633. /**
  106634. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  106635. * @param successCallback defines the callback triggered once the data are available
  106636. * @param mimeType defines the mime type of the result
  106637. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  106638. */
  106639. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106640. /**
  106641. * Downloads a blob in the browser
  106642. * @param blob defines the blob to download
  106643. * @param fileName defines the name of the downloaded file
  106644. */
  106645. static Download(blob: Blob, fileName: string): void;
  106646. /**
  106647. * Captures a screenshot of the current rendering
  106648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106649. * @param engine defines the rendering engine
  106650. * @param camera defines the source camera
  106651. * @param size This parameter can be set to a single number or to an object with the
  106652. * following (optional) properties: precision, width, height. If a single number is passed,
  106653. * it will be used for both width and height. If an object is passed, the screenshot size
  106654. * will be derived from the parameters. The precision property is a multiplier allowing
  106655. * rendering at a higher or lower resolution
  106656. * @param successCallback defines the callback receives a single parameter which contains the
  106657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106658. * src parameter of an <img> to display it
  106659. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106660. * Check your browser for supported MIME types
  106661. */
  106662. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  106663. /**
  106664. * Captures a screenshot of the current rendering
  106665. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106666. * @param engine defines the rendering engine
  106667. * @param camera defines the source camera
  106668. * @param size This parameter can be set to a single number or to an object with the
  106669. * following (optional) properties: precision, width, height. If a single number is passed,
  106670. * it will be used for both width and height. If an object is passed, the screenshot size
  106671. * will be derived from the parameters. The precision property is a multiplier allowing
  106672. * rendering at a higher or lower resolution
  106673. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106674. * Check your browser for supported MIME types
  106675. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106676. * to the src parameter of an <img> to display it
  106677. */
  106678. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  106679. /**
  106680. * Generates an image screenshot from the specified camera.
  106681. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106682. * @param engine The engine to use for rendering
  106683. * @param camera The camera to use for rendering
  106684. * @param size This parameter can be set to a single number or to an object with the
  106685. * following (optional) properties: precision, width, height. If a single number is passed,
  106686. * it will be used for both width and height. If an object is passed, the screenshot size
  106687. * will be derived from the parameters. The precision property is a multiplier allowing
  106688. * rendering at a higher or lower resolution
  106689. * @param successCallback The callback receives a single parameter which contains the
  106690. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106691. * src parameter of an <img> to display it
  106692. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106693. * Check your browser for supported MIME types
  106694. * @param samples Texture samples (default: 1)
  106695. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106696. * @param fileName A name for for the downloaded file.
  106697. */
  106698. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  106699. /**
  106700. * Generates an image screenshot from the specified camera.
  106701. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106702. * @param engine The engine to use for rendering
  106703. * @param camera The camera to use for rendering
  106704. * @param size This parameter can be set to a single number or to an object with the
  106705. * following (optional) properties: precision, width, height. If a single number is passed,
  106706. * it will be used for both width and height. If an object is passed, the screenshot size
  106707. * will be derived from the parameters. The precision property is a multiplier allowing
  106708. * rendering at a higher or lower resolution
  106709. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106710. * Check your browser for supported MIME types
  106711. * @param samples Texture samples (default: 1)
  106712. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106713. * @param fileName A name for for the downloaded file.
  106714. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106715. * to the src parameter of an <img> to display it
  106716. */
  106717. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  106718. /**
  106719. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106720. * Be aware Math.random() could cause collisions, but:
  106721. * "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"
  106722. * @returns a pseudo random id
  106723. */
  106724. static RandomId(): string;
  106725. /**
  106726. * Test if the given uri is a base64 string
  106727. * @param uri The uri to test
  106728. * @return True if the uri is a base64 string or false otherwise
  106729. */
  106730. static IsBase64(uri: string): boolean;
  106731. /**
  106732. * Decode the given base64 uri.
  106733. * @param uri The uri to decode
  106734. * @return The decoded base64 data.
  106735. */
  106736. static DecodeBase64(uri: string): ArrayBuffer;
  106737. /**
  106738. * Gets the absolute url.
  106739. * @param url the input url
  106740. * @return the absolute url
  106741. */
  106742. static GetAbsoluteUrl(url: string): string;
  106743. /**
  106744. * No log
  106745. */
  106746. static readonly NoneLogLevel: number;
  106747. /**
  106748. * Only message logs
  106749. */
  106750. static readonly MessageLogLevel: number;
  106751. /**
  106752. * Only warning logs
  106753. */
  106754. static readonly WarningLogLevel: number;
  106755. /**
  106756. * Only error logs
  106757. */
  106758. static readonly ErrorLogLevel: number;
  106759. /**
  106760. * All logs
  106761. */
  106762. static readonly AllLogLevel: number;
  106763. /**
  106764. * Gets a value indicating the number of loading errors
  106765. * @ignorenaming
  106766. */
  106767. static get errorsCount(): number;
  106768. /**
  106769. * Callback called when a new log is added
  106770. */
  106771. static OnNewCacheEntry: (entry: string) => void;
  106772. /**
  106773. * Log a message to the console
  106774. * @param message defines the message to log
  106775. */
  106776. static Log(message: string): void;
  106777. /**
  106778. * Write a warning message to the console
  106779. * @param message defines the message to log
  106780. */
  106781. static Warn(message: string): void;
  106782. /**
  106783. * Write an error message to the console
  106784. * @param message defines the message to log
  106785. */
  106786. static Error(message: string): void;
  106787. /**
  106788. * Gets current log cache (list of logs)
  106789. */
  106790. static get LogCache(): string;
  106791. /**
  106792. * Clears the log cache
  106793. */
  106794. static ClearLogCache(): void;
  106795. /**
  106796. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  106797. */
  106798. static set LogLevels(level: number);
  106799. /**
  106800. * Checks if the window object exists
  106801. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  106802. */
  106803. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  106804. /**
  106805. * No performance log
  106806. */
  106807. static readonly PerformanceNoneLogLevel: number;
  106808. /**
  106809. * Use user marks to log performance
  106810. */
  106811. static readonly PerformanceUserMarkLogLevel: number;
  106812. /**
  106813. * Log performance to the console
  106814. */
  106815. static readonly PerformanceConsoleLogLevel: number;
  106816. private static _performance;
  106817. /**
  106818. * Sets the current performance log level
  106819. */
  106820. static set PerformanceLogLevel(level: number);
  106821. private static _StartPerformanceCounterDisabled;
  106822. private static _EndPerformanceCounterDisabled;
  106823. private static _StartUserMark;
  106824. private static _EndUserMark;
  106825. private static _StartPerformanceConsole;
  106826. private static _EndPerformanceConsole;
  106827. /**
  106828. * Starts a performance counter
  106829. */
  106830. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106831. /**
  106832. * Ends a specific performance coutner
  106833. */
  106834. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106835. /**
  106836. * Gets either window.performance.now() if supported or Date.now() else
  106837. */
  106838. static get Now(): number;
  106839. /**
  106840. * This method will return the name of the class used to create the instance of the given object.
  106841. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  106842. * @param object the object to get the class name from
  106843. * @param isType defines if the object is actually a type
  106844. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  106845. */
  106846. static GetClassName(object: any, isType?: boolean): string;
  106847. /**
  106848. * Gets the first element of an array satisfying a given predicate
  106849. * @param array defines the array to browse
  106850. * @param predicate defines the predicate to use
  106851. * @returns null if not found or the element
  106852. */
  106853. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  106854. /**
  106855. * This method will return the name of the full name of the class, including its owning module (if any).
  106856. * 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).
  106857. * @param object the object to get the class name from
  106858. * @param isType defines if the object is actually a type
  106859. * @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.
  106860. * @ignorenaming
  106861. */
  106862. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  106863. /**
  106864. * Returns a promise that resolves after the given amount of time.
  106865. * @param delay Number of milliseconds to delay
  106866. * @returns Promise that resolves after the given amount of time
  106867. */
  106868. static DelayAsync(delay: number): Promise<void>;
  106869. /**
  106870. * Utility function to detect if the current user agent is Safari
  106871. * @returns whether or not the current user agent is safari
  106872. */
  106873. static IsSafari(): boolean;
  106874. }
  106875. /**
  106876. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  106877. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  106878. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  106879. * @param name The name of the class, case should be preserved
  106880. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  106881. */
  106882. export function className(name: string, module?: string): (target: Object) => void;
  106883. /**
  106884. * An implementation of a loop for asynchronous functions.
  106885. */
  106886. export class AsyncLoop {
  106887. /**
  106888. * Defines the number of iterations for the loop
  106889. */
  106890. iterations: number;
  106891. /**
  106892. * Defines the current index of the loop.
  106893. */
  106894. index: number;
  106895. private _done;
  106896. private _fn;
  106897. private _successCallback;
  106898. /**
  106899. * Constructor.
  106900. * @param iterations the number of iterations.
  106901. * @param func the function to run each iteration
  106902. * @param successCallback the callback that will be called upon succesful execution
  106903. * @param offset starting offset.
  106904. */
  106905. constructor(
  106906. /**
  106907. * Defines the number of iterations for the loop
  106908. */
  106909. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  106910. /**
  106911. * Execute the next iteration. Must be called after the last iteration was finished.
  106912. */
  106913. executeNext(): void;
  106914. /**
  106915. * Break the loop and run the success callback.
  106916. */
  106917. breakLoop(): void;
  106918. /**
  106919. * Create and run an async loop.
  106920. * @param iterations the number of iterations.
  106921. * @param fn the function to run each iteration
  106922. * @param successCallback the callback that will be called upon succesful execution
  106923. * @param offset starting offset.
  106924. * @returns the created async loop object
  106925. */
  106926. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  106927. /**
  106928. * A for-loop that will run a given number of iterations synchronous and the rest async.
  106929. * @param iterations total number of iterations
  106930. * @param syncedIterations number of synchronous iterations in each async iteration.
  106931. * @param fn the function to call each iteration.
  106932. * @param callback a success call back that will be called when iterating stops.
  106933. * @param breakFunction a break condition (optional)
  106934. * @param timeout timeout settings for the setTimeout function. default - 0.
  106935. * @returns the created async loop object
  106936. */
  106937. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  106938. }
  106939. }
  106940. declare module BABYLON {
  106941. /**
  106942. * This class implement a typical dictionary using a string as key and the generic type T as value.
  106943. * The underlying implementation relies on an associative array to ensure the best performances.
  106944. * The value can be anything including 'null' but except 'undefined'
  106945. */
  106946. export class StringDictionary<T> {
  106947. /**
  106948. * This will clear this dictionary and copy the content from the 'source' one.
  106949. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  106950. * @param source the dictionary to take the content from and copy to this dictionary
  106951. */
  106952. copyFrom(source: StringDictionary<T>): void;
  106953. /**
  106954. * Get a value based from its key
  106955. * @param key the given key to get the matching value from
  106956. * @return the value if found, otherwise undefined is returned
  106957. */
  106958. get(key: string): T | undefined;
  106959. /**
  106960. * Get a value from its key or add it if it doesn't exist.
  106961. * This method will ensure you that a given key/data will be present in the dictionary.
  106962. * @param key the given key to get the matching value from
  106963. * @param factory the factory that will create the value if the key is not present in the dictionary.
  106964. * The factory will only be invoked if there's no data for the given key.
  106965. * @return the value corresponding to the key.
  106966. */
  106967. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  106968. /**
  106969. * Get a value from its key if present in the dictionary otherwise add it
  106970. * @param key the key to get the value from
  106971. * @param val if there's no such key/value pair in the dictionary add it with this value
  106972. * @return the value corresponding to the key
  106973. */
  106974. getOrAdd(key: string, val: T): T;
  106975. /**
  106976. * Check if there's a given key in the dictionary
  106977. * @param key the key to check for
  106978. * @return true if the key is present, false otherwise
  106979. */
  106980. contains(key: string): boolean;
  106981. /**
  106982. * Add a new key and its corresponding value
  106983. * @param key the key to add
  106984. * @param value the value corresponding to the key
  106985. * @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
  106986. */
  106987. add(key: string, value: T): boolean;
  106988. /**
  106989. * Update a specific value associated to a key
  106990. * @param key defines the key to use
  106991. * @param value defines the value to store
  106992. * @returns true if the value was updated (or false if the key was not found)
  106993. */
  106994. set(key: string, value: T): boolean;
  106995. /**
  106996. * Get the element of the given key and remove it from the dictionary
  106997. * @param key defines the key to search
  106998. * @returns the value associated with the key or null if not found
  106999. */
  107000. getAndRemove(key: string): Nullable<T>;
  107001. /**
  107002. * Remove a key/value from the dictionary.
  107003. * @param key the key to remove
  107004. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107005. */
  107006. remove(key: string): boolean;
  107007. /**
  107008. * Clear the whole content of the dictionary
  107009. */
  107010. clear(): void;
  107011. /**
  107012. * Gets the current count
  107013. */
  107014. get count(): number;
  107015. /**
  107016. * Execute a callback on each key/val of the dictionary.
  107017. * Note that you can remove any element in this dictionary in the callback implementation
  107018. * @param callback the callback to execute on a given key/value pair
  107019. */
  107020. forEach(callback: (key: string, val: T) => void): void;
  107021. /**
  107022. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107023. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107024. * Note that you can remove any element in this dictionary in the callback implementation
  107025. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107026. * @returns the first item
  107027. */
  107028. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107029. private _count;
  107030. private _data;
  107031. }
  107032. }
  107033. declare module BABYLON {
  107034. /** @hidden */
  107035. export interface ICollisionCoordinator {
  107036. createCollider(): Collider;
  107037. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107038. init(scene: Scene): void;
  107039. }
  107040. /** @hidden */
  107041. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107042. private _scene;
  107043. private _scaledPosition;
  107044. private _scaledVelocity;
  107045. private _finalPosition;
  107046. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107047. createCollider(): Collider;
  107048. init(scene: Scene): void;
  107049. private _collideWithWorld;
  107050. }
  107051. }
  107052. declare module BABYLON {
  107053. /**
  107054. * Class used to manage all inputs for the scene.
  107055. */
  107056. export class InputManager {
  107057. /** The distance in pixel that you have to move to prevent some events */
  107058. static DragMovementThreshold: number;
  107059. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107060. static LongPressDelay: number;
  107061. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107062. static DoubleClickDelay: number;
  107063. /** If you need to check double click without raising a single click at first click, enable this flag */
  107064. static ExclusiveDoubleClickMode: boolean;
  107065. private _wheelEventName;
  107066. private _onPointerMove;
  107067. private _onPointerDown;
  107068. private _onPointerUp;
  107069. private _initClickEvent;
  107070. private _initActionManager;
  107071. private _delayedSimpleClick;
  107072. private _delayedSimpleClickTimeout;
  107073. private _previousDelayedSimpleClickTimeout;
  107074. private _meshPickProceed;
  107075. private _previousButtonPressed;
  107076. private _currentPickResult;
  107077. private _previousPickResult;
  107078. private _totalPointersPressed;
  107079. private _doubleClickOccured;
  107080. private _pointerOverMesh;
  107081. private _pickedDownMesh;
  107082. private _pickedUpMesh;
  107083. private _pointerX;
  107084. private _pointerY;
  107085. private _unTranslatedPointerX;
  107086. private _unTranslatedPointerY;
  107087. private _startingPointerPosition;
  107088. private _previousStartingPointerPosition;
  107089. private _startingPointerTime;
  107090. private _previousStartingPointerTime;
  107091. private _pointerCaptures;
  107092. private _onKeyDown;
  107093. private _onKeyUp;
  107094. private _onCanvasFocusObserver;
  107095. private _onCanvasBlurObserver;
  107096. private _scene;
  107097. /**
  107098. * Creates a new InputManager
  107099. * @param scene defines the hosting scene
  107100. */
  107101. constructor(scene: Scene);
  107102. /**
  107103. * Gets the mesh that is currently under the pointer
  107104. */
  107105. get meshUnderPointer(): Nullable<AbstractMesh>;
  107106. /**
  107107. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107108. */
  107109. get unTranslatedPointer(): Vector2;
  107110. /**
  107111. * Gets or sets the current on-screen X position of the pointer
  107112. */
  107113. get pointerX(): number;
  107114. set pointerX(value: number);
  107115. /**
  107116. * Gets or sets the current on-screen Y position of the pointer
  107117. */
  107118. get pointerY(): number;
  107119. set pointerY(value: number);
  107120. private _updatePointerPosition;
  107121. private _processPointerMove;
  107122. private _setRayOnPointerInfo;
  107123. private _checkPrePointerObservable;
  107124. /**
  107125. * Use this method to simulate a pointer move on a mesh
  107126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107129. */
  107130. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107131. /**
  107132. * Use this method to simulate a pointer down on a mesh
  107133. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107134. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107135. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107136. */
  107137. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107138. private _processPointerDown;
  107139. /** @hidden */
  107140. _isPointerSwiping(): boolean;
  107141. /**
  107142. * Use this method to simulate a pointer up on a mesh
  107143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107146. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107147. */
  107148. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107149. private _processPointerUp;
  107150. /**
  107151. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107152. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107153. * @returns true if the pointer was captured
  107154. */
  107155. isPointerCaptured(pointerId?: number): boolean;
  107156. /**
  107157. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107158. * @param attachUp defines if you want to attach events to pointerup
  107159. * @param attachDown defines if you want to attach events to pointerdown
  107160. * @param attachMove defines if you want to attach events to pointermove
  107161. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107162. */
  107163. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107164. /**
  107165. * Detaches all event handlers
  107166. */
  107167. detachControl(): void;
  107168. /**
  107169. * Force the value of meshUnderPointer
  107170. * @param mesh defines the mesh to use
  107171. */
  107172. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107173. /**
  107174. * Gets the mesh under the pointer
  107175. * @returns a Mesh or null if no mesh is under the pointer
  107176. */
  107177. getPointerOverMesh(): Nullable<AbstractMesh>;
  107178. }
  107179. }
  107180. declare module BABYLON {
  107181. /**
  107182. * Helper class used to generate session unique ID
  107183. */
  107184. export class UniqueIdGenerator {
  107185. private static _UniqueIdCounter;
  107186. /**
  107187. * Gets an unique (relatively to the current scene) Id
  107188. */
  107189. static get UniqueId(): number;
  107190. }
  107191. }
  107192. declare module BABYLON {
  107193. /**
  107194. * This class defines the direct association between an animation and a target
  107195. */
  107196. export class TargetedAnimation {
  107197. /**
  107198. * Animation to perform
  107199. */
  107200. animation: Animation;
  107201. /**
  107202. * Target to animate
  107203. */
  107204. target: any;
  107205. /**
  107206. * Serialize the object
  107207. * @returns the JSON object representing the current entity
  107208. */
  107209. serialize(): any;
  107210. }
  107211. /**
  107212. * Use this class to create coordinated animations on multiple targets
  107213. */
  107214. export class AnimationGroup implements IDisposable {
  107215. /** The name of the animation group */
  107216. name: string;
  107217. private _scene;
  107218. private _targetedAnimations;
  107219. private _animatables;
  107220. private _from;
  107221. private _to;
  107222. private _isStarted;
  107223. private _isPaused;
  107224. private _speedRatio;
  107225. private _loopAnimation;
  107226. /**
  107227. * Gets or sets the unique id of the node
  107228. */
  107229. uniqueId: number;
  107230. /**
  107231. * This observable will notify when one animation have ended
  107232. */
  107233. onAnimationEndObservable: Observable<TargetedAnimation>;
  107234. /**
  107235. * Observer raised when one animation loops
  107236. */
  107237. onAnimationLoopObservable: Observable<TargetedAnimation>;
  107238. /**
  107239. * Observer raised when all animations have looped
  107240. */
  107241. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  107242. /**
  107243. * This observable will notify when all animations have ended.
  107244. */
  107245. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  107246. /**
  107247. * This observable will notify when all animations have paused.
  107248. */
  107249. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  107250. /**
  107251. * This observable will notify when all animations are playing.
  107252. */
  107253. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  107254. /**
  107255. * Gets the first frame
  107256. */
  107257. get from(): number;
  107258. /**
  107259. * Gets the last frame
  107260. */
  107261. get to(): number;
  107262. /**
  107263. * Define if the animations are started
  107264. */
  107265. get isStarted(): boolean;
  107266. /**
  107267. * Gets a value indicating that the current group is playing
  107268. */
  107269. get isPlaying(): boolean;
  107270. /**
  107271. * Gets or sets the speed ratio to use for all animations
  107272. */
  107273. get speedRatio(): number;
  107274. /**
  107275. * Gets or sets the speed ratio to use for all animations
  107276. */
  107277. set speedRatio(value: number);
  107278. /**
  107279. * Gets or sets if all animations should loop or not
  107280. */
  107281. get loopAnimation(): boolean;
  107282. set loopAnimation(value: boolean);
  107283. /**
  107284. * Gets the targeted animations for this animation group
  107285. */
  107286. get targetedAnimations(): Array<TargetedAnimation>;
  107287. /**
  107288. * returning the list of animatables controlled by this animation group.
  107289. */
  107290. get animatables(): Array<Animatable>;
  107291. /**
  107292. * Instantiates a new Animation Group.
  107293. * This helps managing several animations at once.
  107294. * @see http://doc.babylonjs.com/how_to/group
  107295. * @param name Defines the name of the group
  107296. * @param scene Defines the scene the group belongs to
  107297. */
  107298. constructor(
  107299. /** The name of the animation group */
  107300. name: string, scene?: Nullable<Scene>);
  107301. /**
  107302. * Add an animation (with its target) in the group
  107303. * @param animation defines the animation we want to add
  107304. * @param target defines the target of the animation
  107305. * @returns the TargetedAnimation object
  107306. */
  107307. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  107308. /**
  107309. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  107310. * It can add constant keys at begin or end
  107311. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  107312. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  107313. * @returns the animation group
  107314. */
  107315. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  107316. private _animationLoopCount;
  107317. private _animationLoopFlags;
  107318. private _processLoop;
  107319. /**
  107320. * Start all animations on given targets
  107321. * @param loop defines if animations must loop
  107322. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  107323. * @param from defines the from key (optional)
  107324. * @param to defines the to key (optional)
  107325. * @returns the current animation group
  107326. */
  107327. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  107328. /**
  107329. * Pause all animations
  107330. * @returns the animation group
  107331. */
  107332. pause(): AnimationGroup;
  107333. /**
  107334. * Play all animations to initial state
  107335. * This function will start() the animations if they were not started or will restart() them if they were paused
  107336. * @param loop defines if animations must loop
  107337. * @returns the animation group
  107338. */
  107339. play(loop?: boolean): AnimationGroup;
  107340. /**
  107341. * Reset all animations to initial state
  107342. * @returns the animation group
  107343. */
  107344. reset(): AnimationGroup;
  107345. /**
  107346. * Restart animations from key 0
  107347. * @returns the animation group
  107348. */
  107349. restart(): AnimationGroup;
  107350. /**
  107351. * Stop all animations
  107352. * @returns the animation group
  107353. */
  107354. stop(): AnimationGroup;
  107355. /**
  107356. * Set animation weight for all animatables
  107357. * @param weight defines the weight to use
  107358. * @return the animationGroup
  107359. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107360. */
  107361. setWeightForAllAnimatables(weight: number): AnimationGroup;
  107362. /**
  107363. * Synchronize and normalize all animatables with a source animatable
  107364. * @param root defines the root animatable to synchronize with
  107365. * @return the animationGroup
  107366. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107367. */
  107368. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  107369. /**
  107370. * Goes to a specific frame in this animation group
  107371. * @param frame the frame number to go to
  107372. * @return the animationGroup
  107373. */
  107374. goToFrame(frame: number): AnimationGroup;
  107375. /**
  107376. * Dispose all associated resources
  107377. */
  107378. dispose(): void;
  107379. private _checkAnimationGroupEnded;
  107380. /**
  107381. * Clone the current animation group and returns a copy
  107382. * @param newName defines the name of the new group
  107383. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  107384. * @returns the new aniamtion group
  107385. */
  107386. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  107387. /**
  107388. * Serializes the animationGroup to an object
  107389. * @returns Serialized object
  107390. */
  107391. serialize(): any;
  107392. /**
  107393. * Returns a new AnimationGroup object parsed from the source provided.
  107394. * @param parsedAnimationGroup defines the source
  107395. * @param scene defines the scene that will receive the animationGroup
  107396. * @returns a new AnimationGroup
  107397. */
  107398. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  107399. /**
  107400. * Returns the string "AnimationGroup"
  107401. * @returns "AnimationGroup"
  107402. */
  107403. getClassName(): string;
  107404. /**
  107405. * Creates a detailled string about the object
  107406. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  107407. * @returns a string representing the object
  107408. */
  107409. toString(fullDetails?: boolean): string;
  107410. }
  107411. }
  107412. declare module BABYLON {
  107413. /**
  107414. * Define an interface for all classes that will hold resources
  107415. */
  107416. export interface IDisposable {
  107417. /**
  107418. * Releases all held resources
  107419. */
  107420. dispose(): void;
  107421. }
  107422. /** Interface defining initialization parameters for Scene class */
  107423. export interface SceneOptions {
  107424. /**
  107425. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  107426. * It will improve performance when the number of geometries becomes important.
  107427. */
  107428. useGeometryUniqueIdsMap?: boolean;
  107429. /**
  107430. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  107431. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107432. */
  107433. useMaterialMeshMap?: boolean;
  107434. /**
  107435. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  107436. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107437. */
  107438. useClonedMeshMap?: boolean;
  107439. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  107440. virtual?: boolean;
  107441. }
  107442. /**
  107443. * Represents a scene to be rendered by the engine.
  107444. * @see http://doc.babylonjs.com/features/scene
  107445. */
  107446. export class Scene extends AbstractScene implements IAnimatable {
  107447. /** The fog is deactivated */
  107448. static readonly FOGMODE_NONE: number;
  107449. /** The fog density is following an exponential function */
  107450. static readonly FOGMODE_EXP: number;
  107451. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107452. static readonly FOGMODE_EXP2: number;
  107453. /** The fog density is following a linear function. */
  107454. static readonly FOGMODE_LINEAR: number;
  107455. /**
  107456. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  107457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107458. */
  107459. static MinDeltaTime: number;
  107460. /**
  107461. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  107462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107463. */
  107464. static MaxDeltaTime: number;
  107465. /**
  107466. * Factory used to create the default material.
  107467. * @param name The name of the material to create
  107468. * @param scene The scene to create the material for
  107469. * @returns The default material
  107470. */
  107471. static DefaultMaterialFactory(scene: Scene): Material;
  107472. /**
  107473. * Factory used to create the a collision coordinator.
  107474. * @returns The collision coordinator
  107475. */
  107476. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  107477. /** @hidden */
  107478. _inputManager: InputManager;
  107479. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  107480. cameraToUseForPointers: Nullable<Camera>;
  107481. /** @hidden */
  107482. readonly _isScene: boolean;
  107483. /**
  107484. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  107485. */
  107486. autoClear: boolean;
  107487. /**
  107488. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  107489. */
  107490. autoClearDepthAndStencil: boolean;
  107491. /**
  107492. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  107493. */
  107494. clearColor: Color4;
  107495. /**
  107496. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  107497. */
  107498. ambientColor: Color3;
  107499. /**
  107500. * This is use to store the default BRDF lookup for PBR materials in your scene.
  107501. * It should only be one of the following (if not the default embedded one):
  107502. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107503. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  107504. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107505. * The material properties need to be setup according to the type of texture in use.
  107506. */
  107507. environmentBRDFTexture: BaseTexture;
  107508. /** @hidden */
  107509. protected _environmentTexture: Nullable<BaseTexture>;
  107510. /**
  107511. * Texture used in all pbr material as the reflection texture.
  107512. * As in the majority of the scene they are the same (exception for multi room and so on),
  107513. * this is easier to reference from here than from all the materials.
  107514. */
  107515. get environmentTexture(): Nullable<BaseTexture>;
  107516. /**
  107517. * Texture used in all pbr material as the reflection texture.
  107518. * As in the majority of the scene they are the same (exception for multi room and so on),
  107519. * this is easier to set here than in all the materials.
  107520. */
  107521. set environmentTexture(value: Nullable<BaseTexture>);
  107522. /** @hidden */
  107523. protected _environmentIntensity: number;
  107524. /**
  107525. * Intensity of the environment in all pbr material.
  107526. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107527. * As in the majority of the scene they are the same (exception for multi room and so on),
  107528. * this is easier to reference from here than from all the materials.
  107529. */
  107530. get environmentIntensity(): number;
  107531. /**
  107532. * Intensity of the environment in all pbr material.
  107533. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107534. * As in the majority of the scene they are the same (exception for multi room and so on),
  107535. * this is easier to set here than in all the materials.
  107536. */
  107537. set environmentIntensity(value: number);
  107538. /** @hidden */
  107539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107540. /**
  107541. * Default image processing configuration used either in the rendering
  107542. * Forward main pass or through the imageProcessingPostProcess if present.
  107543. * As in the majority of the scene they are the same (exception for multi camera),
  107544. * this is easier to reference from here than from all the materials and post process.
  107545. *
  107546. * No setter as we it is a shared configuration, you can set the values instead.
  107547. */
  107548. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107549. private _forceWireframe;
  107550. /**
  107551. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  107552. */
  107553. set forceWireframe(value: boolean);
  107554. get forceWireframe(): boolean;
  107555. private _skipFrustumClipping;
  107556. /**
  107557. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  107558. */
  107559. set skipFrustumClipping(value: boolean);
  107560. get skipFrustumClipping(): boolean;
  107561. private _forcePointsCloud;
  107562. /**
  107563. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  107564. */
  107565. set forcePointsCloud(value: boolean);
  107566. get forcePointsCloud(): boolean;
  107567. /**
  107568. * Gets or sets the active clipplane 1
  107569. */
  107570. clipPlane: Nullable<Plane>;
  107571. /**
  107572. * Gets or sets the active clipplane 2
  107573. */
  107574. clipPlane2: Nullable<Plane>;
  107575. /**
  107576. * Gets or sets the active clipplane 3
  107577. */
  107578. clipPlane3: Nullable<Plane>;
  107579. /**
  107580. * Gets or sets the active clipplane 4
  107581. */
  107582. clipPlane4: Nullable<Plane>;
  107583. /**
  107584. * Gets or sets the active clipplane 5
  107585. */
  107586. clipPlane5: Nullable<Plane>;
  107587. /**
  107588. * Gets or sets the active clipplane 6
  107589. */
  107590. clipPlane6: Nullable<Plane>;
  107591. /**
  107592. * Gets or sets a boolean indicating if animations are enabled
  107593. */
  107594. animationsEnabled: boolean;
  107595. private _animationPropertiesOverride;
  107596. /**
  107597. * Gets or sets the animation properties override
  107598. */
  107599. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107600. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107601. /**
  107602. * Gets or sets a boolean indicating if a constant deltatime has to be used
  107603. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  107604. */
  107605. useConstantAnimationDeltaTime: boolean;
  107606. /**
  107607. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  107608. * Please note that it requires to run a ray cast through the scene on every frame
  107609. */
  107610. constantlyUpdateMeshUnderPointer: boolean;
  107611. /**
  107612. * Defines the HTML cursor to use when hovering over interactive elements
  107613. */
  107614. hoverCursor: string;
  107615. /**
  107616. * Defines the HTML default cursor to use (empty by default)
  107617. */
  107618. defaultCursor: string;
  107619. /**
  107620. * Defines wether cursors are handled by the scene.
  107621. */
  107622. doNotHandleCursors: boolean;
  107623. /**
  107624. * This is used to call preventDefault() on pointer down
  107625. * in order to block unwanted artifacts like system double clicks
  107626. */
  107627. preventDefaultOnPointerDown: boolean;
  107628. /**
  107629. * This is used to call preventDefault() on pointer up
  107630. * in order to block unwanted artifacts like system double clicks
  107631. */
  107632. preventDefaultOnPointerUp: boolean;
  107633. /**
  107634. * Gets or sets user defined metadata
  107635. */
  107636. metadata: any;
  107637. /**
  107638. * For internal use only. Please do not use.
  107639. */
  107640. reservedDataStore: any;
  107641. /**
  107642. * Gets the name of the plugin used to load this scene (null by default)
  107643. */
  107644. loadingPluginName: string;
  107645. /**
  107646. * Use this array to add regular expressions used to disable offline support for specific urls
  107647. */
  107648. disableOfflineSupportExceptionRules: RegExp[];
  107649. /**
  107650. * An event triggered when the scene is disposed.
  107651. */
  107652. onDisposeObservable: Observable<Scene>;
  107653. private _onDisposeObserver;
  107654. /** Sets a function to be executed when this scene is disposed. */
  107655. set onDispose(callback: () => void);
  107656. /**
  107657. * An event triggered before rendering the scene (right after animations and physics)
  107658. */
  107659. onBeforeRenderObservable: Observable<Scene>;
  107660. private _onBeforeRenderObserver;
  107661. /** Sets a function to be executed before rendering this scene */
  107662. set beforeRender(callback: Nullable<() => void>);
  107663. /**
  107664. * An event triggered after rendering the scene
  107665. */
  107666. onAfterRenderObservable: Observable<Scene>;
  107667. /**
  107668. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  107669. */
  107670. onAfterRenderCameraObservable: Observable<Camera>;
  107671. private _onAfterRenderObserver;
  107672. /** Sets a function to be executed after rendering this scene */
  107673. set afterRender(callback: Nullable<() => void>);
  107674. /**
  107675. * An event triggered before animating the scene
  107676. */
  107677. onBeforeAnimationsObservable: Observable<Scene>;
  107678. /**
  107679. * An event triggered after animations processing
  107680. */
  107681. onAfterAnimationsObservable: Observable<Scene>;
  107682. /**
  107683. * An event triggered before draw calls are ready to be sent
  107684. */
  107685. onBeforeDrawPhaseObservable: Observable<Scene>;
  107686. /**
  107687. * An event triggered after draw calls have been sent
  107688. */
  107689. onAfterDrawPhaseObservable: Observable<Scene>;
  107690. /**
  107691. * An event triggered when the scene is ready
  107692. */
  107693. onReadyObservable: Observable<Scene>;
  107694. /**
  107695. * An event triggered before rendering a camera
  107696. */
  107697. onBeforeCameraRenderObservable: Observable<Camera>;
  107698. private _onBeforeCameraRenderObserver;
  107699. /** Sets a function to be executed before rendering a camera*/
  107700. set beforeCameraRender(callback: () => void);
  107701. /**
  107702. * An event triggered after rendering a camera
  107703. */
  107704. onAfterCameraRenderObservable: Observable<Camera>;
  107705. private _onAfterCameraRenderObserver;
  107706. /** Sets a function to be executed after rendering a camera*/
  107707. set afterCameraRender(callback: () => void);
  107708. /**
  107709. * An event triggered when active meshes evaluation is about to start
  107710. */
  107711. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  107712. /**
  107713. * An event triggered when active meshes evaluation is done
  107714. */
  107715. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  107716. /**
  107717. * An event triggered when particles rendering is about to start
  107718. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107719. */
  107720. onBeforeParticlesRenderingObservable: Observable<Scene>;
  107721. /**
  107722. * An event triggered when particles rendering is done
  107723. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107724. */
  107725. onAfterParticlesRenderingObservable: Observable<Scene>;
  107726. /**
  107727. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  107728. */
  107729. onDataLoadedObservable: Observable<Scene>;
  107730. /**
  107731. * An event triggered when a camera is created
  107732. */
  107733. onNewCameraAddedObservable: Observable<Camera>;
  107734. /**
  107735. * An event triggered when a camera is removed
  107736. */
  107737. onCameraRemovedObservable: Observable<Camera>;
  107738. /**
  107739. * An event triggered when a light is created
  107740. */
  107741. onNewLightAddedObservable: Observable<Light>;
  107742. /**
  107743. * An event triggered when a light is removed
  107744. */
  107745. onLightRemovedObservable: Observable<Light>;
  107746. /**
  107747. * An event triggered when a geometry is created
  107748. */
  107749. onNewGeometryAddedObservable: Observable<Geometry>;
  107750. /**
  107751. * An event triggered when a geometry is removed
  107752. */
  107753. onGeometryRemovedObservable: Observable<Geometry>;
  107754. /**
  107755. * An event triggered when a transform node is created
  107756. */
  107757. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  107758. /**
  107759. * An event triggered when a transform node is removed
  107760. */
  107761. onTransformNodeRemovedObservable: Observable<TransformNode>;
  107762. /**
  107763. * An event triggered when a mesh is created
  107764. */
  107765. onNewMeshAddedObservable: Observable<AbstractMesh>;
  107766. /**
  107767. * An event triggered when a mesh is removed
  107768. */
  107769. onMeshRemovedObservable: Observable<AbstractMesh>;
  107770. /**
  107771. * An event triggered when a skeleton is created
  107772. */
  107773. onNewSkeletonAddedObservable: Observable<Skeleton>;
  107774. /**
  107775. * An event triggered when a skeleton is removed
  107776. */
  107777. onSkeletonRemovedObservable: Observable<Skeleton>;
  107778. /**
  107779. * An event triggered when a material is created
  107780. */
  107781. onNewMaterialAddedObservable: Observable<Material>;
  107782. /**
  107783. * An event triggered when a material is removed
  107784. */
  107785. onMaterialRemovedObservable: Observable<Material>;
  107786. /**
  107787. * An event triggered when a texture is created
  107788. */
  107789. onNewTextureAddedObservable: Observable<BaseTexture>;
  107790. /**
  107791. * An event triggered when a texture is removed
  107792. */
  107793. onTextureRemovedObservable: Observable<BaseTexture>;
  107794. /**
  107795. * An event triggered when render targets are about to be rendered
  107796. * Can happen multiple times per frame.
  107797. */
  107798. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  107799. /**
  107800. * An event triggered when render targets were rendered.
  107801. * Can happen multiple times per frame.
  107802. */
  107803. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  107804. /**
  107805. * An event triggered before calculating deterministic simulation step
  107806. */
  107807. onBeforeStepObservable: Observable<Scene>;
  107808. /**
  107809. * An event triggered after calculating deterministic simulation step
  107810. */
  107811. onAfterStepObservable: Observable<Scene>;
  107812. /**
  107813. * An event triggered when the activeCamera property is updated
  107814. */
  107815. onActiveCameraChanged: Observable<Scene>;
  107816. /**
  107817. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  107818. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107819. * 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)
  107820. */
  107821. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107822. /**
  107823. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  107824. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107825. * 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)
  107826. */
  107827. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107828. /**
  107829. * This Observable will when a mesh has been imported into the scene.
  107830. */
  107831. onMeshImportedObservable: Observable<AbstractMesh>;
  107832. /**
  107833. * This Observable will when an animation file has been imported into the scene.
  107834. */
  107835. onAnimationFileImportedObservable: Observable<Scene>;
  107836. /**
  107837. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  107838. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  107839. */
  107840. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  107841. /** @hidden */
  107842. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  107843. /**
  107844. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  107845. */
  107846. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  107847. /**
  107848. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  107849. */
  107850. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  107851. /**
  107852. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  107853. */
  107854. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  107855. /** Callback called when a pointer move is detected */
  107856. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  107857. /** Callback called when a pointer down is detected */
  107858. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  107859. /** Callback called when a pointer up is detected */
  107860. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  107861. /** Callback called when a pointer pick is detected */
  107862. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  107863. /**
  107864. * 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).
  107865. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  107866. */
  107867. onPrePointerObservable: Observable<PointerInfoPre>;
  107868. /**
  107869. * Observable event triggered each time an input event is received from the rendering canvas
  107870. */
  107871. onPointerObservable: Observable<PointerInfo>;
  107872. /**
  107873. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  107874. */
  107875. get unTranslatedPointer(): Vector2;
  107876. /**
  107877. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  107878. */
  107879. static get DragMovementThreshold(): number;
  107880. static set DragMovementThreshold(value: number);
  107881. /**
  107882. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  107883. */
  107884. static get LongPressDelay(): number;
  107885. static set LongPressDelay(value: number);
  107886. /**
  107887. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  107888. */
  107889. static get DoubleClickDelay(): number;
  107890. static set DoubleClickDelay(value: number);
  107891. /** If you need to check double click without raising a single click at first click, enable this flag */
  107892. static get ExclusiveDoubleClickMode(): boolean;
  107893. static set ExclusiveDoubleClickMode(value: boolean);
  107894. /** @hidden */
  107895. _mirroredCameraPosition: Nullable<Vector3>;
  107896. /**
  107897. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  107898. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  107899. */
  107900. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  107901. /**
  107902. * Observable event triggered each time an keyboard event is received from the hosting window
  107903. */
  107904. onKeyboardObservable: Observable<KeyboardInfo>;
  107905. private _useRightHandedSystem;
  107906. /**
  107907. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  107908. */
  107909. set useRightHandedSystem(value: boolean);
  107910. get useRightHandedSystem(): boolean;
  107911. private _timeAccumulator;
  107912. private _currentStepId;
  107913. private _currentInternalStep;
  107914. /**
  107915. * Sets the step Id used by deterministic lock step
  107916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107917. * @param newStepId defines the step Id
  107918. */
  107919. setStepId(newStepId: number): void;
  107920. /**
  107921. * Gets the step Id used by deterministic lock step
  107922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107923. * @returns the step Id
  107924. */
  107925. getStepId(): number;
  107926. /**
  107927. * Gets the internal step used by deterministic lock step
  107928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107929. * @returns the internal step
  107930. */
  107931. getInternalStep(): number;
  107932. private _fogEnabled;
  107933. /**
  107934. * Gets or sets a boolean indicating if fog is enabled on this scene
  107935. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107936. * (Default is true)
  107937. */
  107938. set fogEnabled(value: boolean);
  107939. get fogEnabled(): boolean;
  107940. private _fogMode;
  107941. /**
  107942. * Gets or sets the fog mode to use
  107943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107944. * | mode | value |
  107945. * | --- | --- |
  107946. * | FOGMODE_NONE | 0 |
  107947. * | FOGMODE_EXP | 1 |
  107948. * | FOGMODE_EXP2 | 2 |
  107949. * | FOGMODE_LINEAR | 3 |
  107950. */
  107951. set fogMode(value: number);
  107952. get fogMode(): number;
  107953. /**
  107954. * Gets or sets the fog color to use
  107955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107956. * (Default is Color3(0.2, 0.2, 0.3))
  107957. */
  107958. fogColor: Color3;
  107959. /**
  107960. * Gets or sets the fog density to use
  107961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107962. * (Default is 0.1)
  107963. */
  107964. fogDensity: number;
  107965. /**
  107966. * Gets or sets the fog start distance to use
  107967. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107968. * (Default is 0)
  107969. */
  107970. fogStart: number;
  107971. /**
  107972. * Gets or sets the fog end distance to use
  107973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107974. * (Default is 1000)
  107975. */
  107976. fogEnd: number;
  107977. private _shadowsEnabled;
  107978. /**
  107979. * Gets or sets a boolean indicating if shadows are enabled on this scene
  107980. */
  107981. set shadowsEnabled(value: boolean);
  107982. get shadowsEnabled(): boolean;
  107983. private _lightsEnabled;
  107984. /**
  107985. * Gets or sets a boolean indicating if lights are enabled on this scene
  107986. */
  107987. set lightsEnabled(value: boolean);
  107988. get lightsEnabled(): boolean;
  107989. /** All of the active cameras added to this scene. */
  107990. activeCameras: Camera[];
  107991. /** @hidden */
  107992. _activeCamera: Nullable<Camera>;
  107993. /** Gets or sets the current active camera */
  107994. get activeCamera(): Nullable<Camera>;
  107995. set activeCamera(value: Nullable<Camera>);
  107996. private _defaultMaterial;
  107997. /** The default material used on meshes when no material is affected */
  107998. get defaultMaterial(): Material;
  107999. /** The default material used on meshes when no material is affected */
  108000. set defaultMaterial(value: Material);
  108001. private _texturesEnabled;
  108002. /**
  108003. * Gets or sets a boolean indicating if textures are enabled on this scene
  108004. */
  108005. set texturesEnabled(value: boolean);
  108006. get texturesEnabled(): boolean;
  108007. /**
  108008. * Gets or sets a boolean indicating if particles are enabled on this scene
  108009. */
  108010. particlesEnabled: boolean;
  108011. /**
  108012. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108013. */
  108014. spritesEnabled: boolean;
  108015. private _skeletonsEnabled;
  108016. /**
  108017. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108018. */
  108019. set skeletonsEnabled(value: boolean);
  108020. get skeletonsEnabled(): boolean;
  108021. /**
  108022. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108023. */
  108024. lensFlaresEnabled: boolean;
  108025. /**
  108026. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108027. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108028. */
  108029. collisionsEnabled: boolean;
  108030. private _collisionCoordinator;
  108031. /** @hidden */
  108032. get collisionCoordinator(): ICollisionCoordinator;
  108033. /**
  108034. * Defines the gravity applied to this scene (used only for collisions)
  108035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108036. */
  108037. gravity: Vector3;
  108038. /**
  108039. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108040. */
  108041. postProcessesEnabled: boolean;
  108042. /**
  108043. * The list of postprocesses added to the scene
  108044. */
  108045. postProcesses: PostProcess[];
  108046. /**
  108047. * Gets the current postprocess manager
  108048. */
  108049. postProcessManager: PostProcessManager;
  108050. /**
  108051. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108052. */
  108053. renderTargetsEnabled: boolean;
  108054. /**
  108055. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108056. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108057. */
  108058. dumpNextRenderTargets: boolean;
  108059. /**
  108060. * The list of user defined render targets added to the scene
  108061. */
  108062. customRenderTargets: RenderTargetTexture[];
  108063. /**
  108064. * Defines if texture loading must be delayed
  108065. * If true, textures will only be loaded when they need to be rendered
  108066. */
  108067. useDelayedTextureLoading: boolean;
  108068. /**
  108069. * Gets the list of meshes imported to the scene through SceneLoader
  108070. */
  108071. importedMeshesFiles: String[];
  108072. /**
  108073. * Gets or sets a boolean indicating if probes are enabled on this scene
  108074. */
  108075. probesEnabled: boolean;
  108076. /**
  108077. * Gets or sets the current offline provider to use to store scene data
  108078. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108079. */
  108080. offlineProvider: IOfflineProvider;
  108081. /**
  108082. * Gets or sets the action manager associated with the scene
  108083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108084. */
  108085. actionManager: AbstractActionManager;
  108086. private _meshesForIntersections;
  108087. /**
  108088. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108089. */
  108090. proceduralTexturesEnabled: boolean;
  108091. private _engine;
  108092. private _totalVertices;
  108093. /** @hidden */
  108094. _activeIndices: PerfCounter;
  108095. /** @hidden */
  108096. _activeParticles: PerfCounter;
  108097. /** @hidden */
  108098. _activeBones: PerfCounter;
  108099. private _animationRatio;
  108100. /** @hidden */
  108101. _animationTimeLast: number;
  108102. /** @hidden */
  108103. _animationTime: number;
  108104. /**
  108105. * Gets or sets a general scale for animation speed
  108106. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108107. */
  108108. animationTimeScale: number;
  108109. /** @hidden */
  108110. _cachedMaterial: Nullable<Material>;
  108111. /** @hidden */
  108112. _cachedEffect: Nullable<Effect>;
  108113. /** @hidden */
  108114. _cachedVisibility: Nullable<number>;
  108115. private _renderId;
  108116. private _frameId;
  108117. private _executeWhenReadyTimeoutId;
  108118. private _intermediateRendering;
  108119. private _viewUpdateFlag;
  108120. private _projectionUpdateFlag;
  108121. /** @hidden */
  108122. _toBeDisposed: Nullable<IDisposable>[];
  108123. private _activeRequests;
  108124. /** @hidden */
  108125. _pendingData: any[];
  108126. private _isDisposed;
  108127. /**
  108128. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108129. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108130. */
  108131. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108132. private _activeMeshes;
  108133. private _processedMaterials;
  108134. private _renderTargets;
  108135. /** @hidden */
  108136. _activeParticleSystems: SmartArray<IParticleSystem>;
  108137. private _activeSkeletons;
  108138. private _softwareSkinnedMeshes;
  108139. private _renderingManager;
  108140. /** @hidden */
  108141. _activeAnimatables: Animatable[];
  108142. private _transformMatrix;
  108143. private _sceneUbo;
  108144. /** @hidden */
  108145. _viewMatrix: Matrix;
  108146. private _projectionMatrix;
  108147. /** @hidden */
  108148. _forcedViewPosition: Nullable<Vector3>;
  108149. /** @hidden */
  108150. _frustumPlanes: Plane[];
  108151. /**
  108152. * Gets the list of frustum planes (built from the active camera)
  108153. */
  108154. get frustumPlanes(): Plane[];
  108155. /**
  108156. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108157. * This is useful if there are more lights that the maximum simulteanous authorized
  108158. */
  108159. requireLightSorting: boolean;
  108160. /** @hidden */
  108161. readonly useMaterialMeshMap: boolean;
  108162. /** @hidden */
  108163. readonly useClonedMeshMap: boolean;
  108164. private _externalData;
  108165. private _uid;
  108166. /**
  108167. * @hidden
  108168. * Backing store of defined scene components.
  108169. */
  108170. _components: ISceneComponent[];
  108171. /**
  108172. * @hidden
  108173. * Backing store of defined scene components.
  108174. */
  108175. _serializableComponents: ISceneSerializableComponent[];
  108176. /**
  108177. * List of components to register on the next registration step.
  108178. */
  108179. private _transientComponents;
  108180. /**
  108181. * Registers the transient components if needed.
  108182. */
  108183. private _registerTransientComponents;
  108184. /**
  108185. * @hidden
  108186. * Add a component to the scene.
  108187. * Note that the ccomponent could be registered on th next frame if this is called after
  108188. * the register component stage.
  108189. * @param component Defines the component to add to the scene
  108190. */
  108191. _addComponent(component: ISceneComponent): void;
  108192. /**
  108193. * @hidden
  108194. * Gets a component from the scene.
  108195. * @param name defines the name of the component to retrieve
  108196. * @returns the component or null if not present
  108197. */
  108198. _getComponent(name: string): Nullable<ISceneComponent>;
  108199. /**
  108200. * @hidden
  108201. * Defines the actions happening before camera updates.
  108202. */
  108203. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  108204. /**
  108205. * @hidden
  108206. * Defines the actions happening before clear the canvas.
  108207. */
  108208. _beforeClearStage: Stage<SimpleStageAction>;
  108209. /**
  108210. * @hidden
  108211. * Defines the actions when collecting render targets for the frame.
  108212. */
  108213. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108214. /**
  108215. * @hidden
  108216. * Defines the actions happening for one camera in the frame.
  108217. */
  108218. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108219. /**
  108220. * @hidden
  108221. * Defines the actions happening during the per mesh ready checks.
  108222. */
  108223. _isReadyForMeshStage: Stage<MeshStageAction>;
  108224. /**
  108225. * @hidden
  108226. * Defines the actions happening before evaluate active mesh checks.
  108227. */
  108228. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  108229. /**
  108230. * @hidden
  108231. * Defines the actions happening during the evaluate sub mesh checks.
  108232. */
  108233. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  108234. /**
  108235. * @hidden
  108236. * Defines the actions happening during the active mesh stage.
  108237. */
  108238. _activeMeshStage: Stage<ActiveMeshStageAction>;
  108239. /**
  108240. * @hidden
  108241. * Defines the actions happening during the per camera render target step.
  108242. */
  108243. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  108244. /**
  108245. * @hidden
  108246. * Defines the actions happening just before the active camera is drawing.
  108247. */
  108248. _beforeCameraDrawStage: Stage<CameraStageAction>;
  108249. /**
  108250. * @hidden
  108251. * Defines the actions happening just before a render target is drawing.
  108252. */
  108253. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108254. /**
  108255. * @hidden
  108256. * Defines the actions happening just before a rendering group is drawing.
  108257. */
  108258. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108259. /**
  108260. * @hidden
  108261. * Defines the actions happening just before a mesh is drawing.
  108262. */
  108263. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108264. /**
  108265. * @hidden
  108266. * Defines the actions happening just after a mesh has been drawn.
  108267. */
  108268. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108269. /**
  108270. * @hidden
  108271. * Defines the actions happening just after a rendering group has been drawn.
  108272. */
  108273. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108274. /**
  108275. * @hidden
  108276. * Defines the actions happening just after the active camera has been drawn.
  108277. */
  108278. _afterCameraDrawStage: Stage<CameraStageAction>;
  108279. /**
  108280. * @hidden
  108281. * Defines the actions happening just after a render target has been drawn.
  108282. */
  108283. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108284. /**
  108285. * @hidden
  108286. * Defines the actions happening just after rendering all cameras and computing intersections.
  108287. */
  108288. _afterRenderStage: Stage<SimpleStageAction>;
  108289. /**
  108290. * @hidden
  108291. * Defines the actions happening when a pointer move event happens.
  108292. */
  108293. _pointerMoveStage: Stage<PointerMoveStageAction>;
  108294. /**
  108295. * @hidden
  108296. * Defines the actions happening when a pointer down event happens.
  108297. */
  108298. _pointerDownStage: Stage<PointerUpDownStageAction>;
  108299. /**
  108300. * @hidden
  108301. * Defines the actions happening when a pointer up event happens.
  108302. */
  108303. _pointerUpStage: Stage<PointerUpDownStageAction>;
  108304. /**
  108305. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  108306. */
  108307. private geometriesByUniqueId;
  108308. /**
  108309. * Creates a new Scene
  108310. * @param engine defines the engine to use to render this scene
  108311. * @param options defines the scene options
  108312. */
  108313. constructor(engine: Engine, options?: SceneOptions);
  108314. /**
  108315. * Gets a string idenfifying the name of the class
  108316. * @returns "Scene" string
  108317. */
  108318. getClassName(): string;
  108319. private _defaultMeshCandidates;
  108320. /**
  108321. * @hidden
  108322. */
  108323. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108324. private _defaultSubMeshCandidates;
  108325. /**
  108326. * @hidden
  108327. */
  108328. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108329. /**
  108330. * Sets the default candidate providers for the scene.
  108331. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  108332. * and getCollidingSubMeshCandidates to their default function
  108333. */
  108334. setDefaultCandidateProviders(): void;
  108335. /**
  108336. * Gets the mesh that is currently under the pointer
  108337. */
  108338. get meshUnderPointer(): Nullable<AbstractMesh>;
  108339. /**
  108340. * Gets or sets the current on-screen X position of the pointer
  108341. */
  108342. get pointerX(): number;
  108343. set pointerX(value: number);
  108344. /**
  108345. * Gets or sets the current on-screen Y position of the pointer
  108346. */
  108347. get pointerY(): number;
  108348. set pointerY(value: number);
  108349. /**
  108350. * Gets the cached material (ie. the latest rendered one)
  108351. * @returns the cached material
  108352. */
  108353. getCachedMaterial(): Nullable<Material>;
  108354. /**
  108355. * Gets the cached effect (ie. the latest rendered one)
  108356. * @returns the cached effect
  108357. */
  108358. getCachedEffect(): Nullable<Effect>;
  108359. /**
  108360. * Gets the cached visibility state (ie. the latest rendered one)
  108361. * @returns the cached visibility state
  108362. */
  108363. getCachedVisibility(): Nullable<number>;
  108364. /**
  108365. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  108366. * @param material defines the current material
  108367. * @param effect defines the current effect
  108368. * @param visibility defines the current visibility state
  108369. * @returns true if one parameter is not cached
  108370. */
  108371. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  108372. /**
  108373. * Gets the engine associated with the scene
  108374. * @returns an Engine
  108375. */
  108376. getEngine(): Engine;
  108377. /**
  108378. * Gets the total number of vertices rendered per frame
  108379. * @returns the total number of vertices rendered per frame
  108380. */
  108381. getTotalVertices(): number;
  108382. /**
  108383. * Gets the performance counter for total vertices
  108384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108385. */
  108386. get totalVerticesPerfCounter(): PerfCounter;
  108387. /**
  108388. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  108389. * @returns the total number of active indices rendered per frame
  108390. */
  108391. getActiveIndices(): number;
  108392. /**
  108393. * Gets the performance counter for active indices
  108394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108395. */
  108396. get totalActiveIndicesPerfCounter(): PerfCounter;
  108397. /**
  108398. * Gets the total number of active particles rendered per frame
  108399. * @returns the total number of active particles rendered per frame
  108400. */
  108401. getActiveParticles(): number;
  108402. /**
  108403. * Gets the performance counter for active particles
  108404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108405. */
  108406. get activeParticlesPerfCounter(): PerfCounter;
  108407. /**
  108408. * Gets the total number of active bones rendered per frame
  108409. * @returns the total number of active bones rendered per frame
  108410. */
  108411. getActiveBones(): number;
  108412. /**
  108413. * Gets the performance counter for active bones
  108414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108415. */
  108416. get activeBonesPerfCounter(): PerfCounter;
  108417. /**
  108418. * Gets the array of active meshes
  108419. * @returns an array of AbstractMesh
  108420. */
  108421. getActiveMeshes(): SmartArray<AbstractMesh>;
  108422. /**
  108423. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  108424. * @returns a number
  108425. */
  108426. getAnimationRatio(): number;
  108427. /**
  108428. * Gets an unique Id for the current render phase
  108429. * @returns a number
  108430. */
  108431. getRenderId(): number;
  108432. /**
  108433. * Gets an unique Id for the current frame
  108434. * @returns a number
  108435. */
  108436. getFrameId(): number;
  108437. /** Call this function if you want to manually increment the render Id*/
  108438. incrementRenderId(): void;
  108439. private _createUbo;
  108440. /**
  108441. * Use this method to simulate a pointer move on a mesh
  108442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108445. * @returns the current scene
  108446. */
  108447. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108448. /**
  108449. * Use this method to simulate a pointer down on a mesh
  108450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108453. * @returns the current scene
  108454. */
  108455. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108456. /**
  108457. * Use this method to simulate a pointer up on a mesh
  108458. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108459. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108460. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108461. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108462. * @returns the current scene
  108463. */
  108464. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  108465. /**
  108466. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108467. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108468. * @returns true if the pointer was captured
  108469. */
  108470. isPointerCaptured(pointerId?: number): boolean;
  108471. /**
  108472. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108473. * @param attachUp defines if you want to attach events to pointerup
  108474. * @param attachDown defines if you want to attach events to pointerdown
  108475. * @param attachMove defines if you want to attach events to pointermove
  108476. */
  108477. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  108478. /** Detaches all event handlers*/
  108479. detachControl(): void;
  108480. /**
  108481. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  108482. * Delay loaded resources are not taking in account
  108483. * @return true if all required resources are ready
  108484. */
  108485. isReady(): boolean;
  108486. /** Resets all cached information relative to material (including effect and visibility) */
  108487. resetCachedMaterial(): void;
  108488. /**
  108489. * Registers a function to be called before every frame render
  108490. * @param func defines the function to register
  108491. */
  108492. registerBeforeRender(func: () => void): void;
  108493. /**
  108494. * Unregisters a function called before every frame render
  108495. * @param func defines the function to unregister
  108496. */
  108497. unregisterBeforeRender(func: () => void): void;
  108498. /**
  108499. * Registers a function to be called after every frame render
  108500. * @param func defines the function to register
  108501. */
  108502. registerAfterRender(func: () => void): void;
  108503. /**
  108504. * Unregisters a function called after every frame render
  108505. * @param func defines the function to unregister
  108506. */
  108507. unregisterAfterRender(func: () => void): void;
  108508. private _executeOnceBeforeRender;
  108509. /**
  108510. * The provided function will run before render once and will be disposed afterwards.
  108511. * A timeout delay can be provided so that the function will be executed in N ms.
  108512. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  108513. * @param func The function to be executed.
  108514. * @param timeout optional delay in ms
  108515. */
  108516. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  108517. /** @hidden */
  108518. _addPendingData(data: any): void;
  108519. /** @hidden */
  108520. _removePendingData(data: any): void;
  108521. /**
  108522. * Returns the number of items waiting to be loaded
  108523. * @returns the number of items waiting to be loaded
  108524. */
  108525. getWaitingItemsCount(): number;
  108526. /**
  108527. * Returns a boolean indicating if the scene is still loading data
  108528. */
  108529. get isLoading(): boolean;
  108530. /**
  108531. * Registers a function to be executed when the scene is ready
  108532. * @param {Function} func - the function to be executed
  108533. */
  108534. executeWhenReady(func: () => void): void;
  108535. /**
  108536. * Returns a promise that resolves when the scene is ready
  108537. * @returns A promise that resolves when the scene is ready
  108538. */
  108539. whenReadyAsync(): Promise<void>;
  108540. /** @hidden */
  108541. _checkIsReady(): void;
  108542. /**
  108543. * Gets all animatable attached to the scene
  108544. */
  108545. get animatables(): Animatable[];
  108546. /**
  108547. * Resets the last animation time frame.
  108548. * Useful to override when animations start running when loading a scene for the first time.
  108549. */
  108550. resetLastAnimationTimeFrame(): void;
  108551. /**
  108552. * Gets the current view matrix
  108553. * @returns a Matrix
  108554. */
  108555. getViewMatrix(): Matrix;
  108556. /**
  108557. * Gets the current projection matrix
  108558. * @returns a Matrix
  108559. */
  108560. getProjectionMatrix(): Matrix;
  108561. /**
  108562. * Gets the current transform matrix
  108563. * @returns a Matrix made of View * Projection
  108564. */
  108565. getTransformMatrix(): Matrix;
  108566. /**
  108567. * Sets the current transform matrix
  108568. * @param viewL defines the View matrix to use
  108569. * @param projectionL defines the Projection matrix to use
  108570. * @param viewR defines the right View matrix to use (if provided)
  108571. * @param projectionR defines the right Projection matrix to use (if provided)
  108572. */
  108573. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  108574. /**
  108575. * Gets the uniform buffer used to store scene data
  108576. * @returns a UniformBuffer
  108577. */
  108578. getSceneUniformBuffer(): UniformBuffer;
  108579. /**
  108580. * Gets an unique (relatively to the current scene) Id
  108581. * @returns an unique number for the scene
  108582. */
  108583. getUniqueId(): number;
  108584. /**
  108585. * Add a mesh to the list of scene's meshes
  108586. * @param newMesh defines the mesh to add
  108587. * @param recursive if all child meshes should also be added to the scene
  108588. */
  108589. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  108590. /**
  108591. * Remove a mesh for the list of scene's meshes
  108592. * @param toRemove defines the mesh to remove
  108593. * @param recursive if all child meshes should also be removed from the scene
  108594. * @returns the index where the mesh was in the mesh list
  108595. */
  108596. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  108597. /**
  108598. * Add a transform node to the list of scene's transform nodes
  108599. * @param newTransformNode defines the transform node to add
  108600. */
  108601. addTransformNode(newTransformNode: TransformNode): void;
  108602. /**
  108603. * Remove a transform node for the list of scene's transform nodes
  108604. * @param toRemove defines the transform node to remove
  108605. * @returns the index where the transform node was in the transform node list
  108606. */
  108607. removeTransformNode(toRemove: TransformNode): number;
  108608. /**
  108609. * Remove a skeleton for the list of scene's skeletons
  108610. * @param toRemove defines the skeleton to remove
  108611. * @returns the index where the skeleton was in the skeleton list
  108612. */
  108613. removeSkeleton(toRemove: Skeleton): number;
  108614. /**
  108615. * Remove a morph target for the list of scene's morph targets
  108616. * @param toRemove defines the morph target to remove
  108617. * @returns the index where the morph target was in the morph target list
  108618. */
  108619. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  108620. /**
  108621. * Remove a light for the list of scene's lights
  108622. * @param toRemove defines the light to remove
  108623. * @returns the index where the light was in the light list
  108624. */
  108625. removeLight(toRemove: Light): number;
  108626. /**
  108627. * Remove a camera for the list of scene's cameras
  108628. * @param toRemove defines the camera to remove
  108629. * @returns the index where the camera was in the camera list
  108630. */
  108631. removeCamera(toRemove: Camera): number;
  108632. /**
  108633. * Remove a particle system for the list of scene's particle systems
  108634. * @param toRemove defines the particle system to remove
  108635. * @returns the index where the particle system was in the particle system list
  108636. */
  108637. removeParticleSystem(toRemove: IParticleSystem): number;
  108638. /**
  108639. * Remove a animation for the list of scene's animations
  108640. * @param toRemove defines the animation to remove
  108641. * @returns the index where the animation was in the animation list
  108642. */
  108643. removeAnimation(toRemove: Animation): number;
  108644. /**
  108645. * Will stop the animation of the given target
  108646. * @param target - the target
  108647. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  108648. * @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)
  108649. */
  108650. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  108651. /**
  108652. * Removes the given animation group from this scene.
  108653. * @param toRemove The animation group to remove
  108654. * @returns The index of the removed animation group
  108655. */
  108656. removeAnimationGroup(toRemove: AnimationGroup): number;
  108657. /**
  108658. * Removes the given multi-material from this scene.
  108659. * @param toRemove The multi-material to remove
  108660. * @returns The index of the removed multi-material
  108661. */
  108662. removeMultiMaterial(toRemove: MultiMaterial): number;
  108663. /**
  108664. * Removes the given material from this scene.
  108665. * @param toRemove The material to remove
  108666. * @returns The index of the removed material
  108667. */
  108668. removeMaterial(toRemove: Material): number;
  108669. /**
  108670. * Removes the given action manager from this scene.
  108671. * @param toRemove The action manager to remove
  108672. * @returns The index of the removed action manager
  108673. */
  108674. removeActionManager(toRemove: AbstractActionManager): number;
  108675. /**
  108676. * Removes the given texture from this scene.
  108677. * @param toRemove The texture to remove
  108678. * @returns The index of the removed texture
  108679. */
  108680. removeTexture(toRemove: BaseTexture): number;
  108681. /**
  108682. * Adds the given light to this scene
  108683. * @param newLight The light to add
  108684. */
  108685. addLight(newLight: Light): void;
  108686. /**
  108687. * Sorts the list list based on light priorities
  108688. */
  108689. sortLightsByPriority(): void;
  108690. /**
  108691. * Adds the given camera to this scene
  108692. * @param newCamera The camera to add
  108693. */
  108694. addCamera(newCamera: Camera): void;
  108695. /**
  108696. * Adds the given skeleton to this scene
  108697. * @param newSkeleton The skeleton to add
  108698. */
  108699. addSkeleton(newSkeleton: Skeleton): void;
  108700. /**
  108701. * Adds the given particle system to this scene
  108702. * @param newParticleSystem The particle system to add
  108703. */
  108704. addParticleSystem(newParticleSystem: IParticleSystem): void;
  108705. /**
  108706. * Adds the given animation to this scene
  108707. * @param newAnimation The animation to add
  108708. */
  108709. addAnimation(newAnimation: Animation): void;
  108710. /**
  108711. * Adds the given animation group to this scene.
  108712. * @param newAnimationGroup The animation group to add
  108713. */
  108714. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  108715. /**
  108716. * Adds the given multi-material to this scene
  108717. * @param newMultiMaterial The multi-material to add
  108718. */
  108719. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  108720. /**
  108721. * Adds the given material to this scene
  108722. * @param newMaterial The material to add
  108723. */
  108724. addMaterial(newMaterial: Material): void;
  108725. /**
  108726. * Adds the given morph target to this scene
  108727. * @param newMorphTargetManager The morph target to add
  108728. */
  108729. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  108730. /**
  108731. * Adds the given geometry to this scene
  108732. * @param newGeometry The geometry to add
  108733. */
  108734. addGeometry(newGeometry: Geometry): void;
  108735. /**
  108736. * Adds the given action manager to this scene
  108737. * @param newActionManager The action manager to add
  108738. */
  108739. addActionManager(newActionManager: AbstractActionManager): void;
  108740. /**
  108741. * Adds the given texture to this scene.
  108742. * @param newTexture The texture to add
  108743. */
  108744. addTexture(newTexture: BaseTexture): void;
  108745. /**
  108746. * Switch active camera
  108747. * @param newCamera defines the new active camera
  108748. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  108749. */
  108750. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  108751. /**
  108752. * sets the active camera of the scene using its ID
  108753. * @param id defines the camera's ID
  108754. * @return the new active camera or null if none found.
  108755. */
  108756. setActiveCameraByID(id: string): Nullable<Camera>;
  108757. /**
  108758. * sets the active camera of the scene using its name
  108759. * @param name defines the camera's name
  108760. * @returns the new active camera or null if none found.
  108761. */
  108762. setActiveCameraByName(name: string): Nullable<Camera>;
  108763. /**
  108764. * get an animation group using its name
  108765. * @param name defines the material's name
  108766. * @return the animation group or null if none found.
  108767. */
  108768. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  108769. /**
  108770. * Get a material using its unique id
  108771. * @param uniqueId defines the material's unique id
  108772. * @return the material or null if none found.
  108773. */
  108774. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  108775. /**
  108776. * get a material using its id
  108777. * @param id defines the material's ID
  108778. * @return the material or null if none found.
  108779. */
  108780. getMaterialByID(id: string): Nullable<Material>;
  108781. /**
  108782. * Gets a the last added material using a given id
  108783. * @param id defines the material's ID
  108784. * @return the last material with the given id or null if none found.
  108785. */
  108786. getLastMaterialByID(id: string): Nullable<Material>;
  108787. /**
  108788. * Gets a material using its name
  108789. * @param name defines the material's name
  108790. * @return the material or null if none found.
  108791. */
  108792. getMaterialByName(name: string): Nullable<Material>;
  108793. /**
  108794. * Get a texture using its unique id
  108795. * @param uniqueId defines the texture's unique id
  108796. * @return the texture or null if none found.
  108797. */
  108798. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  108799. /**
  108800. * Gets a camera using its id
  108801. * @param id defines the id to look for
  108802. * @returns the camera or null if not found
  108803. */
  108804. getCameraByID(id: string): Nullable<Camera>;
  108805. /**
  108806. * Gets a camera using its unique id
  108807. * @param uniqueId defines the unique id to look for
  108808. * @returns the camera or null if not found
  108809. */
  108810. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  108811. /**
  108812. * Gets a camera using its name
  108813. * @param name defines the camera's name
  108814. * @return the camera or null if none found.
  108815. */
  108816. getCameraByName(name: string): Nullable<Camera>;
  108817. /**
  108818. * Gets a bone using its id
  108819. * @param id defines the bone's id
  108820. * @return the bone or null if not found
  108821. */
  108822. getBoneByID(id: string): Nullable<Bone>;
  108823. /**
  108824. * Gets a bone using its id
  108825. * @param name defines the bone's name
  108826. * @return the bone or null if not found
  108827. */
  108828. getBoneByName(name: string): Nullable<Bone>;
  108829. /**
  108830. * Gets a light node using its name
  108831. * @param name defines the the light's name
  108832. * @return the light or null if none found.
  108833. */
  108834. getLightByName(name: string): Nullable<Light>;
  108835. /**
  108836. * Gets a light node using its id
  108837. * @param id defines the light's id
  108838. * @return the light or null if none found.
  108839. */
  108840. getLightByID(id: string): Nullable<Light>;
  108841. /**
  108842. * Gets a light node using its scene-generated unique ID
  108843. * @param uniqueId defines the light's unique id
  108844. * @return the light or null if none found.
  108845. */
  108846. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  108847. /**
  108848. * Gets a particle system by id
  108849. * @param id defines the particle system id
  108850. * @return the corresponding system or null if none found
  108851. */
  108852. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  108853. /**
  108854. * Gets a geometry using its ID
  108855. * @param id defines the geometry's id
  108856. * @return the geometry or null if none found.
  108857. */
  108858. getGeometryByID(id: string): Nullable<Geometry>;
  108859. private _getGeometryByUniqueID;
  108860. /**
  108861. * Add a new geometry to this scene
  108862. * @param geometry defines the geometry to be added to the scene.
  108863. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  108864. * @return a boolean defining if the geometry was added or not
  108865. */
  108866. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  108867. /**
  108868. * Removes an existing geometry
  108869. * @param geometry defines the geometry to be removed from the scene
  108870. * @return a boolean defining if the geometry was removed or not
  108871. */
  108872. removeGeometry(geometry: Geometry): boolean;
  108873. /**
  108874. * Gets the list of geometries attached to the scene
  108875. * @returns an array of Geometry
  108876. */
  108877. getGeometries(): Geometry[];
  108878. /**
  108879. * Gets the first added mesh found of a given ID
  108880. * @param id defines the id to search for
  108881. * @return the mesh found or null if not found at all
  108882. */
  108883. getMeshByID(id: string): Nullable<AbstractMesh>;
  108884. /**
  108885. * Gets a list of meshes using their id
  108886. * @param id defines the id to search for
  108887. * @returns a list of meshes
  108888. */
  108889. getMeshesByID(id: string): Array<AbstractMesh>;
  108890. /**
  108891. * Gets the first added transform node found of a given ID
  108892. * @param id defines the id to search for
  108893. * @return the found transform node or null if not found at all.
  108894. */
  108895. getTransformNodeByID(id: string): Nullable<TransformNode>;
  108896. /**
  108897. * Gets a transform node with its auto-generated unique id
  108898. * @param uniqueId efines the unique id to search for
  108899. * @return the found transform node or null if not found at all.
  108900. */
  108901. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  108902. /**
  108903. * Gets a list of transform nodes using their id
  108904. * @param id defines the id to search for
  108905. * @returns a list of transform nodes
  108906. */
  108907. getTransformNodesByID(id: string): Array<TransformNode>;
  108908. /**
  108909. * Gets a mesh with its auto-generated unique id
  108910. * @param uniqueId defines the unique id to search for
  108911. * @return the found mesh or null if not found at all.
  108912. */
  108913. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  108914. /**
  108915. * Gets a the last added mesh using a given id
  108916. * @param id defines the id to search for
  108917. * @return the found mesh or null if not found at all.
  108918. */
  108919. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  108920. /**
  108921. * Gets a the last added node (Mesh, Camera, Light) using a given id
  108922. * @param id defines the id to search for
  108923. * @return the found node or null if not found at all
  108924. */
  108925. getLastEntryByID(id: string): Nullable<Node>;
  108926. /**
  108927. * Gets a node (Mesh, Camera, Light) using a given id
  108928. * @param id defines the id to search for
  108929. * @return the found node or null if not found at all
  108930. */
  108931. getNodeByID(id: string): Nullable<Node>;
  108932. /**
  108933. * Gets a node (Mesh, Camera, Light) using a given name
  108934. * @param name defines the name to search for
  108935. * @return the found node or null if not found at all.
  108936. */
  108937. getNodeByName(name: string): Nullable<Node>;
  108938. /**
  108939. * Gets a mesh using a given name
  108940. * @param name defines the name to search for
  108941. * @return the found mesh or null if not found at all.
  108942. */
  108943. getMeshByName(name: string): Nullable<AbstractMesh>;
  108944. /**
  108945. * Gets a transform node using a given name
  108946. * @param name defines the name to search for
  108947. * @return the found transform node or null if not found at all.
  108948. */
  108949. getTransformNodeByName(name: string): Nullable<TransformNode>;
  108950. /**
  108951. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  108952. * @param id defines the id to search for
  108953. * @return the found skeleton or null if not found at all.
  108954. */
  108955. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  108956. /**
  108957. * Gets a skeleton using a given auto generated unique id
  108958. * @param uniqueId defines the unique id to search for
  108959. * @return the found skeleton or null if not found at all.
  108960. */
  108961. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  108962. /**
  108963. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  108964. * @param id defines the id to search for
  108965. * @return the found skeleton or null if not found at all.
  108966. */
  108967. getSkeletonById(id: string): Nullable<Skeleton>;
  108968. /**
  108969. * Gets a skeleton using a given name
  108970. * @param name defines the name to search for
  108971. * @return the found skeleton or null if not found at all.
  108972. */
  108973. getSkeletonByName(name: string): Nullable<Skeleton>;
  108974. /**
  108975. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  108976. * @param id defines the id to search for
  108977. * @return the found morph target manager or null if not found at all.
  108978. */
  108979. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  108980. /**
  108981. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  108982. * @param id defines the id to search for
  108983. * @return the found morph target or null if not found at all.
  108984. */
  108985. getMorphTargetById(id: string): Nullable<MorphTarget>;
  108986. /**
  108987. * Gets a boolean indicating if the given mesh is active
  108988. * @param mesh defines the mesh to look for
  108989. * @returns true if the mesh is in the active list
  108990. */
  108991. isActiveMesh(mesh: AbstractMesh): boolean;
  108992. /**
  108993. * Return a unique id as a string which can serve as an identifier for the scene
  108994. */
  108995. get uid(): string;
  108996. /**
  108997. * Add an externaly attached data from its key.
  108998. * This method call will fail and return false, if such key already exists.
  108999. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109000. * @param key the unique key that identifies the data
  109001. * @param data the data object to associate to the key for this Engine instance
  109002. * @return true if no such key were already present and the data was added successfully, false otherwise
  109003. */
  109004. addExternalData<T>(key: string, data: T): boolean;
  109005. /**
  109006. * Get an externaly attached data from its key
  109007. * @param key the unique key that identifies the data
  109008. * @return the associated data, if present (can be null), or undefined if not present
  109009. */
  109010. getExternalData<T>(key: string): Nullable<T>;
  109011. /**
  109012. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109013. * @param key the unique key that identifies the data
  109014. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109015. * @return the associated data, can be null if the factory returned null.
  109016. */
  109017. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109018. /**
  109019. * Remove an externaly attached data from the Engine instance
  109020. * @param key the unique key that identifies the data
  109021. * @return true if the data was successfully removed, false if it doesn't exist
  109022. */
  109023. removeExternalData(key: string): boolean;
  109024. private _evaluateSubMesh;
  109025. /**
  109026. * Clear the processed materials smart array preventing retention point in material dispose.
  109027. */
  109028. freeProcessedMaterials(): void;
  109029. private _preventFreeActiveMeshesAndRenderingGroups;
  109030. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109031. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109032. * when disposing several meshes in a row or a hierarchy of meshes.
  109033. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109034. */
  109035. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109036. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109037. /**
  109038. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109039. */
  109040. freeActiveMeshes(): void;
  109041. /**
  109042. * Clear the info related to rendering groups preventing retention points during dispose.
  109043. */
  109044. freeRenderingGroups(): void;
  109045. /** @hidden */
  109046. _isInIntermediateRendering(): boolean;
  109047. /**
  109048. * Lambda returning the list of potentially active meshes.
  109049. */
  109050. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109051. /**
  109052. * Lambda returning the list of potentially active sub meshes.
  109053. */
  109054. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109055. /**
  109056. * Lambda returning the list of potentially intersecting sub meshes.
  109057. */
  109058. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109059. /**
  109060. * Lambda returning the list of potentially colliding sub meshes.
  109061. */
  109062. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109063. private _activeMeshesFrozen;
  109064. private _skipEvaluateActiveMeshesCompletely;
  109065. /**
  109066. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109067. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109068. * @returns the current scene
  109069. */
  109070. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109071. /**
  109072. * Use this function to restart evaluating active meshes on every frame
  109073. * @returns the current scene
  109074. */
  109075. unfreezeActiveMeshes(): Scene;
  109076. private _evaluateActiveMeshes;
  109077. private _activeMesh;
  109078. /**
  109079. * Update the transform matrix to update from the current active camera
  109080. * @param force defines a boolean used to force the update even if cache is up to date
  109081. */
  109082. updateTransformMatrix(force?: boolean): void;
  109083. private _bindFrameBuffer;
  109084. /** @hidden */
  109085. _allowPostProcessClearColor: boolean;
  109086. /** @hidden */
  109087. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109088. private _processSubCameras;
  109089. private _checkIntersections;
  109090. /** @hidden */
  109091. _advancePhysicsEngineStep(step: number): void;
  109092. /**
  109093. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109094. */
  109095. getDeterministicFrameTime: () => number;
  109096. /** @hidden */
  109097. _animate(): void;
  109098. /** Execute all animations (for a frame) */
  109099. animate(): void;
  109100. /**
  109101. * Render the scene
  109102. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109103. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109104. */
  109105. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109106. /**
  109107. * Freeze all materials
  109108. * A frozen material will not be updatable but should be faster to render
  109109. */
  109110. freezeMaterials(): void;
  109111. /**
  109112. * Unfreeze all materials
  109113. * A frozen material will not be updatable but should be faster to render
  109114. */
  109115. unfreezeMaterials(): void;
  109116. /**
  109117. * Releases all held ressources
  109118. */
  109119. dispose(): void;
  109120. /**
  109121. * Gets if the scene is already disposed
  109122. */
  109123. get isDisposed(): boolean;
  109124. /**
  109125. * Call this function to reduce memory footprint of the scene.
  109126. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109127. */
  109128. clearCachedVertexData(): void;
  109129. /**
  109130. * This function will remove the local cached buffer data from texture.
  109131. * It will save memory but will prevent the texture from being rebuilt
  109132. */
  109133. cleanCachedTextureBuffer(): void;
  109134. /**
  109135. * Get the world extend vectors with an optional filter
  109136. *
  109137. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109138. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109139. */
  109140. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109141. min: Vector3;
  109142. max: Vector3;
  109143. };
  109144. /**
  109145. * Creates a ray that can be used to pick in the scene
  109146. * @param x defines the x coordinate of the origin (on-screen)
  109147. * @param y defines the y coordinate of the origin (on-screen)
  109148. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109149. * @param camera defines the camera to use for the picking
  109150. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109151. * @returns a Ray
  109152. */
  109153. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109154. /**
  109155. * Creates a ray that can be used to pick in the scene
  109156. * @param x defines the x coordinate of the origin (on-screen)
  109157. * @param y defines the y coordinate of the origin (on-screen)
  109158. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109159. * @param result defines the ray where to store the picking ray
  109160. * @param camera defines the camera to use for the picking
  109161. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109162. * @returns the current scene
  109163. */
  109164. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109165. /**
  109166. * Creates a ray that can be used to pick in the scene
  109167. * @param x defines the x coordinate of the origin (on-screen)
  109168. * @param y defines the y coordinate of the origin (on-screen)
  109169. * @param camera defines the camera to use for the picking
  109170. * @returns a Ray
  109171. */
  109172. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109173. /**
  109174. * Creates a ray that can be used to pick in the scene
  109175. * @param x defines the x coordinate of the origin (on-screen)
  109176. * @param y defines the y coordinate of the origin (on-screen)
  109177. * @param result defines the ray where to store the picking ray
  109178. * @param camera defines the camera to use for the picking
  109179. * @returns the current scene
  109180. */
  109181. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109182. /** Launch a ray to try to pick a mesh in the scene
  109183. * @param x position on screen
  109184. * @param y position on screen
  109185. * @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
  109186. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109187. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109189. * @returns a PickingInfo
  109190. */
  109191. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109192. /** Use the given ray to pick a mesh in the scene
  109193. * @param ray The ray to use to pick meshes
  109194. * @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
  109195. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109197. * @returns a PickingInfo
  109198. */
  109199. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109200. /**
  109201. * Launch a ray to try to pick a mesh in the scene
  109202. * @param x X position on screen
  109203. * @param y Y position on screen
  109204. * @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
  109205. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109206. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109207. * @returns an array of PickingInfo
  109208. */
  109209. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109210. /**
  109211. * Launch a ray to try to pick a mesh in the scene
  109212. * @param ray Ray to use
  109213. * @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
  109214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109215. * @returns an array of PickingInfo
  109216. */
  109217. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109218. /**
  109219. * Force the value of meshUnderPointer
  109220. * @param mesh defines the mesh to use
  109221. */
  109222. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109223. /**
  109224. * Gets the mesh under the pointer
  109225. * @returns a Mesh or null if no mesh is under the pointer
  109226. */
  109227. getPointerOverMesh(): Nullable<AbstractMesh>;
  109228. /** @hidden */
  109229. _rebuildGeometries(): void;
  109230. /** @hidden */
  109231. _rebuildTextures(): void;
  109232. private _getByTags;
  109233. /**
  109234. * Get a list of meshes by tags
  109235. * @param tagsQuery defines the tags query to use
  109236. * @param forEach defines a predicate used to filter results
  109237. * @returns an array of Mesh
  109238. */
  109239. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  109240. /**
  109241. * Get a list of cameras by tags
  109242. * @param tagsQuery defines the tags query to use
  109243. * @param forEach defines a predicate used to filter results
  109244. * @returns an array of Camera
  109245. */
  109246. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  109247. /**
  109248. * Get a list of lights by tags
  109249. * @param tagsQuery defines the tags query to use
  109250. * @param forEach defines a predicate used to filter results
  109251. * @returns an array of Light
  109252. */
  109253. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  109254. /**
  109255. * Get a list of materials by tags
  109256. * @param tagsQuery defines the tags query to use
  109257. * @param forEach defines a predicate used to filter results
  109258. * @returns an array of Material
  109259. */
  109260. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  109261. /**
  109262. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109263. * This allowed control for front to back rendering or reversly depending of the special needs.
  109264. *
  109265. * @param renderingGroupId The rendering group id corresponding to its index
  109266. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109267. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109268. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109269. */
  109270. 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;
  109271. /**
  109272. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109273. *
  109274. * @param renderingGroupId The rendering group id corresponding to its index
  109275. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109276. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109277. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109278. */
  109279. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109280. /**
  109281. * Gets the current auto clear configuration for one rendering group of the rendering
  109282. * manager.
  109283. * @param index the rendering group index to get the information for
  109284. * @returns The auto clear setup for the requested rendering group
  109285. */
  109286. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  109287. private _blockMaterialDirtyMechanism;
  109288. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  109289. get blockMaterialDirtyMechanism(): boolean;
  109290. set blockMaterialDirtyMechanism(value: boolean);
  109291. /**
  109292. * Will flag all materials as dirty to trigger new shader compilation
  109293. * @param flag defines the flag used to specify which material part must be marked as dirty
  109294. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  109295. */
  109296. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109297. /** @hidden */
  109298. _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;
  109299. /** @hidden */
  109300. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109301. /** @hidden */
  109302. _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;
  109303. /** @hidden */
  109304. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  109305. /** @hidden */
  109306. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109307. /** @hidden */
  109308. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109309. }
  109310. }
  109311. declare module BABYLON {
  109312. /**
  109313. * Set of assets to keep when moving a scene into an asset container.
  109314. */
  109315. export class KeepAssets extends AbstractScene {
  109316. }
  109317. /**
  109318. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  109319. */
  109320. export class InstantiatedEntries {
  109321. /**
  109322. * List of new root nodes (eg. nodes with no parent)
  109323. */
  109324. rootNodes: TransformNode[];
  109325. /**
  109326. * List of new skeletons
  109327. */
  109328. skeletons: Skeleton[];
  109329. /**
  109330. * List of new animation groups
  109331. */
  109332. animationGroups: AnimationGroup[];
  109333. }
  109334. /**
  109335. * Container with a set of assets that can be added or removed from a scene.
  109336. */
  109337. export class AssetContainer extends AbstractScene {
  109338. /**
  109339. * The scene the AssetContainer belongs to.
  109340. */
  109341. scene: Scene;
  109342. /**
  109343. * Instantiates an AssetContainer.
  109344. * @param scene The scene the AssetContainer belongs to.
  109345. */
  109346. constructor(scene: Scene);
  109347. /**
  109348. * Instantiate or clone all meshes and add the new ones to the scene.
  109349. * Skeletons and animation groups will all be cloned
  109350. * @param nameFunction defines an optional function used to get new names for clones
  109351. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  109352. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  109353. */
  109354. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  109355. /**
  109356. * Adds all the assets from the container to the scene.
  109357. */
  109358. addAllToScene(): void;
  109359. /**
  109360. * Removes all the assets in the container from the scene
  109361. */
  109362. removeAllFromScene(): void;
  109363. /**
  109364. * Disposes all the assets in the container
  109365. */
  109366. dispose(): void;
  109367. private _moveAssets;
  109368. /**
  109369. * Removes all the assets contained in the scene and adds them to the container.
  109370. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  109371. */
  109372. moveAllFromScene(keepAssets?: KeepAssets): void;
  109373. /**
  109374. * 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.
  109375. * @returns the root mesh
  109376. */
  109377. createRootMesh(): Mesh;
  109378. /**
  109379. * Merge animations from this asset container into a scene
  109380. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109381. * @param animatables set of animatables to retarget to a node from the scene
  109382. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  109383. */
  109384. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  109385. }
  109386. }
  109387. declare module BABYLON {
  109388. /**
  109389. * Defines how the parser contract is defined.
  109390. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  109391. */
  109392. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  109393. /**
  109394. * Defines how the individual parser contract is defined.
  109395. * These parser can parse an individual asset
  109396. */
  109397. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  109398. /**
  109399. * Base class of the scene acting as a container for the different elements composing a scene.
  109400. * This class is dynamically extended by the different components of the scene increasing
  109401. * flexibility and reducing coupling
  109402. */
  109403. export abstract class AbstractScene {
  109404. /**
  109405. * Stores the list of available parsers in the application.
  109406. */
  109407. private static _BabylonFileParsers;
  109408. /**
  109409. * Stores the list of available individual parsers in the application.
  109410. */
  109411. private static _IndividualBabylonFileParsers;
  109412. /**
  109413. * Adds a parser in the list of available ones
  109414. * @param name Defines the name of the parser
  109415. * @param parser Defines the parser to add
  109416. */
  109417. static AddParser(name: string, parser: BabylonFileParser): void;
  109418. /**
  109419. * Gets a general parser from the list of avaialble ones
  109420. * @param name Defines the name of the parser
  109421. * @returns the requested parser or null
  109422. */
  109423. static GetParser(name: string): Nullable<BabylonFileParser>;
  109424. /**
  109425. * Adds n individual parser in the list of available ones
  109426. * @param name Defines the name of the parser
  109427. * @param parser Defines the parser to add
  109428. */
  109429. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  109430. /**
  109431. * Gets an individual parser from the list of avaialble ones
  109432. * @param name Defines the name of the parser
  109433. * @returns the requested parser or null
  109434. */
  109435. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  109436. /**
  109437. * Parser json data and populate both a scene and its associated container object
  109438. * @param jsonData Defines the data to parse
  109439. * @param scene Defines the scene to parse the data for
  109440. * @param container Defines the container attached to the parsing sequence
  109441. * @param rootUrl Defines the root url of the data
  109442. */
  109443. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  109444. /**
  109445. * Gets the list of root nodes (ie. nodes with no parent)
  109446. */
  109447. rootNodes: Node[];
  109448. /** All of the cameras added to this scene
  109449. * @see http://doc.babylonjs.com/babylon101/cameras
  109450. */
  109451. cameras: Camera[];
  109452. /**
  109453. * All of the lights added to this scene
  109454. * @see http://doc.babylonjs.com/babylon101/lights
  109455. */
  109456. lights: Light[];
  109457. /**
  109458. * All of the (abstract) meshes added to this scene
  109459. */
  109460. meshes: AbstractMesh[];
  109461. /**
  109462. * The list of skeletons added to the scene
  109463. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109464. */
  109465. skeletons: Skeleton[];
  109466. /**
  109467. * All of the particle systems added to this scene
  109468. * @see http://doc.babylonjs.com/babylon101/particles
  109469. */
  109470. particleSystems: IParticleSystem[];
  109471. /**
  109472. * Gets a list of Animations associated with the scene
  109473. */
  109474. animations: Animation[];
  109475. /**
  109476. * All of the animation groups added to this scene
  109477. * @see http://doc.babylonjs.com/how_to/group
  109478. */
  109479. animationGroups: AnimationGroup[];
  109480. /**
  109481. * All of the multi-materials added to this scene
  109482. * @see http://doc.babylonjs.com/how_to/multi_materials
  109483. */
  109484. multiMaterials: MultiMaterial[];
  109485. /**
  109486. * All of the materials added to this scene
  109487. * In the context of a Scene, it is not supposed to be modified manually.
  109488. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  109489. * Note also that the order of the Material within the array is not significant and might change.
  109490. * @see http://doc.babylonjs.com/babylon101/materials
  109491. */
  109492. materials: Material[];
  109493. /**
  109494. * The list of morph target managers added to the scene
  109495. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  109496. */
  109497. morphTargetManagers: MorphTargetManager[];
  109498. /**
  109499. * The list of geometries used in the scene.
  109500. */
  109501. geometries: Geometry[];
  109502. /**
  109503. * All of the tranform nodes added to this scene
  109504. * In the context of a Scene, it is not supposed to be modified manually.
  109505. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  109506. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  109507. * @see http://doc.babylonjs.com/how_to/transformnode
  109508. */
  109509. transformNodes: TransformNode[];
  109510. /**
  109511. * ActionManagers available on the scene.
  109512. */
  109513. actionManagers: AbstractActionManager[];
  109514. /**
  109515. * Textures to keep.
  109516. */
  109517. textures: BaseTexture[];
  109518. /**
  109519. * Environment texture for the scene
  109520. */
  109521. environmentTexture: Nullable<BaseTexture>;
  109522. /**
  109523. * @returns all meshes, lights, cameras, transformNodes and bones
  109524. */
  109525. getNodes(): Array<Node>;
  109526. }
  109527. }
  109528. declare module BABYLON {
  109529. /**
  109530. * Interface used to define options for Sound class
  109531. */
  109532. export interface ISoundOptions {
  109533. /**
  109534. * Does the sound autoplay once loaded.
  109535. */
  109536. autoplay?: boolean;
  109537. /**
  109538. * Does the sound loop after it finishes playing once.
  109539. */
  109540. loop?: boolean;
  109541. /**
  109542. * Sound's volume
  109543. */
  109544. volume?: number;
  109545. /**
  109546. * Is it a spatial sound?
  109547. */
  109548. spatialSound?: boolean;
  109549. /**
  109550. * Maximum distance to hear that sound
  109551. */
  109552. maxDistance?: number;
  109553. /**
  109554. * Uses user defined attenuation function
  109555. */
  109556. useCustomAttenuation?: boolean;
  109557. /**
  109558. * Define the roll off factor of spatial sounds.
  109559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109560. */
  109561. rolloffFactor?: number;
  109562. /**
  109563. * Define the reference distance the sound should be heard perfectly.
  109564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109565. */
  109566. refDistance?: number;
  109567. /**
  109568. * Define the distance attenuation model the sound will follow.
  109569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109570. */
  109571. distanceModel?: string;
  109572. /**
  109573. * Defines the playback speed (1 by default)
  109574. */
  109575. playbackRate?: number;
  109576. /**
  109577. * Defines if the sound is from a streaming source
  109578. */
  109579. streaming?: boolean;
  109580. /**
  109581. * Defines an optional length (in seconds) inside the sound file
  109582. */
  109583. length?: number;
  109584. /**
  109585. * Defines an optional offset (in seconds) inside the sound file
  109586. */
  109587. offset?: number;
  109588. /**
  109589. * If true, URLs will not be required to state the audio file codec to use.
  109590. */
  109591. skipCodecCheck?: boolean;
  109592. }
  109593. /**
  109594. * Defines a sound that can be played in the application.
  109595. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  109596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109597. */
  109598. export class Sound {
  109599. /**
  109600. * The name of the sound in the scene.
  109601. */
  109602. name: string;
  109603. /**
  109604. * Does the sound autoplay once loaded.
  109605. */
  109606. autoplay: boolean;
  109607. /**
  109608. * Does the sound loop after it finishes playing once.
  109609. */
  109610. loop: boolean;
  109611. /**
  109612. * Does the sound use a custom attenuation curve to simulate the falloff
  109613. * happening when the source gets further away from the camera.
  109614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109615. */
  109616. useCustomAttenuation: boolean;
  109617. /**
  109618. * The sound track id this sound belongs to.
  109619. */
  109620. soundTrackId: number;
  109621. /**
  109622. * Is this sound currently played.
  109623. */
  109624. isPlaying: boolean;
  109625. /**
  109626. * Is this sound currently paused.
  109627. */
  109628. isPaused: boolean;
  109629. /**
  109630. * Does this sound enables spatial sound.
  109631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109632. */
  109633. spatialSound: boolean;
  109634. /**
  109635. * Define the reference distance the sound should be heard perfectly.
  109636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109637. */
  109638. refDistance: number;
  109639. /**
  109640. * Define the roll off factor of spatial sounds.
  109641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109642. */
  109643. rolloffFactor: number;
  109644. /**
  109645. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  109646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109647. */
  109648. maxDistance: number;
  109649. /**
  109650. * Define the distance attenuation model the sound will follow.
  109651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109652. */
  109653. distanceModel: string;
  109654. /**
  109655. * @hidden
  109656. * Back Compat
  109657. **/
  109658. onended: () => any;
  109659. /**
  109660. * Observable event when the current playing sound finishes.
  109661. */
  109662. onEndedObservable: Observable<Sound>;
  109663. private _panningModel;
  109664. private _playbackRate;
  109665. private _streaming;
  109666. private _startTime;
  109667. private _startOffset;
  109668. private _position;
  109669. /** @hidden */
  109670. _positionInEmitterSpace: boolean;
  109671. private _localDirection;
  109672. private _volume;
  109673. private _isReadyToPlay;
  109674. private _isDirectional;
  109675. private _readyToPlayCallback;
  109676. private _audioBuffer;
  109677. private _soundSource;
  109678. private _streamingSource;
  109679. private _soundPanner;
  109680. private _soundGain;
  109681. private _inputAudioNode;
  109682. private _outputAudioNode;
  109683. private _coneInnerAngle;
  109684. private _coneOuterAngle;
  109685. private _coneOuterGain;
  109686. private _scene;
  109687. private _connectedTransformNode;
  109688. private _customAttenuationFunction;
  109689. private _registerFunc;
  109690. private _isOutputConnected;
  109691. private _htmlAudioElement;
  109692. private _urlType;
  109693. private _length?;
  109694. private _offset?;
  109695. /** @hidden */
  109696. static _SceneComponentInitialization: (scene: Scene) => void;
  109697. /**
  109698. * Create a sound and attach it to a scene
  109699. * @param name Name of your sound
  109700. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  109701. * @param scene defines the scene the sound belongs to
  109702. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  109703. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  109704. */
  109705. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  109706. /**
  109707. * Release the sound and its associated resources
  109708. */
  109709. dispose(): void;
  109710. /**
  109711. * Gets if the sounds is ready to be played or not.
  109712. * @returns true if ready, otherwise false
  109713. */
  109714. isReady(): boolean;
  109715. private _soundLoaded;
  109716. /**
  109717. * Sets the data of the sound from an audiobuffer
  109718. * @param audioBuffer The audioBuffer containing the data
  109719. */
  109720. setAudioBuffer(audioBuffer: AudioBuffer): void;
  109721. /**
  109722. * Updates the current sounds options such as maxdistance, loop...
  109723. * @param options A JSON object containing values named as the object properties
  109724. */
  109725. updateOptions(options: ISoundOptions): void;
  109726. private _createSpatialParameters;
  109727. private _updateSpatialParameters;
  109728. /**
  109729. * Switch the panning model to HRTF:
  109730. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  109731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109732. */
  109733. switchPanningModelToHRTF(): void;
  109734. /**
  109735. * Switch the panning model to Equal Power:
  109736. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  109737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109738. */
  109739. switchPanningModelToEqualPower(): void;
  109740. private _switchPanningModel;
  109741. /**
  109742. * Connect this sound to a sound track audio node like gain...
  109743. * @param soundTrackAudioNode the sound track audio node to connect to
  109744. */
  109745. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  109746. /**
  109747. * Transform this sound into a directional source
  109748. * @param coneInnerAngle Size of the inner cone in degree
  109749. * @param coneOuterAngle Size of the outer cone in degree
  109750. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  109751. */
  109752. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  109753. /**
  109754. * Gets or sets the inner angle for the directional cone.
  109755. */
  109756. get directionalConeInnerAngle(): number;
  109757. /**
  109758. * Gets or sets the inner angle for the directional cone.
  109759. */
  109760. set directionalConeInnerAngle(value: number);
  109761. /**
  109762. * Gets or sets the outer angle for the directional cone.
  109763. */
  109764. get directionalConeOuterAngle(): number;
  109765. /**
  109766. * Gets or sets the outer angle for the directional cone.
  109767. */
  109768. set directionalConeOuterAngle(value: number);
  109769. /**
  109770. * Sets the position of the emitter if spatial sound is enabled
  109771. * @param newPosition Defines the new posisiton
  109772. */
  109773. setPosition(newPosition: Vector3): void;
  109774. /**
  109775. * Sets the local direction of the emitter if spatial sound is enabled
  109776. * @param newLocalDirection Defines the new local direction
  109777. */
  109778. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  109779. private _updateDirection;
  109780. /** @hidden */
  109781. updateDistanceFromListener(): void;
  109782. /**
  109783. * Sets a new custom attenuation function for the sound.
  109784. * @param callback Defines the function used for the attenuation
  109785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109786. */
  109787. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  109788. /**
  109789. * Play the sound
  109790. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  109791. * @param offset (optional) Start the sound at a specific time in seconds
  109792. * @param length (optional) Sound duration (in seconds)
  109793. */
  109794. play(time?: number, offset?: number, length?: number): void;
  109795. private _onended;
  109796. /**
  109797. * Stop the sound
  109798. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  109799. */
  109800. stop(time?: number): void;
  109801. /**
  109802. * Put the sound in pause
  109803. */
  109804. pause(): void;
  109805. /**
  109806. * Sets a dedicated volume for this sounds
  109807. * @param newVolume Define the new volume of the sound
  109808. * @param time Define time for gradual change to new volume
  109809. */
  109810. setVolume(newVolume: number, time?: number): void;
  109811. /**
  109812. * Set the sound play back rate
  109813. * @param newPlaybackRate Define the playback rate the sound should be played at
  109814. */
  109815. setPlaybackRate(newPlaybackRate: number): void;
  109816. /**
  109817. * Gets the volume of the sound.
  109818. * @returns the volume of the sound
  109819. */
  109820. getVolume(): number;
  109821. /**
  109822. * Attach the sound to a dedicated mesh
  109823. * @param transformNode The transform node to connect the sound with
  109824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109825. */
  109826. attachToMesh(transformNode: TransformNode): void;
  109827. /**
  109828. * Detach the sound from the previously attached mesh
  109829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109830. */
  109831. detachFromMesh(): void;
  109832. private _onRegisterAfterWorldMatrixUpdate;
  109833. /**
  109834. * Clone the current sound in the scene.
  109835. * @returns the new sound clone
  109836. */
  109837. clone(): Nullable<Sound>;
  109838. /**
  109839. * Gets the current underlying audio buffer containing the data
  109840. * @returns the audio buffer
  109841. */
  109842. getAudioBuffer(): Nullable<AudioBuffer>;
  109843. /**
  109844. * Serializes the Sound in a JSON representation
  109845. * @returns the JSON representation of the sound
  109846. */
  109847. serialize(): any;
  109848. /**
  109849. * Parse a JSON representation of a sound to innstantiate in a given scene
  109850. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  109851. * @param scene Define the scene the new parsed sound should be created in
  109852. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  109853. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  109854. * @returns the newly parsed sound
  109855. */
  109856. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  109857. }
  109858. }
  109859. declare module BABYLON {
  109860. /**
  109861. * This defines an action helpful to play a defined sound on a triggered action.
  109862. */
  109863. export class PlaySoundAction extends Action {
  109864. private _sound;
  109865. /**
  109866. * Instantiate the action
  109867. * @param triggerOptions defines the trigger options
  109868. * @param sound defines the sound to play
  109869. * @param condition defines the trigger related conditions
  109870. */
  109871. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  109872. /** @hidden */
  109873. _prepare(): void;
  109874. /**
  109875. * Execute the action and play the sound.
  109876. */
  109877. execute(): void;
  109878. /**
  109879. * Serializes the actions and its related information.
  109880. * @param parent defines the object to serialize in
  109881. * @returns the serialized object
  109882. */
  109883. serialize(parent: any): any;
  109884. }
  109885. /**
  109886. * This defines an action helpful to stop a defined sound on a triggered action.
  109887. */
  109888. export class StopSoundAction extends Action {
  109889. private _sound;
  109890. /**
  109891. * Instantiate the action
  109892. * @param triggerOptions defines the trigger options
  109893. * @param sound defines the sound to stop
  109894. * @param condition defines the trigger related conditions
  109895. */
  109896. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  109897. /** @hidden */
  109898. _prepare(): void;
  109899. /**
  109900. * Execute the action and stop the sound.
  109901. */
  109902. execute(): void;
  109903. /**
  109904. * Serializes the actions and its related information.
  109905. * @param parent defines the object to serialize in
  109906. * @returns the serialized object
  109907. */
  109908. serialize(parent: any): any;
  109909. }
  109910. }
  109911. declare module BABYLON {
  109912. /**
  109913. * This defines an action responsible to change the value of a property
  109914. * by interpolating between its current value and the newly set one once triggered.
  109915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109916. */
  109917. export class InterpolateValueAction extends Action {
  109918. /**
  109919. * Defines the path of the property where the value should be interpolated
  109920. */
  109921. propertyPath: string;
  109922. /**
  109923. * Defines the target value at the end of the interpolation.
  109924. */
  109925. value: any;
  109926. /**
  109927. * Defines the time it will take for the property to interpolate to the value.
  109928. */
  109929. duration: number;
  109930. /**
  109931. * Defines if the other scene animations should be stopped when the action has been triggered
  109932. */
  109933. stopOtherAnimations?: boolean;
  109934. /**
  109935. * Defines a callback raised once the interpolation animation has been done.
  109936. */
  109937. onInterpolationDone?: () => void;
  109938. /**
  109939. * Observable triggered once the interpolation animation has been done.
  109940. */
  109941. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  109942. private _target;
  109943. private _effectiveTarget;
  109944. private _property;
  109945. /**
  109946. * Instantiate the action
  109947. * @param triggerOptions defines the trigger options
  109948. * @param target defines the object containing the value to interpolate
  109949. * @param propertyPath defines the path to the property in the target object
  109950. * @param value defines the target value at the end of the interpolation
  109951. * @param duration deines the time it will take for the property to interpolate to the value.
  109952. * @param condition defines the trigger related conditions
  109953. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  109954. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  109955. */
  109956. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  109957. /** @hidden */
  109958. _prepare(): void;
  109959. /**
  109960. * Execute the action starts the value interpolation.
  109961. */
  109962. execute(): void;
  109963. /**
  109964. * Serializes the actions and its related information.
  109965. * @param parent defines the object to serialize in
  109966. * @returns the serialized object
  109967. */
  109968. serialize(parent: any): any;
  109969. }
  109970. }
  109971. declare module BABYLON {
  109972. /**
  109973. * Options allowed during the creation of a sound track.
  109974. */
  109975. export interface ISoundTrackOptions {
  109976. /**
  109977. * The volume the sound track should take during creation
  109978. */
  109979. volume?: number;
  109980. /**
  109981. * Define if the sound track is the main sound track of the scene
  109982. */
  109983. mainTrack?: boolean;
  109984. }
  109985. /**
  109986. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  109987. * It will be also used in a future release to apply effects on a specific track.
  109988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  109989. */
  109990. export class SoundTrack {
  109991. /**
  109992. * The unique identifier of the sound track in the scene.
  109993. */
  109994. id: number;
  109995. /**
  109996. * The list of sounds included in the sound track.
  109997. */
  109998. soundCollection: Array<Sound>;
  109999. private _outputAudioNode;
  110000. private _scene;
  110001. private _connectedAnalyser;
  110002. private _options;
  110003. private _isInitialized;
  110004. /**
  110005. * Creates a new sound track.
  110006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110007. * @param scene Define the scene the sound track belongs to
  110008. * @param options
  110009. */
  110010. constructor(scene: Scene, options?: ISoundTrackOptions);
  110011. private _initializeSoundTrackAudioGraph;
  110012. /**
  110013. * Release the sound track and its associated resources
  110014. */
  110015. dispose(): void;
  110016. /**
  110017. * Adds a sound to this sound track
  110018. * @param sound define the cound to add
  110019. * @ignoreNaming
  110020. */
  110021. AddSound(sound: Sound): void;
  110022. /**
  110023. * Removes a sound to this sound track
  110024. * @param sound define the cound to remove
  110025. * @ignoreNaming
  110026. */
  110027. RemoveSound(sound: Sound): void;
  110028. /**
  110029. * Set a global volume for the full sound track.
  110030. * @param newVolume Define the new volume of the sound track
  110031. */
  110032. setVolume(newVolume: number): void;
  110033. /**
  110034. * Switch the panning model to HRTF:
  110035. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110037. */
  110038. switchPanningModelToHRTF(): void;
  110039. /**
  110040. * Switch the panning model to Equal Power:
  110041. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110043. */
  110044. switchPanningModelToEqualPower(): void;
  110045. /**
  110046. * Connect the sound track to an audio analyser allowing some amazing
  110047. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110049. * @param analyser The analyser to connect to the engine
  110050. */
  110051. connectToAnalyser(analyser: Analyser): void;
  110052. }
  110053. }
  110054. declare module BABYLON {
  110055. interface AbstractScene {
  110056. /**
  110057. * The list of sounds used in the scene.
  110058. */
  110059. sounds: Nullable<Array<Sound>>;
  110060. }
  110061. interface Scene {
  110062. /**
  110063. * @hidden
  110064. * Backing field
  110065. */
  110066. _mainSoundTrack: SoundTrack;
  110067. /**
  110068. * The main sound track played by the scene.
  110069. * It cotains your primary collection of sounds.
  110070. */
  110071. mainSoundTrack: SoundTrack;
  110072. /**
  110073. * The list of sound tracks added to the scene
  110074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110075. */
  110076. soundTracks: Nullable<Array<SoundTrack>>;
  110077. /**
  110078. * Gets a sound using a given name
  110079. * @param name defines the name to search for
  110080. * @return the found sound or null if not found at all.
  110081. */
  110082. getSoundByName(name: string): Nullable<Sound>;
  110083. /**
  110084. * Gets or sets if audio support is enabled
  110085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110086. */
  110087. audioEnabled: boolean;
  110088. /**
  110089. * Gets or sets if audio will be output to headphones
  110090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110091. */
  110092. headphone: boolean;
  110093. /**
  110094. * Gets or sets custom audio listener position provider
  110095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110096. */
  110097. audioListenerPositionProvider: Nullable<() => Vector3>;
  110098. /**
  110099. * Gets or sets a refresh rate when using 3D audio positioning
  110100. */
  110101. audioPositioningRefreshRate: number;
  110102. }
  110103. /**
  110104. * Defines the sound scene component responsible to manage any sounds
  110105. * in a given scene.
  110106. */
  110107. export class AudioSceneComponent implements ISceneSerializableComponent {
  110108. /**
  110109. * The component name helpfull to identify the component in the list of scene components.
  110110. */
  110111. readonly name: string;
  110112. /**
  110113. * The scene the component belongs to.
  110114. */
  110115. scene: Scene;
  110116. private _audioEnabled;
  110117. /**
  110118. * Gets whether audio is enabled or not.
  110119. * Please use related enable/disable method to switch state.
  110120. */
  110121. get audioEnabled(): boolean;
  110122. private _headphone;
  110123. /**
  110124. * Gets whether audio is outputing to headphone or not.
  110125. * Please use the according Switch methods to change output.
  110126. */
  110127. get headphone(): boolean;
  110128. /**
  110129. * Gets or sets a refresh rate when using 3D audio positioning
  110130. */
  110131. audioPositioningRefreshRate: number;
  110132. private _audioListenerPositionProvider;
  110133. /**
  110134. * Gets the current audio listener position provider
  110135. */
  110136. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110137. /**
  110138. * Sets a custom listener position for all sounds in the scene
  110139. * By default, this is the position of the first active camera
  110140. */
  110141. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110142. /**
  110143. * Creates a new instance of the component for the given scene
  110144. * @param scene Defines the scene to register the component in
  110145. */
  110146. constructor(scene: Scene);
  110147. /**
  110148. * Registers the component in a given scene
  110149. */
  110150. register(): void;
  110151. /**
  110152. * Rebuilds the elements related to this component in case of
  110153. * context lost for instance.
  110154. */
  110155. rebuild(): void;
  110156. /**
  110157. * Serializes the component data to the specified json object
  110158. * @param serializationObject The object to serialize to
  110159. */
  110160. serialize(serializationObject: any): void;
  110161. /**
  110162. * Adds all the elements from the container to the scene
  110163. * @param container the container holding the elements
  110164. */
  110165. addFromContainer(container: AbstractScene): void;
  110166. /**
  110167. * Removes all the elements in the container from the scene
  110168. * @param container contains the elements to remove
  110169. * @param dispose if the removed element should be disposed (default: false)
  110170. */
  110171. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110172. /**
  110173. * Disposes the component and the associated ressources.
  110174. */
  110175. dispose(): void;
  110176. /**
  110177. * Disables audio in the associated scene.
  110178. */
  110179. disableAudio(): void;
  110180. /**
  110181. * Enables audio in the associated scene.
  110182. */
  110183. enableAudio(): void;
  110184. /**
  110185. * Switch audio to headphone output.
  110186. */
  110187. switchAudioModeForHeadphones(): void;
  110188. /**
  110189. * Switch audio to normal speakers.
  110190. */
  110191. switchAudioModeForNormalSpeakers(): void;
  110192. private _cachedCameraDirection;
  110193. private _cachedCameraPosition;
  110194. private _lastCheck;
  110195. private _afterRender;
  110196. }
  110197. }
  110198. declare module BABYLON {
  110199. /**
  110200. * Wraps one or more Sound objects and selects one with random weight for playback.
  110201. */
  110202. export class WeightedSound {
  110203. /** When true a Sound will be selected and played when the current playing Sound completes. */
  110204. loop: boolean;
  110205. private _coneInnerAngle;
  110206. private _coneOuterAngle;
  110207. private _volume;
  110208. /** A Sound is currently playing. */
  110209. isPlaying: boolean;
  110210. /** A Sound is currently paused. */
  110211. isPaused: boolean;
  110212. private _sounds;
  110213. private _weights;
  110214. private _currentIndex?;
  110215. /**
  110216. * Creates a new WeightedSound from the list of sounds given.
  110217. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  110218. * @param sounds Array of Sounds that will be selected from.
  110219. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  110220. */
  110221. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  110222. /**
  110223. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  110224. */
  110225. get directionalConeInnerAngle(): number;
  110226. /**
  110227. * The size of cone in degress for a directional sound in which there will be no attenuation.
  110228. */
  110229. set directionalConeInnerAngle(value: number);
  110230. /**
  110231. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110232. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110233. */
  110234. get directionalConeOuterAngle(): number;
  110235. /**
  110236. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110237. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110238. */
  110239. set directionalConeOuterAngle(value: number);
  110240. /**
  110241. * Playback volume.
  110242. */
  110243. get volume(): number;
  110244. /**
  110245. * Playback volume.
  110246. */
  110247. set volume(value: number);
  110248. private _onended;
  110249. /**
  110250. * Suspend playback
  110251. */
  110252. pause(): void;
  110253. /**
  110254. * Stop playback
  110255. */
  110256. stop(): void;
  110257. /**
  110258. * Start playback.
  110259. * @param startOffset Position the clip head at a specific time in seconds.
  110260. */
  110261. play(startOffset?: number): void;
  110262. }
  110263. }
  110264. declare module BABYLON {
  110265. /**
  110266. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  110267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  110268. */
  110269. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  110270. /**
  110271. * Gets the name of the behavior.
  110272. */
  110273. get name(): string;
  110274. /**
  110275. * The easing function used by animations
  110276. */
  110277. static EasingFunction: BackEase;
  110278. /**
  110279. * The easing mode used by animations
  110280. */
  110281. static EasingMode: number;
  110282. /**
  110283. * The duration of the animation, in milliseconds
  110284. */
  110285. transitionDuration: number;
  110286. /**
  110287. * Length of the distance animated by the transition when lower radius is reached
  110288. */
  110289. lowerRadiusTransitionRange: number;
  110290. /**
  110291. * Length of the distance animated by the transition when upper radius is reached
  110292. */
  110293. upperRadiusTransitionRange: number;
  110294. private _autoTransitionRange;
  110295. /**
  110296. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110297. */
  110298. get autoTransitionRange(): boolean;
  110299. /**
  110300. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110301. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  110302. */
  110303. set autoTransitionRange(value: boolean);
  110304. private _attachedCamera;
  110305. private _onAfterCheckInputsObserver;
  110306. private _onMeshTargetChangedObserver;
  110307. /**
  110308. * Initializes the behavior.
  110309. */
  110310. init(): void;
  110311. /**
  110312. * Attaches the behavior to its arc rotate camera.
  110313. * @param camera Defines the camera to attach the behavior to
  110314. */
  110315. attach(camera: ArcRotateCamera): void;
  110316. /**
  110317. * Detaches the behavior from its current arc rotate camera.
  110318. */
  110319. detach(): void;
  110320. private _radiusIsAnimating;
  110321. private _radiusBounceTransition;
  110322. private _animatables;
  110323. private _cachedWheelPrecision;
  110324. /**
  110325. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  110326. * @param radiusLimit The limit to check against.
  110327. * @return Bool to indicate if at limit.
  110328. */
  110329. private _isRadiusAtLimit;
  110330. /**
  110331. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  110332. * @param radiusDelta The delta by which to animate to. Can be negative.
  110333. */
  110334. private _applyBoundRadiusAnimation;
  110335. /**
  110336. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  110337. */
  110338. protected _clearAnimationLocks(): void;
  110339. /**
  110340. * Stops and removes all animations that have been applied to the camera
  110341. */
  110342. stopAllAnimations(): void;
  110343. }
  110344. }
  110345. declare module BABYLON {
  110346. /**
  110347. * 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.
  110348. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  110349. */
  110350. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  110351. /**
  110352. * Gets the name of the behavior.
  110353. */
  110354. get name(): string;
  110355. private _mode;
  110356. private _radiusScale;
  110357. private _positionScale;
  110358. private _defaultElevation;
  110359. private _elevationReturnTime;
  110360. private _elevationReturnWaitTime;
  110361. private _zoomStopsAnimation;
  110362. private _framingTime;
  110363. /**
  110364. * The easing function used by animations
  110365. */
  110366. static EasingFunction: ExponentialEase;
  110367. /**
  110368. * The easing mode used by animations
  110369. */
  110370. static EasingMode: number;
  110371. /**
  110372. * Sets the current mode used by the behavior
  110373. */
  110374. set mode(mode: number);
  110375. /**
  110376. * Gets current mode used by the behavior.
  110377. */
  110378. get mode(): number;
  110379. /**
  110380. * Sets the scale applied to the radius (1 by default)
  110381. */
  110382. set radiusScale(radius: number);
  110383. /**
  110384. * Gets the scale applied to the radius
  110385. */
  110386. get radiusScale(): number;
  110387. /**
  110388. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110389. */
  110390. set positionScale(scale: number);
  110391. /**
  110392. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110393. */
  110394. get positionScale(): number;
  110395. /**
  110396. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110397. * behaviour is triggered, in radians.
  110398. */
  110399. set defaultElevation(elevation: number);
  110400. /**
  110401. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110402. * behaviour is triggered, in radians.
  110403. */
  110404. get defaultElevation(): number;
  110405. /**
  110406. * Sets the time (in milliseconds) taken to return to the default beta position.
  110407. * Negative value indicates camera should not return to default.
  110408. */
  110409. set elevationReturnTime(speed: number);
  110410. /**
  110411. * Gets the time (in milliseconds) taken to return to the default beta position.
  110412. * Negative value indicates camera should not return to default.
  110413. */
  110414. get elevationReturnTime(): number;
  110415. /**
  110416. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110417. */
  110418. set elevationReturnWaitTime(time: number);
  110419. /**
  110420. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110421. */
  110422. get elevationReturnWaitTime(): number;
  110423. /**
  110424. * Sets the flag that indicates if user zooming should stop animation.
  110425. */
  110426. set zoomStopsAnimation(flag: boolean);
  110427. /**
  110428. * Gets the flag that indicates if user zooming should stop animation.
  110429. */
  110430. get zoomStopsAnimation(): boolean;
  110431. /**
  110432. * Sets the transition time when framing the mesh, in milliseconds
  110433. */
  110434. set framingTime(time: number);
  110435. /**
  110436. * Gets the transition time when framing the mesh, in milliseconds
  110437. */
  110438. get framingTime(): number;
  110439. /**
  110440. * Define if the behavior should automatically change the configured
  110441. * camera limits and sensibilities.
  110442. */
  110443. autoCorrectCameraLimitsAndSensibility: boolean;
  110444. private _onPrePointerObservableObserver;
  110445. private _onAfterCheckInputsObserver;
  110446. private _onMeshTargetChangedObserver;
  110447. private _attachedCamera;
  110448. private _isPointerDown;
  110449. private _lastInteractionTime;
  110450. /**
  110451. * Initializes the behavior.
  110452. */
  110453. init(): void;
  110454. /**
  110455. * Attaches the behavior to its arc rotate camera.
  110456. * @param camera Defines the camera to attach the behavior to
  110457. */
  110458. attach(camera: ArcRotateCamera): void;
  110459. /**
  110460. * Detaches the behavior from its current arc rotate camera.
  110461. */
  110462. detach(): void;
  110463. private _animatables;
  110464. private _betaIsAnimating;
  110465. private _betaTransition;
  110466. private _radiusTransition;
  110467. private _vectorTransition;
  110468. /**
  110469. * Targets the given mesh and updates zoom level accordingly.
  110470. * @param mesh The mesh to target.
  110471. * @param radius Optional. If a cached radius position already exists, overrides default.
  110472. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110473. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110474. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110475. */
  110476. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110477. /**
  110478. * Targets the given mesh with its children and updates zoom level accordingly.
  110479. * @param mesh The mesh to target.
  110480. * @param radius Optional. If a cached radius position already exists, overrides default.
  110481. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110482. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110483. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110484. */
  110485. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110486. /**
  110487. * Targets the given meshes with their children and updates zoom level accordingly.
  110488. * @param meshes The mesh to target.
  110489. * @param radius Optional. If a cached radius position already exists, overrides default.
  110490. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110491. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110492. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110493. */
  110494. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110495. /**
  110496. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  110497. * @param minimumWorld Determines the smaller position of the bounding box extend
  110498. * @param maximumWorld Determines the bigger position of the bounding box extend
  110499. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110500. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110501. */
  110502. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110503. /**
  110504. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  110505. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  110506. * frustum width.
  110507. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  110508. * to fully enclose the mesh in the viewing frustum.
  110509. */
  110510. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  110511. /**
  110512. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  110513. * is automatically returned to its default position (expected to be above ground plane).
  110514. */
  110515. private _maintainCameraAboveGround;
  110516. /**
  110517. * Returns the frustum slope based on the canvas ratio and camera FOV
  110518. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  110519. */
  110520. private _getFrustumSlope;
  110521. /**
  110522. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  110523. */
  110524. private _clearAnimationLocks;
  110525. /**
  110526. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110527. */
  110528. private _applyUserInteraction;
  110529. /**
  110530. * Stops and removes all animations that have been applied to the camera
  110531. */
  110532. stopAllAnimations(): void;
  110533. /**
  110534. * Gets a value indicating if the user is moving the camera
  110535. */
  110536. get isUserIsMoving(): boolean;
  110537. /**
  110538. * The camera can move all the way towards the mesh.
  110539. */
  110540. static IgnoreBoundsSizeMode: number;
  110541. /**
  110542. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  110543. */
  110544. static FitFrustumSidesMode: number;
  110545. }
  110546. }
  110547. declare module BABYLON {
  110548. /**
  110549. * Base class for Camera Pointer Inputs.
  110550. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  110551. * for example usage.
  110552. */
  110553. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  110554. /**
  110555. * Defines the camera the input is attached to.
  110556. */
  110557. abstract camera: Camera;
  110558. /**
  110559. * Whether keyboard modifier keys are pressed at time of last mouse event.
  110560. */
  110561. protected _altKey: boolean;
  110562. protected _ctrlKey: boolean;
  110563. protected _metaKey: boolean;
  110564. protected _shiftKey: boolean;
  110565. /**
  110566. * Which mouse buttons were pressed at time of last mouse event.
  110567. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  110568. */
  110569. protected _buttonsPressed: number;
  110570. /**
  110571. * Defines the buttons associated with the input to handle camera move.
  110572. */
  110573. buttons: number[];
  110574. /**
  110575. * Attach the input controls to a specific dom element to get the input from.
  110576. * @param element Defines the element the controls should be listened from
  110577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110578. */
  110579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110580. /**
  110581. * Detach the current controls from the specified dom element.
  110582. * @param element Defines the element to stop listening the inputs from
  110583. */
  110584. detachControl(element: Nullable<HTMLElement>): void;
  110585. /**
  110586. * Gets the class name of the current input.
  110587. * @returns the class name
  110588. */
  110589. getClassName(): string;
  110590. /**
  110591. * Get the friendly name associated with the input class.
  110592. * @returns the input friendly name
  110593. */
  110594. getSimpleName(): string;
  110595. /**
  110596. * Called on pointer POINTERDOUBLETAP event.
  110597. * Override this method to provide functionality on POINTERDOUBLETAP event.
  110598. */
  110599. protected onDoubleTap(type: string): void;
  110600. /**
  110601. * Called on pointer POINTERMOVE event if only a single touch is active.
  110602. * Override this method to provide functionality.
  110603. */
  110604. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110605. /**
  110606. * Called on pointer POINTERMOVE event if multiple touches are active.
  110607. * Override this method to provide functionality.
  110608. */
  110609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110610. /**
  110611. * Called on JS contextmenu event.
  110612. * Override this method to provide functionality.
  110613. */
  110614. protected onContextMenu(evt: PointerEvent): void;
  110615. /**
  110616. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110617. * press.
  110618. * Override this method to provide functionality.
  110619. */
  110620. protected onButtonDown(evt: PointerEvent): void;
  110621. /**
  110622. * Called each time a new POINTERUP event occurs. Ie, for each button
  110623. * release.
  110624. * Override this method to provide functionality.
  110625. */
  110626. protected onButtonUp(evt: PointerEvent): void;
  110627. /**
  110628. * Called when window becomes inactive.
  110629. * Override this method to provide functionality.
  110630. */
  110631. protected onLostFocus(): void;
  110632. private _pointerInput;
  110633. private _observer;
  110634. private _onLostFocus;
  110635. private pointA;
  110636. private pointB;
  110637. }
  110638. }
  110639. declare module BABYLON {
  110640. /**
  110641. * Manage the pointers inputs to control an arc rotate camera.
  110642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110643. */
  110644. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  110645. /**
  110646. * Defines the camera the input is attached to.
  110647. */
  110648. camera: ArcRotateCamera;
  110649. /**
  110650. * Gets the class name of the current input.
  110651. * @returns the class name
  110652. */
  110653. getClassName(): string;
  110654. /**
  110655. * Defines the buttons associated with the input to handle camera move.
  110656. */
  110657. buttons: number[];
  110658. /**
  110659. * Defines the pointer angular sensibility along the X axis or how fast is
  110660. * the camera rotating.
  110661. */
  110662. angularSensibilityX: number;
  110663. /**
  110664. * Defines the pointer angular sensibility along the Y axis or how fast is
  110665. * the camera rotating.
  110666. */
  110667. angularSensibilityY: number;
  110668. /**
  110669. * Defines the pointer pinch precision or how fast is the camera zooming.
  110670. */
  110671. pinchPrecision: number;
  110672. /**
  110673. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110674. * from 0.
  110675. * It defines the percentage of current camera.radius to use as delta when
  110676. * pinch zoom is used.
  110677. */
  110678. pinchDeltaPercentage: number;
  110679. /**
  110680. * Defines the pointer panning sensibility or how fast is the camera moving.
  110681. */
  110682. panningSensibility: number;
  110683. /**
  110684. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  110685. */
  110686. multiTouchPanning: boolean;
  110687. /**
  110688. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  110689. * zoom (pinch) through multitouch.
  110690. */
  110691. multiTouchPanAndZoom: boolean;
  110692. /**
  110693. * Revers pinch action direction.
  110694. */
  110695. pinchInwards: boolean;
  110696. private _isPanClick;
  110697. private _twoFingerActivityCount;
  110698. private _isPinching;
  110699. /**
  110700. * Called on pointer POINTERMOVE event if only a single touch is active.
  110701. */
  110702. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110703. /**
  110704. * Called on pointer POINTERDOUBLETAP event.
  110705. */
  110706. protected onDoubleTap(type: string): void;
  110707. /**
  110708. * Called on pointer POINTERMOVE event if multiple touches are active.
  110709. */
  110710. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110711. /**
  110712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110713. * press.
  110714. */
  110715. protected onButtonDown(evt: PointerEvent): void;
  110716. /**
  110717. * Called each time a new POINTERUP event occurs. Ie, for each button
  110718. * release.
  110719. */
  110720. protected onButtonUp(evt: PointerEvent): void;
  110721. /**
  110722. * Called when window becomes inactive.
  110723. */
  110724. protected onLostFocus(): void;
  110725. }
  110726. }
  110727. declare module BABYLON {
  110728. /**
  110729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  110730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110731. */
  110732. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  110733. /**
  110734. * Defines the camera the input is attached to.
  110735. */
  110736. camera: ArcRotateCamera;
  110737. /**
  110738. * Defines the list of key codes associated with the up action (increase alpha)
  110739. */
  110740. keysUp: number[];
  110741. /**
  110742. * Defines the list of key codes associated with the down action (decrease alpha)
  110743. */
  110744. keysDown: number[];
  110745. /**
  110746. * Defines the list of key codes associated with the left action (increase beta)
  110747. */
  110748. keysLeft: number[];
  110749. /**
  110750. * Defines the list of key codes associated with the right action (decrease beta)
  110751. */
  110752. keysRight: number[];
  110753. /**
  110754. * Defines the list of key codes associated with the reset action.
  110755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  110756. */
  110757. keysReset: number[];
  110758. /**
  110759. * Defines the panning sensibility of the inputs.
  110760. * (How fast is the camera paning)
  110761. */
  110762. panningSensibility: number;
  110763. /**
  110764. * Defines the zooming sensibility of the inputs.
  110765. * (How fast is the camera zooming)
  110766. */
  110767. zoomingSensibility: number;
  110768. /**
  110769. * Defines wether maintaining the alt key down switch the movement mode from
  110770. * orientation to zoom.
  110771. */
  110772. useAltToZoom: boolean;
  110773. /**
  110774. * Rotation speed of the camera
  110775. */
  110776. angularSpeed: number;
  110777. private _keys;
  110778. private _ctrlPressed;
  110779. private _altPressed;
  110780. private _onCanvasBlurObserver;
  110781. private _onKeyboardObserver;
  110782. private _engine;
  110783. private _scene;
  110784. /**
  110785. * Attach the input controls to a specific dom element to get the input from.
  110786. * @param element Defines the element the controls should be listened from
  110787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110788. */
  110789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110790. /**
  110791. * Detach the current controls from the specified dom element.
  110792. * @param element Defines the element to stop listening the inputs from
  110793. */
  110794. detachControl(element: Nullable<HTMLElement>): void;
  110795. /**
  110796. * Update the current camera state depending on the inputs that have been used this frame.
  110797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110798. */
  110799. checkInputs(): void;
  110800. /**
  110801. * Gets the class name of the current intput.
  110802. * @returns the class name
  110803. */
  110804. getClassName(): string;
  110805. /**
  110806. * Get the friendly name associated with the input class.
  110807. * @returns the input friendly name
  110808. */
  110809. getSimpleName(): string;
  110810. }
  110811. }
  110812. declare module BABYLON {
  110813. /**
  110814. * Manage the mouse wheel inputs to control an arc rotate camera.
  110815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110816. */
  110817. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  110818. /**
  110819. * Defines the camera the input is attached to.
  110820. */
  110821. camera: ArcRotateCamera;
  110822. /**
  110823. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  110824. */
  110825. wheelPrecision: number;
  110826. /**
  110827. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110828. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110829. */
  110830. wheelDeltaPercentage: number;
  110831. private _wheel;
  110832. private _observer;
  110833. private computeDeltaFromMouseWheelLegacyEvent;
  110834. /**
  110835. * Attach the input controls to a specific dom element to get the input from.
  110836. * @param element Defines the element the controls should be listened from
  110837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110838. */
  110839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110840. /**
  110841. * Detach the current controls from the specified dom element.
  110842. * @param element Defines the element to stop listening the inputs from
  110843. */
  110844. detachControl(element: Nullable<HTMLElement>): void;
  110845. /**
  110846. * Gets the class name of the current intput.
  110847. * @returns the class name
  110848. */
  110849. getClassName(): string;
  110850. /**
  110851. * Get the friendly name associated with the input class.
  110852. * @returns the input friendly name
  110853. */
  110854. getSimpleName(): string;
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. /**
  110859. * Default Inputs manager for the ArcRotateCamera.
  110860. * It groups all the default supported inputs for ease of use.
  110861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110862. */
  110863. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  110864. /**
  110865. * Instantiates a new ArcRotateCameraInputsManager.
  110866. * @param camera Defines the camera the inputs belong to
  110867. */
  110868. constructor(camera: ArcRotateCamera);
  110869. /**
  110870. * Add mouse wheel input support to the input manager.
  110871. * @returns the current input manager
  110872. */
  110873. addMouseWheel(): ArcRotateCameraInputsManager;
  110874. /**
  110875. * Add pointers input support to the input manager.
  110876. * @returns the current input manager
  110877. */
  110878. addPointers(): ArcRotateCameraInputsManager;
  110879. /**
  110880. * Add keyboard input support to the input manager.
  110881. * @returns the current input manager
  110882. */
  110883. addKeyboard(): ArcRotateCameraInputsManager;
  110884. }
  110885. }
  110886. declare module BABYLON {
  110887. /**
  110888. * This represents an orbital type of camera.
  110889. *
  110890. * 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.
  110891. * 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.
  110892. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  110893. */
  110894. export class ArcRotateCamera extends TargetCamera {
  110895. /**
  110896. * Defines the rotation angle of the camera along the longitudinal axis.
  110897. */
  110898. alpha: number;
  110899. /**
  110900. * Defines the rotation angle of the camera along the latitudinal axis.
  110901. */
  110902. beta: number;
  110903. /**
  110904. * Defines the radius of the camera from it s target point.
  110905. */
  110906. radius: number;
  110907. protected _target: Vector3;
  110908. protected _targetHost: Nullable<AbstractMesh>;
  110909. /**
  110910. * Defines the target point of the camera.
  110911. * The camera looks towards it form the radius distance.
  110912. */
  110913. get target(): Vector3;
  110914. set target(value: Vector3);
  110915. /**
  110916. * Define the current local position of the camera in the scene
  110917. */
  110918. get position(): Vector3;
  110919. set position(newPosition: Vector3);
  110920. protected _upVector: Vector3;
  110921. protected _upToYMatrix: Matrix;
  110922. protected _YToUpMatrix: Matrix;
  110923. /**
  110924. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  110925. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  110926. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  110927. */
  110928. set upVector(vec: Vector3);
  110929. get upVector(): Vector3;
  110930. /**
  110931. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  110932. */
  110933. setMatUp(): void;
  110934. /**
  110935. * Current inertia value on the longitudinal axis.
  110936. * The bigger this number the longer it will take for the camera to stop.
  110937. */
  110938. inertialAlphaOffset: number;
  110939. /**
  110940. * Current inertia value on the latitudinal axis.
  110941. * The bigger this number the longer it will take for the camera to stop.
  110942. */
  110943. inertialBetaOffset: number;
  110944. /**
  110945. * Current inertia value on the radius axis.
  110946. * The bigger this number the longer it will take for the camera to stop.
  110947. */
  110948. inertialRadiusOffset: number;
  110949. /**
  110950. * Minimum allowed angle on the longitudinal axis.
  110951. * This can help limiting how the Camera is able to move in the scene.
  110952. */
  110953. lowerAlphaLimit: Nullable<number>;
  110954. /**
  110955. * Maximum allowed angle on the longitudinal axis.
  110956. * This can help limiting how the Camera is able to move in the scene.
  110957. */
  110958. upperAlphaLimit: Nullable<number>;
  110959. /**
  110960. * Minimum allowed angle on the latitudinal axis.
  110961. * This can help limiting how the Camera is able to move in the scene.
  110962. */
  110963. lowerBetaLimit: number;
  110964. /**
  110965. * Maximum allowed angle on the latitudinal axis.
  110966. * This can help limiting how the Camera is able to move in the scene.
  110967. */
  110968. upperBetaLimit: number;
  110969. /**
  110970. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  110971. * This can help limiting how the Camera is able to move in the scene.
  110972. */
  110973. lowerRadiusLimit: Nullable<number>;
  110974. /**
  110975. * Maximum allowed distance of the camera to the target (The camera can not get further).
  110976. * This can help limiting how the Camera is able to move in the scene.
  110977. */
  110978. upperRadiusLimit: Nullable<number>;
  110979. /**
  110980. * Defines the current inertia value used during panning of the camera along the X axis.
  110981. */
  110982. inertialPanningX: number;
  110983. /**
  110984. * Defines the current inertia value used during panning of the camera along the Y axis.
  110985. */
  110986. inertialPanningY: number;
  110987. /**
  110988. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  110989. * Basically if your fingers moves away from more than this distance you will be considered
  110990. * in pinch mode.
  110991. */
  110992. pinchToPanMaxDistance: number;
  110993. /**
  110994. * Defines the maximum distance the camera can pan.
  110995. * This could help keeping the cammera always in your scene.
  110996. */
  110997. panningDistanceLimit: Nullable<number>;
  110998. /**
  110999. * Defines the target of the camera before paning.
  111000. */
  111001. panningOriginTarget: Vector3;
  111002. /**
  111003. * Defines the value of the inertia used during panning.
  111004. * 0 would mean stop inertia and one would mean no decelleration at all.
  111005. */
  111006. panningInertia: number;
  111007. /**
  111008. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111009. */
  111010. get angularSensibilityX(): number;
  111011. set angularSensibilityX(value: number);
  111012. /**
  111013. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111014. */
  111015. get angularSensibilityY(): number;
  111016. set angularSensibilityY(value: number);
  111017. /**
  111018. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111019. */
  111020. get pinchPrecision(): number;
  111021. set pinchPrecision(value: number);
  111022. /**
  111023. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111024. * It will be used instead of pinchDeltaPrecision if different from 0.
  111025. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111026. */
  111027. get pinchDeltaPercentage(): number;
  111028. set pinchDeltaPercentage(value: number);
  111029. /**
  111030. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111031. */
  111032. get panningSensibility(): number;
  111033. set panningSensibility(value: number);
  111034. /**
  111035. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111036. */
  111037. get keysUp(): number[];
  111038. set keysUp(value: number[]);
  111039. /**
  111040. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111041. */
  111042. get keysDown(): number[];
  111043. set keysDown(value: number[]);
  111044. /**
  111045. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111046. */
  111047. get keysLeft(): number[];
  111048. set keysLeft(value: number[]);
  111049. /**
  111050. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111051. */
  111052. get keysRight(): number[];
  111053. set keysRight(value: number[]);
  111054. /**
  111055. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111056. */
  111057. get wheelPrecision(): number;
  111058. set wheelPrecision(value: number);
  111059. /**
  111060. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111061. * It will be used instead of pinchDeltaPrecision if different from 0.
  111062. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111063. */
  111064. get wheelDeltaPercentage(): number;
  111065. set wheelDeltaPercentage(value: number);
  111066. /**
  111067. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111068. */
  111069. zoomOnFactor: number;
  111070. /**
  111071. * Defines a screen offset for the camera position.
  111072. */
  111073. targetScreenOffset: Vector2;
  111074. /**
  111075. * Allows the camera to be completely reversed.
  111076. * If false the camera can not arrive upside down.
  111077. */
  111078. allowUpsideDown: boolean;
  111079. /**
  111080. * Define if double tap/click is used to restore the previously saved state of the camera.
  111081. */
  111082. useInputToRestoreState: boolean;
  111083. /** @hidden */
  111084. _viewMatrix: Matrix;
  111085. /** @hidden */
  111086. _useCtrlForPanning: boolean;
  111087. /** @hidden */
  111088. _panningMouseButton: number;
  111089. /**
  111090. * Defines the input associated to the camera.
  111091. */
  111092. inputs: ArcRotateCameraInputsManager;
  111093. /** @hidden */
  111094. _reset: () => void;
  111095. /**
  111096. * Defines the allowed panning axis.
  111097. */
  111098. panningAxis: Vector3;
  111099. protected _localDirection: Vector3;
  111100. protected _transformedDirection: Vector3;
  111101. private _bouncingBehavior;
  111102. /**
  111103. * Gets the bouncing behavior of the camera if it has been enabled.
  111104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111105. */
  111106. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111107. /**
  111108. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111110. */
  111111. get useBouncingBehavior(): boolean;
  111112. set useBouncingBehavior(value: boolean);
  111113. private _framingBehavior;
  111114. /**
  111115. * Gets the framing behavior of the camera if it has been enabled.
  111116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111117. */
  111118. get framingBehavior(): Nullable<FramingBehavior>;
  111119. /**
  111120. * Defines if the framing behavior of the camera is enabled on the camera.
  111121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111122. */
  111123. get useFramingBehavior(): boolean;
  111124. set useFramingBehavior(value: boolean);
  111125. private _autoRotationBehavior;
  111126. /**
  111127. * Gets the auto rotation behavior of the camera if it has been enabled.
  111128. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111129. */
  111130. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111131. /**
  111132. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111134. */
  111135. get useAutoRotationBehavior(): boolean;
  111136. set useAutoRotationBehavior(value: boolean);
  111137. /**
  111138. * Observable triggered when the mesh target has been changed on the camera.
  111139. */
  111140. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111141. /**
  111142. * Event raised when the camera is colliding with a mesh.
  111143. */
  111144. onCollide: (collidedMesh: AbstractMesh) => void;
  111145. /**
  111146. * Defines whether the camera should check collision with the objects oh the scene.
  111147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111148. */
  111149. checkCollisions: boolean;
  111150. /**
  111151. * Defines the collision radius of the camera.
  111152. * This simulates a sphere around the camera.
  111153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111154. */
  111155. collisionRadius: Vector3;
  111156. protected _collider: Collider;
  111157. protected _previousPosition: Vector3;
  111158. protected _collisionVelocity: Vector3;
  111159. protected _newPosition: Vector3;
  111160. protected _previousAlpha: number;
  111161. protected _previousBeta: number;
  111162. protected _previousRadius: number;
  111163. protected _collisionTriggered: boolean;
  111164. protected _targetBoundingCenter: Nullable<Vector3>;
  111165. private _computationVector;
  111166. /**
  111167. * Instantiates a new ArcRotateCamera in a given scene
  111168. * @param name Defines the name of the camera
  111169. * @param alpha Defines the camera rotation along the logitudinal axis
  111170. * @param beta Defines the camera rotation along the latitudinal axis
  111171. * @param radius Defines the camera distance from its target
  111172. * @param target Defines the camera target
  111173. * @param scene Defines the scene the camera belongs to
  111174. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111175. */
  111176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111177. /** @hidden */
  111178. _initCache(): void;
  111179. /** @hidden */
  111180. _updateCache(ignoreParentClass?: boolean): void;
  111181. protected _getTargetPosition(): Vector3;
  111182. private _storedAlpha;
  111183. private _storedBeta;
  111184. private _storedRadius;
  111185. private _storedTarget;
  111186. private _storedTargetScreenOffset;
  111187. /**
  111188. * Stores the current state of the camera (alpha, beta, radius and target)
  111189. * @returns the camera itself
  111190. */
  111191. storeState(): Camera;
  111192. /**
  111193. * @hidden
  111194. * Restored camera state. You must call storeState() first
  111195. */
  111196. _restoreStateValues(): boolean;
  111197. /** @hidden */
  111198. _isSynchronizedViewMatrix(): boolean;
  111199. /**
  111200. * Attached controls to the current camera.
  111201. * @param element Defines the element the controls should be listened from
  111202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111203. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  111204. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  111205. */
  111206. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  111207. /**
  111208. * Detach the current controls from the camera.
  111209. * The camera will stop reacting to inputs.
  111210. * @param element Defines the element to stop listening the inputs from
  111211. */
  111212. detachControl(element: HTMLElement): void;
  111213. /** @hidden */
  111214. _checkInputs(): void;
  111215. protected _checkLimits(): void;
  111216. /**
  111217. * Rebuilds angles (alpha, beta) and radius from the give position and target
  111218. */
  111219. rebuildAnglesAndRadius(): void;
  111220. /**
  111221. * Use a position to define the current camera related information like alpha, beta and radius
  111222. * @param position Defines the position to set the camera at
  111223. */
  111224. setPosition(position: Vector3): void;
  111225. /**
  111226. * Defines the target the camera should look at.
  111227. * This will automatically adapt alpha beta and radius to fit within the new target.
  111228. * @param target Defines the new target as a Vector or a mesh
  111229. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  111230. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  111231. */
  111232. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  111233. /** @hidden */
  111234. _getViewMatrix(): Matrix;
  111235. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  111236. /**
  111237. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  111238. * @param meshes Defines the mesh to zoom on
  111239. * @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)
  111240. */
  111241. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  111242. /**
  111243. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  111244. * The target will be changed but the radius
  111245. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  111246. * @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)
  111247. */
  111248. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  111249. min: Vector3;
  111250. max: Vector3;
  111251. distance: number;
  111252. }, doNotUpdateMaxZ?: boolean): void;
  111253. /**
  111254. * @override
  111255. * Override Camera.createRigCamera
  111256. */
  111257. createRigCamera(name: string, cameraIndex: number): Camera;
  111258. /**
  111259. * @hidden
  111260. * @override
  111261. * Override Camera._updateRigCameras
  111262. */
  111263. _updateRigCameras(): void;
  111264. /**
  111265. * Destroy the camera and release the current resources hold by it.
  111266. */
  111267. dispose(): void;
  111268. /**
  111269. * Gets the current object class name.
  111270. * @return the class name
  111271. */
  111272. getClassName(): string;
  111273. }
  111274. }
  111275. declare module BABYLON {
  111276. /**
  111277. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  111278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111279. */
  111280. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  111281. /**
  111282. * Gets the name of the behavior.
  111283. */
  111284. get name(): string;
  111285. private _zoomStopsAnimation;
  111286. private _idleRotationSpeed;
  111287. private _idleRotationWaitTime;
  111288. private _idleRotationSpinupTime;
  111289. /**
  111290. * Sets the flag that indicates if user zooming should stop animation.
  111291. */
  111292. set zoomStopsAnimation(flag: boolean);
  111293. /**
  111294. * Gets the flag that indicates if user zooming should stop animation.
  111295. */
  111296. get zoomStopsAnimation(): boolean;
  111297. /**
  111298. * Sets the default speed at which the camera rotates around the model.
  111299. */
  111300. set idleRotationSpeed(speed: number);
  111301. /**
  111302. * Gets the default speed at which the camera rotates around the model.
  111303. */
  111304. get idleRotationSpeed(): number;
  111305. /**
  111306. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  111307. */
  111308. set idleRotationWaitTime(time: number);
  111309. /**
  111310. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  111311. */
  111312. get idleRotationWaitTime(): number;
  111313. /**
  111314. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111315. */
  111316. set idleRotationSpinupTime(time: number);
  111317. /**
  111318. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111319. */
  111320. get idleRotationSpinupTime(): number;
  111321. /**
  111322. * Gets a value indicating if the camera is currently rotating because of this behavior
  111323. */
  111324. get rotationInProgress(): boolean;
  111325. private _onPrePointerObservableObserver;
  111326. private _onAfterCheckInputsObserver;
  111327. private _attachedCamera;
  111328. private _isPointerDown;
  111329. private _lastFrameTime;
  111330. private _lastInteractionTime;
  111331. private _cameraRotationSpeed;
  111332. /**
  111333. * Initializes the behavior.
  111334. */
  111335. init(): void;
  111336. /**
  111337. * Attaches the behavior to its arc rotate camera.
  111338. * @param camera Defines the camera to attach the behavior to
  111339. */
  111340. attach(camera: ArcRotateCamera): void;
  111341. /**
  111342. * Detaches the behavior from its current arc rotate camera.
  111343. */
  111344. detach(): void;
  111345. /**
  111346. * Returns true if user is scrolling.
  111347. * @return true if user is scrolling.
  111348. */
  111349. private _userIsZooming;
  111350. private _lastFrameRadius;
  111351. private _shouldAnimationStopForInteraction;
  111352. /**
  111353. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111354. */
  111355. private _applyUserInteraction;
  111356. private _userIsMoving;
  111357. }
  111358. }
  111359. declare module BABYLON {
  111360. /**
  111361. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  111362. */
  111363. export class AttachToBoxBehavior implements Behavior<Mesh> {
  111364. private ui;
  111365. /**
  111366. * The name of the behavior
  111367. */
  111368. name: string;
  111369. /**
  111370. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  111371. */
  111372. distanceAwayFromFace: number;
  111373. /**
  111374. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  111375. */
  111376. distanceAwayFromBottomOfFace: number;
  111377. private _faceVectors;
  111378. private _target;
  111379. private _scene;
  111380. private _onRenderObserver;
  111381. private _tmpMatrix;
  111382. private _tmpVector;
  111383. /**
  111384. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  111385. * @param ui The transform node that should be attched to the mesh
  111386. */
  111387. constructor(ui: TransformNode);
  111388. /**
  111389. * Initializes the behavior
  111390. */
  111391. init(): void;
  111392. private _closestFace;
  111393. private _zeroVector;
  111394. private _lookAtTmpMatrix;
  111395. private _lookAtToRef;
  111396. /**
  111397. * Attaches the AttachToBoxBehavior to the passed in mesh
  111398. * @param target The mesh that the specified node will be attached to
  111399. */
  111400. attach(target: Mesh): void;
  111401. /**
  111402. * Detaches the behavior from the mesh
  111403. */
  111404. detach(): void;
  111405. }
  111406. }
  111407. declare module BABYLON {
  111408. /**
  111409. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  111410. */
  111411. export class FadeInOutBehavior implements Behavior<Mesh> {
  111412. /**
  111413. * Time in milliseconds to delay before fading in (Default: 0)
  111414. */
  111415. delay: number;
  111416. /**
  111417. * Time in milliseconds for the mesh to fade in (Default: 300)
  111418. */
  111419. fadeInTime: number;
  111420. private _millisecondsPerFrame;
  111421. private _hovered;
  111422. private _hoverValue;
  111423. private _ownerNode;
  111424. /**
  111425. * Instatiates the FadeInOutBehavior
  111426. */
  111427. constructor();
  111428. /**
  111429. * The name of the behavior
  111430. */
  111431. get name(): string;
  111432. /**
  111433. * Initializes the behavior
  111434. */
  111435. init(): void;
  111436. /**
  111437. * Attaches the fade behavior on the passed in mesh
  111438. * @param ownerNode The mesh that will be faded in/out once attached
  111439. */
  111440. attach(ownerNode: Mesh): void;
  111441. /**
  111442. * Detaches the behavior from the mesh
  111443. */
  111444. detach(): void;
  111445. /**
  111446. * Triggers the mesh to begin fading in or out
  111447. * @param value if the object should fade in or out (true to fade in)
  111448. */
  111449. fadeIn(value: boolean): void;
  111450. private _update;
  111451. private _setAllVisibility;
  111452. }
  111453. }
  111454. declare module BABYLON {
  111455. /**
  111456. * Class containing a set of static utilities functions for managing Pivots
  111457. * @hidden
  111458. */
  111459. export class PivotTools {
  111460. private static _PivotCached;
  111461. private static _OldPivotPoint;
  111462. private static _PivotTranslation;
  111463. private static _PivotTmpVector;
  111464. /** @hidden */
  111465. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  111466. /** @hidden */
  111467. static _RestorePivotPoint(mesh: AbstractMesh): void;
  111468. }
  111469. }
  111470. declare module BABYLON {
  111471. /**
  111472. * Class containing static functions to help procedurally build meshes
  111473. */
  111474. export class PlaneBuilder {
  111475. /**
  111476. * Creates a plane mesh
  111477. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  111478. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  111479. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  111480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111483. * @param name defines the name of the mesh
  111484. * @param options defines the options used to create the mesh
  111485. * @param scene defines the hosting scene
  111486. * @returns the plane mesh
  111487. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  111488. */
  111489. static CreatePlane(name: string, options: {
  111490. size?: number;
  111491. width?: number;
  111492. height?: number;
  111493. sideOrientation?: number;
  111494. frontUVs?: Vector4;
  111495. backUVs?: Vector4;
  111496. updatable?: boolean;
  111497. sourcePlane?: Plane;
  111498. }, scene?: Nullable<Scene>): Mesh;
  111499. }
  111500. }
  111501. declare module BABYLON {
  111502. /**
  111503. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  111504. */
  111505. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  111506. private static _AnyMouseID;
  111507. /**
  111508. * Abstract mesh the behavior is set on
  111509. */
  111510. attachedNode: AbstractMesh;
  111511. private _dragPlane;
  111512. private _scene;
  111513. private _pointerObserver;
  111514. private _beforeRenderObserver;
  111515. private static _planeScene;
  111516. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  111517. /**
  111518. * 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)
  111519. */
  111520. maxDragAngle: number;
  111521. /**
  111522. * @hidden
  111523. */
  111524. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  111525. /**
  111526. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111527. */
  111528. currentDraggingPointerID: number;
  111529. /**
  111530. * The last position where the pointer hit the drag plane in world space
  111531. */
  111532. lastDragPosition: Vector3;
  111533. /**
  111534. * If the behavior is currently in a dragging state
  111535. */
  111536. dragging: boolean;
  111537. /**
  111538. * 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)
  111539. */
  111540. dragDeltaRatio: number;
  111541. /**
  111542. * If the drag plane orientation should be updated during the dragging (Default: true)
  111543. */
  111544. updateDragPlane: boolean;
  111545. private _debugMode;
  111546. private _moving;
  111547. /**
  111548. * Fires each time the attached mesh is dragged with the pointer
  111549. * * delta between last drag position and current drag position in world space
  111550. * * dragDistance along the drag axis
  111551. * * dragPlaneNormal normal of the current drag plane used during the drag
  111552. * * dragPlanePoint in world space where the drag intersects the drag plane
  111553. */
  111554. onDragObservable: Observable<{
  111555. delta: Vector3;
  111556. dragPlanePoint: Vector3;
  111557. dragPlaneNormal: Vector3;
  111558. dragDistance: number;
  111559. pointerId: number;
  111560. }>;
  111561. /**
  111562. * Fires each time a drag begins (eg. mouse down on mesh)
  111563. */
  111564. onDragStartObservable: Observable<{
  111565. dragPlanePoint: Vector3;
  111566. pointerId: number;
  111567. }>;
  111568. /**
  111569. * Fires each time a drag ends (eg. mouse release after drag)
  111570. */
  111571. onDragEndObservable: Observable<{
  111572. dragPlanePoint: Vector3;
  111573. pointerId: number;
  111574. }>;
  111575. /**
  111576. * If the attached mesh should be moved when dragged
  111577. */
  111578. moveAttached: boolean;
  111579. /**
  111580. * If the drag behavior will react to drag events (Default: true)
  111581. */
  111582. enabled: boolean;
  111583. /**
  111584. * If pointer events should start and release the drag (Default: true)
  111585. */
  111586. startAndReleaseDragOnPointerEvents: boolean;
  111587. /**
  111588. * If camera controls should be detached during the drag
  111589. */
  111590. detachCameraControls: boolean;
  111591. /**
  111592. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  111593. */
  111594. useObjectOrientationForDragging: boolean;
  111595. private _options;
  111596. /**
  111597. * Gets the options used by the behavior
  111598. */
  111599. get options(): {
  111600. dragAxis?: Vector3;
  111601. dragPlaneNormal?: Vector3;
  111602. };
  111603. /**
  111604. * Sets the options used by the behavior
  111605. */
  111606. set options(options: {
  111607. dragAxis?: Vector3;
  111608. dragPlaneNormal?: Vector3;
  111609. });
  111610. /**
  111611. * Creates a pointer drag behavior that can be attached to a mesh
  111612. * @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)
  111613. */
  111614. constructor(options?: {
  111615. dragAxis?: Vector3;
  111616. dragPlaneNormal?: Vector3;
  111617. });
  111618. /**
  111619. * Predicate to determine if it is valid to move the object to a new position when it is moved
  111620. */
  111621. validateDrag: (targetPosition: Vector3) => boolean;
  111622. /**
  111623. * The name of the behavior
  111624. */
  111625. get name(): string;
  111626. /**
  111627. * Initializes the behavior
  111628. */
  111629. init(): void;
  111630. private _tmpVector;
  111631. private _alternatePickedPoint;
  111632. private _worldDragAxis;
  111633. private _targetPosition;
  111634. private _attachedElement;
  111635. /**
  111636. * Attaches the drag behavior the passed in mesh
  111637. * @param ownerNode The mesh that will be dragged around once attached
  111638. * @param predicate Predicate to use for pick filtering
  111639. */
  111640. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  111641. /**
  111642. * Force relase the drag action by code.
  111643. */
  111644. releaseDrag(): void;
  111645. private _startDragRay;
  111646. private _lastPointerRay;
  111647. /**
  111648. * Simulates the start of a pointer drag event on the behavior
  111649. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  111650. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  111651. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  111652. */
  111653. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  111654. private _startDrag;
  111655. private _dragDelta;
  111656. private _moveDrag;
  111657. private _pickWithRayOnDragPlane;
  111658. private _pointA;
  111659. private _pointB;
  111660. private _pointC;
  111661. private _lineA;
  111662. private _lineB;
  111663. private _localAxis;
  111664. private _lookAt;
  111665. private _updateDragPlanePosition;
  111666. /**
  111667. * Detaches the behavior from the mesh
  111668. */
  111669. detach(): void;
  111670. }
  111671. }
  111672. declare module BABYLON {
  111673. /**
  111674. * A behavior that when attached to a mesh will allow the mesh to be scaled
  111675. */
  111676. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  111677. private _dragBehaviorA;
  111678. private _dragBehaviorB;
  111679. private _startDistance;
  111680. private _initialScale;
  111681. private _targetScale;
  111682. private _ownerNode;
  111683. private _sceneRenderObserver;
  111684. /**
  111685. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  111686. */
  111687. constructor();
  111688. /**
  111689. * The name of the behavior
  111690. */
  111691. get name(): string;
  111692. /**
  111693. * Initializes the behavior
  111694. */
  111695. init(): void;
  111696. private _getCurrentDistance;
  111697. /**
  111698. * Attaches the scale behavior the passed in mesh
  111699. * @param ownerNode The mesh that will be scaled around once attached
  111700. */
  111701. attach(ownerNode: Mesh): void;
  111702. /**
  111703. * Detaches the behavior from the mesh
  111704. */
  111705. detach(): void;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /**
  111710. * 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
  111711. */
  111712. export class SixDofDragBehavior implements Behavior<Mesh> {
  111713. private static _virtualScene;
  111714. private _ownerNode;
  111715. private _sceneRenderObserver;
  111716. private _scene;
  111717. private _targetPosition;
  111718. private _virtualOriginMesh;
  111719. private _virtualDragMesh;
  111720. private _pointerObserver;
  111721. private _moving;
  111722. private _startingOrientation;
  111723. /**
  111724. * 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)
  111725. */
  111726. private zDragFactor;
  111727. /**
  111728. * If the object should rotate to face the drag origin
  111729. */
  111730. rotateDraggedObject: boolean;
  111731. /**
  111732. * If the behavior is currently in a dragging state
  111733. */
  111734. dragging: boolean;
  111735. /**
  111736. * 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)
  111737. */
  111738. dragDeltaRatio: number;
  111739. /**
  111740. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111741. */
  111742. currentDraggingPointerID: number;
  111743. /**
  111744. * If camera controls should be detached during the drag
  111745. */
  111746. detachCameraControls: boolean;
  111747. /**
  111748. * Fires each time a drag starts
  111749. */
  111750. onDragStartObservable: Observable<{}>;
  111751. /**
  111752. * Fires each time a drag ends (eg. mouse release after drag)
  111753. */
  111754. onDragEndObservable: Observable<{}>;
  111755. /**
  111756. * 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
  111757. */
  111758. constructor();
  111759. /**
  111760. * The name of the behavior
  111761. */
  111762. get name(): string;
  111763. /**
  111764. * Initializes the behavior
  111765. */
  111766. init(): void;
  111767. /**
  111768. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  111769. */
  111770. private get _pointerCamera();
  111771. /**
  111772. * Attaches the scale behavior the passed in mesh
  111773. * @param ownerNode The mesh that will be scaled around once attached
  111774. */
  111775. attach(ownerNode: Mesh): void;
  111776. /**
  111777. * Detaches the behavior from the mesh
  111778. */
  111779. detach(): void;
  111780. }
  111781. }
  111782. declare module BABYLON {
  111783. /**
  111784. * Class used to apply inverse kinematics to bones
  111785. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  111786. */
  111787. export class BoneIKController {
  111788. private static _tmpVecs;
  111789. private static _tmpQuat;
  111790. private static _tmpMats;
  111791. /**
  111792. * Gets or sets the target mesh
  111793. */
  111794. targetMesh: AbstractMesh;
  111795. /** Gets or sets the mesh used as pole */
  111796. poleTargetMesh: AbstractMesh;
  111797. /**
  111798. * Gets or sets the bone used as pole
  111799. */
  111800. poleTargetBone: Nullable<Bone>;
  111801. /**
  111802. * Gets or sets the target position
  111803. */
  111804. targetPosition: Vector3;
  111805. /**
  111806. * Gets or sets the pole target position
  111807. */
  111808. poleTargetPosition: Vector3;
  111809. /**
  111810. * Gets or sets the pole target local offset
  111811. */
  111812. poleTargetLocalOffset: Vector3;
  111813. /**
  111814. * Gets or sets the pole angle
  111815. */
  111816. poleAngle: number;
  111817. /**
  111818. * Gets or sets the mesh associated with the controller
  111819. */
  111820. mesh: AbstractMesh;
  111821. /**
  111822. * 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)
  111823. */
  111824. slerpAmount: number;
  111825. private _bone1Quat;
  111826. private _bone1Mat;
  111827. private _bone2Ang;
  111828. private _bone1;
  111829. private _bone2;
  111830. private _bone1Length;
  111831. private _bone2Length;
  111832. private _maxAngle;
  111833. private _maxReach;
  111834. private _rightHandedSystem;
  111835. private _bendAxis;
  111836. private _slerping;
  111837. private _adjustRoll;
  111838. /**
  111839. * Gets or sets maximum allowed angle
  111840. */
  111841. get maxAngle(): number;
  111842. set maxAngle(value: number);
  111843. /**
  111844. * Creates a new BoneIKController
  111845. * @param mesh defines the mesh to control
  111846. * @param bone defines the bone to control
  111847. * @param options defines options to set up the controller
  111848. */
  111849. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  111850. targetMesh?: AbstractMesh;
  111851. poleTargetMesh?: AbstractMesh;
  111852. poleTargetBone?: Bone;
  111853. poleTargetLocalOffset?: Vector3;
  111854. poleAngle?: number;
  111855. bendAxis?: Vector3;
  111856. maxAngle?: number;
  111857. slerpAmount?: number;
  111858. });
  111859. private _setMaxAngle;
  111860. /**
  111861. * Force the controller to update the bones
  111862. */
  111863. update(): void;
  111864. }
  111865. }
  111866. declare module BABYLON {
  111867. /**
  111868. * Class used to make a bone look toward a point in space
  111869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  111870. */
  111871. export class BoneLookController {
  111872. private static _tmpVecs;
  111873. private static _tmpQuat;
  111874. private static _tmpMats;
  111875. /**
  111876. * The target Vector3 that the bone will look at
  111877. */
  111878. target: Vector3;
  111879. /**
  111880. * The mesh that the bone is attached to
  111881. */
  111882. mesh: AbstractMesh;
  111883. /**
  111884. * The bone that will be looking to the target
  111885. */
  111886. bone: Bone;
  111887. /**
  111888. * The up axis of the coordinate system that is used when the bone is rotated
  111889. */
  111890. upAxis: Vector3;
  111891. /**
  111892. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  111893. */
  111894. upAxisSpace: Space;
  111895. /**
  111896. * Used to make an adjustment to the yaw of the bone
  111897. */
  111898. adjustYaw: number;
  111899. /**
  111900. * Used to make an adjustment to the pitch of the bone
  111901. */
  111902. adjustPitch: number;
  111903. /**
  111904. * Used to make an adjustment to the roll of the bone
  111905. */
  111906. adjustRoll: number;
  111907. /**
  111908. * 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)
  111909. */
  111910. slerpAmount: number;
  111911. private _minYaw;
  111912. private _maxYaw;
  111913. private _minPitch;
  111914. private _maxPitch;
  111915. private _minYawSin;
  111916. private _minYawCos;
  111917. private _maxYawSin;
  111918. private _maxYawCos;
  111919. private _midYawConstraint;
  111920. private _minPitchTan;
  111921. private _maxPitchTan;
  111922. private _boneQuat;
  111923. private _slerping;
  111924. private _transformYawPitch;
  111925. private _transformYawPitchInv;
  111926. private _firstFrameSkipped;
  111927. private _yawRange;
  111928. private _fowardAxis;
  111929. /**
  111930. * Gets or sets the minimum yaw angle that the bone can look to
  111931. */
  111932. get minYaw(): number;
  111933. set minYaw(value: number);
  111934. /**
  111935. * Gets or sets the maximum yaw angle that the bone can look to
  111936. */
  111937. get maxYaw(): number;
  111938. set maxYaw(value: number);
  111939. /**
  111940. * Gets or sets the minimum pitch angle that the bone can look to
  111941. */
  111942. get minPitch(): number;
  111943. set minPitch(value: number);
  111944. /**
  111945. * Gets or sets the maximum pitch angle that the bone can look to
  111946. */
  111947. get maxPitch(): number;
  111948. set maxPitch(value: number);
  111949. /**
  111950. * Create a BoneLookController
  111951. * @param mesh the mesh that the bone belongs to
  111952. * @param bone the bone that will be looking to the target
  111953. * @param target the target Vector3 to look at
  111954. * @param options optional settings:
  111955. * * maxYaw: the maximum angle the bone will yaw to
  111956. * * minYaw: the minimum angle the bone will yaw to
  111957. * * maxPitch: the maximum angle the bone will pitch to
  111958. * * minPitch: the minimum angle the bone will yaw to
  111959. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  111960. * * upAxis: the up axis of the coordinate system
  111961. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  111962. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  111963. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  111964. * * adjustYaw: used to make an adjustment to the yaw of the bone
  111965. * * adjustPitch: used to make an adjustment to the pitch of the bone
  111966. * * adjustRoll: used to make an adjustment to the roll of the bone
  111967. **/
  111968. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  111969. maxYaw?: number;
  111970. minYaw?: number;
  111971. maxPitch?: number;
  111972. minPitch?: number;
  111973. slerpAmount?: number;
  111974. upAxis?: Vector3;
  111975. upAxisSpace?: Space;
  111976. yawAxis?: Vector3;
  111977. pitchAxis?: Vector3;
  111978. adjustYaw?: number;
  111979. adjustPitch?: number;
  111980. adjustRoll?: number;
  111981. });
  111982. /**
  111983. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  111984. */
  111985. update(): void;
  111986. private _getAngleDiff;
  111987. private _getAngleBetween;
  111988. private _isAngleBetween;
  111989. }
  111990. }
  111991. declare module BABYLON {
  111992. /**
  111993. * Manage the gamepad inputs to control an arc rotate camera.
  111994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111995. */
  111996. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  111997. /**
  111998. * Defines the camera the input is attached to.
  111999. */
  112000. camera: ArcRotateCamera;
  112001. /**
  112002. * Defines the gamepad the input is gathering event from.
  112003. */
  112004. gamepad: Nullable<Gamepad>;
  112005. /**
  112006. * Defines the gamepad rotation sensiblity.
  112007. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112008. */
  112009. gamepadRotationSensibility: number;
  112010. /**
  112011. * Defines the gamepad move sensiblity.
  112012. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112013. */
  112014. gamepadMoveSensibility: number;
  112015. private _yAxisScale;
  112016. /**
  112017. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112018. */
  112019. get invertYAxis(): boolean;
  112020. set invertYAxis(value: boolean);
  112021. private _onGamepadConnectedObserver;
  112022. private _onGamepadDisconnectedObserver;
  112023. /**
  112024. * Attach the input controls to a specific dom element to get the input from.
  112025. * @param element Defines the element the controls should be listened from
  112026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112027. */
  112028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112029. /**
  112030. * Detach the current controls from the specified dom element.
  112031. * @param element Defines the element to stop listening the inputs from
  112032. */
  112033. detachControl(element: Nullable<HTMLElement>): void;
  112034. /**
  112035. * Update the current camera state depending on the inputs that have been used this frame.
  112036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112037. */
  112038. checkInputs(): void;
  112039. /**
  112040. * Gets the class name of the current intput.
  112041. * @returns the class name
  112042. */
  112043. getClassName(): string;
  112044. /**
  112045. * Get the friendly name associated with the input class.
  112046. * @returns the input friendly name
  112047. */
  112048. getSimpleName(): string;
  112049. }
  112050. }
  112051. declare module BABYLON {
  112052. interface ArcRotateCameraInputsManager {
  112053. /**
  112054. * Add orientation input support to the input manager.
  112055. * @returns the current input manager
  112056. */
  112057. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112058. }
  112059. /**
  112060. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112062. */
  112063. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112064. /**
  112065. * Defines the camera the input is attached to.
  112066. */
  112067. camera: ArcRotateCamera;
  112068. /**
  112069. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112070. */
  112071. alphaCorrection: number;
  112072. /**
  112073. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112074. */
  112075. gammaCorrection: number;
  112076. private _alpha;
  112077. private _gamma;
  112078. private _dirty;
  112079. private _deviceOrientationHandler;
  112080. /**
  112081. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112082. */
  112083. constructor();
  112084. /**
  112085. * Attach the input controls to a specific dom element to get the input from.
  112086. * @param element Defines the element the controls should be listened from
  112087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112088. */
  112089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112090. /** @hidden */
  112091. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112092. /**
  112093. * Update the current camera state depending on the inputs that have been used this frame.
  112094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112095. */
  112096. checkInputs(): void;
  112097. /**
  112098. * Detach the current controls from the specified dom element.
  112099. * @param element Defines the element to stop listening the inputs from
  112100. */
  112101. detachControl(element: Nullable<HTMLElement>): void;
  112102. /**
  112103. * Gets the class name of the current intput.
  112104. * @returns the class name
  112105. */
  112106. getClassName(): string;
  112107. /**
  112108. * Get the friendly name associated with the input class.
  112109. * @returns the input friendly name
  112110. */
  112111. getSimpleName(): string;
  112112. }
  112113. }
  112114. declare module BABYLON {
  112115. /**
  112116. * Listen to mouse events to control the camera.
  112117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112118. */
  112119. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112120. /**
  112121. * Defines the camera the input is attached to.
  112122. */
  112123. camera: FlyCamera;
  112124. /**
  112125. * Defines if touch is enabled. (Default is true.)
  112126. */
  112127. touchEnabled: boolean;
  112128. /**
  112129. * Defines the buttons associated with the input to handle camera rotation.
  112130. */
  112131. buttons: number[];
  112132. /**
  112133. * Assign buttons for Yaw control.
  112134. */
  112135. buttonsYaw: number[];
  112136. /**
  112137. * Assign buttons for Pitch control.
  112138. */
  112139. buttonsPitch: number[];
  112140. /**
  112141. * Assign buttons for Roll control.
  112142. */
  112143. buttonsRoll: number[];
  112144. /**
  112145. * Detect if any button is being pressed while mouse is moved.
  112146. * -1 = Mouse locked.
  112147. * 0 = Left button.
  112148. * 1 = Middle Button.
  112149. * 2 = Right Button.
  112150. */
  112151. activeButton: number;
  112152. /**
  112153. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112154. * Higher values reduce its sensitivity.
  112155. */
  112156. angularSensibility: number;
  112157. private _mousemoveCallback;
  112158. private _observer;
  112159. private _rollObserver;
  112160. private previousPosition;
  112161. private noPreventDefault;
  112162. private element;
  112163. /**
  112164. * Listen to mouse events to control the camera.
  112165. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112167. */
  112168. constructor(touchEnabled?: boolean);
  112169. /**
  112170. * Attach the mouse control to the HTML DOM element.
  112171. * @param element Defines the element that listens to the input events.
  112172. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112173. */
  112174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112175. /**
  112176. * Detach the current controls from the specified dom element.
  112177. * @param element Defines the element to stop listening the inputs from
  112178. */
  112179. detachControl(element: Nullable<HTMLElement>): void;
  112180. /**
  112181. * Gets the class name of the current input.
  112182. * @returns the class name.
  112183. */
  112184. getClassName(): string;
  112185. /**
  112186. * Get the friendly name associated with the input class.
  112187. * @returns the input's friendly name.
  112188. */
  112189. getSimpleName(): string;
  112190. private _pointerInput;
  112191. private _onMouseMove;
  112192. /**
  112193. * Rotate camera by mouse offset.
  112194. */
  112195. private rotateCamera;
  112196. }
  112197. }
  112198. declare module BABYLON {
  112199. /**
  112200. * Default Inputs manager for the FlyCamera.
  112201. * It groups all the default supported inputs for ease of use.
  112202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112203. */
  112204. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  112205. /**
  112206. * Instantiates a new FlyCameraInputsManager.
  112207. * @param camera Defines the camera the inputs belong to.
  112208. */
  112209. constructor(camera: FlyCamera);
  112210. /**
  112211. * Add keyboard input support to the input manager.
  112212. * @returns the new FlyCameraKeyboardMoveInput().
  112213. */
  112214. addKeyboard(): FlyCameraInputsManager;
  112215. /**
  112216. * Add mouse input support to the input manager.
  112217. * @param touchEnabled Enable touch screen support.
  112218. * @returns the new FlyCameraMouseInput().
  112219. */
  112220. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  112221. }
  112222. }
  112223. declare module BABYLON {
  112224. /**
  112225. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112226. * such as in a 3D Space Shooter or a Flight Simulator.
  112227. */
  112228. export class FlyCamera extends TargetCamera {
  112229. /**
  112230. * Define the collision ellipsoid of the camera.
  112231. * This is helpful for simulating a camera body, like a player's body.
  112232. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112233. */
  112234. ellipsoid: Vector3;
  112235. /**
  112236. * Define an offset for the position of the ellipsoid around the camera.
  112237. * This can be helpful if the camera is attached away from the player's body center,
  112238. * such as at its head.
  112239. */
  112240. ellipsoidOffset: Vector3;
  112241. /**
  112242. * Enable or disable collisions of the camera with the rest of the scene objects.
  112243. */
  112244. checkCollisions: boolean;
  112245. /**
  112246. * Enable or disable gravity on the camera.
  112247. */
  112248. applyGravity: boolean;
  112249. /**
  112250. * Define the current direction the camera is moving to.
  112251. */
  112252. cameraDirection: Vector3;
  112253. /**
  112254. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  112255. * This overrides and empties cameraRotation.
  112256. */
  112257. rotationQuaternion: Quaternion;
  112258. /**
  112259. * Track Roll to maintain the wanted Rolling when looking around.
  112260. */
  112261. _trackRoll: number;
  112262. /**
  112263. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  112264. */
  112265. rollCorrect: number;
  112266. /**
  112267. * Mimic a banked turn, Rolling the camera when Yawing.
  112268. * It's recommended to use rollCorrect = 10 for faster banking correction.
  112269. */
  112270. bankedTurn: boolean;
  112271. /**
  112272. * Limit in radians for how much Roll banking will add. (Default: 90°)
  112273. */
  112274. bankedTurnLimit: number;
  112275. /**
  112276. * Value of 0 disables the banked Roll.
  112277. * Value of 1 is equal to the Yaw angle in radians.
  112278. */
  112279. bankedTurnMultiplier: number;
  112280. /**
  112281. * The inputs manager loads all the input sources, such as keyboard and mouse.
  112282. */
  112283. inputs: FlyCameraInputsManager;
  112284. /**
  112285. * Gets the input sensibility for mouse input.
  112286. * Higher values reduce sensitivity.
  112287. */
  112288. get angularSensibility(): number;
  112289. /**
  112290. * Sets the input sensibility for a mouse input.
  112291. * Higher values reduce sensitivity.
  112292. */
  112293. set angularSensibility(value: number);
  112294. /**
  112295. * Get the keys for camera movement forward.
  112296. */
  112297. get keysForward(): number[];
  112298. /**
  112299. * Set the keys for camera movement forward.
  112300. */
  112301. set keysForward(value: number[]);
  112302. /**
  112303. * Get the keys for camera movement backward.
  112304. */
  112305. get keysBackward(): number[];
  112306. set keysBackward(value: number[]);
  112307. /**
  112308. * Get the keys for camera movement up.
  112309. */
  112310. get keysUp(): number[];
  112311. /**
  112312. * Set the keys for camera movement up.
  112313. */
  112314. set keysUp(value: number[]);
  112315. /**
  112316. * Get the keys for camera movement down.
  112317. */
  112318. get keysDown(): number[];
  112319. /**
  112320. * Set the keys for camera movement down.
  112321. */
  112322. set keysDown(value: number[]);
  112323. /**
  112324. * Get the keys for camera movement left.
  112325. */
  112326. get keysLeft(): number[];
  112327. /**
  112328. * Set the keys for camera movement left.
  112329. */
  112330. set keysLeft(value: number[]);
  112331. /**
  112332. * Set the keys for camera movement right.
  112333. */
  112334. get keysRight(): number[];
  112335. /**
  112336. * Set the keys for camera movement right.
  112337. */
  112338. set keysRight(value: number[]);
  112339. /**
  112340. * Event raised when the camera collides with a mesh in the scene.
  112341. */
  112342. onCollide: (collidedMesh: AbstractMesh) => void;
  112343. private _collider;
  112344. private _needMoveForGravity;
  112345. private _oldPosition;
  112346. private _diffPosition;
  112347. private _newPosition;
  112348. /** @hidden */
  112349. _localDirection: Vector3;
  112350. /** @hidden */
  112351. _transformedDirection: Vector3;
  112352. /**
  112353. * Instantiates a FlyCamera.
  112354. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112355. * such as in a 3D Space Shooter or a Flight Simulator.
  112356. * @param name Define the name of the camera in the scene.
  112357. * @param position Define the starting position of the camera in the scene.
  112358. * @param scene Define the scene the camera belongs to.
  112359. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  112360. */
  112361. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112362. /**
  112363. * Attach a control to the HTML DOM element.
  112364. * @param element Defines the element that listens to the input events.
  112365. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  112366. */
  112367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112368. /**
  112369. * Detach a control from the HTML DOM element.
  112370. * The camera will stop reacting to that input.
  112371. * @param element Defines the element that listens to the input events.
  112372. */
  112373. detachControl(element: HTMLElement): void;
  112374. private _collisionMask;
  112375. /**
  112376. * Get the mask that the camera ignores in collision events.
  112377. */
  112378. get collisionMask(): number;
  112379. /**
  112380. * Set the mask that the camera ignores in collision events.
  112381. */
  112382. set collisionMask(mask: number);
  112383. /** @hidden */
  112384. _collideWithWorld(displacement: Vector3): void;
  112385. /** @hidden */
  112386. private _onCollisionPositionChange;
  112387. /** @hidden */
  112388. _checkInputs(): void;
  112389. /** @hidden */
  112390. _decideIfNeedsToMove(): boolean;
  112391. /** @hidden */
  112392. _updatePosition(): void;
  112393. /**
  112394. * Restore the Roll to its target value at the rate specified.
  112395. * @param rate - Higher means slower restoring.
  112396. * @hidden
  112397. */
  112398. restoreRoll(rate: number): void;
  112399. /**
  112400. * Destroy the camera and release the current resources held by it.
  112401. */
  112402. dispose(): void;
  112403. /**
  112404. * Get the current object class name.
  112405. * @returns the class name.
  112406. */
  112407. getClassName(): string;
  112408. }
  112409. }
  112410. declare module BABYLON {
  112411. /**
  112412. * Listen to keyboard events to control the camera.
  112413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112414. */
  112415. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  112416. /**
  112417. * Defines the camera the input is attached to.
  112418. */
  112419. camera: FlyCamera;
  112420. /**
  112421. * The list of keyboard keys used to control the forward move of the camera.
  112422. */
  112423. keysForward: number[];
  112424. /**
  112425. * The list of keyboard keys used to control the backward move of the camera.
  112426. */
  112427. keysBackward: number[];
  112428. /**
  112429. * The list of keyboard keys used to control the forward move of the camera.
  112430. */
  112431. keysUp: number[];
  112432. /**
  112433. * The list of keyboard keys used to control the backward move of the camera.
  112434. */
  112435. keysDown: number[];
  112436. /**
  112437. * The list of keyboard keys used to control the right strafe move of the camera.
  112438. */
  112439. keysRight: number[];
  112440. /**
  112441. * The list of keyboard keys used to control the left strafe move of the camera.
  112442. */
  112443. keysLeft: number[];
  112444. private _keys;
  112445. private _onCanvasBlurObserver;
  112446. private _onKeyboardObserver;
  112447. private _engine;
  112448. private _scene;
  112449. /**
  112450. * Attach the input controls to a specific dom element to get the input from.
  112451. * @param element Defines the element the controls should be listened from
  112452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112453. */
  112454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112455. /**
  112456. * Detach the current controls from the specified dom element.
  112457. * @param element Defines the element to stop listening the inputs from
  112458. */
  112459. detachControl(element: Nullable<HTMLElement>): void;
  112460. /**
  112461. * Gets the class name of the current intput.
  112462. * @returns the class name
  112463. */
  112464. getClassName(): string;
  112465. /** @hidden */
  112466. _onLostFocus(e: FocusEvent): void;
  112467. /**
  112468. * Get the friendly name associated with the input class.
  112469. * @returns the input friendly name
  112470. */
  112471. getSimpleName(): string;
  112472. /**
  112473. * Update the current camera state depending on the inputs that have been used this frame.
  112474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112475. */
  112476. checkInputs(): void;
  112477. }
  112478. }
  112479. declare module BABYLON {
  112480. /**
  112481. * Manage the mouse wheel inputs to control a follow camera.
  112482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112483. */
  112484. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  112485. /**
  112486. * Defines the camera the input is attached to.
  112487. */
  112488. camera: FollowCamera;
  112489. /**
  112490. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  112491. */
  112492. axisControlRadius: boolean;
  112493. /**
  112494. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  112495. */
  112496. axisControlHeight: boolean;
  112497. /**
  112498. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  112499. */
  112500. axisControlRotation: boolean;
  112501. /**
  112502. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  112503. * relation to mouseWheel events.
  112504. */
  112505. wheelPrecision: number;
  112506. /**
  112507. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112508. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112509. */
  112510. wheelDeltaPercentage: number;
  112511. private _wheel;
  112512. private _observer;
  112513. /**
  112514. * Attach the input controls to a specific dom element to get the input from.
  112515. * @param element Defines the element the controls should be listened from
  112516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112517. */
  112518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112519. /**
  112520. * Detach the current controls from the specified dom element.
  112521. * @param element Defines the element to stop listening the inputs from
  112522. */
  112523. detachControl(element: Nullable<HTMLElement>): void;
  112524. /**
  112525. * Gets the class name of the current intput.
  112526. * @returns the class name
  112527. */
  112528. getClassName(): string;
  112529. /**
  112530. * Get the friendly name associated with the input class.
  112531. * @returns the input friendly name
  112532. */
  112533. getSimpleName(): string;
  112534. }
  112535. }
  112536. declare module BABYLON {
  112537. /**
  112538. * Manage the pointers inputs to control an follow camera.
  112539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112540. */
  112541. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  112542. /**
  112543. * Defines the camera the input is attached to.
  112544. */
  112545. camera: FollowCamera;
  112546. /**
  112547. * Gets the class name of the current input.
  112548. * @returns the class name
  112549. */
  112550. getClassName(): string;
  112551. /**
  112552. * Defines the pointer angular sensibility along the X axis or how fast is
  112553. * the camera rotating.
  112554. * A negative number will reverse the axis direction.
  112555. */
  112556. angularSensibilityX: number;
  112557. /**
  112558. * Defines the pointer angular sensibility along the Y axis or how fast is
  112559. * the camera rotating.
  112560. * A negative number will reverse the axis direction.
  112561. */
  112562. angularSensibilityY: number;
  112563. /**
  112564. * Defines the pointer pinch precision or how fast is the camera zooming.
  112565. * A negative number will reverse the axis direction.
  112566. */
  112567. pinchPrecision: number;
  112568. /**
  112569. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112570. * from 0.
  112571. * It defines the percentage of current camera.radius to use as delta when
  112572. * pinch zoom is used.
  112573. */
  112574. pinchDeltaPercentage: number;
  112575. /**
  112576. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  112577. */
  112578. axisXControlRadius: boolean;
  112579. /**
  112580. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  112581. */
  112582. axisXControlHeight: boolean;
  112583. /**
  112584. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  112585. */
  112586. axisXControlRotation: boolean;
  112587. /**
  112588. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  112589. */
  112590. axisYControlRadius: boolean;
  112591. /**
  112592. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  112593. */
  112594. axisYControlHeight: boolean;
  112595. /**
  112596. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  112597. */
  112598. axisYControlRotation: boolean;
  112599. /**
  112600. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  112601. */
  112602. axisPinchControlRadius: boolean;
  112603. /**
  112604. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  112605. */
  112606. axisPinchControlHeight: boolean;
  112607. /**
  112608. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  112609. */
  112610. axisPinchControlRotation: boolean;
  112611. /**
  112612. * Log error messages if basic misconfiguration has occurred.
  112613. */
  112614. warningEnable: boolean;
  112615. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112616. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112617. private _warningCounter;
  112618. private _warning;
  112619. }
  112620. }
  112621. declare module BABYLON {
  112622. /**
  112623. * Default Inputs manager for the FollowCamera.
  112624. * It groups all the default supported inputs for ease of use.
  112625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112626. */
  112627. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  112628. /**
  112629. * Instantiates a new FollowCameraInputsManager.
  112630. * @param camera Defines the camera the inputs belong to
  112631. */
  112632. constructor(camera: FollowCamera);
  112633. /**
  112634. * Add keyboard input support to the input manager.
  112635. * @returns the current input manager
  112636. */
  112637. addKeyboard(): FollowCameraInputsManager;
  112638. /**
  112639. * Add mouse wheel input support to the input manager.
  112640. * @returns the current input manager
  112641. */
  112642. addMouseWheel(): FollowCameraInputsManager;
  112643. /**
  112644. * Add pointers input support to the input manager.
  112645. * @returns the current input manager
  112646. */
  112647. addPointers(): FollowCameraInputsManager;
  112648. /**
  112649. * Add orientation input support to the input manager.
  112650. * @returns the current input manager
  112651. */
  112652. addVRDeviceOrientation(): FollowCameraInputsManager;
  112653. }
  112654. }
  112655. declare module BABYLON {
  112656. /**
  112657. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  112658. * an arc rotate version arcFollowCamera are available.
  112659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112660. */
  112661. export class FollowCamera extends TargetCamera {
  112662. /**
  112663. * Distance the follow camera should follow an object at
  112664. */
  112665. radius: number;
  112666. /**
  112667. * Minimum allowed distance of the camera to the axis of rotation
  112668. * (The camera can not get closer).
  112669. * This can help limiting how the Camera is able to move in the scene.
  112670. */
  112671. lowerRadiusLimit: Nullable<number>;
  112672. /**
  112673. * Maximum allowed distance of the camera to the axis of rotation
  112674. * (The camera can not get further).
  112675. * This can help limiting how the Camera is able to move in the scene.
  112676. */
  112677. upperRadiusLimit: Nullable<number>;
  112678. /**
  112679. * Define a rotation offset between the camera and the object it follows
  112680. */
  112681. rotationOffset: number;
  112682. /**
  112683. * Minimum allowed angle to camera position relative to target object.
  112684. * This can help limiting how the Camera is able to move in the scene.
  112685. */
  112686. lowerRotationOffsetLimit: Nullable<number>;
  112687. /**
  112688. * Maximum allowed angle to camera position relative to target object.
  112689. * This can help limiting how the Camera is able to move in the scene.
  112690. */
  112691. upperRotationOffsetLimit: Nullable<number>;
  112692. /**
  112693. * Define a height offset between the camera and the object it follows.
  112694. * It can help following an object from the top (like a car chaing a plane)
  112695. */
  112696. heightOffset: number;
  112697. /**
  112698. * Minimum allowed height of camera position relative to target object.
  112699. * This can help limiting how the Camera is able to move in the scene.
  112700. */
  112701. lowerHeightOffsetLimit: Nullable<number>;
  112702. /**
  112703. * Maximum allowed height of camera position relative to target object.
  112704. * This can help limiting how the Camera is able to move in the scene.
  112705. */
  112706. upperHeightOffsetLimit: Nullable<number>;
  112707. /**
  112708. * Define how fast the camera can accelerate to follow it s target.
  112709. */
  112710. cameraAcceleration: number;
  112711. /**
  112712. * Define the speed limit of the camera following an object.
  112713. */
  112714. maxCameraSpeed: number;
  112715. /**
  112716. * Define the target of the camera.
  112717. */
  112718. lockedTarget: Nullable<AbstractMesh>;
  112719. /**
  112720. * Defines the input associated with the camera.
  112721. */
  112722. inputs: FollowCameraInputsManager;
  112723. /**
  112724. * Instantiates the follow camera.
  112725. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112726. * @param name Define the name of the camera in the scene
  112727. * @param position Define the position of the camera
  112728. * @param scene Define the scene the camera belong to
  112729. * @param lockedTarget Define the target of the camera
  112730. */
  112731. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  112732. private _follow;
  112733. /**
  112734. * Attached controls to the current camera.
  112735. * @param element Defines the element the controls should be listened from
  112736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112737. */
  112738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112739. /**
  112740. * Detach the current controls from the camera.
  112741. * The camera will stop reacting to inputs.
  112742. * @param element Defines the element to stop listening the inputs from
  112743. */
  112744. detachControl(element: HTMLElement): void;
  112745. /** @hidden */
  112746. _checkInputs(): void;
  112747. private _checkLimits;
  112748. /**
  112749. * Gets the camera class name.
  112750. * @returns the class name
  112751. */
  112752. getClassName(): string;
  112753. }
  112754. /**
  112755. * Arc Rotate version of the follow camera.
  112756. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  112757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112758. */
  112759. export class ArcFollowCamera extends TargetCamera {
  112760. /** The longitudinal angle of the camera */
  112761. alpha: number;
  112762. /** The latitudinal angle of the camera */
  112763. beta: number;
  112764. /** The radius of the camera from its target */
  112765. radius: number;
  112766. /** Define the camera target (the messh it should follow) */
  112767. target: Nullable<AbstractMesh>;
  112768. private _cartesianCoordinates;
  112769. /**
  112770. * Instantiates a new ArcFollowCamera
  112771. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112772. * @param name Define the name of the camera
  112773. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  112774. * @param beta Define the rotation angle of the camera around the elevation axis
  112775. * @param radius Define the radius of the camera from its target point
  112776. * @param target Define the target of the camera
  112777. * @param scene Define the scene the camera belongs to
  112778. */
  112779. constructor(name: string,
  112780. /** The longitudinal angle of the camera */
  112781. alpha: number,
  112782. /** The latitudinal angle of the camera */
  112783. beta: number,
  112784. /** The radius of the camera from its target */
  112785. radius: number,
  112786. /** Define the camera target (the messh it should follow) */
  112787. target: Nullable<AbstractMesh>, scene: Scene);
  112788. private _follow;
  112789. /** @hidden */
  112790. _checkInputs(): void;
  112791. /**
  112792. * Returns the class name of the object.
  112793. * It is mostly used internally for serialization purposes.
  112794. */
  112795. getClassName(): string;
  112796. }
  112797. }
  112798. declare module BABYLON {
  112799. /**
  112800. * Manage the keyboard inputs to control the movement of a follow camera.
  112801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112802. */
  112803. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  112804. /**
  112805. * Defines the camera the input is attached to.
  112806. */
  112807. camera: FollowCamera;
  112808. /**
  112809. * Defines the list of key codes associated with the up action (increase heightOffset)
  112810. */
  112811. keysHeightOffsetIncr: number[];
  112812. /**
  112813. * Defines the list of key codes associated with the down action (decrease heightOffset)
  112814. */
  112815. keysHeightOffsetDecr: number[];
  112816. /**
  112817. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  112818. */
  112819. keysHeightOffsetModifierAlt: boolean;
  112820. /**
  112821. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  112822. */
  112823. keysHeightOffsetModifierCtrl: boolean;
  112824. /**
  112825. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  112826. */
  112827. keysHeightOffsetModifierShift: boolean;
  112828. /**
  112829. * Defines the list of key codes associated with the left action (increase rotationOffset)
  112830. */
  112831. keysRotationOffsetIncr: number[];
  112832. /**
  112833. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  112834. */
  112835. keysRotationOffsetDecr: number[];
  112836. /**
  112837. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  112838. */
  112839. keysRotationOffsetModifierAlt: boolean;
  112840. /**
  112841. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  112842. */
  112843. keysRotationOffsetModifierCtrl: boolean;
  112844. /**
  112845. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  112846. */
  112847. keysRotationOffsetModifierShift: boolean;
  112848. /**
  112849. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  112850. */
  112851. keysRadiusIncr: number[];
  112852. /**
  112853. * Defines the list of key codes associated with the zoom-out action (increase radius)
  112854. */
  112855. keysRadiusDecr: number[];
  112856. /**
  112857. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  112858. */
  112859. keysRadiusModifierAlt: boolean;
  112860. /**
  112861. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  112862. */
  112863. keysRadiusModifierCtrl: boolean;
  112864. /**
  112865. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  112866. */
  112867. keysRadiusModifierShift: boolean;
  112868. /**
  112869. * Defines the rate of change of heightOffset.
  112870. */
  112871. heightSensibility: number;
  112872. /**
  112873. * Defines the rate of change of rotationOffset.
  112874. */
  112875. rotationSensibility: number;
  112876. /**
  112877. * Defines the rate of change of radius.
  112878. */
  112879. radiusSensibility: number;
  112880. private _keys;
  112881. private _ctrlPressed;
  112882. private _altPressed;
  112883. private _shiftPressed;
  112884. private _onCanvasBlurObserver;
  112885. private _onKeyboardObserver;
  112886. private _engine;
  112887. private _scene;
  112888. /**
  112889. * Attach the input controls to a specific dom element to get the input from.
  112890. * @param element Defines the element the controls should be listened from
  112891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112892. */
  112893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112894. /**
  112895. * Detach the current controls from the specified dom element.
  112896. * @param element Defines the element to stop listening the inputs from
  112897. */
  112898. detachControl(element: Nullable<HTMLElement>): void;
  112899. /**
  112900. * Update the current camera state depending on the inputs that have been used this frame.
  112901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112902. */
  112903. checkInputs(): void;
  112904. /**
  112905. * Gets the class name of the current input.
  112906. * @returns the class name
  112907. */
  112908. getClassName(): string;
  112909. /**
  112910. * Get the friendly name associated with the input class.
  112911. * @returns the input friendly name
  112912. */
  112913. getSimpleName(): string;
  112914. /**
  112915. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112916. * allow modification of the heightOffset value.
  112917. */
  112918. private _modifierHeightOffset;
  112919. /**
  112920. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112921. * allow modification of the rotationOffset value.
  112922. */
  112923. private _modifierRotationOffset;
  112924. /**
  112925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112926. * allow modification of the radius value.
  112927. */
  112928. private _modifierRadius;
  112929. }
  112930. }
  112931. declare module BABYLON {
  112932. interface FreeCameraInputsManager {
  112933. /**
  112934. * @hidden
  112935. */
  112936. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  112937. /**
  112938. * Add orientation input support to the input manager.
  112939. * @returns the current input manager
  112940. */
  112941. addDeviceOrientation(): FreeCameraInputsManager;
  112942. }
  112943. /**
  112944. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  112945. * Screen rotation is taken into account.
  112946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112947. */
  112948. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  112949. private _camera;
  112950. private _screenOrientationAngle;
  112951. private _constantTranform;
  112952. private _screenQuaternion;
  112953. private _alpha;
  112954. private _beta;
  112955. private _gamma;
  112956. /**
  112957. * Can be used to detect if a device orientation sensor is available on a device
  112958. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  112959. * @returns a promise that will resolve on orientation change
  112960. */
  112961. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  112962. /**
  112963. * @hidden
  112964. */
  112965. _onDeviceOrientationChangedObservable: Observable<void>;
  112966. /**
  112967. * Instantiates a new input
  112968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112969. */
  112970. constructor();
  112971. /**
  112972. * Define the camera controlled by the input.
  112973. */
  112974. get camera(): FreeCamera;
  112975. set camera(camera: FreeCamera);
  112976. /**
  112977. * Attach the input controls to a specific dom element to get the input from.
  112978. * @param element Defines the element the controls should be listened from
  112979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112980. */
  112981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112982. private _orientationChanged;
  112983. private _deviceOrientation;
  112984. /**
  112985. * Detach the current controls from the specified dom element.
  112986. * @param element Defines the element to stop listening the inputs from
  112987. */
  112988. detachControl(element: Nullable<HTMLElement>): void;
  112989. /**
  112990. * Update the current camera state depending on the inputs that have been used this frame.
  112991. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112992. */
  112993. checkInputs(): void;
  112994. /**
  112995. * Gets the class name of the current intput.
  112996. * @returns the class name
  112997. */
  112998. getClassName(): string;
  112999. /**
  113000. * Get the friendly name associated with the input class.
  113001. * @returns the input friendly name
  113002. */
  113003. getSimpleName(): string;
  113004. }
  113005. }
  113006. declare module BABYLON {
  113007. /**
  113008. * Manage the gamepad inputs to control a free camera.
  113009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113010. */
  113011. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113012. /**
  113013. * Define the camera the input is attached to.
  113014. */
  113015. camera: FreeCamera;
  113016. /**
  113017. * Define the Gamepad controlling the input
  113018. */
  113019. gamepad: Nullable<Gamepad>;
  113020. /**
  113021. * Defines the gamepad rotation sensiblity.
  113022. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113023. */
  113024. gamepadAngularSensibility: number;
  113025. /**
  113026. * Defines the gamepad move sensiblity.
  113027. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113028. */
  113029. gamepadMoveSensibility: number;
  113030. private _yAxisScale;
  113031. /**
  113032. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113033. */
  113034. get invertYAxis(): boolean;
  113035. set invertYAxis(value: boolean);
  113036. private _onGamepadConnectedObserver;
  113037. private _onGamepadDisconnectedObserver;
  113038. private _cameraTransform;
  113039. private _deltaTransform;
  113040. private _vector3;
  113041. private _vector2;
  113042. /**
  113043. * Attach the input controls to a specific dom element to get the input from.
  113044. * @param element Defines the element the controls should be listened from
  113045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113046. */
  113047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113048. /**
  113049. * Detach the current controls from the specified dom element.
  113050. * @param element Defines the element to stop listening the inputs from
  113051. */
  113052. detachControl(element: Nullable<HTMLElement>): void;
  113053. /**
  113054. * Update the current camera state depending on the inputs that have been used this frame.
  113055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113056. */
  113057. checkInputs(): void;
  113058. /**
  113059. * Gets the class name of the current intput.
  113060. * @returns the class name
  113061. */
  113062. getClassName(): string;
  113063. /**
  113064. * Get the friendly name associated with the input class.
  113065. * @returns the input friendly name
  113066. */
  113067. getSimpleName(): string;
  113068. }
  113069. }
  113070. declare module BABYLON {
  113071. /**
  113072. * Defines the potential axis of a Joystick
  113073. */
  113074. export enum JoystickAxis {
  113075. /** X axis */
  113076. X = 0,
  113077. /** Y axis */
  113078. Y = 1,
  113079. /** Z axis */
  113080. Z = 2
  113081. }
  113082. /**
  113083. * Class used to define virtual joystick (used in touch mode)
  113084. */
  113085. export class VirtualJoystick {
  113086. /**
  113087. * Gets or sets a boolean indicating that left and right values must be inverted
  113088. */
  113089. reverseLeftRight: boolean;
  113090. /**
  113091. * Gets or sets a boolean indicating that up and down values must be inverted
  113092. */
  113093. reverseUpDown: boolean;
  113094. /**
  113095. * Gets the offset value for the position (ie. the change of the position value)
  113096. */
  113097. deltaPosition: Vector3;
  113098. /**
  113099. * Gets a boolean indicating if the virtual joystick was pressed
  113100. */
  113101. pressed: boolean;
  113102. /**
  113103. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113104. */
  113105. static Canvas: Nullable<HTMLCanvasElement>;
  113106. private static _globalJoystickIndex;
  113107. private static vjCanvasContext;
  113108. private static vjCanvasWidth;
  113109. private static vjCanvasHeight;
  113110. private static halfWidth;
  113111. private _action;
  113112. private _axisTargetedByLeftAndRight;
  113113. private _axisTargetedByUpAndDown;
  113114. private _joystickSensibility;
  113115. private _inversedSensibility;
  113116. private _joystickPointerID;
  113117. private _joystickColor;
  113118. private _joystickPointerPos;
  113119. private _joystickPreviousPointerPos;
  113120. private _joystickPointerStartPos;
  113121. private _deltaJoystickVector;
  113122. private _leftJoystick;
  113123. private _touches;
  113124. private _onPointerDownHandlerRef;
  113125. private _onPointerMoveHandlerRef;
  113126. private _onPointerUpHandlerRef;
  113127. private _onResize;
  113128. /**
  113129. * Creates a new virtual joystick
  113130. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113131. */
  113132. constructor(leftJoystick?: boolean);
  113133. /**
  113134. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113135. * @param newJoystickSensibility defines the new sensibility
  113136. */
  113137. setJoystickSensibility(newJoystickSensibility: number): void;
  113138. private _onPointerDown;
  113139. private _onPointerMove;
  113140. private _onPointerUp;
  113141. /**
  113142. * Change the color of the virtual joystick
  113143. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113144. */
  113145. setJoystickColor(newColor: string): void;
  113146. /**
  113147. * Defines a callback to call when the joystick is touched
  113148. * @param action defines the callback
  113149. */
  113150. setActionOnTouch(action: () => any): void;
  113151. /**
  113152. * Defines which axis you'd like to control for left & right
  113153. * @param axis defines the axis to use
  113154. */
  113155. setAxisForLeftRight(axis: JoystickAxis): void;
  113156. /**
  113157. * Defines which axis you'd like to control for up & down
  113158. * @param axis defines the axis to use
  113159. */
  113160. setAxisForUpDown(axis: JoystickAxis): void;
  113161. private _drawVirtualJoystick;
  113162. /**
  113163. * Release internal HTML canvas
  113164. */
  113165. releaseCanvas(): void;
  113166. }
  113167. }
  113168. declare module BABYLON {
  113169. interface FreeCameraInputsManager {
  113170. /**
  113171. * Add virtual joystick input support to the input manager.
  113172. * @returns the current input manager
  113173. */
  113174. addVirtualJoystick(): FreeCameraInputsManager;
  113175. }
  113176. /**
  113177. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113179. */
  113180. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113181. /**
  113182. * Defines the camera the input is attached to.
  113183. */
  113184. camera: FreeCamera;
  113185. private _leftjoystick;
  113186. private _rightjoystick;
  113187. /**
  113188. * Gets the left stick of the virtual joystick.
  113189. * @returns The virtual Joystick
  113190. */
  113191. getLeftJoystick(): VirtualJoystick;
  113192. /**
  113193. * Gets the right stick of the virtual joystick.
  113194. * @returns The virtual Joystick
  113195. */
  113196. getRightJoystick(): VirtualJoystick;
  113197. /**
  113198. * Update the current camera state depending on the inputs that have been used this frame.
  113199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113200. */
  113201. checkInputs(): void;
  113202. /**
  113203. * Attach the input controls to a specific dom element to get the input from.
  113204. * @param element Defines the element the controls should be listened from
  113205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113206. */
  113207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113208. /**
  113209. * Detach the current controls from the specified dom element.
  113210. * @param element Defines the element to stop listening the inputs from
  113211. */
  113212. detachControl(element: Nullable<HTMLElement>): void;
  113213. /**
  113214. * Gets the class name of the current intput.
  113215. * @returns the class name
  113216. */
  113217. getClassName(): string;
  113218. /**
  113219. * Get the friendly name associated with the input class.
  113220. * @returns the input friendly name
  113221. */
  113222. getSimpleName(): string;
  113223. }
  113224. }
  113225. declare module BABYLON {
  113226. /**
  113227. * This represents a FPS type of camera controlled by touch.
  113228. * This is like a universal camera minus the Gamepad controls.
  113229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113230. */
  113231. export class TouchCamera extends FreeCamera {
  113232. /**
  113233. * Defines the touch sensibility for rotation.
  113234. * The higher the faster.
  113235. */
  113236. get touchAngularSensibility(): number;
  113237. set touchAngularSensibility(value: number);
  113238. /**
  113239. * Defines the touch sensibility for move.
  113240. * The higher the faster.
  113241. */
  113242. get touchMoveSensibility(): number;
  113243. set touchMoveSensibility(value: number);
  113244. /**
  113245. * Instantiates a new touch camera.
  113246. * This represents a FPS type of camera controlled by touch.
  113247. * This is like a universal camera minus the Gamepad controls.
  113248. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113249. * @param name Define the name of the camera in the scene
  113250. * @param position Define the start position of the camera in the scene
  113251. * @param scene Define the scene the camera belongs to
  113252. */
  113253. constructor(name: string, position: Vector3, scene: Scene);
  113254. /**
  113255. * Gets the current object class name.
  113256. * @return the class name
  113257. */
  113258. getClassName(): string;
  113259. /** @hidden */
  113260. _setupInputs(): void;
  113261. }
  113262. }
  113263. declare module BABYLON {
  113264. /**
  113265. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  113266. * being tilted forward or back and left or right.
  113267. */
  113268. export class DeviceOrientationCamera extends FreeCamera {
  113269. private _initialQuaternion;
  113270. private _quaternionCache;
  113271. private _tmpDragQuaternion;
  113272. private _disablePointerInputWhenUsingDeviceOrientation;
  113273. /**
  113274. * Creates a new device orientation camera
  113275. * @param name The name of the camera
  113276. * @param position The start position camera
  113277. * @param scene The scene the camera belongs to
  113278. */
  113279. constructor(name: string, position: Vector3, scene: Scene);
  113280. /**
  113281. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  113282. */
  113283. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  113284. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  113285. private _dragFactor;
  113286. /**
  113287. * Enabled turning on the y axis when the orientation sensor is active
  113288. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  113289. */
  113290. enableHorizontalDragging(dragFactor?: number): void;
  113291. /**
  113292. * Gets the current instance class name ("DeviceOrientationCamera").
  113293. * This helps avoiding instanceof at run time.
  113294. * @returns the class name
  113295. */
  113296. getClassName(): string;
  113297. /**
  113298. * @hidden
  113299. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  113300. */
  113301. _checkInputs(): void;
  113302. /**
  113303. * Reset the camera to its default orientation on the specified axis only.
  113304. * @param axis The axis to reset
  113305. */
  113306. resetToCurrentRotation(axis?: Axis): void;
  113307. }
  113308. }
  113309. declare module BABYLON {
  113310. /**
  113311. * Defines supported buttons for XBox360 compatible gamepads
  113312. */
  113313. export enum Xbox360Button {
  113314. /** A */
  113315. A = 0,
  113316. /** B */
  113317. B = 1,
  113318. /** X */
  113319. X = 2,
  113320. /** Y */
  113321. Y = 3,
  113322. /** Start */
  113323. Start = 4,
  113324. /** Back */
  113325. Back = 5,
  113326. /** Left button */
  113327. LB = 6,
  113328. /** Right button */
  113329. RB = 7,
  113330. /** Left stick */
  113331. LeftStick = 8,
  113332. /** Right stick */
  113333. RightStick = 9
  113334. }
  113335. /** Defines values for XBox360 DPad */
  113336. export enum Xbox360Dpad {
  113337. /** Up */
  113338. Up = 0,
  113339. /** Down */
  113340. Down = 1,
  113341. /** Left */
  113342. Left = 2,
  113343. /** Right */
  113344. Right = 3
  113345. }
  113346. /**
  113347. * Defines a XBox360 gamepad
  113348. */
  113349. export class Xbox360Pad extends Gamepad {
  113350. private _leftTrigger;
  113351. private _rightTrigger;
  113352. private _onlefttriggerchanged;
  113353. private _onrighttriggerchanged;
  113354. private _onbuttondown;
  113355. private _onbuttonup;
  113356. private _ondpaddown;
  113357. private _ondpadup;
  113358. /** Observable raised when a button is pressed */
  113359. onButtonDownObservable: Observable<Xbox360Button>;
  113360. /** Observable raised when a button is released */
  113361. onButtonUpObservable: Observable<Xbox360Button>;
  113362. /** Observable raised when a pad is pressed */
  113363. onPadDownObservable: Observable<Xbox360Dpad>;
  113364. /** Observable raised when a pad is released */
  113365. onPadUpObservable: Observable<Xbox360Dpad>;
  113366. private _buttonA;
  113367. private _buttonB;
  113368. private _buttonX;
  113369. private _buttonY;
  113370. private _buttonBack;
  113371. private _buttonStart;
  113372. private _buttonLB;
  113373. private _buttonRB;
  113374. private _buttonLeftStick;
  113375. private _buttonRightStick;
  113376. private _dPadUp;
  113377. private _dPadDown;
  113378. private _dPadLeft;
  113379. private _dPadRight;
  113380. private _isXboxOnePad;
  113381. /**
  113382. * Creates a new XBox360 gamepad object
  113383. * @param id defines the id of this gamepad
  113384. * @param index defines its index
  113385. * @param gamepad defines the internal HTML gamepad object
  113386. * @param xboxOne defines if it is a XBox One gamepad
  113387. */
  113388. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  113389. /**
  113390. * Defines the callback to call when left trigger is pressed
  113391. * @param callback defines the callback to use
  113392. */
  113393. onlefttriggerchanged(callback: (value: number) => void): void;
  113394. /**
  113395. * Defines the callback to call when right trigger is pressed
  113396. * @param callback defines the callback to use
  113397. */
  113398. onrighttriggerchanged(callback: (value: number) => void): void;
  113399. /**
  113400. * Gets the left trigger value
  113401. */
  113402. get leftTrigger(): number;
  113403. /**
  113404. * Sets the left trigger value
  113405. */
  113406. set leftTrigger(newValue: number);
  113407. /**
  113408. * Gets the right trigger value
  113409. */
  113410. get rightTrigger(): number;
  113411. /**
  113412. * Sets the right trigger value
  113413. */
  113414. set rightTrigger(newValue: number);
  113415. /**
  113416. * Defines the callback to call when a button is pressed
  113417. * @param callback defines the callback to use
  113418. */
  113419. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113420. /**
  113421. * Defines the callback to call when a button is released
  113422. * @param callback defines the callback to use
  113423. */
  113424. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  113425. /**
  113426. * Defines the callback to call when a pad is pressed
  113427. * @param callback defines the callback to use
  113428. */
  113429. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  113430. /**
  113431. * Defines the callback to call when a pad is released
  113432. * @param callback defines the callback to use
  113433. */
  113434. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  113435. private _setButtonValue;
  113436. private _setDPadValue;
  113437. /**
  113438. * Gets the value of the `A` button
  113439. */
  113440. get buttonA(): number;
  113441. /**
  113442. * Sets the value of the `A` button
  113443. */
  113444. set buttonA(value: number);
  113445. /**
  113446. * Gets the value of the `B` button
  113447. */
  113448. get buttonB(): number;
  113449. /**
  113450. * Sets the value of the `B` button
  113451. */
  113452. set buttonB(value: number);
  113453. /**
  113454. * Gets the value of the `X` button
  113455. */
  113456. get buttonX(): number;
  113457. /**
  113458. * Sets the value of the `X` button
  113459. */
  113460. set buttonX(value: number);
  113461. /**
  113462. * Gets the value of the `Y` button
  113463. */
  113464. get buttonY(): number;
  113465. /**
  113466. * Sets the value of the `Y` button
  113467. */
  113468. set buttonY(value: number);
  113469. /**
  113470. * Gets the value of the `Start` button
  113471. */
  113472. get buttonStart(): number;
  113473. /**
  113474. * Sets the value of the `Start` button
  113475. */
  113476. set buttonStart(value: number);
  113477. /**
  113478. * Gets the value of the `Back` button
  113479. */
  113480. get buttonBack(): number;
  113481. /**
  113482. * Sets the value of the `Back` button
  113483. */
  113484. set buttonBack(value: number);
  113485. /**
  113486. * Gets the value of the `Left` button
  113487. */
  113488. get buttonLB(): number;
  113489. /**
  113490. * Sets the value of the `Left` button
  113491. */
  113492. set buttonLB(value: number);
  113493. /**
  113494. * Gets the value of the `Right` button
  113495. */
  113496. get buttonRB(): number;
  113497. /**
  113498. * Sets the value of the `Right` button
  113499. */
  113500. set buttonRB(value: number);
  113501. /**
  113502. * Gets the value of the Left joystick
  113503. */
  113504. get buttonLeftStick(): number;
  113505. /**
  113506. * Sets the value of the Left joystick
  113507. */
  113508. set buttonLeftStick(value: number);
  113509. /**
  113510. * Gets the value of the Right joystick
  113511. */
  113512. get buttonRightStick(): number;
  113513. /**
  113514. * Sets the value of the Right joystick
  113515. */
  113516. set buttonRightStick(value: number);
  113517. /**
  113518. * Gets the value of D-pad up
  113519. */
  113520. get dPadUp(): number;
  113521. /**
  113522. * Sets the value of D-pad up
  113523. */
  113524. set dPadUp(value: number);
  113525. /**
  113526. * Gets the value of D-pad down
  113527. */
  113528. get dPadDown(): number;
  113529. /**
  113530. * Sets the value of D-pad down
  113531. */
  113532. set dPadDown(value: number);
  113533. /**
  113534. * Gets the value of D-pad left
  113535. */
  113536. get dPadLeft(): number;
  113537. /**
  113538. * Sets the value of D-pad left
  113539. */
  113540. set dPadLeft(value: number);
  113541. /**
  113542. * Gets the value of D-pad right
  113543. */
  113544. get dPadRight(): number;
  113545. /**
  113546. * Sets the value of D-pad right
  113547. */
  113548. set dPadRight(value: number);
  113549. /**
  113550. * Force the gamepad to synchronize with device values
  113551. */
  113552. update(): void;
  113553. /**
  113554. * Disposes the gamepad
  113555. */
  113556. dispose(): void;
  113557. }
  113558. }
  113559. declare module BABYLON {
  113560. /**
  113561. * Defines supported buttons for DualShock compatible gamepads
  113562. */
  113563. export enum DualShockButton {
  113564. /** Cross */
  113565. Cross = 0,
  113566. /** Circle */
  113567. Circle = 1,
  113568. /** Square */
  113569. Square = 2,
  113570. /** Triangle */
  113571. Triangle = 3,
  113572. /** Options */
  113573. Options = 4,
  113574. /** Share */
  113575. Share = 5,
  113576. /** L1 */
  113577. L1 = 6,
  113578. /** R1 */
  113579. R1 = 7,
  113580. /** Left stick */
  113581. LeftStick = 8,
  113582. /** Right stick */
  113583. RightStick = 9
  113584. }
  113585. /** Defines values for DualShock DPad */
  113586. export enum DualShockDpad {
  113587. /** Up */
  113588. Up = 0,
  113589. /** Down */
  113590. Down = 1,
  113591. /** Left */
  113592. Left = 2,
  113593. /** Right */
  113594. Right = 3
  113595. }
  113596. /**
  113597. * Defines a DualShock gamepad
  113598. */
  113599. export class DualShockPad extends Gamepad {
  113600. private _leftTrigger;
  113601. private _rightTrigger;
  113602. private _onlefttriggerchanged;
  113603. private _onrighttriggerchanged;
  113604. private _onbuttondown;
  113605. private _onbuttonup;
  113606. private _ondpaddown;
  113607. private _ondpadup;
  113608. /** Observable raised when a button is pressed */
  113609. onButtonDownObservable: Observable<DualShockButton>;
  113610. /** Observable raised when a button is released */
  113611. onButtonUpObservable: Observable<DualShockButton>;
  113612. /** Observable raised when a pad is pressed */
  113613. onPadDownObservable: Observable<DualShockDpad>;
  113614. /** Observable raised when a pad is released */
  113615. onPadUpObservable: Observable<DualShockDpad>;
  113616. private _buttonCross;
  113617. private _buttonCircle;
  113618. private _buttonSquare;
  113619. private _buttonTriangle;
  113620. private _buttonShare;
  113621. private _buttonOptions;
  113622. private _buttonL1;
  113623. private _buttonR1;
  113624. private _buttonLeftStick;
  113625. private _buttonRightStick;
  113626. private _dPadUp;
  113627. private _dPadDown;
  113628. private _dPadLeft;
  113629. private _dPadRight;
  113630. /**
  113631. * Creates a new DualShock gamepad object
  113632. * @param id defines the id of this gamepad
  113633. * @param index defines its index
  113634. * @param gamepad defines the internal HTML gamepad object
  113635. */
  113636. constructor(id: string, index: number, gamepad: any);
  113637. /**
  113638. * Defines the callback to call when left trigger is pressed
  113639. * @param callback defines the callback to use
  113640. */
  113641. onlefttriggerchanged(callback: (value: number) => void): void;
  113642. /**
  113643. * Defines the callback to call when right trigger is pressed
  113644. * @param callback defines the callback to use
  113645. */
  113646. onrighttriggerchanged(callback: (value: number) => void): void;
  113647. /**
  113648. * Gets the left trigger value
  113649. */
  113650. get leftTrigger(): number;
  113651. /**
  113652. * Sets the left trigger value
  113653. */
  113654. set leftTrigger(newValue: number);
  113655. /**
  113656. * Gets the right trigger value
  113657. */
  113658. get rightTrigger(): number;
  113659. /**
  113660. * Sets the right trigger value
  113661. */
  113662. set rightTrigger(newValue: number);
  113663. /**
  113664. * Defines the callback to call when a button is pressed
  113665. * @param callback defines the callback to use
  113666. */
  113667. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  113668. /**
  113669. * Defines the callback to call when a button is released
  113670. * @param callback defines the callback to use
  113671. */
  113672. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  113673. /**
  113674. * Defines the callback to call when a pad is pressed
  113675. * @param callback defines the callback to use
  113676. */
  113677. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  113678. /**
  113679. * Defines the callback to call when a pad is released
  113680. * @param callback defines the callback to use
  113681. */
  113682. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  113683. private _setButtonValue;
  113684. private _setDPadValue;
  113685. /**
  113686. * Gets the value of the `Cross` button
  113687. */
  113688. get buttonCross(): number;
  113689. /**
  113690. * Sets the value of the `Cross` button
  113691. */
  113692. set buttonCross(value: number);
  113693. /**
  113694. * Gets the value of the `Circle` button
  113695. */
  113696. get buttonCircle(): number;
  113697. /**
  113698. * Sets the value of the `Circle` button
  113699. */
  113700. set buttonCircle(value: number);
  113701. /**
  113702. * Gets the value of the `Square` button
  113703. */
  113704. get buttonSquare(): number;
  113705. /**
  113706. * Sets the value of the `Square` button
  113707. */
  113708. set buttonSquare(value: number);
  113709. /**
  113710. * Gets the value of the `Triangle` button
  113711. */
  113712. get buttonTriangle(): number;
  113713. /**
  113714. * Sets the value of the `Triangle` button
  113715. */
  113716. set buttonTriangle(value: number);
  113717. /**
  113718. * Gets the value of the `Options` button
  113719. */
  113720. get buttonOptions(): number;
  113721. /**
  113722. * Sets the value of the `Options` button
  113723. */
  113724. set buttonOptions(value: number);
  113725. /**
  113726. * Gets the value of the `Share` button
  113727. */
  113728. get buttonShare(): number;
  113729. /**
  113730. * Sets the value of the `Share` button
  113731. */
  113732. set buttonShare(value: number);
  113733. /**
  113734. * Gets the value of the `L1` button
  113735. */
  113736. get buttonL1(): number;
  113737. /**
  113738. * Sets the value of the `L1` button
  113739. */
  113740. set buttonL1(value: number);
  113741. /**
  113742. * Gets the value of the `R1` button
  113743. */
  113744. get buttonR1(): number;
  113745. /**
  113746. * Sets the value of the `R1` button
  113747. */
  113748. set buttonR1(value: number);
  113749. /**
  113750. * Gets the value of the Left joystick
  113751. */
  113752. get buttonLeftStick(): number;
  113753. /**
  113754. * Sets the value of the Left joystick
  113755. */
  113756. set buttonLeftStick(value: number);
  113757. /**
  113758. * Gets the value of the Right joystick
  113759. */
  113760. get buttonRightStick(): number;
  113761. /**
  113762. * Sets the value of the Right joystick
  113763. */
  113764. set buttonRightStick(value: number);
  113765. /**
  113766. * Gets the value of D-pad up
  113767. */
  113768. get dPadUp(): number;
  113769. /**
  113770. * Sets the value of D-pad up
  113771. */
  113772. set dPadUp(value: number);
  113773. /**
  113774. * Gets the value of D-pad down
  113775. */
  113776. get dPadDown(): number;
  113777. /**
  113778. * Sets the value of D-pad down
  113779. */
  113780. set dPadDown(value: number);
  113781. /**
  113782. * Gets the value of D-pad left
  113783. */
  113784. get dPadLeft(): number;
  113785. /**
  113786. * Sets the value of D-pad left
  113787. */
  113788. set dPadLeft(value: number);
  113789. /**
  113790. * Gets the value of D-pad right
  113791. */
  113792. get dPadRight(): number;
  113793. /**
  113794. * Sets the value of D-pad right
  113795. */
  113796. set dPadRight(value: number);
  113797. /**
  113798. * Force the gamepad to synchronize with device values
  113799. */
  113800. update(): void;
  113801. /**
  113802. * Disposes the gamepad
  113803. */
  113804. dispose(): void;
  113805. }
  113806. }
  113807. declare module BABYLON {
  113808. /**
  113809. * Manager for handling gamepads
  113810. */
  113811. export class GamepadManager {
  113812. private _scene?;
  113813. private _babylonGamepads;
  113814. private _oneGamepadConnected;
  113815. /** @hidden */
  113816. _isMonitoring: boolean;
  113817. private _gamepadEventSupported;
  113818. private _gamepadSupport?;
  113819. /**
  113820. * observable to be triggered when the gamepad controller has been connected
  113821. */
  113822. onGamepadConnectedObservable: Observable<Gamepad>;
  113823. /**
  113824. * observable to be triggered when the gamepad controller has been disconnected
  113825. */
  113826. onGamepadDisconnectedObservable: Observable<Gamepad>;
  113827. private _onGamepadConnectedEvent;
  113828. private _onGamepadDisconnectedEvent;
  113829. /**
  113830. * Initializes the gamepad manager
  113831. * @param _scene BabylonJS scene
  113832. */
  113833. constructor(_scene?: Scene | undefined);
  113834. /**
  113835. * The gamepads in the game pad manager
  113836. */
  113837. get gamepads(): Gamepad[];
  113838. /**
  113839. * Get the gamepad controllers based on type
  113840. * @param type The type of gamepad controller
  113841. * @returns Nullable gamepad
  113842. */
  113843. getGamepadByType(type?: number): Nullable<Gamepad>;
  113844. /**
  113845. * Disposes the gamepad manager
  113846. */
  113847. dispose(): void;
  113848. private _addNewGamepad;
  113849. private _startMonitoringGamepads;
  113850. private _stopMonitoringGamepads;
  113851. /** @hidden */
  113852. _checkGamepadsStatus(): void;
  113853. private _updateGamepadObjects;
  113854. }
  113855. }
  113856. declare module BABYLON {
  113857. interface Scene {
  113858. /** @hidden */
  113859. _gamepadManager: Nullable<GamepadManager>;
  113860. /**
  113861. * Gets the gamepad manager associated with the scene
  113862. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  113863. */
  113864. gamepadManager: GamepadManager;
  113865. }
  113866. /**
  113867. * Interface representing a free camera inputs manager
  113868. */
  113869. interface FreeCameraInputsManager {
  113870. /**
  113871. * Adds gamepad input support to the FreeCameraInputsManager.
  113872. * @returns the FreeCameraInputsManager
  113873. */
  113874. addGamepad(): FreeCameraInputsManager;
  113875. }
  113876. /**
  113877. * Interface representing an arc rotate camera inputs manager
  113878. */
  113879. interface ArcRotateCameraInputsManager {
  113880. /**
  113881. * Adds gamepad input support to the ArcRotateCamera InputManager.
  113882. * @returns the camera inputs manager
  113883. */
  113884. addGamepad(): ArcRotateCameraInputsManager;
  113885. }
  113886. /**
  113887. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  113888. */
  113889. export class GamepadSystemSceneComponent implements ISceneComponent {
  113890. /**
  113891. * The component name helpfull to identify the component in the list of scene components.
  113892. */
  113893. readonly name: string;
  113894. /**
  113895. * The scene the component belongs to.
  113896. */
  113897. scene: Scene;
  113898. /**
  113899. * Creates a new instance of the component for the given scene
  113900. * @param scene Defines the scene to register the component in
  113901. */
  113902. constructor(scene: Scene);
  113903. /**
  113904. * Registers the component in a given scene
  113905. */
  113906. register(): void;
  113907. /**
  113908. * Rebuilds the elements related to this component in case of
  113909. * context lost for instance.
  113910. */
  113911. rebuild(): void;
  113912. /**
  113913. * Disposes the component and the associated ressources
  113914. */
  113915. dispose(): void;
  113916. private _beforeCameraUpdate;
  113917. }
  113918. }
  113919. declare module BABYLON {
  113920. /**
  113921. * 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,
  113922. * which still works and will still be found in many Playgrounds.
  113923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113924. */
  113925. export class UniversalCamera extends TouchCamera {
  113926. /**
  113927. * Defines the gamepad rotation sensiblity.
  113928. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113929. */
  113930. get gamepadAngularSensibility(): number;
  113931. set gamepadAngularSensibility(value: number);
  113932. /**
  113933. * Defines the gamepad move sensiblity.
  113934. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113935. */
  113936. get gamepadMoveSensibility(): number;
  113937. set gamepadMoveSensibility(value: number);
  113938. /**
  113939. * 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,
  113940. * which still works and will still be found in many Playgrounds.
  113941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113942. * @param name Define the name of the camera in the scene
  113943. * @param position Define the start position of the camera in the scene
  113944. * @param scene Define the scene the camera belongs to
  113945. */
  113946. constructor(name: string, position: Vector3, scene: Scene);
  113947. /**
  113948. * Gets the current object class name.
  113949. * @return the class name
  113950. */
  113951. getClassName(): string;
  113952. }
  113953. }
  113954. declare module BABYLON {
  113955. /**
  113956. * This represents a FPS type of camera. This is only here for back compat purpose.
  113957. * Please use the UniversalCamera instead as both are identical.
  113958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113959. */
  113960. export class GamepadCamera extends UniversalCamera {
  113961. /**
  113962. * Instantiates a new Gamepad Camera
  113963. * This represents a FPS type of camera. This is only here for back compat purpose.
  113964. * Please use the UniversalCamera instead as both are identical.
  113965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113966. * @param name Define the name of the camera in the scene
  113967. * @param position Define the start position of the camera in the scene
  113968. * @param scene Define the scene the camera belongs to
  113969. */
  113970. constructor(name: string, position: Vector3, scene: Scene);
  113971. /**
  113972. * Gets the current object class name.
  113973. * @return the class name
  113974. */
  113975. getClassName(): string;
  113976. }
  113977. }
  113978. declare module BABYLON {
  113979. /** @hidden */
  113980. export var passPixelShader: {
  113981. name: string;
  113982. shader: string;
  113983. };
  113984. }
  113985. declare module BABYLON {
  113986. /** @hidden */
  113987. export var passCubePixelShader: {
  113988. name: string;
  113989. shader: string;
  113990. };
  113991. }
  113992. declare module BABYLON {
  113993. /**
  113994. * PassPostProcess which produces an output the same as it's input
  113995. */
  113996. export class PassPostProcess extends PostProcess {
  113997. /**
  113998. * Creates the PassPostProcess
  113999. * @param name The name of the effect.
  114000. * @param options The required width/height ratio to downsize to before computing the render pass.
  114001. * @param camera The camera to apply the render pass to.
  114002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114003. * @param engine The engine which the post process will be applied. (default: current engine)
  114004. * @param reusable If the post process can be reused on the same frame. (default: false)
  114005. * @param textureType The type of texture to be used when performing the post processing.
  114006. * @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)
  114007. */
  114008. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114009. }
  114010. /**
  114011. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114012. */
  114013. export class PassCubePostProcess extends PostProcess {
  114014. private _face;
  114015. /**
  114016. * Gets or sets the cube face to display.
  114017. * * 0 is +X
  114018. * * 1 is -X
  114019. * * 2 is +Y
  114020. * * 3 is -Y
  114021. * * 4 is +Z
  114022. * * 5 is -Z
  114023. */
  114024. get face(): number;
  114025. set face(value: number);
  114026. /**
  114027. * Creates the PassCubePostProcess
  114028. * @param name The name of the effect.
  114029. * @param options The required width/height ratio to downsize to before computing the render pass.
  114030. * @param camera The camera to apply the render pass to.
  114031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114032. * @param engine The engine which the post process will be applied. (default: current engine)
  114033. * @param reusable If the post process can be reused on the same frame. (default: false)
  114034. * @param textureType The type of texture to be used when performing the post processing.
  114035. * @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)
  114036. */
  114037. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114038. }
  114039. }
  114040. declare module BABYLON {
  114041. /** @hidden */
  114042. export var anaglyphPixelShader: {
  114043. name: string;
  114044. shader: string;
  114045. };
  114046. }
  114047. declare module BABYLON {
  114048. /**
  114049. * Postprocess used to generate anaglyphic rendering
  114050. */
  114051. export class AnaglyphPostProcess extends PostProcess {
  114052. private _passedProcess;
  114053. /**
  114054. * Creates a new AnaglyphPostProcess
  114055. * @param name defines postprocess name
  114056. * @param options defines creation options or target ratio scale
  114057. * @param rigCameras defines cameras using this postprocess
  114058. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114059. * @param engine defines hosting engine
  114060. * @param reusable defines if the postprocess will be reused multiple times per frame
  114061. */
  114062. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114063. }
  114064. }
  114065. declare module BABYLON {
  114066. /**
  114067. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114068. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114069. */
  114070. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114071. /**
  114072. * Creates a new AnaglyphArcRotateCamera
  114073. * @param name defines camera name
  114074. * @param alpha defines alpha angle (in radians)
  114075. * @param beta defines beta angle (in radians)
  114076. * @param radius defines radius
  114077. * @param target defines camera target
  114078. * @param interaxialDistance defines distance between each color axis
  114079. * @param scene defines the hosting scene
  114080. */
  114081. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114082. /**
  114083. * Gets camera class name
  114084. * @returns AnaglyphArcRotateCamera
  114085. */
  114086. getClassName(): string;
  114087. }
  114088. }
  114089. declare module BABYLON {
  114090. /**
  114091. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114092. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114093. */
  114094. export class AnaglyphFreeCamera extends FreeCamera {
  114095. /**
  114096. * Creates a new AnaglyphFreeCamera
  114097. * @param name defines camera name
  114098. * @param position defines initial position
  114099. * @param interaxialDistance defines distance between each color axis
  114100. * @param scene defines the hosting scene
  114101. */
  114102. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114103. /**
  114104. * Gets camera class name
  114105. * @returns AnaglyphFreeCamera
  114106. */
  114107. getClassName(): string;
  114108. }
  114109. }
  114110. declare module BABYLON {
  114111. /**
  114112. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114113. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114114. */
  114115. export class AnaglyphGamepadCamera extends GamepadCamera {
  114116. /**
  114117. * Creates a new AnaglyphGamepadCamera
  114118. * @param name defines camera name
  114119. * @param position defines initial position
  114120. * @param interaxialDistance defines distance between each color axis
  114121. * @param scene defines the hosting scene
  114122. */
  114123. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114124. /**
  114125. * Gets camera class name
  114126. * @returns AnaglyphGamepadCamera
  114127. */
  114128. getClassName(): string;
  114129. }
  114130. }
  114131. declare module BABYLON {
  114132. /**
  114133. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114134. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114135. */
  114136. export class AnaglyphUniversalCamera extends UniversalCamera {
  114137. /**
  114138. * Creates a new AnaglyphUniversalCamera
  114139. * @param name defines camera name
  114140. * @param position defines initial position
  114141. * @param interaxialDistance defines distance between each color axis
  114142. * @param scene defines the hosting scene
  114143. */
  114144. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114145. /**
  114146. * Gets camera class name
  114147. * @returns AnaglyphUniversalCamera
  114148. */
  114149. getClassName(): string;
  114150. }
  114151. }
  114152. declare module BABYLON {
  114153. /** @hidden */
  114154. export var stereoscopicInterlacePixelShader: {
  114155. name: string;
  114156. shader: string;
  114157. };
  114158. }
  114159. declare module BABYLON {
  114160. /**
  114161. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114162. */
  114163. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114164. private _stepSize;
  114165. private _passedProcess;
  114166. /**
  114167. * Initializes a StereoscopicInterlacePostProcessI
  114168. * @param name The name of the effect.
  114169. * @param rigCameras The rig cameras to be appled to the post process
  114170. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114171. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114173. * @param engine The engine which the post process will be applied. (default: current engine)
  114174. * @param reusable If the post process can be reused on the same frame. (default: false)
  114175. */
  114176. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114177. }
  114178. /**
  114179. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114180. */
  114181. export class StereoscopicInterlacePostProcess extends PostProcess {
  114182. private _stepSize;
  114183. private _passedProcess;
  114184. /**
  114185. * Initializes a StereoscopicInterlacePostProcess
  114186. * @param name The name of the effect.
  114187. * @param rigCameras The rig cameras to be appled to the post process
  114188. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  114189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114190. * @param engine The engine which the post process will be applied. (default: current engine)
  114191. * @param reusable If the post process can be reused on the same frame. (default: false)
  114192. */
  114193. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114194. }
  114195. }
  114196. declare module BABYLON {
  114197. /**
  114198. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  114199. * @see http://doc.babylonjs.com/features/cameras
  114200. */
  114201. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  114202. /**
  114203. * Creates a new StereoscopicArcRotateCamera
  114204. * @param name defines camera name
  114205. * @param alpha defines alpha angle (in radians)
  114206. * @param beta defines beta angle (in radians)
  114207. * @param radius defines radius
  114208. * @param target defines camera target
  114209. * @param interaxialDistance defines distance between each color axis
  114210. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114211. * @param scene defines the hosting scene
  114212. */
  114213. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114214. /**
  114215. * Gets camera class name
  114216. * @returns StereoscopicArcRotateCamera
  114217. */
  114218. getClassName(): string;
  114219. }
  114220. }
  114221. declare module BABYLON {
  114222. /**
  114223. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  114224. * @see http://doc.babylonjs.com/features/cameras
  114225. */
  114226. export class StereoscopicFreeCamera extends FreeCamera {
  114227. /**
  114228. * Creates a new StereoscopicFreeCamera
  114229. * @param name defines camera name
  114230. * @param position defines initial position
  114231. * @param interaxialDistance defines distance between each color axis
  114232. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114233. * @param scene defines the hosting scene
  114234. */
  114235. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114236. /**
  114237. * Gets camera class name
  114238. * @returns StereoscopicFreeCamera
  114239. */
  114240. getClassName(): string;
  114241. }
  114242. }
  114243. declare module BABYLON {
  114244. /**
  114245. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  114246. * @see http://doc.babylonjs.com/features/cameras
  114247. */
  114248. export class StereoscopicGamepadCamera extends GamepadCamera {
  114249. /**
  114250. * Creates a new StereoscopicGamepadCamera
  114251. * @param name defines camera name
  114252. * @param position defines initial position
  114253. * @param interaxialDistance defines distance between each color axis
  114254. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114255. * @param scene defines the hosting scene
  114256. */
  114257. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114258. /**
  114259. * Gets camera class name
  114260. * @returns StereoscopicGamepadCamera
  114261. */
  114262. getClassName(): string;
  114263. }
  114264. }
  114265. declare module BABYLON {
  114266. /**
  114267. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  114268. * @see http://doc.babylonjs.com/features/cameras
  114269. */
  114270. export class StereoscopicUniversalCamera extends UniversalCamera {
  114271. /**
  114272. * Creates a new StereoscopicUniversalCamera
  114273. * @param name defines camera name
  114274. * @param position defines initial position
  114275. * @param interaxialDistance defines distance between each color axis
  114276. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114277. * @param scene defines the hosting scene
  114278. */
  114279. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114280. /**
  114281. * Gets camera class name
  114282. * @returns StereoscopicUniversalCamera
  114283. */
  114284. getClassName(): string;
  114285. }
  114286. }
  114287. declare module BABYLON {
  114288. /**
  114289. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  114290. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114291. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114292. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114293. */
  114294. export class VirtualJoysticksCamera extends FreeCamera {
  114295. /**
  114296. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  114297. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114298. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114299. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114300. * @param name Define the name of the camera in the scene
  114301. * @param position Define the start position of the camera in the scene
  114302. * @param scene Define the scene the camera belongs to
  114303. */
  114304. constructor(name: string, position: Vector3, scene: Scene);
  114305. /**
  114306. * Gets the current object class name.
  114307. * @return the class name
  114308. */
  114309. getClassName(): string;
  114310. }
  114311. }
  114312. declare module BABYLON {
  114313. /**
  114314. * This represents all the required metrics to create a VR camera.
  114315. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  114316. */
  114317. export class VRCameraMetrics {
  114318. /**
  114319. * Define the horizontal resolution off the screen.
  114320. */
  114321. hResolution: number;
  114322. /**
  114323. * Define the vertical resolution off the screen.
  114324. */
  114325. vResolution: number;
  114326. /**
  114327. * Define the horizontal screen size.
  114328. */
  114329. hScreenSize: number;
  114330. /**
  114331. * Define the vertical screen size.
  114332. */
  114333. vScreenSize: number;
  114334. /**
  114335. * Define the vertical screen center position.
  114336. */
  114337. vScreenCenter: number;
  114338. /**
  114339. * Define the distance of the eyes to the screen.
  114340. */
  114341. eyeToScreenDistance: number;
  114342. /**
  114343. * Define the distance between both lenses
  114344. */
  114345. lensSeparationDistance: number;
  114346. /**
  114347. * Define the distance between both viewer's eyes.
  114348. */
  114349. interpupillaryDistance: number;
  114350. /**
  114351. * Define the distortion factor of the VR postprocess.
  114352. * Please, touch with care.
  114353. */
  114354. distortionK: number[];
  114355. /**
  114356. * Define the chromatic aberration correction factors for the VR post process.
  114357. */
  114358. chromaAbCorrection: number[];
  114359. /**
  114360. * Define the scale factor of the post process.
  114361. * The smaller the better but the slower.
  114362. */
  114363. postProcessScaleFactor: number;
  114364. /**
  114365. * Define an offset for the lens center.
  114366. */
  114367. lensCenterOffset: number;
  114368. /**
  114369. * Define if the current vr camera should compensate the distortion of the lense or not.
  114370. */
  114371. compensateDistortion: boolean;
  114372. /**
  114373. * Defines if multiview should be enabled when rendering (Default: false)
  114374. */
  114375. multiviewEnabled: boolean;
  114376. /**
  114377. * Gets the rendering aspect ratio based on the provided resolutions.
  114378. */
  114379. get aspectRatio(): number;
  114380. /**
  114381. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  114382. */
  114383. get aspectRatioFov(): number;
  114384. /**
  114385. * @hidden
  114386. */
  114387. get leftHMatrix(): Matrix;
  114388. /**
  114389. * @hidden
  114390. */
  114391. get rightHMatrix(): Matrix;
  114392. /**
  114393. * @hidden
  114394. */
  114395. get leftPreViewMatrix(): Matrix;
  114396. /**
  114397. * @hidden
  114398. */
  114399. get rightPreViewMatrix(): Matrix;
  114400. /**
  114401. * Get the default VRMetrics based on the most generic setup.
  114402. * @returns the default vr metrics
  114403. */
  114404. static GetDefault(): VRCameraMetrics;
  114405. }
  114406. }
  114407. declare module BABYLON {
  114408. /** @hidden */
  114409. export var vrDistortionCorrectionPixelShader: {
  114410. name: string;
  114411. shader: string;
  114412. };
  114413. }
  114414. declare module BABYLON {
  114415. /**
  114416. * VRDistortionCorrectionPostProcess used for mobile VR
  114417. */
  114418. export class VRDistortionCorrectionPostProcess extends PostProcess {
  114419. private _isRightEye;
  114420. private _distortionFactors;
  114421. private _postProcessScaleFactor;
  114422. private _lensCenterOffset;
  114423. private _scaleIn;
  114424. private _scaleFactor;
  114425. private _lensCenter;
  114426. /**
  114427. * Initializes the VRDistortionCorrectionPostProcess
  114428. * @param name The name of the effect.
  114429. * @param camera The camera to apply the render pass to.
  114430. * @param isRightEye If this is for the right eye distortion
  114431. * @param vrMetrics All the required metrics for the VR camera
  114432. */
  114433. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  114434. }
  114435. }
  114436. declare module BABYLON {
  114437. /**
  114438. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  114439. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114440. */
  114441. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  114442. /**
  114443. * Creates a new VRDeviceOrientationArcRotateCamera
  114444. * @param name defines camera name
  114445. * @param alpha defines the camera rotation along the logitudinal axis
  114446. * @param beta defines the camera rotation along the latitudinal axis
  114447. * @param radius defines the camera distance from its target
  114448. * @param target defines the camera target
  114449. * @param scene defines the scene the camera belongs to
  114450. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114451. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114452. */
  114453. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114454. /**
  114455. * Gets camera class name
  114456. * @returns VRDeviceOrientationArcRotateCamera
  114457. */
  114458. getClassName(): string;
  114459. }
  114460. }
  114461. declare module BABYLON {
  114462. /**
  114463. * Camera used to simulate VR rendering (based on FreeCamera)
  114464. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114465. */
  114466. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  114467. /**
  114468. * Creates a new VRDeviceOrientationFreeCamera
  114469. * @param name defines camera name
  114470. * @param position defines the start position of the camera
  114471. * @param scene defines the scene the camera belongs to
  114472. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114473. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114474. */
  114475. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114476. /**
  114477. * Gets camera class name
  114478. * @returns VRDeviceOrientationFreeCamera
  114479. */
  114480. getClassName(): string;
  114481. }
  114482. }
  114483. declare module BABYLON {
  114484. /**
  114485. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  114486. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114487. */
  114488. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  114489. /**
  114490. * Creates a new VRDeviceOrientationGamepadCamera
  114491. * @param name defines camera name
  114492. * @param position defines the start position of the camera
  114493. * @param scene defines the scene the camera belongs to
  114494. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114495. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114496. */
  114497. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114498. /**
  114499. * Gets camera class name
  114500. * @returns VRDeviceOrientationGamepadCamera
  114501. */
  114502. getClassName(): string;
  114503. }
  114504. }
  114505. declare module BABYLON {
  114506. /** @hidden */
  114507. export var imageProcessingPixelShader: {
  114508. name: string;
  114509. shader: string;
  114510. };
  114511. }
  114512. declare module BABYLON {
  114513. /**
  114514. * ImageProcessingPostProcess
  114515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  114516. */
  114517. export class ImageProcessingPostProcess extends PostProcess {
  114518. /**
  114519. * Default configuration related to image processing available in the PBR Material.
  114520. */
  114521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114522. /**
  114523. * Gets the image processing configuration used either in this material.
  114524. */
  114525. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  114526. /**
  114527. * Sets the Default image processing configuration used either in the this material.
  114528. *
  114529. * If sets to null, the scene one is in use.
  114530. */
  114531. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  114532. /**
  114533. * Keep track of the image processing observer to allow dispose and replace.
  114534. */
  114535. private _imageProcessingObserver;
  114536. /**
  114537. * Attaches a new image processing configuration to the PBR Material.
  114538. * @param configuration
  114539. */
  114540. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  114541. /**
  114542. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114543. */
  114544. get colorCurves(): Nullable<ColorCurves>;
  114545. /**
  114546. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114547. */
  114548. set colorCurves(value: Nullable<ColorCurves>);
  114549. /**
  114550. * Gets wether the color curves effect is enabled.
  114551. */
  114552. get colorCurvesEnabled(): boolean;
  114553. /**
  114554. * Sets wether the color curves effect is enabled.
  114555. */
  114556. set colorCurvesEnabled(value: boolean);
  114557. /**
  114558. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114559. */
  114560. get colorGradingTexture(): Nullable<BaseTexture>;
  114561. /**
  114562. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114563. */
  114564. set colorGradingTexture(value: Nullable<BaseTexture>);
  114565. /**
  114566. * Gets wether the color grading effect is enabled.
  114567. */
  114568. get colorGradingEnabled(): boolean;
  114569. /**
  114570. * Gets wether the color grading effect is enabled.
  114571. */
  114572. set colorGradingEnabled(value: boolean);
  114573. /**
  114574. * Gets exposure used in the effect.
  114575. */
  114576. get exposure(): number;
  114577. /**
  114578. * Sets exposure used in the effect.
  114579. */
  114580. set exposure(value: number);
  114581. /**
  114582. * Gets wether tonemapping is enabled or not.
  114583. */
  114584. get toneMappingEnabled(): boolean;
  114585. /**
  114586. * Sets wether tonemapping is enabled or not
  114587. */
  114588. set toneMappingEnabled(value: boolean);
  114589. /**
  114590. * Gets the type of tone mapping effect.
  114591. */
  114592. get toneMappingType(): number;
  114593. /**
  114594. * Sets the type of tone mapping effect.
  114595. */
  114596. set toneMappingType(value: number);
  114597. /**
  114598. * Gets contrast used in the effect.
  114599. */
  114600. get contrast(): number;
  114601. /**
  114602. * Sets contrast used in the effect.
  114603. */
  114604. set contrast(value: number);
  114605. /**
  114606. * Gets Vignette stretch size.
  114607. */
  114608. get vignetteStretch(): number;
  114609. /**
  114610. * Sets Vignette stretch size.
  114611. */
  114612. set vignetteStretch(value: number);
  114613. /**
  114614. * Gets Vignette centre X Offset.
  114615. */
  114616. get vignetteCentreX(): number;
  114617. /**
  114618. * Sets Vignette centre X Offset.
  114619. */
  114620. set vignetteCentreX(value: number);
  114621. /**
  114622. * Gets Vignette centre Y Offset.
  114623. */
  114624. get vignetteCentreY(): number;
  114625. /**
  114626. * Sets Vignette centre Y Offset.
  114627. */
  114628. set vignetteCentreY(value: number);
  114629. /**
  114630. * Gets Vignette weight or intensity of the vignette effect.
  114631. */
  114632. get vignetteWeight(): number;
  114633. /**
  114634. * Sets Vignette weight or intensity of the vignette effect.
  114635. */
  114636. set vignetteWeight(value: number);
  114637. /**
  114638. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114639. * if vignetteEnabled is set to true.
  114640. */
  114641. get vignetteColor(): Color4;
  114642. /**
  114643. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114644. * if vignetteEnabled is set to true.
  114645. */
  114646. set vignetteColor(value: Color4);
  114647. /**
  114648. * Gets Camera field of view used by the Vignette effect.
  114649. */
  114650. get vignetteCameraFov(): number;
  114651. /**
  114652. * Sets Camera field of view used by the Vignette effect.
  114653. */
  114654. set vignetteCameraFov(value: number);
  114655. /**
  114656. * Gets the vignette blend mode allowing different kind of effect.
  114657. */
  114658. get vignetteBlendMode(): number;
  114659. /**
  114660. * Sets the vignette blend mode allowing different kind of effect.
  114661. */
  114662. set vignetteBlendMode(value: number);
  114663. /**
  114664. * Gets wether the vignette effect is enabled.
  114665. */
  114666. get vignetteEnabled(): boolean;
  114667. /**
  114668. * Sets wether the vignette effect is enabled.
  114669. */
  114670. set vignetteEnabled(value: boolean);
  114671. private _fromLinearSpace;
  114672. /**
  114673. * Gets wether the input of the processing is in Gamma or Linear Space.
  114674. */
  114675. get fromLinearSpace(): boolean;
  114676. /**
  114677. * Sets wether the input of the processing is in Gamma or Linear Space.
  114678. */
  114679. set fromLinearSpace(value: boolean);
  114680. /**
  114681. * Defines cache preventing GC.
  114682. */
  114683. private _defines;
  114684. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  114685. /**
  114686. * "ImageProcessingPostProcess"
  114687. * @returns "ImageProcessingPostProcess"
  114688. */
  114689. getClassName(): string;
  114690. protected _updateParameters(): void;
  114691. dispose(camera?: Camera): void;
  114692. }
  114693. }
  114694. declare module BABYLON {
  114695. /**
  114696. * Class containing static functions to help procedurally build meshes
  114697. */
  114698. export class GroundBuilder {
  114699. /**
  114700. * Creates a ground mesh
  114701. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  114702. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  114703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114704. * @param name defines the name of the mesh
  114705. * @param options defines the options used to create the mesh
  114706. * @param scene defines the hosting scene
  114707. * @returns the ground mesh
  114708. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  114709. */
  114710. static CreateGround(name: string, options: {
  114711. width?: number;
  114712. height?: number;
  114713. subdivisions?: number;
  114714. subdivisionsX?: number;
  114715. subdivisionsY?: number;
  114716. updatable?: boolean;
  114717. }, scene: any): Mesh;
  114718. /**
  114719. * Creates a tiled ground mesh
  114720. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  114721. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  114722. * * 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
  114723. * * 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
  114724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114725. * @param name defines the name of the mesh
  114726. * @param options defines the options used to create the mesh
  114727. * @param scene defines the hosting scene
  114728. * @returns the tiled ground mesh
  114729. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  114730. */
  114731. static CreateTiledGround(name: string, options: {
  114732. xmin: number;
  114733. zmin: number;
  114734. xmax: number;
  114735. zmax: number;
  114736. subdivisions?: {
  114737. w: number;
  114738. h: number;
  114739. };
  114740. precision?: {
  114741. w: number;
  114742. h: number;
  114743. };
  114744. updatable?: boolean;
  114745. }, scene?: Nullable<Scene>): Mesh;
  114746. /**
  114747. * Creates a ground mesh from a height map
  114748. * * The parameter `url` sets the URL of the height map image resource.
  114749. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  114750. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  114751. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  114752. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  114753. * * 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.
  114754. * * 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).
  114755. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114757. * @param name defines the name of the mesh
  114758. * @param url defines the url to the height map
  114759. * @param options defines the options used to create the mesh
  114760. * @param scene defines the hosting scene
  114761. * @returns the ground mesh
  114762. * @see https://doc.babylonjs.com/babylon101/height_map
  114763. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  114764. */
  114765. static CreateGroundFromHeightMap(name: string, url: string, options: {
  114766. width?: number;
  114767. height?: number;
  114768. subdivisions?: number;
  114769. minHeight?: number;
  114770. maxHeight?: number;
  114771. colorFilter?: Color3;
  114772. alphaFilter?: number;
  114773. updatable?: boolean;
  114774. onReady?: (mesh: GroundMesh) => void;
  114775. }, scene?: Nullable<Scene>): GroundMesh;
  114776. }
  114777. }
  114778. declare module BABYLON {
  114779. /**
  114780. * Class containing static functions to help procedurally build meshes
  114781. */
  114782. export class TorusBuilder {
  114783. /**
  114784. * Creates a torus mesh
  114785. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114786. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114787. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114791. * @param name defines the name of the mesh
  114792. * @param options defines the options used to create the mesh
  114793. * @param scene defines the hosting scene
  114794. * @returns the torus mesh
  114795. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114796. */
  114797. static CreateTorus(name: string, options: {
  114798. diameter?: number;
  114799. thickness?: number;
  114800. tessellation?: number;
  114801. updatable?: boolean;
  114802. sideOrientation?: number;
  114803. frontUVs?: Vector4;
  114804. backUVs?: Vector4;
  114805. }, scene: any): Mesh;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. /**
  114810. * Class containing static functions to help procedurally build meshes
  114811. */
  114812. export class CylinderBuilder {
  114813. /**
  114814. * Creates a cylinder or a cone mesh
  114815. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114816. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114817. * * 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.
  114818. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114819. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114820. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114821. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114822. * * 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).
  114823. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114824. * * 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).
  114825. * * 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
  114826. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114827. * * 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
  114828. * * 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.
  114829. * * If `enclose` is false, a ring surface is one element.
  114830. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114831. * * 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
  114832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114835. * @param name defines the name of the mesh
  114836. * @param options defines the options used to create the mesh
  114837. * @param scene defines the hosting scene
  114838. * @returns the cylinder mesh
  114839. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114840. */
  114841. static CreateCylinder(name: string, options: {
  114842. height?: number;
  114843. diameterTop?: number;
  114844. diameterBottom?: number;
  114845. diameter?: number;
  114846. tessellation?: number;
  114847. subdivisions?: number;
  114848. arc?: number;
  114849. faceColors?: Color4[];
  114850. faceUV?: Vector4[];
  114851. updatable?: boolean;
  114852. hasRings?: boolean;
  114853. enclose?: boolean;
  114854. cap?: number;
  114855. sideOrientation?: number;
  114856. frontUVs?: Vector4;
  114857. backUVs?: Vector4;
  114858. }, scene: any): Mesh;
  114859. }
  114860. }
  114861. declare module BABYLON {
  114862. /**
  114863. * States of the webXR experience
  114864. */
  114865. export enum WebXRState {
  114866. /**
  114867. * Transitioning to being in XR mode
  114868. */
  114869. ENTERING_XR = 0,
  114870. /**
  114871. * Transitioning to non XR mode
  114872. */
  114873. EXITING_XR = 1,
  114874. /**
  114875. * In XR mode and presenting
  114876. */
  114877. IN_XR = 2,
  114878. /**
  114879. * Not entered XR mode
  114880. */
  114881. NOT_IN_XR = 3
  114882. }
  114883. /**
  114884. * Abstraction of the XR render target
  114885. */
  114886. export interface WebXRRenderTarget extends IDisposable {
  114887. /**
  114888. * xrpresent context of the canvas which can be used to display/mirror xr content
  114889. */
  114890. canvasContext: WebGLRenderingContext;
  114891. /**
  114892. * xr layer for the canvas
  114893. */
  114894. xrLayer: Nullable<XRWebGLLayer>;
  114895. /**
  114896. * Initializes the xr layer for the session
  114897. * @param xrSession xr session
  114898. * @returns a promise that will resolve once the XR Layer has been created
  114899. */
  114900. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  114901. }
  114902. }
  114903. declare module BABYLON {
  114904. /**
  114905. * COnfiguration object for WebXR output canvas
  114906. */
  114907. export class WebXRManagedOutputCanvasOptions {
  114908. /**
  114909. * Options for this XR Layer output
  114910. */
  114911. canvasOptions?: XRWebGLLayerOptions;
  114912. /**
  114913. * CSS styling for a newly created canvas (if not provided)
  114914. */
  114915. newCanvasCssStyle?: string;
  114916. /**
  114917. * An optional canvas in case you wish to create it yourself and provide it here.
  114918. * If not provided, a new canvas will be created
  114919. */
  114920. canvasElement?: HTMLCanvasElement;
  114921. /**
  114922. * Get the default values of the configuration object
  114923. * @returns default values of this configuration object
  114924. */
  114925. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  114926. }
  114927. /**
  114928. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  114929. */
  114930. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  114931. private _options;
  114932. private _engine;
  114933. private _canvas;
  114934. /**
  114935. * Rendering context of the canvas which can be used to display/mirror xr content
  114936. */
  114937. canvasContext: WebGLRenderingContext;
  114938. /**
  114939. * xr layer for the canvas
  114940. */
  114941. xrLayer: Nullable<XRWebGLLayer>;
  114942. /**
  114943. * Initializes the xr layer for the session
  114944. * @param xrSession xr session
  114945. * @returns a promise that will resolve once the XR Layer has been created
  114946. */
  114947. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  114948. /**
  114949. * Initializes the canvas to be added/removed upon entering/exiting xr
  114950. * @param _xrSessionManager The XR Session manager
  114951. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  114952. */
  114953. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  114954. /**
  114955. * Disposes of the object
  114956. */
  114957. dispose(): void;
  114958. private _setManagedOutputCanvas;
  114959. private _addCanvas;
  114960. private _removeCanvas;
  114961. }
  114962. }
  114963. declare module BABYLON {
  114964. /**
  114965. * Manages an XRSession to work with Babylon's engine
  114966. * @see https://doc.babylonjs.com/how_to/webxr
  114967. */
  114968. export class WebXRSessionManager implements IDisposable {
  114969. /** The scene which the session should be created for */
  114970. scene: Scene;
  114971. /**
  114972. * Fires every time a new xrFrame arrives which can be used to update the camera
  114973. */
  114974. onXRFrameObservable: Observable<XRFrame>;
  114975. /**
  114976. * Fires when the xr session is ended either by the device or manually done
  114977. */
  114978. onXRSessionEnded: Observable<any>;
  114979. /**
  114980. * Fires when the xr session is ended either by the device or manually done
  114981. */
  114982. onXRSessionInit: Observable<XRSession>;
  114983. /**
  114984. * Fires when the reference space changed
  114985. */
  114986. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  114987. /**
  114988. * Underlying xr session
  114989. */
  114990. session: XRSession;
  114991. /**
  114992. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  114993. * or get the offset the player is currently at.
  114994. */
  114995. viewerReferenceSpace: XRReferenceSpace;
  114996. private _referenceSpace;
  114997. /**
  114998. * The current reference space used in this session. This reference space can constantly change!
  114999. * It is mainly used to offset the camera's position.
  115000. */
  115001. get referenceSpace(): XRReferenceSpace;
  115002. /**
  115003. * Set a new reference space and triggers the observable
  115004. */
  115005. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115006. /**
  115007. * The base reference space from which the session started. good if you want to reset your
  115008. * reference space
  115009. */
  115010. baseReferenceSpace: XRReferenceSpace;
  115011. /**
  115012. * Used just in case of a failure to initialize an immersive session.
  115013. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115014. */
  115015. defaultHeightCompensation: number;
  115016. /**
  115017. * Current XR frame
  115018. */
  115019. currentFrame: Nullable<XRFrame>;
  115020. /** WebXR timestamp updated every frame */
  115021. currentTimestamp: number;
  115022. private _xrNavigator;
  115023. private baseLayer;
  115024. private _rttProvider;
  115025. private _sessionEnded;
  115026. /**
  115027. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115028. * @param scene The scene which the session should be created for
  115029. */
  115030. constructor(
  115031. /** The scene which the session should be created for */
  115032. scene: Scene);
  115033. /**
  115034. * Initializes the manager
  115035. * After initialization enterXR can be called to start an XR session
  115036. * @returns Promise which resolves after it is initialized
  115037. */
  115038. initializeAsync(): Promise<void>;
  115039. /**
  115040. * Initializes an xr session
  115041. * @param xrSessionMode mode to initialize
  115042. * @param xrSessionInit defines optional and required values to pass to the session builder
  115043. * @returns a promise which will resolve once the session has been initialized
  115044. */
  115045. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115046. /**
  115047. * Sets the reference space on the xr session
  115048. * @param referenceSpaceType space to set
  115049. * @returns a promise that will resolve once the reference space has been set
  115050. */
  115051. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115052. /**
  115053. * Resets the reference space to the one started the session
  115054. */
  115055. resetReferenceSpace(): void;
  115056. /**
  115057. * Updates the render state of the session
  115058. * @param state state to set
  115059. * @returns a promise that resolves once the render state has been updated
  115060. */
  115061. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115062. /**
  115063. * Starts rendering to the xr layer
  115064. */
  115065. runXRRenderLoop(): void;
  115066. /**
  115067. * Gets the correct render target texture to be rendered this frame for this eye
  115068. * @param eye the eye for which to get the render target
  115069. * @returns the render target for the specified eye
  115070. */
  115071. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115072. /**
  115073. * Stops the xrSession and restores the renderloop
  115074. * @returns Promise which resolves after it exits XR
  115075. */
  115076. exitXRAsync(): Promise<void>;
  115077. /**
  115078. * Checks if a session would be supported for the creation options specified
  115079. * @param sessionMode session mode to check if supported eg. immersive-vr
  115080. * @returns true if supported
  115081. */
  115082. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115083. /**
  115084. * Creates a WebXRRenderTarget object for the XR session
  115085. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115086. * @param options optional options to provide when creating a new render target
  115087. * @returns a WebXR render target to which the session can render
  115088. */
  115089. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115090. /**
  115091. * @hidden
  115092. * Converts the render layer of xrSession to a render target
  115093. * @param session session to create render target for
  115094. * @param scene scene the new render target should be created for
  115095. * @param baseLayer the webgl layer to create the render target for
  115096. */
  115097. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115098. /**
  115099. * Disposes of the session manager
  115100. */
  115101. dispose(): void;
  115102. /**
  115103. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115104. * @param sessionMode defines the session to test
  115105. * @returns a promise with boolean as final value
  115106. */
  115107. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115108. }
  115109. }
  115110. declare module BABYLON {
  115111. /**
  115112. * WebXR Camera which holds the views for the xrSession
  115113. * @see https://doc.babylonjs.com/how_to/webxr
  115114. */
  115115. export class WebXRCamera extends FreeCamera {
  115116. private _xrSessionManager;
  115117. private _firstFrame;
  115118. private _referencedPosition;
  115119. private _referenceQuaternion;
  115120. private _xrInvPositionCache;
  115121. private _xrInvQuaternionCache;
  115122. /**
  115123. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115124. * @param name the name of the camera
  115125. * @param scene the scene to add the camera to
  115126. */
  115127. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115128. private _updateNumberOfRigCameras;
  115129. /**
  115130. * Sets this camera's transformation based on a non-vr camera
  115131. * @param otherCamera the non-vr camera to copy the transformation from
  115132. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115133. */
  115134. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115135. /** @hidden */
  115136. _updateForDualEyeDebugging(): void;
  115137. private _updateReferenceSpace;
  115138. private _updateReferenceSpaceOffset;
  115139. private _updateFromXRSession;
  115140. }
  115141. }
  115142. declare module BABYLON {
  115143. /**
  115144. * Defining the interface required for a (webxr) feature
  115145. */
  115146. export interface IWebXRFeature extends IDisposable {
  115147. /**
  115148. * Is this feature attached
  115149. */
  115150. attached: boolean;
  115151. /**
  115152. * Should auto-attach be disabled?
  115153. */
  115154. disableAutoAttach: boolean;
  115155. /**
  115156. * Attach the feature to the session
  115157. * Will usually be called by the features manager
  115158. *
  115159. * @param force should attachment be forced (even when already attached)
  115160. * @returns true if successful.
  115161. */
  115162. attach(force?: boolean): boolean;
  115163. /**
  115164. * Detach the feature from the session
  115165. * Will usually be called by the features manager
  115166. *
  115167. * @returns true if successful.
  115168. */
  115169. detach(): boolean;
  115170. }
  115171. /**
  115172. * A list of the currently available features without referencing them
  115173. */
  115174. export class WebXRFeatureName {
  115175. /**
  115176. * The name of the hit test feature
  115177. */
  115178. static HIT_TEST: string;
  115179. /**
  115180. * The name of the anchor system feature
  115181. */
  115182. static ANCHOR_SYSTEM: string;
  115183. /**
  115184. * The name of the background remover feature
  115185. */
  115186. static BACKGROUND_REMOVER: string;
  115187. /**
  115188. * The name of the pointer selection feature
  115189. */
  115190. static POINTER_SELECTION: string;
  115191. /**
  115192. * The name of the teleportation feature
  115193. */
  115194. static TELEPORTATION: string;
  115195. /**
  115196. * The name of the plane detection feature
  115197. */
  115198. static PLANE_DETECTION: string;
  115199. }
  115200. /**
  115201. * Defining the constructor of a feature. Used to register the modules.
  115202. */
  115203. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  115204. /**
  115205. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  115206. * It is mainly used in AR sessions.
  115207. *
  115208. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  115209. */
  115210. export class WebXRFeaturesManager implements IDisposable {
  115211. private _xrSessionManager;
  115212. private static readonly _AvailableFeatures;
  115213. /**
  115214. * Used to register a module. After calling this function a developer can use this feature in the scene.
  115215. * Mainly used internally.
  115216. *
  115217. * @param featureName the name of the feature to register
  115218. * @param constructorFunction the function used to construct the module
  115219. * @param version the (babylon) version of the module
  115220. * @param stable is that a stable version of this module
  115221. */
  115222. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  115223. /**
  115224. * Returns a constructor of a specific feature.
  115225. *
  115226. * @param featureName the name of the feature to construct
  115227. * @param version the version of the feature to load
  115228. * @param xrSessionManager the xrSessionManager. Used to construct the module
  115229. * @param options optional options provided to the module.
  115230. * @returns a function that, when called, will return a new instance of this feature
  115231. */
  115232. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  115233. /**
  115234. * Return the latest unstable version of this feature
  115235. * @param featureName the name of the feature to search
  115236. * @returns the version number. if not found will return -1
  115237. */
  115238. static GetLatestVersionOfFeature(featureName: string): number;
  115239. /**
  115240. * Return the latest stable version of this feature
  115241. * @param featureName the name of the feature to search
  115242. * @returns the version number. if not found will return -1
  115243. */
  115244. static GetStableVersionOfFeature(featureName: string): number;
  115245. /**
  115246. * Can be used to return the list of features currently registered
  115247. *
  115248. * @returns an Array of available features
  115249. */
  115250. static GetAvailableFeatures(): string[];
  115251. /**
  115252. * Gets the versions available for a specific feature
  115253. * @param featureName the name of the feature
  115254. * @returns an array with the available versions
  115255. */
  115256. static GetAvailableVersions(featureName: string): string[];
  115257. private _features;
  115258. /**
  115259. * constructs a new features manages.
  115260. *
  115261. * @param _xrSessionManager an instance of WebXRSessionManager
  115262. */
  115263. constructor(_xrSessionManager: WebXRSessionManager);
  115264. /**
  115265. * 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.
  115266. * 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.
  115267. *
  115268. * @param featureName the name of the feature to load or the class of the feature
  115269. * @param version optional version to load. if not provided the latest version will be enabled
  115270. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  115271. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  115272. * @returns a new constructed feature or throws an error if feature not found.
  115273. */
  115274. enableFeature(featureName: string | {
  115275. Name: string;
  115276. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  115277. /**
  115278. * Used to disable an already-enabled feature
  115279. * The feature will be disposed and will be recreated once enabled.
  115280. * @param featureName the feature to disable
  115281. * @returns true if disable was successful
  115282. */
  115283. disableFeature(featureName: string | {
  115284. Name: string;
  115285. }): boolean;
  115286. /**
  115287. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  115288. * Can be used during a session to start a feature
  115289. * @param featureName the name of feature to attach
  115290. */
  115291. attachFeature(featureName: string): void;
  115292. /**
  115293. * Can be used inside a session or when the session ends to detach a specific feature
  115294. * @param featureName the name of the feature to detach
  115295. */
  115296. detachFeature(featureName: string): void;
  115297. /**
  115298. * Get the list of enabled features
  115299. * @returns an array of enabled features
  115300. */
  115301. getEnabledFeatures(): string[];
  115302. /**
  115303. * get the implementation of an enabled feature.
  115304. * @param featureName the name of the feature to load
  115305. * @returns the feature class, if found
  115306. */
  115307. getEnabledFeature(featureName: string): IWebXRFeature;
  115308. /**
  115309. * dispose this features manager
  115310. */
  115311. dispose(): void;
  115312. }
  115313. }
  115314. declare module BABYLON {
  115315. /**
  115316. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  115317. * @see https://doc.babylonjs.com/how_to/webxr
  115318. */
  115319. export class WebXRExperienceHelper implements IDisposable {
  115320. private scene;
  115321. /**
  115322. * Camera used to render xr content
  115323. */
  115324. camera: WebXRCamera;
  115325. /**
  115326. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  115327. */
  115328. state: WebXRState;
  115329. private _setState;
  115330. /**
  115331. * Fires when the state of the experience helper has changed
  115332. */
  115333. onStateChangedObservable: Observable<WebXRState>;
  115334. /**
  115335. * Observers registered here will be triggered after the camera's initial transformation is set
  115336. * This can be used to set a different ground level or an extra rotation.
  115337. *
  115338. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  115339. * to the position set after this observable is done executing.
  115340. */
  115341. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  115342. /** Session manager used to keep track of xr session */
  115343. sessionManager: WebXRSessionManager;
  115344. /** A features manager for this xr session */
  115345. featuresManager: WebXRFeaturesManager;
  115346. private _nonVRCamera;
  115347. private _originalSceneAutoClear;
  115348. private _supported;
  115349. /**
  115350. * Creates the experience helper
  115351. * @param scene the scene to attach the experience helper to
  115352. * @returns a promise for the experience helper
  115353. */
  115354. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  115355. /**
  115356. * Creates a WebXRExperienceHelper
  115357. * @param scene The scene the helper should be created in
  115358. */
  115359. private constructor();
  115360. /**
  115361. * Exits XR mode and returns the scene to its original state
  115362. * @returns promise that resolves after xr mode has exited
  115363. */
  115364. exitXRAsync(): Promise<void>;
  115365. /**
  115366. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  115367. * @param sessionMode options for the XR session
  115368. * @param referenceSpaceType frame of reference of the XR session
  115369. * @param renderTarget the output canvas that will be used to enter XR mode
  115370. * @returns promise that resolves after xr mode has entered
  115371. */
  115372. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  115373. /**
  115374. * Disposes of the experience helper
  115375. */
  115376. dispose(): void;
  115377. private _nonXRToXRCamera;
  115378. }
  115379. }
  115380. declare module BABYLON {
  115381. /**
  115382. * X-Y values for axes in WebXR
  115383. */
  115384. export interface IWebXRMotionControllerAxesValue {
  115385. /**
  115386. * The value of the x axis
  115387. */
  115388. x: number;
  115389. /**
  115390. * The value of the y-axis
  115391. */
  115392. y: number;
  115393. }
  115394. /**
  115395. * changed / previous values for the values of this component
  115396. */
  115397. export interface IWebXRMotionControllerComponentChangesValues<T> {
  115398. /**
  115399. * current (this frame) value
  115400. */
  115401. current: T;
  115402. /**
  115403. * previous (last change) value
  115404. */
  115405. previous: T;
  115406. }
  115407. /**
  115408. * Represents changes in the component between current frame and last values recorded
  115409. */
  115410. export interface IWebXRMotionControllerComponentChanges {
  115411. /**
  115412. * will be populated with previous and current values if touched changed
  115413. */
  115414. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115415. /**
  115416. * will be populated with previous and current values if pressed changed
  115417. */
  115418. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115419. /**
  115420. * will be populated with previous and current values if value changed
  115421. */
  115422. value?: IWebXRMotionControllerComponentChangesValues<number>;
  115423. /**
  115424. * will be populated with previous and current values if axes changed
  115425. */
  115426. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  115427. }
  115428. /**
  115429. * This class represents a single component (for example button or thumbstick) of a motion controller
  115430. */
  115431. export class WebXRControllerComponent implements IDisposable {
  115432. /**
  115433. * the id of this component
  115434. */
  115435. id: string;
  115436. /**
  115437. * the type of the component
  115438. */
  115439. type: MotionControllerComponentType;
  115440. private _buttonIndex;
  115441. private _axesIndices;
  115442. /**
  115443. * Thumbstick component type
  115444. */
  115445. static THUMBSTICK: string;
  115446. /**
  115447. * Touchpad component type
  115448. */
  115449. static TOUCHPAD: string;
  115450. /**
  115451. * trigger component type
  115452. */
  115453. static TRIGGER: string;
  115454. /**
  115455. * squeeze component type
  115456. */
  115457. static SQUEEZE: string;
  115458. /**
  115459. * Observers registered here will be triggered when the state of a button changes
  115460. * State change is either pressed / touched / value
  115461. */
  115462. onButtonStateChanged: Observable<WebXRControllerComponent>;
  115463. /**
  115464. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  115465. * the axes data changes
  115466. */
  115467. onAxisValueChanged: Observable<{
  115468. x: number;
  115469. y: number;
  115470. }>;
  115471. private _currentValue;
  115472. private _touched;
  115473. private _pressed;
  115474. private _axes;
  115475. private _changes;
  115476. /**
  115477. * Creates a new component for a motion controller.
  115478. * It is created by the motion controller itself
  115479. *
  115480. * @param id the id of this component
  115481. * @param type the type of the component
  115482. * @param _buttonIndex index in the buttons array of the gamepad
  115483. * @param _axesIndices indices of the values in the axes array of the gamepad
  115484. */
  115485. constructor(
  115486. /**
  115487. * the id of this component
  115488. */
  115489. id: string,
  115490. /**
  115491. * the type of the component
  115492. */
  115493. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  115494. /**
  115495. * Get the current value of this component
  115496. */
  115497. get value(): number;
  115498. /**
  115499. * is the button currently pressed
  115500. */
  115501. get pressed(): boolean;
  115502. /**
  115503. * is the button currently touched
  115504. */
  115505. get touched(): boolean;
  115506. /**
  115507. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  115508. */
  115509. get axes(): IWebXRMotionControllerAxesValue;
  115510. /**
  115511. * Get the changes. Elements will be populated only if they changed with their previous and current value
  115512. */
  115513. get changes(): IWebXRMotionControllerComponentChanges;
  115514. /**
  115515. * Is this component a button (hence - pressable)
  115516. * @returns true if can be pressed
  115517. */
  115518. isButton(): boolean;
  115519. /**
  115520. * Are there axes correlating to this component
  115521. * @return true is axes data is available
  115522. */
  115523. isAxes(): boolean;
  115524. /**
  115525. * update this component using the gamepad object it is in. Called on every frame
  115526. * @param nativeController the native gamepad controller object
  115527. */
  115528. update(nativeController: IMinimalMotionControllerObject): void;
  115529. /**
  115530. * Dispose this component
  115531. */
  115532. dispose(): void;
  115533. }
  115534. }
  115535. declare module BABYLON {
  115536. /**
  115537. * Class used to represent data loading progression
  115538. */
  115539. export class SceneLoaderProgressEvent {
  115540. /** defines if data length to load can be evaluated */
  115541. readonly lengthComputable: boolean;
  115542. /** defines the loaded data length */
  115543. readonly loaded: number;
  115544. /** defines the data length to load */
  115545. readonly total: number;
  115546. /**
  115547. * Create a new progress event
  115548. * @param lengthComputable defines if data length to load can be evaluated
  115549. * @param loaded defines the loaded data length
  115550. * @param total defines the data length to load
  115551. */
  115552. constructor(
  115553. /** defines if data length to load can be evaluated */
  115554. lengthComputable: boolean,
  115555. /** defines the loaded data length */
  115556. loaded: number,
  115557. /** defines the data length to load */
  115558. total: number);
  115559. /**
  115560. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  115561. * @param event defines the source event
  115562. * @returns a new SceneLoaderProgressEvent
  115563. */
  115564. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  115565. }
  115566. /**
  115567. * Interface used by SceneLoader plugins to define supported file extensions
  115568. */
  115569. export interface ISceneLoaderPluginExtensions {
  115570. /**
  115571. * Defines the list of supported extensions
  115572. */
  115573. [extension: string]: {
  115574. isBinary: boolean;
  115575. };
  115576. }
  115577. /**
  115578. * Interface used by SceneLoader plugin factory
  115579. */
  115580. export interface ISceneLoaderPluginFactory {
  115581. /**
  115582. * Defines the name of the factory
  115583. */
  115584. name: string;
  115585. /**
  115586. * Function called to create a new plugin
  115587. * @return the new plugin
  115588. */
  115589. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  115590. /**
  115591. * The callback that returns true if the data can be directly loaded.
  115592. * @param data string containing the file data
  115593. * @returns if the data can be loaded directly
  115594. */
  115595. canDirectLoad?(data: string): boolean;
  115596. }
  115597. /**
  115598. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  115599. */
  115600. export interface ISceneLoaderPluginBase {
  115601. /**
  115602. * The friendly name of this plugin.
  115603. */
  115604. name: string;
  115605. /**
  115606. * The file extensions supported by this plugin.
  115607. */
  115608. extensions: string | ISceneLoaderPluginExtensions;
  115609. /**
  115610. * The callback called when loading from a url.
  115611. * @param scene scene loading this url
  115612. * @param url url to load
  115613. * @param onSuccess callback called when the file successfully loads
  115614. * @param onProgress callback called while file is loading (if the server supports this mode)
  115615. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115616. * @param onError callback called when the file fails to load
  115617. * @returns a file request object
  115618. */
  115619. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115620. /**
  115621. * The callback called when loading from a file object.
  115622. * @param scene scene loading this file
  115623. * @param file defines the file to load
  115624. * @param onSuccess defines the callback to call when data is loaded
  115625. * @param onProgress defines the callback to call during loading process
  115626. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115627. * @param onError defines the callback to call when an error occurs
  115628. * @returns a file request object
  115629. */
  115630. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115631. /**
  115632. * The callback that returns true if the data can be directly loaded.
  115633. * @param data string containing the file data
  115634. * @returns if the data can be loaded directly
  115635. */
  115636. canDirectLoad?(data: string): boolean;
  115637. /**
  115638. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  115639. * @param scene scene loading this data
  115640. * @param data string containing the data
  115641. * @returns data to pass to the plugin
  115642. */
  115643. directLoad?(scene: Scene, data: string): any;
  115644. /**
  115645. * The callback that allows custom handling of the root url based on the response url.
  115646. * @param rootUrl the original root url
  115647. * @param responseURL the response url if available
  115648. * @returns the new root url
  115649. */
  115650. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  115651. }
  115652. /**
  115653. * Interface used to define a SceneLoader plugin
  115654. */
  115655. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  115656. /**
  115657. * Import meshes into a scene.
  115658. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115659. * @param scene The scene to import into
  115660. * @param data The data to import
  115661. * @param rootUrl The root url for scene and resources
  115662. * @param meshes The meshes array to import into
  115663. * @param particleSystems The particle systems array to import into
  115664. * @param skeletons The skeletons array to import into
  115665. * @param onError The callback when import fails
  115666. * @returns True if successful or false otherwise
  115667. */
  115668. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  115669. /**
  115670. * Load into a scene.
  115671. * @param scene The scene to load into
  115672. * @param data The data to import
  115673. * @param rootUrl The root url for scene and resources
  115674. * @param onError The callback when import fails
  115675. * @returns True if successful or false otherwise
  115676. */
  115677. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  115678. /**
  115679. * Load into an asset container.
  115680. * @param scene The scene to load into
  115681. * @param data The data to import
  115682. * @param rootUrl The root url for scene and resources
  115683. * @param onError The callback when import fails
  115684. * @returns The loaded asset container
  115685. */
  115686. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  115687. }
  115688. /**
  115689. * Interface used to define an async SceneLoader plugin
  115690. */
  115691. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  115692. /**
  115693. * Import meshes into a scene.
  115694. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115695. * @param scene The scene to import into
  115696. * @param data The data to import
  115697. * @param rootUrl The root url for scene and resources
  115698. * @param onProgress The callback when the load progresses
  115699. * @param fileName Defines the name of the file to load
  115700. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  115701. */
  115702. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  115703. meshes: AbstractMesh[];
  115704. particleSystems: IParticleSystem[];
  115705. skeletons: Skeleton[];
  115706. animationGroups: AnimationGroup[];
  115707. }>;
  115708. /**
  115709. * Load into a scene.
  115710. * @param scene The scene to load into
  115711. * @param data The data to import
  115712. * @param rootUrl The root url for scene and resources
  115713. * @param onProgress The callback when the load progresses
  115714. * @param fileName Defines the name of the file to load
  115715. * @returns Nothing
  115716. */
  115717. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  115718. /**
  115719. * Load into an asset container.
  115720. * @param scene The scene to load into
  115721. * @param data The data to import
  115722. * @param rootUrl The root url for scene and resources
  115723. * @param onProgress The callback when the load progresses
  115724. * @param fileName Defines the name of the file to load
  115725. * @returns The loaded asset container
  115726. */
  115727. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  115728. }
  115729. /**
  115730. * Mode that determines how to handle old animation groups before loading new ones.
  115731. */
  115732. export enum SceneLoaderAnimationGroupLoadingMode {
  115733. /**
  115734. * Reset all old animations to initial state then dispose them.
  115735. */
  115736. Clean = 0,
  115737. /**
  115738. * Stop all old animations.
  115739. */
  115740. Stop = 1,
  115741. /**
  115742. * Restart old animations from first frame.
  115743. */
  115744. Sync = 2,
  115745. /**
  115746. * Old animations remains untouched.
  115747. */
  115748. NoSync = 3
  115749. }
  115750. /**
  115751. * Class used to load scene from various file formats using registered plugins
  115752. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  115753. */
  115754. export class SceneLoader {
  115755. /**
  115756. * No logging while loading
  115757. */
  115758. static readonly NO_LOGGING: number;
  115759. /**
  115760. * Minimal logging while loading
  115761. */
  115762. static readonly MINIMAL_LOGGING: number;
  115763. /**
  115764. * Summary logging while loading
  115765. */
  115766. static readonly SUMMARY_LOGGING: number;
  115767. /**
  115768. * Detailled logging while loading
  115769. */
  115770. static readonly DETAILED_LOGGING: number;
  115771. /**
  115772. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115773. */
  115774. static get ForceFullSceneLoadingForIncremental(): boolean;
  115775. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115776. /**
  115777. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115778. */
  115779. static get ShowLoadingScreen(): boolean;
  115780. static set ShowLoadingScreen(value: boolean);
  115781. /**
  115782. * Defines the current logging level (while loading the scene)
  115783. * @ignorenaming
  115784. */
  115785. static get loggingLevel(): number;
  115786. static set loggingLevel(value: number);
  115787. /**
  115788. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115789. */
  115790. static get CleanBoneMatrixWeights(): boolean;
  115791. static set CleanBoneMatrixWeights(value: boolean);
  115792. /**
  115793. * Event raised when a plugin is used to load a scene
  115794. */
  115795. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  115796. private static _registeredPlugins;
  115797. private static _getDefaultPlugin;
  115798. private static _getPluginForExtension;
  115799. private static _getPluginForDirectLoad;
  115800. private static _getPluginForFilename;
  115801. private static _getDirectLoad;
  115802. private static _loadData;
  115803. private static _getFileInfo;
  115804. /**
  115805. * Gets a plugin that can load the given extension
  115806. * @param extension defines the extension to load
  115807. * @returns a plugin or null if none works
  115808. */
  115809. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  115810. /**
  115811. * Gets a boolean indicating that the given extension can be loaded
  115812. * @param extension defines the extension to load
  115813. * @returns true if the extension is supported
  115814. */
  115815. static IsPluginForExtensionAvailable(extension: string): boolean;
  115816. /**
  115817. * Adds a new plugin to the list of registered plugins
  115818. * @param plugin defines the plugin to add
  115819. */
  115820. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  115821. /**
  115822. * Import meshes into a scene
  115823. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115824. * @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)
  115825. * @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)
  115826. * @param scene the instance of BABYLON.Scene to append to
  115827. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  115828. * @param onProgress a callback with a progress event for each file being loaded
  115829. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115830. * @param pluginExtension the extension used to determine the plugin
  115831. * @returns The loaded plugin
  115832. */
  115833. 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>;
  115834. /**
  115835. * Import meshes into a scene
  115836. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115837. * @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)
  115838. * @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)
  115839. * @param scene the instance of BABYLON.Scene to append to
  115840. * @param onProgress a callback with a progress event for each file being loaded
  115841. * @param pluginExtension the extension used to determine the plugin
  115842. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  115843. */
  115844. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  115845. meshes: AbstractMesh[];
  115846. particleSystems: IParticleSystem[];
  115847. skeletons: Skeleton[];
  115848. animationGroups: AnimationGroup[];
  115849. }>;
  115850. /**
  115851. * Load a scene
  115852. * @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)
  115853. * @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)
  115854. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115855. * @param onSuccess a callback with the scene when import succeeds
  115856. * @param onProgress a callback with a progress event for each file being loaded
  115857. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115858. * @param pluginExtension the extension used to determine the plugin
  115859. * @returns The loaded plugin
  115860. */
  115861. 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>;
  115862. /**
  115863. * Load a scene
  115864. * @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)
  115865. * @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)
  115866. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115867. * @param onProgress a callback with a progress event for each file being loaded
  115868. * @param pluginExtension the extension used to determine the plugin
  115869. * @returns The loaded scene
  115870. */
  115871. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  115872. /**
  115873. * Append a scene
  115874. * @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)
  115875. * @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)
  115876. * @param scene is the instance of BABYLON.Scene to append to
  115877. * @param onSuccess a callback with the scene when import succeeds
  115878. * @param onProgress a callback with a progress event for each file being loaded
  115879. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115880. * @param pluginExtension the extension used to determine the plugin
  115881. * @returns The loaded plugin
  115882. */
  115883. 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>;
  115884. /**
  115885. * Append a scene
  115886. * @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)
  115887. * @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)
  115888. * @param scene is the instance of BABYLON.Scene to append to
  115889. * @param onProgress a callback with a progress event for each file being loaded
  115890. * @param pluginExtension the extension used to determine the plugin
  115891. * @returns The given scene
  115892. */
  115893. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  115894. /**
  115895. * Load a scene into an asset container
  115896. * @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)
  115897. * @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)
  115898. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115899. * @param onSuccess a callback with the scene when import succeeds
  115900. * @param onProgress a callback with a progress event for each file being loaded
  115901. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115902. * @param pluginExtension the extension used to determine the plugin
  115903. * @returns The loaded plugin
  115904. */
  115905. 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>;
  115906. /**
  115907. * Load a scene into an asset container
  115908. * @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)
  115909. * @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)
  115910. * @param scene is the instance of Scene to append to
  115911. * @param onProgress a callback with a progress event for each file being loaded
  115912. * @param pluginExtension the extension used to determine the plugin
  115913. * @returns The loaded asset container
  115914. */
  115915. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  115916. /**
  115917. * Import animations from a file into a scene
  115918. * @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)
  115919. * @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)
  115920. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115921. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  115922. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  115923. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  115924. * @param onSuccess a callback with the scene when import succeeds
  115925. * @param onProgress a callback with a progress event for each file being loaded
  115926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115927. */
  115928. 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;
  115929. /**
  115930. * Import animations from a file into a scene
  115931. * @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)
  115932. * @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)
  115933. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115934. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  115935. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  115936. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  115937. * @param onSuccess a callback with the scene when import succeeds
  115938. * @param onProgress a callback with a progress event for each file being loaded
  115939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115940. * @returns the updated scene with imported animations
  115941. */
  115942. 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>;
  115943. }
  115944. }
  115945. declare module BABYLON {
  115946. /**
  115947. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  115948. */
  115949. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  115950. /**
  115951. * The type of components available in motion controllers.
  115952. * This is not the name of the component.
  115953. */
  115954. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  115955. /**
  115956. * The schema of motion controller layout.
  115957. * No object will be initialized using this interface
  115958. * This is used just to define the profile.
  115959. */
  115960. export interface IMotionControllerLayout {
  115961. /**
  115962. * Defines the main button component id
  115963. */
  115964. selectComponentId: string;
  115965. /**
  115966. * Available components (unsorted)
  115967. */
  115968. components: {
  115969. /**
  115970. * A map of component Ids
  115971. */
  115972. [componentId: string]: {
  115973. /**
  115974. * The type of input the component outputs
  115975. */
  115976. type: MotionControllerComponentType;
  115977. };
  115978. };
  115979. /**
  115980. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  115981. */
  115982. gamepad?: {
  115983. /**
  115984. * Is the mapping based on the xr-standard defined here:
  115985. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  115986. */
  115987. mapping: "" | "xr-standard";
  115988. /**
  115989. * The buttons available in this input in the right order
  115990. * index of this button will be the index in the gamepadObject.buttons array
  115991. * correlates to the componentId in components
  115992. */
  115993. buttons: Array<string | null>;
  115994. /**
  115995. * Definition of the axes of the gamepad input, sorted
  115996. * Correlates to componentIds in the components map
  115997. */
  115998. axes: Array<{
  115999. /**
  116000. * The component id that the axis correlates to
  116001. */
  116002. componentId: string;
  116003. /**
  116004. * X or Y Axis
  116005. */
  116006. axis: "x-axis" | "y-axis";
  116007. } | null>;
  116008. };
  116009. }
  116010. /**
  116011. * A definition for the layout map in the input profile
  116012. */
  116013. export interface IMotionControllerLayoutMap {
  116014. /**
  116015. * Layouts with handness type as a key
  116016. */
  116017. [handness: string]: IMotionControllerLayout;
  116018. }
  116019. /**
  116020. * The XR Input profile schema
  116021. * Profiles can be found here:
  116022. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116023. */
  116024. export interface IMotionControllerProfile {
  116025. /**
  116026. * The id of this profile
  116027. * correlates to the profile(s) in the xrInput.profiles array
  116028. */
  116029. profileId: string;
  116030. /**
  116031. * fallback profiles for this profileId
  116032. */
  116033. fallbackProfileIds: string[];
  116034. /**
  116035. * The layout map, with handness as key
  116036. */
  116037. layouts: IMotionControllerLayoutMap;
  116038. }
  116039. /**
  116040. * A helper-interface for the 3 meshes needed for controller button animation
  116041. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116042. */
  116043. export interface IMotionControllerButtonMeshMap {
  116044. /**
  116045. * The mesh that will be changed when value changes
  116046. */
  116047. valueMesh: AbstractMesh;
  116048. /**
  116049. * the mesh that defines the pressed value mesh position.
  116050. * This is used to find the max-position of this button
  116051. */
  116052. pressedMesh: AbstractMesh;
  116053. /**
  116054. * the mesh that defines the unpressed value mesh position.
  116055. * This is used to find the min (or initial) position of this button
  116056. */
  116057. unpressedMesh: AbstractMesh;
  116058. }
  116059. /**
  116060. * A helper-interface for the 3 meshes needed for controller axis animation.
  116061. * This will be expanded when touchpad animations are fully supported
  116062. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116063. */
  116064. export interface IMotionControllerAxisMeshMap {
  116065. /**
  116066. * The mesh that will be changed when axis value changes
  116067. */
  116068. valueMesh: AbstractMesh;
  116069. /**
  116070. * the mesh that defines the minimum value mesh position.
  116071. */
  116072. minMesh: AbstractMesh;
  116073. /**
  116074. * the mesh that defines the maximum value mesh position.
  116075. */
  116076. maxMesh: AbstractMesh;
  116077. }
  116078. /**
  116079. * The elements needed for change-detection of the gamepad objects in motion controllers
  116080. */
  116081. export interface IMinimalMotionControllerObject {
  116082. /**
  116083. * An array of available buttons
  116084. */
  116085. buttons: Array<{
  116086. /**
  116087. * Value of the button/trigger
  116088. */
  116089. value: number;
  116090. /**
  116091. * If the button/trigger is currently touched
  116092. */
  116093. touched: boolean;
  116094. /**
  116095. * If the button/trigger is currently pressed
  116096. */
  116097. pressed: boolean;
  116098. }>;
  116099. /**
  116100. * Available axes of this controller
  116101. */
  116102. axes: number[];
  116103. }
  116104. /**
  116105. * An Abstract Motion controller
  116106. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116107. * Each component has an observable to check for changes in value and state
  116108. */
  116109. export abstract class WebXRAbstractMotionController implements IDisposable {
  116110. protected scene: Scene;
  116111. protected layout: IMotionControllerLayout;
  116112. /**
  116113. * The gamepad object correlating to this controller
  116114. */
  116115. gamepadObject: IMinimalMotionControllerObject;
  116116. /**
  116117. * handness (left/right/none) of this controller
  116118. */
  116119. handness: MotionControllerHandness;
  116120. /**
  116121. * Component type map
  116122. */
  116123. static ComponentType: {
  116124. TRIGGER: string;
  116125. SQUEEZE: string;
  116126. TOUCHPAD: string;
  116127. THUMBSTICK: string;
  116128. BUTTON: string;
  116129. };
  116130. /**
  116131. * The profile id of this motion controller
  116132. */
  116133. abstract profileId: string;
  116134. /**
  116135. * A map of components (WebXRControllerComponent) in this motion controller
  116136. * Components have a ComponentType and can also have both button and axis definitions
  116137. */
  116138. readonly components: {
  116139. [id: string]: WebXRControllerComponent;
  116140. };
  116141. /**
  116142. * Observers registered here will be triggered when the model of this controller is done loading
  116143. */
  116144. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  116145. /**
  116146. * The root mesh of the model. It is null if the model was not yet initialized
  116147. */
  116148. rootMesh: Nullable<AbstractMesh>;
  116149. private _modelReady;
  116150. /**
  116151. * constructs a new abstract motion controller
  116152. * @param scene the scene to which the model of the controller will be added
  116153. * @param layout The profile layout to load
  116154. * @param gamepadObject The gamepad object correlating to this controller
  116155. * @param handness handness (left/right/none) of this controller
  116156. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  116157. */
  116158. constructor(scene: Scene, layout: IMotionControllerLayout,
  116159. /**
  116160. * The gamepad object correlating to this controller
  116161. */
  116162. gamepadObject: IMinimalMotionControllerObject,
  116163. /**
  116164. * handness (left/right/none) of this controller
  116165. */
  116166. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  116167. private _initComponent;
  116168. /**
  116169. * Update this model using the current XRFrame
  116170. * @param xrFrame the current xr frame to use and update the model
  116171. */
  116172. updateFromXRFrame(xrFrame: XRFrame): void;
  116173. /**
  116174. * Get the list of components available in this motion controller
  116175. * @returns an array of strings correlating to available components
  116176. */
  116177. getComponentTypes(): string[];
  116178. /**
  116179. * Get the main (Select) component of this controller as defined in the layout
  116180. * @returns the main component of this controller
  116181. */
  116182. getMainComponent(): WebXRControllerComponent;
  116183. /**
  116184. * get a component based an its component id as defined in layout.components
  116185. * @param id the id of the component
  116186. * @returns the component correlates to the id or undefined if not found
  116187. */
  116188. getComponent(id: string): WebXRControllerComponent;
  116189. /**
  116190. * Loads the model correlating to this controller
  116191. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  116192. * @returns A promise fulfilled with the result of the model loading
  116193. */
  116194. loadModel(): Promise<boolean>;
  116195. /**
  116196. * Update the model itself with the current frame data
  116197. * @param xrFrame the frame to use for updating the model mesh
  116198. */
  116199. protected updateModel(xrFrame: XRFrame): void;
  116200. /**
  116201. * Moves the axis on the controller mesh based on its current state
  116202. * @param axis the index of the axis
  116203. * @param axisValue the value of the axis which determines the meshes new position
  116204. * @hidden
  116205. */
  116206. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  116207. /**
  116208. * Moves the buttons on the controller mesh based on their current state
  116209. * @param buttonName the name of the button to move
  116210. * @param buttonValue the value of the button which determines the buttons new position
  116211. */
  116212. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  116213. private _getGenericFilenameAndPath;
  116214. private _getGenericParentMesh;
  116215. /**
  116216. * Get the filename and path for this controller's model
  116217. * @returns a map of filename and path
  116218. */
  116219. protected abstract _getFilenameAndPath(): {
  116220. filename: string;
  116221. path: string;
  116222. };
  116223. /**
  116224. * This function will be called after the model was successfully loaded and can be used
  116225. * for mesh transformations before it is available for the user
  116226. * @param meshes the loaded meshes
  116227. */
  116228. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  116229. /**
  116230. * Set the root mesh for this controller. Important for the WebXR controller class
  116231. * @param meshes the loaded meshes
  116232. */
  116233. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  116234. /**
  116235. * A function executed each frame that updates the mesh (if needed)
  116236. * @param xrFrame the current xrFrame
  116237. */
  116238. protected abstract _updateModel(xrFrame: XRFrame): void;
  116239. /**
  116240. * This function is called before the mesh is loaded. It checks for loading constraints.
  116241. * For example, this function can check if the GLB loader is available
  116242. * If this function returns false, the generic controller will be loaded instead
  116243. * @returns Is the client ready to load the mesh
  116244. */
  116245. protected abstract _getModelLoadingConstraints(): boolean;
  116246. /**
  116247. * Dispose this controller, the model mesh and all its components
  116248. */
  116249. dispose(): void;
  116250. }
  116251. }
  116252. declare module BABYLON {
  116253. /**
  116254. * A generic trigger-only motion controller for WebXR
  116255. */
  116256. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  116257. /**
  116258. * Static version of the profile id of this controller
  116259. */
  116260. static ProfileId: string;
  116261. profileId: string;
  116262. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116263. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  116264. protected _updateModel(): void;
  116265. protected _getFilenameAndPath(): {
  116266. filename: string;
  116267. path: string;
  116268. };
  116269. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116270. protected _getModelLoadingConstraints(): boolean;
  116271. }
  116272. }
  116273. declare module BABYLON {
  116274. /**
  116275. * A construction function type to create a new controller based on an xrInput object
  116276. */
  116277. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  116278. /**
  116279. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  116280. *
  116281. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  116282. * it should be replaced with auto-loaded controllers.
  116283. *
  116284. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  116285. */
  116286. export class WebXRMotionControllerManager {
  116287. private static _AvailableControllers;
  116288. private static _Fallbacks;
  116289. /**
  116290. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  116291. *
  116292. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  116293. *
  116294. * @param type the profile type to register
  116295. * @param constructFunction the function to be called when loading this profile
  116296. */
  116297. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  116298. /**
  116299. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  116300. * The order of search:
  116301. *
  116302. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  116303. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  116304. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  116305. * 4) return the generic trigger controller if none were found
  116306. *
  116307. * @param xrInput the xrInput to which a new controller is initialized
  116308. * @param scene the scene to which the model will be added
  116309. * @param forceProfile force a certain profile for this controller
  116310. * @return the motion controller class for this profile id or the generic standard class if none was found
  116311. */
  116312. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  116313. /**
  116314. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  116315. * @param profileId the profile to which a fallback needs to be found
  116316. * @return an array with corresponding fallback profiles
  116317. */
  116318. static FindFallbackWithProfileId(profileId: string): string[];
  116319. /**
  116320. * Register a fallback to a specific profile.
  116321. * @param profileId the profileId that will receive the fallbacks
  116322. * @param fallbacks A list of fallback profiles
  116323. */
  116324. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  116325. /**
  116326. * Register the default fallbacks.
  116327. * This function is called automatically when this file is imported.
  116328. */
  116329. static DefaultFallbacks(): void;
  116330. }
  116331. }
  116332. declare module BABYLON {
  116333. /**
  116334. * Configuration options for the WebXR controller creation
  116335. */
  116336. export interface IWebXRControllerOptions {
  116337. /**
  116338. * Force a specific controller type for this controller.
  116339. * This can be used when creating your own profile or when testing different controllers
  116340. */
  116341. forceControllerProfile?: string;
  116342. }
  116343. /**
  116344. * Represents an XR controller
  116345. */
  116346. export class WebXRController {
  116347. private _scene;
  116348. /** The underlying input source for the controller */
  116349. inputSource: XRInputSource;
  116350. private _options;
  116351. /**
  116352. * 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
  116353. */
  116354. grip?: AbstractMesh;
  116355. /**
  116356. * Pointer which can be used to select objects or attach a visible laser to
  116357. */
  116358. pointer: AbstractMesh;
  116359. /**
  116360. * If available, this is the gamepad object related to this controller.
  116361. * Using this object it is possible to get click events and trackpad changes of the
  116362. * webxr controller that is currently being used.
  116363. */
  116364. motionController?: WebXRAbstractMotionController;
  116365. /**
  116366. * Event that fires when the controller is removed/disposed
  116367. */
  116368. onDisposeObservable: Observable<{}>;
  116369. private _tmpQuaternion;
  116370. private _tmpVector;
  116371. private _uniqueId;
  116372. /**
  116373. * Creates the controller
  116374. * @see https://doc.babylonjs.com/how_to/webxr
  116375. * @param _scene the scene which the controller should be associated to
  116376. * @param inputSource the underlying input source for the controller
  116377. * @param _options options for this controller creation
  116378. */
  116379. constructor(_scene: Scene,
  116380. /** The underlying input source for the controller */
  116381. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  116382. /**
  116383. * Get this controllers unique id
  116384. */
  116385. get uniqueId(): string;
  116386. /**
  116387. * Updates the controller pose based on the given XRFrame
  116388. * @param xrFrame xr frame to update the pose with
  116389. * @param referenceSpace reference space to use
  116390. */
  116391. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  116392. /**
  116393. * Gets a world space ray coming from the controller
  116394. * @param result the resulting ray
  116395. */
  116396. getWorldPointerRayToRef(result: Ray): void;
  116397. /**
  116398. * Disposes of the object
  116399. */
  116400. dispose(): void;
  116401. }
  116402. }
  116403. declare module BABYLON {
  116404. /**
  116405. * The schema for initialization options of the XR Input class
  116406. */
  116407. export interface IWebXRInputOptions {
  116408. /**
  116409. * If set to true no model will be automatically loaded
  116410. */
  116411. doNotLoadControllerMeshes?: boolean;
  116412. /**
  116413. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  116414. * If not found, the xr input profile data will be used.
  116415. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  116416. */
  116417. forceInputProfile?: string;
  116418. }
  116419. /**
  116420. * XR input used to track XR inputs such as controllers/rays
  116421. */
  116422. export class WebXRInput implements IDisposable {
  116423. /**
  116424. * the xr session manager for this session
  116425. */
  116426. xrSessionManager: WebXRSessionManager;
  116427. /**
  116428. * the WebXR camera for this session. Mainly used for teleportation
  116429. */
  116430. xrCamera: WebXRCamera;
  116431. private readonly options;
  116432. /**
  116433. * XR controllers being tracked
  116434. */
  116435. controllers: Array<WebXRController>;
  116436. private _frameObserver;
  116437. private _sessionEndedObserver;
  116438. private _sessionInitObserver;
  116439. /**
  116440. * Event when a controller has been connected/added
  116441. */
  116442. onControllerAddedObservable: Observable<WebXRController>;
  116443. /**
  116444. * Event when a controller has been removed/disconnected
  116445. */
  116446. onControllerRemovedObservable: Observable<WebXRController>;
  116447. /**
  116448. * Initializes the WebXRInput
  116449. * @param xrSessionManager the xr session manager for this session
  116450. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  116451. * @param options = initialization options for this xr input
  116452. */
  116453. constructor(
  116454. /**
  116455. * the xr session manager for this session
  116456. */
  116457. xrSessionManager: WebXRSessionManager,
  116458. /**
  116459. * the WebXR camera for this session. Mainly used for teleportation
  116460. */
  116461. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  116462. private _onInputSourcesChange;
  116463. private _addAndRemoveControllers;
  116464. /**
  116465. * Disposes of the object
  116466. */
  116467. dispose(): void;
  116468. }
  116469. }
  116470. declare module BABYLON {
  116471. /**
  116472. * This is the base class for all WebXR features.
  116473. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  116474. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  116475. */
  116476. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  116477. protected _xrSessionManager: WebXRSessionManager;
  116478. /**
  116479. * Construct a new (abstract) webxr feature
  116480. * @param _xrSessionManager the xr session manager for this feature
  116481. */
  116482. constructor(_xrSessionManager: WebXRSessionManager);
  116483. private _attached;
  116484. private _removeOnDetach;
  116485. /**
  116486. * Is this feature attached
  116487. */
  116488. get attached(): boolean;
  116489. /**
  116490. * Should auto-attach be disabled?
  116491. */
  116492. disableAutoAttach: boolean;
  116493. /**
  116494. * attach this feature
  116495. *
  116496. * @param force should attachment be forced (even when already attached)
  116497. * @returns true if successful, false is failed or already attached
  116498. */
  116499. attach(force?: boolean): boolean;
  116500. /**
  116501. * detach this feature.
  116502. *
  116503. * @returns true if successful, false if failed or already detached
  116504. */
  116505. detach(): boolean;
  116506. /**
  116507. * Dispose this feature and all of the resources attached
  116508. */
  116509. dispose(): void;
  116510. /**
  116511. * Code in this function will be executed on each xrFrame received from the browser.
  116512. * This function will not execute after the feature is detached.
  116513. * @param _xrFrame the current frame
  116514. */
  116515. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  116516. /**
  116517. * This is used to register callbacks that will automatically be removed when detach is called.
  116518. * @param observable the observable to which the observer will be attached
  116519. * @param callback the callback to register
  116520. */
  116521. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  116522. }
  116523. }
  116524. declare module BABYLON {
  116525. /**
  116526. * Options interface for the pointer selection module
  116527. */
  116528. export interface IWebXRControllerPointerSelectionOptions {
  116529. /**
  116530. * the xr input to use with this pointer selection
  116531. */
  116532. xrInput: WebXRInput;
  116533. /**
  116534. * Different button type to use instead of the main component
  116535. */
  116536. overrideButtonId?: string;
  116537. /**
  116538. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  116539. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  116540. * 3000 means 3 seconds between pointing at something and selecting it
  116541. */
  116542. timeToSelect?: number;
  116543. /**
  116544. * 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)
  116545. * If not disabled, the last picked point will be used to execute a pointer up event
  116546. * If disabled, pointer up event will be triggered right after the pointer down event.
  116547. * Used in screen and gaze target ray mode only
  116548. */
  116549. disablePointerUpOnTouchOut: boolean;
  116550. /**
  116551. * For gaze mode (time to select instead of press)
  116552. */
  116553. forceGazeMode: boolean;
  116554. /**
  116555. * 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
  116556. * to start a new countdown to the pointer down event.
  116557. * Defaults to 1.
  116558. */
  116559. gazeModePointerMovedFactor?: number;
  116560. }
  116561. /**
  116562. * A module that will enable pointer selection for motion controllers of XR Input Sources
  116563. */
  116564. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  116565. private readonly _options;
  116566. /**
  116567. * The module's name
  116568. */
  116569. static readonly Name: string;
  116570. /**
  116571. * The (Babylon) version of this module.
  116572. * This is an integer representing the implementation version.
  116573. * This number does not correspond to the webxr specs version
  116574. */
  116575. static readonly Version: number;
  116576. /**
  116577. * This color will be set to the laser pointer when selection is triggered
  116578. */
  116579. laserPointerPickedColor: Color3;
  116580. /**
  116581. * This color will be applied to the selection ring when selection is triggered
  116582. */
  116583. selectionMeshPickedColor: Color3;
  116584. /**
  116585. * default color of the selection ring
  116586. */
  116587. selectionMeshDefaultColor: Color3;
  116588. /**
  116589. * Default color of the laser pointer
  116590. */
  116591. lasterPointerDefaultColor: Color3;
  116592. /**
  116593. * Should the laser pointer be displayed
  116594. */
  116595. displayLaserPointer: boolean;
  116596. /**
  116597. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  116598. */
  116599. displaySelectionMesh: boolean;
  116600. /**
  116601. * Disable lighting on the laser pointer (so it will always be visible)
  116602. */
  116603. disablePointerLighting: boolean;
  116604. /**
  116605. * Disable lighting on the selection mesh (so it will always be visible)
  116606. */
  116607. disableSelectionMeshLighting: boolean;
  116608. private static _idCounter;
  116609. private _tmpRay;
  116610. private _controllers;
  116611. private _scene;
  116612. /**
  116613. * constructs a new background remover module
  116614. * @param _xrSessionManager the session manager for this module
  116615. * @param _options read-only options to be used in this module
  116616. */
  116617. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  116618. /**
  116619. * attach this feature
  116620. * Will usually be called by the features manager
  116621. *
  116622. * @returns true if successful.
  116623. */
  116624. attach(): boolean;
  116625. /**
  116626. * detach this feature.
  116627. * Will usually be called by the features manager
  116628. *
  116629. * @returns true if successful.
  116630. */
  116631. detach(): boolean;
  116632. /**
  116633. * Get the xr controller that correlates to the pointer id in the pointer event
  116634. *
  116635. * @param id the pointer id to search for
  116636. * @returns the controller that correlates to this id or null if not found
  116637. */
  116638. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  116639. protected _onXRFrame(_xrFrame: XRFrame): void;
  116640. private _attachController;
  116641. private _attachScreenRayMode;
  116642. private _attachGazeMode;
  116643. private _tmpVectorForPickCompare;
  116644. private _pickingMoved;
  116645. private _attachTrackedPointerRayMode;
  116646. private _detachController;
  116647. private _generateNewMeshPair;
  116648. private _convertNormalToDirectionOfRay;
  116649. private _updatePointerDistance;
  116650. }
  116651. }
  116652. declare module BABYLON {
  116653. /**
  116654. * Button which can be used to enter a different mode of XR
  116655. */
  116656. export class WebXREnterExitUIButton {
  116657. /** button element */
  116658. element: HTMLElement;
  116659. /** XR initialization options for the button */
  116660. sessionMode: XRSessionMode;
  116661. /** Reference space type */
  116662. referenceSpaceType: XRReferenceSpaceType;
  116663. /**
  116664. * Creates a WebXREnterExitUIButton
  116665. * @param element button element
  116666. * @param sessionMode XR initialization session mode
  116667. * @param referenceSpaceType the type of reference space to be used
  116668. */
  116669. constructor(
  116670. /** button element */
  116671. element: HTMLElement,
  116672. /** XR initialization options for the button */
  116673. sessionMode: XRSessionMode,
  116674. /** Reference space type */
  116675. referenceSpaceType: XRReferenceSpaceType);
  116676. /**
  116677. * Overwritable function which can be used to update the button's visuals when the state changes
  116678. * @param activeButton the current active button in the UI
  116679. */
  116680. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  116681. }
  116682. /**
  116683. * Options to create the webXR UI
  116684. */
  116685. export class WebXREnterExitUIOptions {
  116686. /**
  116687. * Context to enter xr with
  116688. */
  116689. renderTarget?: Nullable<WebXRRenderTarget>;
  116690. /**
  116691. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  116692. */
  116693. customButtons?: Array<WebXREnterExitUIButton>;
  116694. /**
  116695. * A session mode to use when creating the default button.
  116696. * Default is immersive-vr
  116697. */
  116698. sessionMode?: XRSessionMode;
  116699. /**
  116700. * A reference space type to use when creating the default button.
  116701. * Default is local-floor
  116702. */
  116703. referenceSpaceType?: XRReferenceSpaceType;
  116704. }
  116705. /**
  116706. * UI to allow the user to enter/exit XR mode
  116707. */
  116708. export class WebXREnterExitUI implements IDisposable {
  116709. private scene;
  116710. /** version of the options passed to this UI */
  116711. options: WebXREnterExitUIOptions;
  116712. private _overlay;
  116713. private _buttons;
  116714. private _activeButton;
  116715. /**
  116716. * Fired every time the active button is changed.
  116717. *
  116718. * When xr is entered via a button that launches xr that button will be the callback parameter
  116719. *
  116720. * When exiting xr the callback parameter will be null)
  116721. */
  116722. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  116723. /**
  116724. * Creates UI to allow the user to enter/exit XR mode
  116725. * @param scene the scene to add the ui to
  116726. * @param helper the xr experience helper to enter/exit xr with
  116727. * @param options options to configure the UI
  116728. * @returns the created ui
  116729. */
  116730. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  116731. /**
  116732. *
  116733. * @param scene babylon scene object to use
  116734. * @param options (read-only) version of the options passed to this UI
  116735. */
  116736. private constructor();
  116737. private _updateButtons;
  116738. /**
  116739. * Disposes of the object
  116740. */
  116741. dispose(): void;
  116742. }
  116743. }
  116744. declare module BABYLON {
  116745. /**
  116746. * Class containing static functions to help procedurally build meshes
  116747. */
  116748. export class LinesBuilder {
  116749. /**
  116750. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116751. * * 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
  116752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116753. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116754. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116755. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116757. * * 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
  116758. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116761. * @param name defines the name of the new line system
  116762. * @param options defines the options used to create the line system
  116763. * @param scene defines the hosting scene
  116764. * @returns a new line system mesh
  116765. */
  116766. static CreateLineSystem(name: string, options: {
  116767. lines: Vector3[][];
  116768. updatable?: boolean;
  116769. instance?: Nullable<LinesMesh>;
  116770. colors?: Nullable<Color4[][]>;
  116771. useVertexAlpha?: boolean;
  116772. }, scene: Nullable<Scene>): LinesMesh;
  116773. /**
  116774. * Creates a line mesh
  116775. * 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
  116776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116777. * * The parameter `points` is an array successive Vector3
  116778. * * 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
  116779. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116780. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116781. * * When updating an instance, remember that only point positions can change, not the number of points
  116782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116784. * @param name defines the name of the new line system
  116785. * @param options defines the options used to create the line system
  116786. * @param scene defines the hosting scene
  116787. * @returns a new line mesh
  116788. */
  116789. static CreateLines(name: string, options: {
  116790. points: Vector3[];
  116791. updatable?: boolean;
  116792. instance?: Nullable<LinesMesh>;
  116793. colors?: Color4[];
  116794. useVertexAlpha?: boolean;
  116795. }, scene?: Nullable<Scene>): LinesMesh;
  116796. /**
  116797. * Creates a dashed line mesh
  116798. * * 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
  116799. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116800. * * The parameter `points` is an array successive Vector3
  116801. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116802. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116803. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116804. * * 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
  116805. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116806. * * When updating an instance, remember that only point positions can change, not the number of points
  116807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116808. * @param name defines the name of the mesh
  116809. * @param options defines the options used to create the mesh
  116810. * @param scene defines the hosting scene
  116811. * @returns the dashed line mesh
  116812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116813. */
  116814. static CreateDashedLines(name: string, options: {
  116815. points: Vector3[];
  116816. dashSize?: number;
  116817. gapSize?: number;
  116818. dashNb?: number;
  116819. updatable?: boolean;
  116820. instance?: LinesMesh;
  116821. useVertexAlpha?: boolean;
  116822. }, scene?: Nullable<Scene>): LinesMesh;
  116823. }
  116824. }
  116825. declare module BABYLON {
  116826. /**
  116827. * The options container for the teleportation module
  116828. */
  116829. export interface IWebXRTeleportationOptions {
  116830. /**
  116831. * Babylon XR Input class for controller
  116832. */
  116833. xrInput: WebXRInput;
  116834. /**
  116835. * A list of meshes to use as floor meshes.
  116836. * Meshes can be added and removed after initializing the feature using the
  116837. * addFloorMesh and removeFloorMesh functions
  116838. * If empty, rotation will still work
  116839. */
  116840. floorMeshes?: AbstractMesh[];
  116841. /**
  116842. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  116843. * If you want to support rotation, make sure your mesh has a direction indicator.
  116844. *
  116845. * When left untouched, the default mesh will be initialized.
  116846. */
  116847. teleportationTargetMesh?: AbstractMesh;
  116848. /**
  116849. * Values to configure the default target mesh
  116850. */
  116851. defaultTargetMeshOptions?: {
  116852. /**
  116853. * Fill color of the teleportation area
  116854. */
  116855. teleportationFillColor?: string;
  116856. /**
  116857. * Border color for the teleportation area
  116858. */
  116859. teleportationBorderColor?: string;
  116860. /**
  116861. * Override the default material of the torus and arrow
  116862. */
  116863. torusArrowMaterial?: Material;
  116864. /**
  116865. * Disable the mesh's animation sequence
  116866. */
  116867. disableAnimation?: boolean;
  116868. };
  116869. /**
  116870. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  116871. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  116872. */
  116873. useMainComponentOnly?: boolean;
  116874. /**
  116875. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  116876. */
  116877. timeToTeleport?: number;
  116878. }
  116879. /**
  116880. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  116881. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  116882. * the input of the attached controllers.
  116883. */
  116884. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  116885. private _options;
  116886. /**
  116887. * The module's name
  116888. */
  116889. static readonly Name: string;
  116890. /**
  116891. * The (Babylon) version of this module.
  116892. * This is an integer representing the implementation version.
  116893. * This number does not correspond to the webxr specs version
  116894. */
  116895. static readonly Version: number;
  116896. /**
  116897. * Is rotation enabled when moving forward?
  116898. * Disabling this feature will prevent the user from deciding the direction when teleporting
  116899. */
  116900. rotationEnabled: boolean;
  116901. /**
  116902. * Should the module support parabolic ray on top of direct ray
  116903. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  116904. * Very helpful when moving between floors / different heights
  116905. */
  116906. parabolicRayEnabled: boolean;
  116907. /**
  116908. * The distance from the user to the inspection point in the direction of the controller
  116909. * A higher number will allow the user to move further
  116910. * defaults to 5 (meters, in xr units)
  116911. */
  116912. parabolicCheckRadius: number;
  116913. /**
  116914. * How much rotation should be applied when rotating right and left
  116915. */
  116916. rotationAngle: number;
  116917. /**
  116918. * Distance to travel when moving backwards
  116919. */
  116920. backwardsTeleportationDistance: number;
  116921. /**
  116922. * Add a new mesh to the floor meshes array
  116923. * @param mesh the mesh to use as floor mesh
  116924. */
  116925. addFloorMesh(mesh: AbstractMesh): void;
  116926. /**
  116927. * Remove a mesh from the floor meshes array
  116928. * @param mesh the mesh to remove
  116929. */
  116930. removeFloorMesh(mesh: AbstractMesh): void;
  116931. /**
  116932. * Remove a mesh from the floor meshes array using its name
  116933. * @param name the mesh name to remove
  116934. */
  116935. removeFloorMeshByName(name: string): void;
  116936. private _tmpRay;
  116937. private _tmpVector;
  116938. private _floorMeshes;
  116939. private _controllers;
  116940. /**
  116941. * constructs a new anchor system
  116942. * @param _xrSessionManager an instance of WebXRSessionManager
  116943. * @param _options configuration object for this feature
  116944. */
  116945. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  116946. private _selectionFeature;
  116947. /**
  116948. * This function sets a selection feature that will be disabled when
  116949. * the forward ray is shown and will be reattached when hidden.
  116950. * This is used to remove the selection rays when moving.
  116951. * @param selectionFeature the feature to disable when forward movement is enabled
  116952. */
  116953. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  116954. attach(): boolean;
  116955. detach(): boolean;
  116956. dispose(): void;
  116957. protected _onXRFrame(_xrFrame: XRFrame): void;
  116958. private _currentTeleportationControllerId;
  116959. private _attachController;
  116960. private _teleportForward;
  116961. private _detachController;
  116962. private createDefaultTargetMesh;
  116963. private setTargetMeshVisibility;
  116964. private setTargetMeshPosition;
  116965. private _quadraticBezierCurve;
  116966. private showParabolicPath;
  116967. }
  116968. }
  116969. declare module BABYLON {
  116970. /**
  116971. * Options for the default xr helper
  116972. */
  116973. export class WebXRDefaultExperienceOptions {
  116974. /**
  116975. * Floor meshes that will be used for teleporting
  116976. */
  116977. floorMeshes?: Array<AbstractMesh>;
  116978. /**
  116979. * Enable or disable default UI to enter XR
  116980. */
  116981. disableDefaultUI?: boolean;
  116982. /**
  116983. * optional configuration for the output canvas
  116984. */
  116985. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  116986. /**
  116987. * optional UI options. This can be used among other to change session mode and reference space type
  116988. */
  116989. uiOptions?: WebXREnterExitUIOptions;
  116990. /**
  116991. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  116992. */
  116993. inputOptions?: IWebXRInputOptions;
  116994. /**
  116995. * Should teleportation not initialize. defaults to false.
  116996. */
  116997. disableTeleportation?: boolean;
  116998. }
  116999. /**
  117000. * Default experience which provides a similar setup to the previous webVRExperience
  117001. */
  117002. export class WebXRDefaultExperience {
  117003. /**
  117004. * Base experience
  117005. */
  117006. baseExperience: WebXRExperienceHelper;
  117007. /**
  117008. * Input experience extension
  117009. */
  117010. input: WebXRInput;
  117011. /**
  117012. * Enables laser pointer and selection
  117013. */
  117014. pointerSelection: WebXRControllerPointerSelection;
  117015. /**
  117016. * Enables teleportation
  117017. */
  117018. teleportation: WebXRMotionControllerTeleportation;
  117019. /**
  117020. * Enables ui for entering/exiting xr
  117021. */
  117022. enterExitUI: WebXREnterExitUI;
  117023. /**
  117024. * Default target xr should render to
  117025. */
  117026. renderTarget: WebXRRenderTarget;
  117027. /**
  117028. * Creates the default xr experience
  117029. * @param scene scene
  117030. * @param options options for basic configuration
  117031. * @returns resulting WebXRDefaultExperience
  117032. */
  117033. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117034. private constructor();
  117035. /**
  117036. * DIsposes of the experience helper
  117037. */
  117038. dispose(): void;
  117039. }
  117040. }
  117041. declare module BABYLON {
  117042. /**
  117043. * Options to modify the vr teleportation behavior.
  117044. */
  117045. export interface VRTeleportationOptions {
  117046. /**
  117047. * The name of the mesh which should be used as the teleportation floor. (default: null)
  117048. */
  117049. floorMeshName?: string;
  117050. /**
  117051. * A list of meshes to be used as the teleportation floor. (default: empty)
  117052. */
  117053. floorMeshes?: Mesh[];
  117054. /**
  117055. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  117056. */
  117057. teleportationMode?: number;
  117058. /**
  117059. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  117060. */
  117061. teleportationTime?: number;
  117062. /**
  117063. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  117064. */
  117065. teleportationSpeed?: number;
  117066. /**
  117067. * The easing function used in the animation or null for Linear. (default CircleEase)
  117068. */
  117069. easingFunction?: EasingFunction;
  117070. }
  117071. /**
  117072. * Options to modify the vr experience helper's behavior.
  117073. */
  117074. export interface VRExperienceHelperOptions extends WebVROptions {
  117075. /**
  117076. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  117077. */
  117078. createDeviceOrientationCamera?: boolean;
  117079. /**
  117080. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  117081. */
  117082. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  117083. /**
  117084. * Uses the main button on the controller to toggle the laser casted. (default: true)
  117085. */
  117086. laserToggle?: boolean;
  117087. /**
  117088. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  117089. */
  117090. floorMeshes?: Mesh[];
  117091. /**
  117092. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  117093. */
  117094. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  117095. /**
  117096. * Defines if WebXR should be used instead of WebVR (if available)
  117097. */
  117098. useXR?: boolean;
  117099. }
  117100. /**
  117101. * Event containing information after VR has been entered
  117102. */
  117103. export class OnAfterEnteringVRObservableEvent {
  117104. /**
  117105. * If entering vr was successful
  117106. */
  117107. success: boolean;
  117108. }
  117109. /**
  117110. * Helps to quickly add VR support to an existing scene.
  117111. * See http://doc.babylonjs.com/how_to/webvr_helper
  117112. */
  117113. export class VRExperienceHelper {
  117114. /** Options to modify the vr experience helper's behavior. */
  117115. webVROptions: VRExperienceHelperOptions;
  117116. private _scene;
  117117. private _position;
  117118. private _btnVR;
  117119. private _btnVRDisplayed;
  117120. private _webVRsupported;
  117121. private _webVRready;
  117122. private _webVRrequesting;
  117123. private _webVRpresenting;
  117124. private _hasEnteredVR;
  117125. private _fullscreenVRpresenting;
  117126. private _inputElement;
  117127. private _webVRCamera;
  117128. private _vrDeviceOrientationCamera;
  117129. private _deviceOrientationCamera;
  117130. private _existingCamera;
  117131. private _onKeyDown;
  117132. private _onVrDisplayPresentChange;
  117133. private _onVRDisplayChanged;
  117134. private _onVRRequestPresentStart;
  117135. private _onVRRequestPresentComplete;
  117136. /**
  117137. * 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)
  117138. */
  117139. enableGazeEvenWhenNoPointerLock: boolean;
  117140. /**
  117141. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  117142. */
  117143. exitVROnDoubleTap: boolean;
  117144. /**
  117145. * Observable raised right before entering VR.
  117146. */
  117147. onEnteringVRObservable: Observable<VRExperienceHelper>;
  117148. /**
  117149. * Observable raised when entering VR has completed.
  117150. */
  117151. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  117152. /**
  117153. * Observable raised when exiting VR.
  117154. */
  117155. onExitingVRObservable: Observable<VRExperienceHelper>;
  117156. /**
  117157. * Observable raised when controller mesh is loaded.
  117158. */
  117159. onControllerMeshLoadedObservable: Observable<WebVRController>;
  117160. /** Return this.onEnteringVRObservable
  117161. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  117162. */
  117163. get onEnteringVR(): Observable<VRExperienceHelper>;
  117164. /** Return this.onExitingVRObservable
  117165. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  117166. */
  117167. get onExitingVR(): Observable<VRExperienceHelper>;
  117168. /** Return this.onControllerMeshLoadedObservable
  117169. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  117170. */
  117171. get onControllerMeshLoaded(): Observable<WebVRController>;
  117172. private _rayLength;
  117173. private _useCustomVRButton;
  117174. private _teleportationRequested;
  117175. private _teleportActive;
  117176. private _floorMeshName;
  117177. private _floorMeshesCollection;
  117178. private _teleportationMode;
  117179. private _teleportationTime;
  117180. private _teleportationSpeed;
  117181. private _teleportationEasing;
  117182. private _rotationAllowed;
  117183. private _teleportBackwardsVector;
  117184. private _teleportationTarget;
  117185. private _isDefaultTeleportationTarget;
  117186. private _postProcessMove;
  117187. private _teleportationFillColor;
  117188. private _teleportationBorderColor;
  117189. private _rotationAngle;
  117190. private _haloCenter;
  117191. private _cameraGazer;
  117192. private _padSensibilityUp;
  117193. private _padSensibilityDown;
  117194. private _leftController;
  117195. private _rightController;
  117196. private _gazeColor;
  117197. private _laserColor;
  117198. private _pickedLaserColor;
  117199. private _pickedGazeColor;
  117200. /**
  117201. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  117202. */
  117203. onNewMeshSelected: Observable<AbstractMesh>;
  117204. /**
  117205. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  117206. * This observable will provide the mesh and the controller used to select the mesh
  117207. */
  117208. onMeshSelectedWithController: Observable<{
  117209. mesh: AbstractMesh;
  117210. controller: WebVRController;
  117211. }>;
  117212. /**
  117213. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  117214. */
  117215. onNewMeshPicked: Observable<PickingInfo>;
  117216. private _circleEase;
  117217. /**
  117218. * Observable raised before camera teleportation
  117219. */
  117220. onBeforeCameraTeleport: Observable<Vector3>;
  117221. /**
  117222. * Observable raised after camera teleportation
  117223. */
  117224. onAfterCameraTeleport: Observable<Vector3>;
  117225. /**
  117226. * Observable raised when current selected mesh gets unselected
  117227. */
  117228. onSelectedMeshUnselected: Observable<AbstractMesh>;
  117229. private _raySelectionPredicate;
  117230. /**
  117231. * To be optionaly changed by user to define custom ray selection
  117232. */
  117233. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  117234. /**
  117235. * To be optionaly changed by user to define custom selection logic (after ray selection)
  117236. */
  117237. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117238. /**
  117239. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  117240. */
  117241. teleportationEnabled: boolean;
  117242. private _defaultHeight;
  117243. private _teleportationInitialized;
  117244. private _interactionsEnabled;
  117245. private _interactionsRequested;
  117246. private _displayGaze;
  117247. private _displayLaserPointer;
  117248. /**
  117249. * The mesh used to display where the user is going to teleport.
  117250. */
  117251. get teleportationTarget(): Mesh;
  117252. /**
  117253. * Sets the mesh to be used to display where the user is going to teleport.
  117254. */
  117255. set teleportationTarget(value: Mesh);
  117256. /**
  117257. * 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
  117258. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  117259. * See http://doc.babylonjs.com/resources/baking_transformations
  117260. */
  117261. get gazeTrackerMesh(): Mesh;
  117262. set gazeTrackerMesh(value: Mesh);
  117263. /**
  117264. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  117265. */
  117266. updateGazeTrackerScale: boolean;
  117267. /**
  117268. * If the gaze trackers color should be updated when selecting meshes
  117269. */
  117270. updateGazeTrackerColor: boolean;
  117271. /**
  117272. * If the controller laser color should be updated when selecting meshes
  117273. */
  117274. updateControllerLaserColor: boolean;
  117275. /**
  117276. * The gaze tracking mesh corresponding to the left controller
  117277. */
  117278. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  117279. /**
  117280. * The gaze tracking mesh corresponding to the right controller
  117281. */
  117282. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  117283. /**
  117284. * If the ray of the gaze should be displayed.
  117285. */
  117286. get displayGaze(): boolean;
  117287. /**
  117288. * Sets if the ray of the gaze should be displayed.
  117289. */
  117290. set displayGaze(value: boolean);
  117291. /**
  117292. * If the ray of the LaserPointer should be displayed.
  117293. */
  117294. get displayLaserPointer(): boolean;
  117295. /**
  117296. * Sets if the ray of the LaserPointer should be displayed.
  117297. */
  117298. set displayLaserPointer(value: boolean);
  117299. /**
  117300. * The deviceOrientationCamera used as the camera when not in VR.
  117301. */
  117302. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  117303. /**
  117304. * Based on the current WebVR support, returns the current VR camera used.
  117305. */
  117306. get currentVRCamera(): Nullable<Camera>;
  117307. /**
  117308. * The webVRCamera which is used when in VR.
  117309. */
  117310. get webVRCamera(): WebVRFreeCamera;
  117311. /**
  117312. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  117313. */
  117314. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  117315. /**
  117316. * The html button that is used to trigger entering into VR.
  117317. */
  117318. get vrButton(): Nullable<HTMLButtonElement>;
  117319. private get _teleportationRequestInitiated();
  117320. /**
  117321. * Defines wether or not Pointer lock should be requested when switching to
  117322. * full screen.
  117323. */
  117324. requestPointerLockOnFullScreen: boolean;
  117325. /**
  117326. * If asking to force XR, this will be populated with the default xr experience
  117327. */
  117328. xr: WebXRDefaultExperience;
  117329. /**
  117330. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  117331. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  117332. */
  117333. xrTestDone: boolean;
  117334. /**
  117335. * Instantiates a VRExperienceHelper.
  117336. * Helps to quickly add VR support to an existing scene.
  117337. * @param scene The scene the VRExperienceHelper belongs to.
  117338. * @param webVROptions Options to modify the vr experience helper's behavior.
  117339. */
  117340. constructor(scene: Scene,
  117341. /** Options to modify the vr experience helper's behavior. */
  117342. webVROptions?: VRExperienceHelperOptions);
  117343. private completeVRInit;
  117344. private _onDefaultMeshLoaded;
  117345. private _onResize;
  117346. private _onFullscreenChange;
  117347. /**
  117348. * Gets a value indicating if we are currently in VR mode.
  117349. */
  117350. get isInVRMode(): boolean;
  117351. private onVrDisplayPresentChange;
  117352. private onVRDisplayChanged;
  117353. private moveButtonToBottomRight;
  117354. private displayVRButton;
  117355. private updateButtonVisibility;
  117356. private _cachedAngularSensibility;
  117357. /**
  117358. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  117359. * Otherwise, will use the fullscreen API.
  117360. */
  117361. enterVR(): void;
  117362. /**
  117363. * Attempt to exit VR, or fullscreen.
  117364. */
  117365. exitVR(): void;
  117366. /**
  117367. * The position of the vr experience helper.
  117368. */
  117369. get position(): Vector3;
  117370. /**
  117371. * Sets the position of the vr experience helper.
  117372. */
  117373. set position(value: Vector3);
  117374. /**
  117375. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  117376. */
  117377. enableInteractions(): void;
  117378. private get _noControllerIsActive();
  117379. private beforeRender;
  117380. private _isTeleportationFloor;
  117381. /**
  117382. * Adds a floor mesh to be used for teleportation.
  117383. * @param floorMesh the mesh to be used for teleportation.
  117384. */
  117385. addFloorMesh(floorMesh: Mesh): void;
  117386. /**
  117387. * Removes a floor mesh from being used for teleportation.
  117388. * @param floorMesh the mesh to be removed.
  117389. */
  117390. removeFloorMesh(floorMesh: Mesh): void;
  117391. /**
  117392. * Enables interactions and teleportation using the VR controllers and gaze.
  117393. * @param vrTeleportationOptions options to modify teleportation behavior.
  117394. */
  117395. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  117396. private _onNewGamepadConnected;
  117397. private _tryEnableInteractionOnController;
  117398. private _onNewGamepadDisconnected;
  117399. private _enableInteractionOnController;
  117400. private _checkTeleportWithRay;
  117401. private _checkRotate;
  117402. private _checkTeleportBackwards;
  117403. private _enableTeleportationOnController;
  117404. private _createTeleportationCircles;
  117405. private _displayTeleportationTarget;
  117406. private _hideTeleportationTarget;
  117407. private _rotateCamera;
  117408. private _moveTeleportationSelectorTo;
  117409. private _workingVector;
  117410. private _workingQuaternion;
  117411. private _workingMatrix;
  117412. /**
  117413. * Time Constant Teleportation Mode
  117414. */
  117415. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  117416. /**
  117417. * Speed Constant Teleportation Mode
  117418. */
  117419. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  117420. /**
  117421. * Teleports the users feet to the desired location
  117422. * @param location The location where the user's feet should be placed
  117423. */
  117424. teleportCamera(location: Vector3): void;
  117425. private _convertNormalToDirectionOfRay;
  117426. private _castRayAndSelectObject;
  117427. private _notifySelectedMeshUnselected;
  117428. /**
  117429. * Permanently set new colors for the laser pointer
  117430. * @param color the new laser color
  117431. * @param pickedColor the new laser color when picked mesh detected
  117432. */
  117433. setLaserColor(color: Color3, pickedColor?: Color3): void;
  117434. /**
  117435. * Set lighting enabled / disabled on the laser pointer of both controllers
  117436. * @param enabled should the lighting be enabled on the laser pointer
  117437. */
  117438. setLaserLightingState(enabled?: boolean): void;
  117439. /**
  117440. * Permanently set new colors for the gaze pointer
  117441. * @param color the new gaze color
  117442. * @param pickedColor the new gaze color when picked mesh detected
  117443. */
  117444. setGazeColor(color: Color3, pickedColor?: Color3): void;
  117445. /**
  117446. * Sets the color of the laser ray from the vr controllers.
  117447. * @param color new color for the ray.
  117448. */
  117449. changeLaserColor(color: Color3): void;
  117450. /**
  117451. * Sets the color of the ray from the vr headsets gaze.
  117452. * @param color new color for the ray.
  117453. */
  117454. changeGazeColor(color: Color3): void;
  117455. /**
  117456. * Exits VR and disposes of the vr experience helper
  117457. */
  117458. dispose(): void;
  117459. /**
  117460. * Gets the name of the VRExperienceHelper class
  117461. * @returns "VRExperienceHelper"
  117462. */
  117463. getClassName(): string;
  117464. }
  117465. }
  117466. declare module BABYLON {
  117467. /**
  117468. * Options used for hit testing
  117469. */
  117470. export interface IWebXRHitTestOptions {
  117471. /**
  117472. * Only test when user interacted with the scene. Default - hit test every frame
  117473. */
  117474. testOnPointerDownOnly?: boolean;
  117475. /**
  117476. * The node to use to transform the local results to world coordinates
  117477. */
  117478. worldParentNode?: TransformNode;
  117479. }
  117480. /**
  117481. * Interface defining the babylon result of raycasting/hit-test
  117482. */
  117483. export interface IWebXRHitResult {
  117484. /**
  117485. * The native hit test result
  117486. */
  117487. xrHitResult: XRHitResult;
  117488. /**
  117489. * Transformation matrix that can be applied to a node that will put it in the hit point location
  117490. */
  117491. transformationMatrix: Matrix;
  117492. }
  117493. /**
  117494. * The currently-working hit-test module.
  117495. * Hit test (or raycasting) is used to interact with the real world.
  117496. * For further information read here - https://github.com/immersive-web/hit-test
  117497. */
  117498. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  117499. /**
  117500. * options to use when constructing this feature
  117501. */
  117502. readonly options: IWebXRHitTestOptions;
  117503. /**
  117504. * The module's name
  117505. */
  117506. static readonly Name: string;
  117507. /**
  117508. * The (Babylon) version of this module.
  117509. * This is an integer representing the implementation version.
  117510. * This number does not correspond to the webxr specs version
  117511. */
  117512. static readonly Version: number;
  117513. /**
  117514. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  117515. * @param event the (select) event to use to select with
  117516. * @param referenceSpace the reference space to use for this hit test
  117517. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117518. */
  117519. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  117520. /**
  117521. * execute a hit test with an XR Ray
  117522. *
  117523. * @param xrSession a native xrSession that will execute this hit test
  117524. * @param xrRay the ray (position and direction) to use for raycasting
  117525. * @param referenceSpace native XR reference space to use for the hit-test
  117526. * @param filter filter function that will filter the results
  117527. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117528. */
  117529. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  117530. /**
  117531. * Triggered when new babylon (transformed) hit test results are available
  117532. */
  117533. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  117534. private _onSelectEnabled;
  117535. /**
  117536. * Creates a new instance of the (legacy version) hit test feature
  117537. * @param _xrSessionManager an instance of WebXRSessionManager
  117538. * @param options options to use when constructing this feature
  117539. */
  117540. constructor(_xrSessionManager: WebXRSessionManager,
  117541. /**
  117542. * options to use when constructing this feature
  117543. */
  117544. options?: IWebXRHitTestOptions);
  117545. /**
  117546. * Populated with the last native XR Hit Results
  117547. */
  117548. lastNativeXRHitResults: XRHitResult[];
  117549. /**
  117550. * attach this feature
  117551. * Will usually be called by the features manager
  117552. *
  117553. * @returns true if successful.
  117554. */
  117555. attach(): boolean;
  117556. /**
  117557. * detach this feature.
  117558. * Will usually be called by the features manager
  117559. *
  117560. * @returns true if successful.
  117561. */
  117562. detach(): boolean;
  117563. private _onHitTestResults;
  117564. private _origin;
  117565. private _direction;
  117566. private _mat;
  117567. protected _onXRFrame(frame: XRFrame): void;
  117568. private _onSelect;
  117569. /**
  117570. * Dispose this feature and all of the resources attached
  117571. */
  117572. dispose(): void;
  117573. }
  117574. }
  117575. declare module BABYLON {
  117576. /**
  117577. * Options used in the plane detector module
  117578. */
  117579. export interface IWebXRPlaneDetectorOptions {
  117580. /**
  117581. * The node to use to transform the local results to world coordinates
  117582. */
  117583. worldParentNode?: TransformNode;
  117584. }
  117585. /**
  117586. * A babylon interface for a webxr plane.
  117587. * A Plane is actually a polygon, built from N points in space
  117588. */
  117589. export interface IWebXRPlane {
  117590. /**
  117591. * a babylon-assigned ID for this polygon
  117592. */
  117593. id: number;
  117594. /**
  117595. * the native xr-plane object
  117596. */
  117597. xrPlane: XRPlane;
  117598. /**
  117599. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  117600. */
  117601. polygonDefinition: Array<Vector3>;
  117602. /**
  117603. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  117604. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  117605. */
  117606. transformationMatrix: Matrix;
  117607. }
  117608. /**
  117609. * The plane detector is used to detect planes in the real world when in AR
  117610. * For more information see https://github.com/immersive-web/real-world-geometry/
  117611. */
  117612. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  117613. private _options;
  117614. /**
  117615. * The module's name
  117616. */
  117617. static readonly Name: string;
  117618. /**
  117619. * The (Babylon) version of this module.
  117620. * This is an integer representing the implementation version.
  117621. * This number does not correspond to the webxr specs version
  117622. */
  117623. static readonly Version: number;
  117624. /**
  117625. * Observers registered here will be executed when a new plane was added to the session
  117626. */
  117627. onPlaneAddedObservable: Observable<IWebXRPlane>;
  117628. /**
  117629. * Observers registered here will be executed when a plane is no longer detected in the session
  117630. */
  117631. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  117632. /**
  117633. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  117634. * This can execute N times every frame
  117635. */
  117636. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  117637. private _enabled;
  117638. private _detectedPlanes;
  117639. private _lastFrameDetected;
  117640. /**
  117641. * construct a new Plane Detector
  117642. * @param _xrSessionManager an instance of xr Session manager
  117643. * @param _options configuration to use when constructing this feature
  117644. */
  117645. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  117646. protected _onXRFrame(frame: XRFrame): void;
  117647. /**
  117648. * Dispose this feature and all of the resources attached
  117649. */
  117650. dispose(): void;
  117651. private _updatePlaneWithXRPlane;
  117652. /**
  117653. * avoiding using Array.find for global support.
  117654. * @param xrPlane the plane to find in the array
  117655. */
  117656. private findIndexInPlaneArray;
  117657. }
  117658. }
  117659. declare module BABYLON {
  117660. /**
  117661. * Configuration options of the anchor system
  117662. */
  117663. export interface IWebXRAnchorSystemOptions {
  117664. /**
  117665. * a node that will be used to convert local to world coordinates
  117666. */
  117667. worldParentNode?: TransformNode;
  117668. /**
  117669. * should the anchor system use plane detection.
  117670. * If set to true, the plane-detection feature should be set using setPlaneDetector
  117671. */
  117672. usePlaneDetection?: boolean;
  117673. /**
  117674. * Should a new anchor be added every time a select event is triggered
  117675. */
  117676. addAnchorOnSelect?: boolean;
  117677. }
  117678. /**
  117679. * A babylon container for an XR Anchor
  117680. */
  117681. export interface IWebXRAnchor {
  117682. /**
  117683. * A babylon-assigned ID for this anchor
  117684. */
  117685. id: number;
  117686. /**
  117687. * The native anchor object
  117688. */
  117689. xrAnchor: XRAnchor;
  117690. /**
  117691. * Transformation matrix to apply to an object attached to this anchor
  117692. */
  117693. transformationMatrix: Matrix;
  117694. }
  117695. /**
  117696. * An implementation of the anchor system of WebXR.
  117697. * Note that the current documented implementation is not available in any browser. Future implementations
  117698. * will use the frame to create an anchor and not the session or a detected plane
  117699. * For further information see https://github.com/immersive-web/anchors/
  117700. */
  117701. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  117702. private _options;
  117703. /**
  117704. * The module's name
  117705. */
  117706. static readonly Name: string;
  117707. /**
  117708. * The (Babylon) version of this module.
  117709. * This is an integer representing the implementation version.
  117710. * This number does not correspond to the webxr specs version
  117711. */
  117712. static readonly Version: number;
  117713. /**
  117714. * Observers registered here will be executed when a new anchor was added to the session
  117715. */
  117716. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  117717. /**
  117718. * Observers registered here will be executed when an existing anchor updates
  117719. * This can execute N times every frame
  117720. */
  117721. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  117722. /**
  117723. * Observers registered here will be executed when an anchor was removed from the session
  117724. */
  117725. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  117726. private _planeDetector;
  117727. private _hitTestModule;
  117728. private _enabled;
  117729. private _trackedAnchors;
  117730. private _lastFrameDetected;
  117731. /**
  117732. * constructs a new anchor system
  117733. * @param _xrSessionManager an instance of WebXRSessionManager
  117734. * @param _options configuration object for this feature
  117735. */
  117736. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  117737. /**
  117738. * set the plane detector to use in order to create anchors from frames
  117739. * @param planeDetector the plane-detector module to use
  117740. * @param enable enable plane-anchors. default is true
  117741. */
  117742. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  117743. /**
  117744. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  117745. * @param hitTestModule the hit-test module to use.
  117746. */
  117747. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  117748. /**
  117749. * attach this feature
  117750. * Will usually be called by the features manager
  117751. *
  117752. * @returns true if successful.
  117753. */
  117754. attach(): boolean;
  117755. /**
  117756. * detach this feature.
  117757. * Will usually be called by the features manager
  117758. *
  117759. * @returns true if successful.
  117760. */
  117761. detach(): boolean;
  117762. /**
  117763. * Dispose this feature and all of the resources attached
  117764. */
  117765. dispose(): void;
  117766. protected _onXRFrame(frame: XRFrame): void;
  117767. private _onSelect;
  117768. /**
  117769. * Add anchor at a specific XR point.
  117770. *
  117771. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  117772. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  117773. * @returns a promise the fulfills when the anchor was created
  117774. */
  117775. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  117776. private _updateAnchorWithXRFrame;
  117777. /**
  117778. * avoiding using Array.find for global support.
  117779. * @param xrAnchor the plane to find in the array
  117780. */
  117781. private _findIndexInAnchorArray;
  117782. }
  117783. }
  117784. declare module BABYLON {
  117785. /**
  117786. * Options interface for the background remover plugin
  117787. */
  117788. export interface IWebXRBackgroundRemoverOptions {
  117789. /**
  117790. * don't disable the environment helper
  117791. */
  117792. ignoreEnvironmentHelper?: boolean;
  117793. /**
  117794. * flags to configure the removal of the environment helper.
  117795. * If not set, the entire background will be removed. If set, flags should be set as well.
  117796. */
  117797. environmentHelperRemovalFlags?: {
  117798. /**
  117799. * Should the skybox be removed (default false)
  117800. */
  117801. skyBox?: boolean;
  117802. /**
  117803. * Should the ground be removed (default false)
  117804. */
  117805. ground?: boolean;
  117806. };
  117807. /**
  117808. * Further background meshes to disable when entering AR
  117809. */
  117810. backgroundMeshes?: AbstractMesh[];
  117811. }
  117812. /**
  117813. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  117814. */
  117815. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  117816. /**
  117817. * read-only options to be used in this module
  117818. */
  117819. readonly options: IWebXRBackgroundRemoverOptions;
  117820. /**
  117821. * The module's name
  117822. */
  117823. static readonly Name: string;
  117824. /**
  117825. * The (Babylon) version of this module.
  117826. * This is an integer representing the implementation version.
  117827. * This number does not correspond to the webxr specs version
  117828. */
  117829. static readonly Version: number;
  117830. /**
  117831. * registered observers will be triggered when the background state changes
  117832. */
  117833. onBackgroundStateChangedObservable: Observable<boolean>;
  117834. /**
  117835. * constructs a new background remover module
  117836. * @param _xrSessionManager the session manager for this module
  117837. * @param options read-only options to be used in this module
  117838. */
  117839. constructor(_xrSessionManager: WebXRSessionManager,
  117840. /**
  117841. * read-only options to be used in this module
  117842. */
  117843. options?: IWebXRBackgroundRemoverOptions);
  117844. /**
  117845. * attach this feature
  117846. * Will usually be called by the features manager
  117847. *
  117848. * @returns true if successful.
  117849. */
  117850. attach(): boolean;
  117851. /**
  117852. * detach this feature.
  117853. * Will usually be called by the features manager
  117854. *
  117855. * @returns true if successful.
  117856. */
  117857. detach(): boolean;
  117858. private _setBackgroundState;
  117859. /**
  117860. * Dispose this feature and all of the resources attached
  117861. */
  117862. dispose(): void;
  117863. protected _onXRFrame(_xrFrame: XRFrame): void;
  117864. }
  117865. }
  117866. declare module BABYLON {
  117867. /**
  117868. * The motion controller class for all microsoft mixed reality controllers
  117869. */
  117870. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  117871. /**
  117872. * The base url used to load the left and right controller models
  117873. */
  117874. static MODEL_BASE_URL: string;
  117875. /**
  117876. * The name of the left controller model file
  117877. */
  117878. static MODEL_LEFT_FILENAME: string;
  117879. /**
  117880. * The name of the right controller model file
  117881. */
  117882. static MODEL_RIGHT_FILENAME: string;
  117883. profileId: string;
  117884. protected readonly _mapping: {
  117885. defaultButton: {
  117886. "valueNodeName": string;
  117887. "unpressedNodeName": string;
  117888. "pressedNodeName": string;
  117889. };
  117890. defaultAxis: {
  117891. "valueNodeName": string;
  117892. "minNodeName": string;
  117893. "maxNodeName": string;
  117894. };
  117895. buttons: {
  117896. "xr-standard-trigger": {
  117897. "rootNodeName": string;
  117898. "componentProperty": string;
  117899. "states": string[];
  117900. };
  117901. "xr-standard-squeeze": {
  117902. "rootNodeName": string;
  117903. "componentProperty": string;
  117904. "states": string[];
  117905. };
  117906. "xr-standard-touchpad": {
  117907. "rootNodeName": string;
  117908. "labelAnchorNodeName": string;
  117909. "touchPointNodeName": string;
  117910. };
  117911. "xr-standard-thumbstick": {
  117912. "rootNodeName": string;
  117913. "componentProperty": string;
  117914. "states": string[];
  117915. };
  117916. };
  117917. axes: {
  117918. "xr-standard-touchpad": {
  117919. "x-axis": {
  117920. "rootNodeName": string;
  117921. };
  117922. "y-axis": {
  117923. "rootNodeName": string;
  117924. };
  117925. };
  117926. "xr-standard-thumbstick": {
  117927. "x-axis": {
  117928. "rootNodeName": string;
  117929. };
  117930. "y-axis": {
  117931. "rootNodeName": string;
  117932. };
  117933. };
  117934. };
  117935. };
  117936. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117937. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117938. private _getChildByName;
  117939. private _getImmediateChildByName;
  117940. protected _getFilenameAndPath(): {
  117941. filename: string;
  117942. path: string;
  117943. };
  117944. protected _updateModel(): void;
  117945. protected _getModelLoadingConstraints(): boolean;
  117946. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117947. }
  117948. }
  117949. declare module BABYLON {
  117950. /**
  117951. * The motion controller class for oculus touch (quest, rift).
  117952. * This class supports legacy mapping as well the standard xr mapping
  117953. */
  117954. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  117955. private _forceLegacyControllers;
  117956. /**
  117957. * The base url used to load the left and right controller models
  117958. */
  117959. static MODEL_BASE_URL: string;
  117960. /**
  117961. * The name of the left controller model file
  117962. */
  117963. static MODEL_LEFT_FILENAME: string;
  117964. /**
  117965. * The name of the right controller model file
  117966. */
  117967. static MODEL_RIGHT_FILENAME: string;
  117968. /**
  117969. * Base Url for the Quest controller model.
  117970. */
  117971. static QUEST_MODEL_BASE_URL: string;
  117972. profileId: string;
  117973. private _modelRootNode;
  117974. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  117975. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117976. protected _getFilenameAndPath(): {
  117977. filename: string;
  117978. path: string;
  117979. };
  117980. /**
  117981. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  117982. * between the touch and touch 2.
  117983. */
  117984. private _isQuest;
  117985. protected _updateModel(): void;
  117986. protected _getModelLoadingConstraints(): boolean;
  117987. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117988. }
  117989. }
  117990. declare module BABYLON {
  117991. /**
  117992. * The motion controller class for the standard HTC-Vive controllers
  117993. */
  117994. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  117995. /**
  117996. * The base url used to load the left and right controller models
  117997. */
  117998. static MODEL_BASE_URL: string;
  117999. /**
  118000. * File name for the controller model.
  118001. */
  118002. static MODEL_FILENAME: string;
  118003. profileId: string;
  118004. private _modelRootNode;
  118005. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  118006. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118007. protected _getFilenameAndPath(): {
  118008. filename: string;
  118009. path: string;
  118010. };
  118011. protected _updateModel(): void;
  118012. protected _getModelLoadingConstraints(): boolean;
  118013. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118014. }
  118015. }
  118016. declare module BABYLON {
  118017. /**
  118018. * Contains an array of blocks representing the octree
  118019. */
  118020. export interface IOctreeContainer<T> {
  118021. /**
  118022. * Blocks within the octree
  118023. */
  118024. blocks: Array<OctreeBlock<T>>;
  118025. }
  118026. /**
  118027. * Class used to store a cell in an octree
  118028. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118029. */
  118030. export class OctreeBlock<T> {
  118031. /**
  118032. * Gets the content of the current block
  118033. */
  118034. entries: T[];
  118035. /**
  118036. * Gets the list of block children
  118037. */
  118038. blocks: Array<OctreeBlock<T>>;
  118039. private _depth;
  118040. private _maxDepth;
  118041. private _capacity;
  118042. private _minPoint;
  118043. private _maxPoint;
  118044. private _boundingVectors;
  118045. private _creationFunc;
  118046. /**
  118047. * Creates a new block
  118048. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118049. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118050. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118051. * @param depth defines the current depth of this block in the octree
  118052. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118053. * @param creationFunc defines a callback to call when an element is added to the block
  118054. */
  118055. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118056. /**
  118057. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118058. */
  118059. get capacity(): number;
  118060. /**
  118061. * Gets the minimum vector (in world space) of the block's bounding box
  118062. */
  118063. get minPoint(): Vector3;
  118064. /**
  118065. * Gets the maximum vector (in world space) of the block's bounding box
  118066. */
  118067. get maxPoint(): Vector3;
  118068. /**
  118069. * Add a new element to this block
  118070. * @param entry defines the element to add
  118071. */
  118072. addEntry(entry: T): void;
  118073. /**
  118074. * Remove an element from this block
  118075. * @param entry defines the element to remove
  118076. */
  118077. removeEntry(entry: T): void;
  118078. /**
  118079. * Add an array of elements to this block
  118080. * @param entries defines the array of elements to add
  118081. */
  118082. addEntries(entries: T[]): void;
  118083. /**
  118084. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118085. * @param frustumPlanes defines the frustum planes to test
  118086. * @param selection defines the array to store current content if selection is positive
  118087. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118088. */
  118089. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118090. /**
  118091. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118092. * @param sphereCenter defines the bounding sphere center
  118093. * @param sphereRadius defines the bounding sphere radius
  118094. * @param selection defines the array to store current content if selection is positive
  118095. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118096. */
  118097. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118098. /**
  118099. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118100. * @param ray defines the ray to test with
  118101. * @param selection defines the array to store current content if selection is positive
  118102. */
  118103. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118104. /**
  118105. * Subdivide the content into child blocks (this block will then be empty)
  118106. */
  118107. createInnerBlocks(): void;
  118108. /**
  118109. * @hidden
  118110. */
  118111. 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;
  118112. }
  118113. }
  118114. declare module BABYLON {
  118115. /**
  118116. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118117. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118118. */
  118119. export class Octree<T> {
  118120. /** 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.) */
  118121. maxDepth: number;
  118122. /**
  118123. * Blocks within the octree containing objects
  118124. */
  118125. blocks: Array<OctreeBlock<T>>;
  118126. /**
  118127. * Content stored in the octree
  118128. */
  118129. dynamicContent: T[];
  118130. private _maxBlockCapacity;
  118131. private _selectionContent;
  118132. private _creationFunc;
  118133. /**
  118134. * Creates a octree
  118135. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118136. * @param creationFunc function to be used to instatiate the octree
  118137. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118138. * @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.)
  118139. */
  118140. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118141. /** 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.) */
  118142. maxDepth?: number);
  118143. /**
  118144. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118145. * @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);
  118146. * @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);
  118147. * @param entries meshes to be added to the octree blocks
  118148. */
  118149. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118150. /**
  118151. * Adds a mesh to the octree
  118152. * @param entry Mesh to add to the octree
  118153. */
  118154. addMesh(entry: T): void;
  118155. /**
  118156. * Remove an element from the octree
  118157. * @param entry defines the element to remove
  118158. */
  118159. removeMesh(entry: T): void;
  118160. /**
  118161. * Selects an array of meshes within the frustum
  118162. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118163. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118164. * @returns array of meshes within the frustum
  118165. */
  118166. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118167. /**
  118168. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118169. * @param sphereCenter defines the bounding sphere center
  118170. * @param sphereRadius defines the bounding sphere radius
  118171. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118172. * @returns an array of objects that intersect the sphere
  118173. */
  118174. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118175. /**
  118176. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118177. * @param ray defines the ray to test with
  118178. * @returns array of intersected objects
  118179. */
  118180. intersectsRay(ray: Ray): SmartArray<T>;
  118181. /**
  118182. * Adds a mesh into the octree block if it intersects the block
  118183. */
  118184. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118185. /**
  118186. * Adds a submesh into the octree block if it intersects the block
  118187. */
  118188. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118189. }
  118190. }
  118191. declare module BABYLON {
  118192. interface Scene {
  118193. /**
  118194. * @hidden
  118195. * Backing Filed
  118196. */
  118197. _selectionOctree: Octree<AbstractMesh>;
  118198. /**
  118199. * Gets the octree used to boost mesh selection (picking)
  118200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118201. */
  118202. selectionOctree: Octree<AbstractMesh>;
  118203. /**
  118204. * Creates or updates the octree used to boost selection (picking)
  118205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118206. * @param maxCapacity defines the maximum capacity per leaf
  118207. * @param maxDepth defines the maximum depth of the octree
  118208. * @returns an octree of AbstractMesh
  118209. */
  118210. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118211. }
  118212. interface AbstractMesh {
  118213. /**
  118214. * @hidden
  118215. * Backing Field
  118216. */
  118217. _submeshesOctree: Octree<SubMesh>;
  118218. /**
  118219. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118220. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118221. * @param maxCapacity defines the maximum size of each block (64 by default)
  118222. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118223. * @returns the new octree
  118224. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118226. */
  118227. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118228. }
  118229. /**
  118230. * Defines the octree scene component responsible to manage any octrees
  118231. * in a given scene.
  118232. */
  118233. export class OctreeSceneComponent {
  118234. /**
  118235. * The component name help to identify the component in the list of scene components.
  118236. */
  118237. readonly name: string;
  118238. /**
  118239. * The scene the component belongs to.
  118240. */
  118241. scene: Scene;
  118242. /**
  118243. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118244. */
  118245. readonly checksIsEnabled: boolean;
  118246. /**
  118247. * Creates a new instance of the component for the given scene
  118248. * @param scene Defines the scene to register the component in
  118249. */
  118250. constructor(scene: Scene);
  118251. /**
  118252. * Registers the component in a given scene
  118253. */
  118254. register(): void;
  118255. /**
  118256. * Return the list of active meshes
  118257. * @returns the list of active meshes
  118258. */
  118259. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118260. /**
  118261. * Return the list of active sub meshes
  118262. * @param mesh The mesh to get the candidates sub meshes from
  118263. * @returns the list of active sub meshes
  118264. */
  118265. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118266. private _tempRay;
  118267. /**
  118268. * Return the list of sub meshes intersecting with a given local ray
  118269. * @param mesh defines the mesh to find the submesh for
  118270. * @param localRay defines the ray in local space
  118271. * @returns the list of intersecting sub meshes
  118272. */
  118273. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118274. /**
  118275. * Return the list of sub meshes colliding with a collider
  118276. * @param mesh defines the mesh to find the submesh for
  118277. * @param collider defines the collider to evaluate the collision against
  118278. * @returns the list of colliding sub meshes
  118279. */
  118280. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118281. /**
  118282. * Rebuilds the elements related to this component in case of
  118283. * context lost for instance.
  118284. */
  118285. rebuild(): void;
  118286. /**
  118287. * Disposes the component and the associated ressources.
  118288. */
  118289. dispose(): void;
  118290. }
  118291. }
  118292. declare module BABYLON {
  118293. /**
  118294. * Renders a layer on top of an existing scene
  118295. */
  118296. export class UtilityLayerRenderer implements IDisposable {
  118297. /** the original scene that will be rendered on top of */
  118298. originalScene: Scene;
  118299. private _pointerCaptures;
  118300. private _lastPointerEvents;
  118301. private static _DefaultUtilityLayer;
  118302. private static _DefaultKeepDepthUtilityLayer;
  118303. private _sharedGizmoLight;
  118304. private _renderCamera;
  118305. /**
  118306. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118307. * @returns the camera that is used when rendering the utility layer
  118308. */
  118309. getRenderCamera(): Nullable<Camera>;
  118310. /**
  118311. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118312. * @param cam the camera that should be used when rendering the utility layer
  118313. */
  118314. setRenderCamera(cam: Nullable<Camera>): void;
  118315. /**
  118316. * @hidden
  118317. * Light which used by gizmos to get light shading
  118318. */
  118319. _getSharedGizmoLight(): HemisphericLight;
  118320. /**
  118321. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118322. */
  118323. pickUtilitySceneFirst: boolean;
  118324. /**
  118325. * 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)
  118326. */
  118327. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118328. /**
  118329. * 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)
  118330. */
  118331. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118332. /**
  118333. * The scene that is rendered on top of the original scene
  118334. */
  118335. utilityLayerScene: Scene;
  118336. /**
  118337. * If the utility layer should automatically be rendered on top of existing scene
  118338. */
  118339. shouldRender: boolean;
  118340. /**
  118341. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118342. */
  118343. onlyCheckPointerDownEvents: boolean;
  118344. /**
  118345. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118346. */
  118347. processAllEvents: boolean;
  118348. /**
  118349. * Observable raised when the pointer move from the utility layer scene to the main scene
  118350. */
  118351. onPointerOutObservable: Observable<number>;
  118352. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118353. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118354. private _afterRenderObserver;
  118355. private _sceneDisposeObserver;
  118356. private _originalPointerObserver;
  118357. /**
  118358. * Instantiates a UtilityLayerRenderer
  118359. * @param originalScene the original scene that will be rendered on top of
  118360. * @param handleEvents boolean indicating if the utility layer should handle events
  118361. */
  118362. constructor(
  118363. /** the original scene that will be rendered on top of */
  118364. originalScene: Scene, handleEvents?: boolean);
  118365. private _notifyObservers;
  118366. /**
  118367. * Renders the utility layers scene on top of the original scene
  118368. */
  118369. render(): void;
  118370. /**
  118371. * Disposes of the renderer
  118372. */
  118373. dispose(): void;
  118374. private _updateCamera;
  118375. }
  118376. }
  118377. declare module BABYLON {
  118378. /**
  118379. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118380. */
  118381. export class Gizmo implements IDisposable {
  118382. /** The utility layer the gizmo will be added to */
  118383. gizmoLayer: UtilityLayerRenderer;
  118384. /**
  118385. * The root mesh of the gizmo
  118386. */
  118387. _rootMesh: Mesh;
  118388. private _attachedMesh;
  118389. /**
  118390. * Ratio for the scale of the gizmo (Default: 1)
  118391. */
  118392. scaleRatio: number;
  118393. /**
  118394. * If a custom mesh has been set (Default: false)
  118395. */
  118396. protected _customMeshSet: boolean;
  118397. /**
  118398. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118399. * * When set, interactions will be enabled
  118400. */
  118401. get attachedMesh(): Nullable<AbstractMesh>;
  118402. set attachedMesh(value: Nullable<AbstractMesh>);
  118403. /**
  118404. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118405. * @param mesh The mesh to replace the default mesh of the gizmo
  118406. */
  118407. setCustomMesh(mesh: Mesh): void;
  118408. /**
  118409. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118410. */
  118411. updateGizmoRotationToMatchAttachedMesh: boolean;
  118412. /**
  118413. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118414. */
  118415. updateGizmoPositionToMatchAttachedMesh: boolean;
  118416. /**
  118417. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118418. */
  118419. updateScale: boolean;
  118420. protected _interactionsEnabled: boolean;
  118421. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118422. private _beforeRenderObserver;
  118423. private _tempVector;
  118424. /**
  118425. * Creates a gizmo
  118426. * @param gizmoLayer The utility layer the gizmo will be added to
  118427. */
  118428. constructor(
  118429. /** The utility layer the gizmo will be added to */
  118430. gizmoLayer?: UtilityLayerRenderer);
  118431. /**
  118432. * Updates the gizmo to match the attached mesh's position/rotation
  118433. */
  118434. protected _update(): void;
  118435. /**
  118436. * Disposes of the gizmo
  118437. */
  118438. dispose(): void;
  118439. }
  118440. }
  118441. declare module BABYLON {
  118442. /**
  118443. * Single plane drag gizmo
  118444. */
  118445. export class PlaneDragGizmo extends Gizmo {
  118446. /**
  118447. * Drag behavior responsible for the gizmos dragging interactions
  118448. */
  118449. dragBehavior: PointerDragBehavior;
  118450. private _pointerObserver;
  118451. /**
  118452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118453. */
  118454. snapDistance: number;
  118455. /**
  118456. * Event that fires each time the gizmo snaps to a new location.
  118457. * * snapDistance is the the change in distance
  118458. */
  118459. onSnapObservable: Observable<{
  118460. snapDistance: number;
  118461. }>;
  118462. private _plane;
  118463. private _coloredMaterial;
  118464. private _hoverMaterial;
  118465. private _isEnabled;
  118466. private _parent;
  118467. /** @hidden */
  118468. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118469. /** @hidden */
  118470. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118471. /**
  118472. * Creates a PlaneDragGizmo
  118473. * @param gizmoLayer The utility layer the gizmo will be added to
  118474. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  118475. * @param color The color of the gizmo
  118476. */
  118477. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118478. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118479. /**
  118480. * If the gizmo is enabled
  118481. */
  118482. set isEnabled(value: boolean);
  118483. get isEnabled(): boolean;
  118484. /**
  118485. * Disposes of the gizmo
  118486. */
  118487. dispose(): void;
  118488. }
  118489. }
  118490. declare module BABYLON {
  118491. /**
  118492. * Gizmo that enables dragging a mesh along 3 axis
  118493. */
  118494. export class PositionGizmo extends Gizmo {
  118495. /**
  118496. * Internal gizmo used for interactions on the x axis
  118497. */
  118498. xGizmo: AxisDragGizmo;
  118499. /**
  118500. * Internal gizmo used for interactions on the y axis
  118501. */
  118502. yGizmo: AxisDragGizmo;
  118503. /**
  118504. * Internal gizmo used for interactions on the z axis
  118505. */
  118506. zGizmo: AxisDragGizmo;
  118507. /**
  118508. * Internal gizmo used for interactions on the yz plane
  118509. */
  118510. xPlaneGizmo: PlaneDragGizmo;
  118511. /**
  118512. * Internal gizmo used for interactions on the xz plane
  118513. */
  118514. yPlaneGizmo: PlaneDragGizmo;
  118515. /**
  118516. * Internal gizmo used for interactions on the xy plane
  118517. */
  118518. zPlaneGizmo: PlaneDragGizmo;
  118519. /**
  118520. * private variables
  118521. */
  118522. private _meshAttached;
  118523. private _updateGizmoRotationToMatchAttachedMesh;
  118524. private _snapDistance;
  118525. private _scaleRatio;
  118526. /** Fires an event when any of it's sub gizmos are dragged */
  118527. onDragStartObservable: Observable<unknown>;
  118528. /** Fires an event when any of it's sub gizmos are released from dragging */
  118529. onDragEndObservable: Observable<unknown>;
  118530. /**
  118531. * If set to true, planar drag is enabled
  118532. */
  118533. private _planarGizmoEnabled;
  118534. get attachedMesh(): Nullable<AbstractMesh>;
  118535. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118536. /**
  118537. * Creates a PositionGizmo
  118538. * @param gizmoLayer The utility layer the gizmo will be added to
  118539. */
  118540. constructor(gizmoLayer?: UtilityLayerRenderer);
  118541. /**
  118542. * If the planar drag gizmo is enabled
  118543. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  118544. */
  118545. set planarGizmoEnabled(value: boolean);
  118546. get planarGizmoEnabled(): boolean;
  118547. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118548. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118549. /**
  118550. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118551. */
  118552. set snapDistance(value: number);
  118553. get snapDistance(): number;
  118554. /**
  118555. * Ratio for the scale of the gizmo (Default: 1)
  118556. */
  118557. set scaleRatio(value: number);
  118558. get scaleRatio(): number;
  118559. /**
  118560. * Disposes of the gizmo
  118561. */
  118562. dispose(): void;
  118563. /**
  118564. * CustomMeshes are not supported by this gizmo
  118565. * @param mesh The mesh to replace the default mesh of the gizmo
  118566. */
  118567. setCustomMesh(mesh: Mesh): void;
  118568. }
  118569. }
  118570. declare module BABYLON {
  118571. /**
  118572. * Single axis drag gizmo
  118573. */
  118574. export class AxisDragGizmo extends Gizmo {
  118575. /**
  118576. * Drag behavior responsible for the gizmos dragging interactions
  118577. */
  118578. dragBehavior: PointerDragBehavior;
  118579. private _pointerObserver;
  118580. /**
  118581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118582. */
  118583. snapDistance: number;
  118584. /**
  118585. * Event that fires each time the gizmo snaps to a new location.
  118586. * * snapDistance is the the change in distance
  118587. */
  118588. onSnapObservable: Observable<{
  118589. snapDistance: number;
  118590. }>;
  118591. private _isEnabled;
  118592. private _parent;
  118593. private _arrow;
  118594. private _coloredMaterial;
  118595. private _hoverMaterial;
  118596. /** @hidden */
  118597. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  118598. /** @hidden */
  118599. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118600. /**
  118601. * Creates an AxisDragGizmo
  118602. * @param gizmoLayer The utility layer the gizmo will be added to
  118603. * @param dragAxis The axis which the gizmo will be able to drag on
  118604. * @param color The color of the gizmo
  118605. */
  118606. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118607. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118608. /**
  118609. * If the gizmo is enabled
  118610. */
  118611. set isEnabled(value: boolean);
  118612. get isEnabled(): boolean;
  118613. /**
  118614. * Disposes of the gizmo
  118615. */
  118616. dispose(): void;
  118617. }
  118618. }
  118619. declare module BABYLON.Debug {
  118620. /**
  118621. * The Axes viewer will show 3 axes in a specific point in space
  118622. */
  118623. export class AxesViewer {
  118624. private _xAxis;
  118625. private _yAxis;
  118626. private _zAxis;
  118627. private _scaleLinesFactor;
  118628. private _instanced;
  118629. /**
  118630. * Gets the hosting scene
  118631. */
  118632. scene: Scene;
  118633. /**
  118634. * Gets or sets a number used to scale line length
  118635. */
  118636. scaleLines: number;
  118637. /** Gets the node hierarchy used to render x-axis */
  118638. get xAxis(): TransformNode;
  118639. /** Gets the node hierarchy used to render y-axis */
  118640. get yAxis(): TransformNode;
  118641. /** Gets the node hierarchy used to render z-axis */
  118642. get zAxis(): TransformNode;
  118643. /**
  118644. * Creates a new AxesViewer
  118645. * @param scene defines the hosting scene
  118646. * @param scaleLines defines a number used to scale line length (1 by default)
  118647. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  118648. * @param xAxis defines the node hierarchy used to render the x-axis
  118649. * @param yAxis defines the node hierarchy used to render the y-axis
  118650. * @param zAxis defines the node hierarchy used to render the z-axis
  118651. */
  118652. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  118653. /**
  118654. * Force the viewer to update
  118655. * @param position defines the position of the viewer
  118656. * @param xaxis defines the x axis of the viewer
  118657. * @param yaxis defines the y axis of the viewer
  118658. * @param zaxis defines the z axis of the viewer
  118659. */
  118660. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  118661. /**
  118662. * Creates an instance of this axes viewer.
  118663. * @returns a new axes viewer with instanced meshes
  118664. */
  118665. createInstance(): AxesViewer;
  118666. /** Releases resources */
  118667. dispose(): void;
  118668. private static _SetRenderingGroupId;
  118669. }
  118670. }
  118671. declare module BABYLON.Debug {
  118672. /**
  118673. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  118674. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  118675. */
  118676. export class BoneAxesViewer extends AxesViewer {
  118677. /**
  118678. * Gets or sets the target mesh where to display the axes viewer
  118679. */
  118680. mesh: Nullable<Mesh>;
  118681. /**
  118682. * Gets or sets the target bone where to display the axes viewer
  118683. */
  118684. bone: Nullable<Bone>;
  118685. /** Gets current position */
  118686. pos: Vector3;
  118687. /** Gets direction of X axis */
  118688. xaxis: Vector3;
  118689. /** Gets direction of Y axis */
  118690. yaxis: Vector3;
  118691. /** Gets direction of Z axis */
  118692. zaxis: Vector3;
  118693. /**
  118694. * Creates a new BoneAxesViewer
  118695. * @param scene defines the hosting scene
  118696. * @param bone defines the target bone
  118697. * @param mesh defines the target mesh
  118698. * @param scaleLines defines a scaling factor for line length (1 by default)
  118699. */
  118700. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  118701. /**
  118702. * Force the viewer to update
  118703. */
  118704. update(): void;
  118705. /** Releases resources */
  118706. dispose(): void;
  118707. }
  118708. }
  118709. declare module BABYLON {
  118710. /**
  118711. * Interface used to define scene explorer extensibility option
  118712. */
  118713. export interface IExplorerExtensibilityOption {
  118714. /**
  118715. * Define the option label
  118716. */
  118717. label: string;
  118718. /**
  118719. * Defines the action to execute on click
  118720. */
  118721. action: (entity: any) => void;
  118722. }
  118723. /**
  118724. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  118725. */
  118726. export interface IExplorerExtensibilityGroup {
  118727. /**
  118728. * Defines a predicate to test if a given type mut be extended
  118729. */
  118730. predicate: (entity: any) => boolean;
  118731. /**
  118732. * Gets the list of options added to a type
  118733. */
  118734. entries: IExplorerExtensibilityOption[];
  118735. }
  118736. /**
  118737. * Interface used to define the options to use to create the Inspector
  118738. */
  118739. export interface IInspectorOptions {
  118740. /**
  118741. * Display in overlay mode (default: false)
  118742. */
  118743. overlay?: boolean;
  118744. /**
  118745. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  118746. */
  118747. globalRoot?: HTMLElement;
  118748. /**
  118749. * Display the Scene explorer
  118750. */
  118751. showExplorer?: boolean;
  118752. /**
  118753. * Display the property inspector
  118754. */
  118755. showInspector?: boolean;
  118756. /**
  118757. * Display in embed mode (both panes on the right)
  118758. */
  118759. embedMode?: boolean;
  118760. /**
  118761. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  118762. */
  118763. handleResize?: boolean;
  118764. /**
  118765. * Allow the panes to popup (default: true)
  118766. */
  118767. enablePopup?: boolean;
  118768. /**
  118769. * Allow the panes to be closed by users (default: true)
  118770. */
  118771. enableClose?: boolean;
  118772. /**
  118773. * Optional list of extensibility entries
  118774. */
  118775. explorerExtensibility?: IExplorerExtensibilityGroup[];
  118776. /**
  118777. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  118778. */
  118779. inspectorURL?: string;
  118780. /**
  118781. * Optional initial tab (default to DebugLayerTab.Properties)
  118782. */
  118783. initialTab?: DebugLayerTab;
  118784. }
  118785. interface Scene {
  118786. /**
  118787. * @hidden
  118788. * Backing field
  118789. */
  118790. _debugLayer: DebugLayer;
  118791. /**
  118792. * Gets the debug layer (aka Inspector) associated with the scene
  118793. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118794. */
  118795. debugLayer: DebugLayer;
  118796. }
  118797. /**
  118798. * Enum of inspector action tab
  118799. */
  118800. export enum DebugLayerTab {
  118801. /**
  118802. * Properties tag (default)
  118803. */
  118804. Properties = 0,
  118805. /**
  118806. * Debug tab
  118807. */
  118808. Debug = 1,
  118809. /**
  118810. * Statistics tab
  118811. */
  118812. Statistics = 2,
  118813. /**
  118814. * Tools tab
  118815. */
  118816. Tools = 3,
  118817. /**
  118818. * Settings tab
  118819. */
  118820. Settings = 4
  118821. }
  118822. /**
  118823. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118824. * what is happening in your scene
  118825. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118826. */
  118827. export class DebugLayer {
  118828. /**
  118829. * Define the url to get the inspector script from.
  118830. * By default it uses the babylonjs CDN.
  118831. * @ignoreNaming
  118832. */
  118833. static InspectorURL: string;
  118834. private _scene;
  118835. private BJSINSPECTOR;
  118836. private _onPropertyChangedObservable?;
  118837. /**
  118838. * Observable triggered when a property is changed through the inspector.
  118839. */
  118840. get onPropertyChangedObservable(): any;
  118841. /**
  118842. * Instantiates a new debug layer.
  118843. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118844. * what is happening in your scene
  118845. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118846. * @param scene Defines the scene to inspect
  118847. */
  118848. constructor(scene: Scene);
  118849. /** Creates the inspector window. */
  118850. private _createInspector;
  118851. /**
  118852. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  118853. * @param entity defines the entity to select
  118854. * @param lineContainerTitle defines the specific block to highlight
  118855. */
  118856. select(entity: any, lineContainerTitle?: string): void;
  118857. /** Get the inspector from bundle or global */
  118858. private _getGlobalInspector;
  118859. /**
  118860. * Get if the inspector is visible or not.
  118861. * @returns true if visible otherwise, false
  118862. */
  118863. isVisible(): boolean;
  118864. /**
  118865. * Hide the inspector and close its window.
  118866. */
  118867. hide(): void;
  118868. /**
  118869. * Launch the debugLayer.
  118870. * @param config Define the configuration of the inspector
  118871. * @return a promise fulfilled when the debug layer is visible
  118872. */
  118873. show(config?: IInspectorOptions): Promise<DebugLayer>;
  118874. }
  118875. }
  118876. declare module BABYLON {
  118877. /**
  118878. * Class containing static functions to help procedurally build meshes
  118879. */
  118880. export class BoxBuilder {
  118881. /**
  118882. * Creates a box mesh
  118883. * * The parameter `size` sets the size (float) of each box side (default 1)
  118884. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118885. * * 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)
  118886. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118891. * @param name defines the name of the mesh
  118892. * @param options defines the options used to create the mesh
  118893. * @param scene defines the hosting scene
  118894. * @returns the box mesh
  118895. */
  118896. static CreateBox(name: string, options: {
  118897. size?: number;
  118898. width?: number;
  118899. height?: number;
  118900. depth?: number;
  118901. faceUV?: Vector4[];
  118902. faceColors?: Color4[];
  118903. sideOrientation?: number;
  118904. frontUVs?: Vector4;
  118905. backUVs?: Vector4;
  118906. wrap?: boolean;
  118907. topBaseAt?: number;
  118908. bottomBaseAt?: number;
  118909. updatable?: boolean;
  118910. }, scene?: Nullable<Scene>): Mesh;
  118911. }
  118912. }
  118913. declare module BABYLON {
  118914. /**
  118915. * Class containing static functions to help procedurally build meshes
  118916. */
  118917. export class SphereBuilder {
  118918. /**
  118919. * Creates a sphere mesh
  118920. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118921. * * 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`)
  118922. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118923. * * 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
  118924. * * 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)
  118925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118928. * @param name defines the name of the mesh
  118929. * @param options defines the options used to create the mesh
  118930. * @param scene defines the hosting scene
  118931. * @returns the sphere mesh
  118932. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118933. */
  118934. static CreateSphere(name: string, options: {
  118935. segments?: number;
  118936. diameter?: number;
  118937. diameterX?: number;
  118938. diameterY?: number;
  118939. diameterZ?: number;
  118940. arc?: number;
  118941. slice?: number;
  118942. sideOrientation?: number;
  118943. frontUVs?: Vector4;
  118944. backUVs?: Vector4;
  118945. updatable?: boolean;
  118946. }, scene?: Nullable<Scene>): Mesh;
  118947. }
  118948. }
  118949. declare module BABYLON.Debug {
  118950. /**
  118951. * Used to show the physics impostor around the specific mesh
  118952. */
  118953. export class PhysicsViewer {
  118954. /** @hidden */
  118955. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  118956. /** @hidden */
  118957. protected _meshes: Array<Nullable<AbstractMesh>>;
  118958. /** @hidden */
  118959. protected _scene: Nullable<Scene>;
  118960. /** @hidden */
  118961. protected _numMeshes: number;
  118962. /** @hidden */
  118963. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  118964. private _renderFunction;
  118965. private _utilityLayer;
  118966. private _debugBoxMesh;
  118967. private _debugSphereMesh;
  118968. private _debugCylinderMesh;
  118969. private _debugMaterial;
  118970. private _debugMeshMeshes;
  118971. /**
  118972. * Creates a new PhysicsViewer
  118973. * @param scene defines the hosting scene
  118974. */
  118975. constructor(scene: Scene);
  118976. /** @hidden */
  118977. protected _updateDebugMeshes(): void;
  118978. /**
  118979. * Renders a specified physic impostor
  118980. * @param impostor defines the impostor to render
  118981. * @param targetMesh defines the mesh represented by the impostor
  118982. * @returns the new debug mesh used to render the impostor
  118983. */
  118984. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  118985. /**
  118986. * Hides a specified physic impostor
  118987. * @param impostor defines the impostor to hide
  118988. */
  118989. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  118990. private _getDebugMaterial;
  118991. private _getDebugBoxMesh;
  118992. private _getDebugSphereMesh;
  118993. private _getDebugCylinderMesh;
  118994. private _getDebugMeshMesh;
  118995. private _getDebugMesh;
  118996. /** Releases all resources */
  118997. dispose(): void;
  118998. }
  118999. }
  119000. declare module BABYLON {
  119001. /**
  119002. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119003. * in order to better appreciate the issue one might have.
  119004. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119005. */
  119006. export class RayHelper {
  119007. /**
  119008. * Defines the ray we are currently tryin to visualize.
  119009. */
  119010. ray: Nullable<Ray>;
  119011. private _renderPoints;
  119012. private _renderLine;
  119013. private _renderFunction;
  119014. private _scene;
  119015. private _updateToMeshFunction;
  119016. private _attachedToMesh;
  119017. private _meshSpaceDirection;
  119018. private _meshSpaceOrigin;
  119019. /**
  119020. * Helper function to create a colored helper in a scene in one line.
  119021. * @param ray Defines the ray we are currently tryin to visualize
  119022. * @param scene Defines the scene the ray is used in
  119023. * @param color Defines the color we want to see the ray in
  119024. * @returns The newly created ray helper.
  119025. */
  119026. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119027. /**
  119028. * Instantiate a new ray helper.
  119029. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119030. * in order to better appreciate the issue one might have.
  119031. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119032. * @param ray Defines the ray we are currently tryin to visualize
  119033. */
  119034. constructor(ray: Ray);
  119035. /**
  119036. * Shows the ray we are willing to debug.
  119037. * @param scene Defines the scene the ray needs to be rendered in
  119038. * @param color Defines the color the ray needs to be rendered in
  119039. */
  119040. show(scene: Scene, color?: Color3): void;
  119041. /**
  119042. * Hides the ray we are debugging.
  119043. */
  119044. hide(): void;
  119045. private _render;
  119046. /**
  119047. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119048. * @param mesh Defines the mesh we want the helper attached to
  119049. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119050. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119051. * @param length Defines the length of the ray
  119052. */
  119053. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119054. /**
  119055. * Detach the ray helper from the mesh it has previously been attached to.
  119056. */
  119057. detachFromMesh(): void;
  119058. private _updateToMesh;
  119059. /**
  119060. * Dispose the helper and release its associated resources.
  119061. */
  119062. dispose(): void;
  119063. }
  119064. }
  119065. declare module BABYLON.Debug {
  119066. /**
  119067. * Class used to render a debug view of a given skeleton
  119068. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119069. */
  119070. export class SkeletonViewer {
  119071. /** defines the skeleton to render */
  119072. skeleton: Skeleton;
  119073. /** defines the mesh attached to the skeleton */
  119074. mesh: AbstractMesh;
  119075. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119076. autoUpdateBonesMatrices: boolean;
  119077. /** defines the rendering group id to use with the viewer */
  119078. renderingGroupId: number;
  119079. /** Gets or sets the color used to render the skeleton */
  119080. color: Color3;
  119081. private _scene;
  119082. private _debugLines;
  119083. private _debugMesh;
  119084. private _isEnabled;
  119085. private _renderFunction;
  119086. private _utilityLayer;
  119087. /**
  119088. * Returns the mesh used to render the bones
  119089. */
  119090. get debugMesh(): Nullable<LinesMesh>;
  119091. /**
  119092. * Creates a new SkeletonViewer
  119093. * @param skeleton defines the skeleton to render
  119094. * @param mesh defines the mesh attached to the skeleton
  119095. * @param scene defines the hosting scene
  119096. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119097. * @param renderingGroupId defines the rendering group id to use with the viewer
  119098. */
  119099. constructor(
  119100. /** defines the skeleton to render */
  119101. skeleton: Skeleton,
  119102. /** defines the mesh attached to the skeleton */
  119103. mesh: AbstractMesh, scene: Scene,
  119104. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119105. autoUpdateBonesMatrices?: boolean,
  119106. /** defines the rendering group id to use with the viewer */
  119107. renderingGroupId?: number);
  119108. /** Gets or sets a boolean indicating if the viewer is enabled */
  119109. set isEnabled(value: boolean);
  119110. get isEnabled(): boolean;
  119111. private _getBonePosition;
  119112. private _getLinesForBonesWithLength;
  119113. private _getLinesForBonesNoLength;
  119114. /** Update the viewer to sync with current skeleton state */
  119115. update(): void;
  119116. /** Release associated resources */
  119117. dispose(): void;
  119118. }
  119119. }
  119120. declare module BABYLON {
  119121. /**
  119122. * Options to create the null engine
  119123. */
  119124. export class NullEngineOptions {
  119125. /**
  119126. * Render width (Default: 512)
  119127. */
  119128. renderWidth: number;
  119129. /**
  119130. * Render height (Default: 256)
  119131. */
  119132. renderHeight: number;
  119133. /**
  119134. * Texture size (Default: 512)
  119135. */
  119136. textureSize: number;
  119137. /**
  119138. * If delta time between frames should be constant
  119139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119140. */
  119141. deterministicLockstep: boolean;
  119142. /**
  119143. * Maximum about of steps between frames (Default: 4)
  119144. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119145. */
  119146. lockstepMaxSteps: number;
  119147. }
  119148. /**
  119149. * The null engine class provides support for headless version of babylon.js.
  119150. * This can be used in server side scenario or for testing purposes
  119151. */
  119152. export class NullEngine extends Engine {
  119153. private _options;
  119154. /**
  119155. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119157. * @returns true if engine is in deterministic lock step mode
  119158. */
  119159. isDeterministicLockStep(): boolean;
  119160. /**
  119161. * Gets the max steps when engine is running in deterministic lock step
  119162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119163. * @returns the max steps
  119164. */
  119165. getLockstepMaxSteps(): number;
  119166. /**
  119167. * Gets the current hardware scaling level.
  119168. * By default the hardware scaling level is computed from the window device ratio.
  119169. * 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.
  119170. * @returns a number indicating the current hardware scaling level
  119171. */
  119172. getHardwareScalingLevel(): number;
  119173. constructor(options?: NullEngineOptions);
  119174. /**
  119175. * Creates a vertex buffer
  119176. * @param vertices the data for the vertex buffer
  119177. * @returns the new WebGL static buffer
  119178. */
  119179. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119180. /**
  119181. * Creates a new index buffer
  119182. * @param indices defines the content of the index buffer
  119183. * @param updatable defines if the index buffer must be updatable
  119184. * @returns a new webGL buffer
  119185. */
  119186. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119187. /**
  119188. * Clear the current render buffer or the current render target (if any is set up)
  119189. * @param color defines the color to use
  119190. * @param backBuffer defines if the back buffer must be cleared
  119191. * @param depth defines if the depth buffer must be cleared
  119192. * @param stencil defines if the stencil buffer must be cleared
  119193. */
  119194. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119195. /**
  119196. * Gets the current render width
  119197. * @param useScreen defines if screen size must be used (or the current render target if any)
  119198. * @returns a number defining the current render width
  119199. */
  119200. getRenderWidth(useScreen?: boolean): number;
  119201. /**
  119202. * Gets the current render height
  119203. * @param useScreen defines if screen size must be used (or the current render target if any)
  119204. * @returns a number defining the current render height
  119205. */
  119206. getRenderHeight(useScreen?: boolean): number;
  119207. /**
  119208. * Set the WebGL's viewport
  119209. * @param viewport defines the viewport element to be used
  119210. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119211. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119212. */
  119213. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119214. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119215. /**
  119216. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119217. * @param pipelineContext defines the pipeline context to use
  119218. * @param uniformsNames defines the list of uniform names
  119219. * @returns an array of webGL uniform locations
  119220. */
  119221. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119222. /**
  119223. * Gets the lsit of active attributes for a given webGL program
  119224. * @param pipelineContext defines the pipeline context to use
  119225. * @param attributesNames defines the list of attribute names to get
  119226. * @returns an array of indices indicating the offset of each attribute
  119227. */
  119228. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119229. /**
  119230. * Binds an effect to the webGL context
  119231. * @param effect defines the effect to bind
  119232. */
  119233. bindSamplers(effect: Effect): void;
  119234. /**
  119235. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119236. * @param effect defines the effect to activate
  119237. */
  119238. enableEffect(effect: Effect): void;
  119239. /**
  119240. * Set various states to the webGL context
  119241. * @param culling defines backface culling state
  119242. * @param zOffset defines the value to apply to zOffset (0 by default)
  119243. * @param force defines if states must be applied even if cache is up to date
  119244. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119245. */
  119246. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119247. /**
  119248. * Set the value of an uniform to an array of int32
  119249. * @param uniform defines the webGL uniform location where to store the value
  119250. * @param array defines the array of int32 to store
  119251. */
  119252. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119253. /**
  119254. * Set the value of an uniform to an array of int32 (stored as vec2)
  119255. * @param uniform defines the webGL uniform location where to store the value
  119256. * @param array defines the array of int32 to store
  119257. */
  119258. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119259. /**
  119260. * Set the value of an uniform to an array of int32 (stored as vec3)
  119261. * @param uniform defines the webGL uniform location where to store the value
  119262. * @param array defines the array of int32 to store
  119263. */
  119264. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119265. /**
  119266. * Set the value of an uniform to an array of int32 (stored as vec4)
  119267. * @param uniform defines the webGL uniform location where to store the value
  119268. * @param array defines the array of int32 to store
  119269. */
  119270. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119271. /**
  119272. * Set the value of an uniform to an array of float32
  119273. * @param uniform defines the webGL uniform location where to store the value
  119274. * @param array defines the array of float32 to store
  119275. */
  119276. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119277. /**
  119278. * Set the value of an uniform to an array of float32 (stored as vec2)
  119279. * @param uniform defines the webGL uniform location where to store the value
  119280. * @param array defines the array of float32 to store
  119281. */
  119282. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119283. /**
  119284. * Set the value of an uniform to an array of float32 (stored as vec3)
  119285. * @param uniform defines the webGL uniform location where to store the value
  119286. * @param array defines the array of float32 to store
  119287. */
  119288. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119289. /**
  119290. * Set the value of an uniform to an array of float32 (stored as vec4)
  119291. * @param uniform defines the webGL uniform location where to store the value
  119292. * @param array defines the array of float32 to store
  119293. */
  119294. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119295. /**
  119296. * Set the value of an uniform to an array of number
  119297. * @param uniform defines the webGL uniform location where to store the value
  119298. * @param array defines the array of number to store
  119299. */
  119300. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119301. /**
  119302. * Set the value of an uniform to an array of number (stored as vec2)
  119303. * @param uniform defines the webGL uniform location where to store the value
  119304. * @param array defines the array of number to store
  119305. */
  119306. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119307. /**
  119308. * Set the value of an uniform to an array of number (stored as vec3)
  119309. * @param uniform defines the webGL uniform location where to store the value
  119310. * @param array defines the array of number to store
  119311. */
  119312. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119313. /**
  119314. * Set the value of an uniform to an array of number (stored as vec4)
  119315. * @param uniform defines the webGL uniform location where to store the value
  119316. * @param array defines the array of number to store
  119317. */
  119318. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119319. /**
  119320. * Set the value of an uniform to an array of float32 (stored as matrices)
  119321. * @param uniform defines the webGL uniform location where to store the value
  119322. * @param matrices defines the array of float32 to store
  119323. */
  119324. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119325. /**
  119326. * Set the value of an uniform to a matrix (3x3)
  119327. * @param uniform defines the webGL uniform location where to store the value
  119328. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119329. */
  119330. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119331. /**
  119332. * Set the value of an uniform to a matrix (2x2)
  119333. * @param uniform defines the webGL uniform location where to store the value
  119334. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119335. */
  119336. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119337. /**
  119338. * Set the value of an uniform to a number (float)
  119339. * @param uniform defines the webGL uniform location where to store the value
  119340. * @param value defines the float number to store
  119341. */
  119342. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119343. /**
  119344. * Set the value of an uniform to a vec2
  119345. * @param uniform defines the webGL uniform location where to store the value
  119346. * @param x defines the 1st component of the value
  119347. * @param y defines the 2nd component of the value
  119348. */
  119349. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119350. /**
  119351. * Set the value of an uniform to a vec3
  119352. * @param uniform defines the webGL uniform location where to store the value
  119353. * @param x defines the 1st component of the value
  119354. * @param y defines the 2nd component of the value
  119355. * @param z defines the 3rd component of the value
  119356. */
  119357. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119358. /**
  119359. * Set the value of an uniform to a boolean
  119360. * @param uniform defines the webGL uniform location where to store the value
  119361. * @param bool defines the boolean to store
  119362. */
  119363. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119364. /**
  119365. * Set the value of an uniform to a vec4
  119366. * @param uniform defines the webGL uniform location where to store the value
  119367. * @param x defines the 1st component of the value
  119368. * @param y defines the 2nd component of the value
  119369. * @param z defines the 3rd component of the value
  119370. * @param w defines the 4th component of the value
  119371. */
  119372. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119373. /**
  119374. * Sets the current alpha mode
  119375. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119376. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119377. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119378. */
  119379. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119380. /**
  119381. * Bind webGl buffers directly to the webGL context
  119382. * @param vertexBuffers defines the vertex buffer to bind
  119383. * @param indexBuffer defines the index buffer to bind
  119384. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119385. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119386. * @param effect defines the effect associated with the vertex buffer
  119387. */
  119388. bindBuffers(vertexBuffers: {
  119389. [key: string]: VertexBuffer;
  119390. }, indexBuffer: DataBuffer, effect: Effect): void;
  119391. /**
  119392. * Force the entire cache to be cleared
  119393. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119394. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119395. */
  119396. wipeCaches(bruteForce?: boolean): void;
  119397. /**
  119398. * Send a draw order
  119399. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119400. * @param indexStart defines the starting index
  119401. * @param indexCount defines the number of index to draw
  119402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119403. */
  119404. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119405. /**
  119406. * Draw a list of indexed primitives
  119407. * @param fillMode defines the primitive to use
  119408. * @param indexStart defines the starting index
  119409. * @param indexCount defines the number of index to draw
  119410. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119411. */
  119412. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119413. /**
  119414. * Draw a list of unindexed primitives
  119415. * @param fillMode defines the primitive to use
  119416. * @param verticesStart defines the index of first vertex to draw
  119417. * @param verticesCount defines the count of vertices to draw
  119418. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119419. */
  119420. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119421. /** @hidden */
  119422. _createTexture(): WebGLTexture;
  119423. /** @hidden */
  119424. _releaseTexture(texture: InternalTexture): void;
  119425. /**
  119426. * Usually called from Texture.ts.
  119427. * Passed information to create a WebGLTexture
  119428. * @param urlArg defines a value which contains one of the following:
  119429. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119430. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119431. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119432. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119433. * @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)
  119434. * @param scene needed for loading to the correct scene
  119435. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119436. * @param onLoad optional callback to be called upon successful completion
  119437. * @param onError optional callback to be called upon failure
  119438. * @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
  119439. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119440. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119441. * @param forcedExtension defines the extension to use to pick the right loader
  119442. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119443. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119444. */
  119445. 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;
  119446. /**
  119447. * Creates a new render target texture
  119448. * @param size defines the size of the texture
  119449. * @param options defines the options used to create the texture
  119450. * @returns a new render target texture stored in an InternalTexture
  119451. */
  119452. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119453. /**
  119454. * Update the sampling mode of a given texture
  119455. * @param samplingMode defines the required sampling mode
  119456. * @param texture defines the texture to update
  119457. */
  119458. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119459. /**
  119460. * Binds the frame buffer to the specified texture.
  119461. * @param texture The texture to render to or null for the default canvas
  119462. * @param faceIndex The face of the texture to render to in case of cube texture
  119463. * @param requiredWidth The width of the target to render to
  119464. * @param requiredHeight The height of the target to render to
  119465. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119466. * @param lodLevel defines le lod level to bind to the frame buffer
  119467. */
  119468. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119469. /**
  119470. * Unbind the current render target texture from the webGL context
  119471. * @param texture defines the render target texture to unbind
  119472. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119473. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119474. */
  119475. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119476. /**
  119477. * Creates a dynamic vertex buffer
  119478. * @param vertices the data for the dynamic vertex buffer
  119479. * @returns the new WebGL dynamic buffer
  119480. */
  119481. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119482. /**
  119483. * Update the content of a dynamic texture
  119484. * @param texture defines the texture to update
  119485. * @param canvas defines the canvas containing the source
  119486. * @param invertY defines if data must be stored with Y axis inverted
  119487. * @param premulAlpha defines if alpha is stored as premultiplied
  119488. * @param format defines the format of the data
  119489. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119490. */
  119491. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119492. /**
  119493. * Gets a boolean indicating if all created effects are ready
  119494. * @returns true if all effects are ready
  119495. */
  119496. areAllEffectsReady(): boolean;
  119497. /**
  119498. * @hidden
  119499. * Get the current error code of the webGL context
  119500. * @returns the error code
  119501. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119502. */
  119503. getError(): number;
  119504. /** @hidden */
  119505. _getUnpackAlignement(): number;
  119506. /** @hidden */
  119507. _unpackFlipY(value: boolean): void;
  119508. /**
  119509. * Update a dynamic index buffer
  119510. * @param indexBuffer defines the target index buffer
  119511. * @param indices defines the data to update
  119512. * @param offset defines the offset in the target index buffer where update should start
  119513. */
  119514. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  119515. /**
  119516. * Updates a dynamic vertex buffer.
  119517. * @param vertexBuffer the vertex buffer to update
  119518. * @param vertices the data used to update the vertex buffer
  119519. * @param byteOffset the byte offset of the data (optional)
  119520. * @param byteLength the byte length of the data (optional)
  119521. */
  119522. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  119523. /** @hidden */
  119524. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  119525. /** @hidden */
  119526. _bindTexture(channel: number, texture: InternalTexture): void;
  119527. protected _deleteBuffer(buffer: WebGLBuffer): void;
  119528. /**
  119529. * 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
  119530. */
  119531. releaseEffects(): void;
  119532. displayLoadingUI(): void;
  119533. hideLoadingUI(): void;
  119534. /** @hidden */
  119535. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119536. /** @hidden */
  119537. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119538. /** @hidden */
  119539. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119540. /** @hidden */
  119541. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  119542. }
  119543. }
  119544. declare module BABYLON {
  119545. /** @hidden */
  119546. export class _OcclusionDataStorage {
  119547. /** @hidden */
  119548. occlusionInternalRetryCounter: number;
  119549. /** @hidden */
  119550. isOcclusionQueryInProgress: boolean;
  119551. /** @hidden */
  119552. isOccluded: boolean;
  119553. /** @hidden */
  119554. occlusionRetryCount: number;
  119555. /** @hidden */
  119556. occlusionType: number;
  119557. /** @hidden */
  119558. occlusionQueryAlgorithmType: number;
  119559. }
  119560. interface Engine {
  119561. /**
  119562. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  119563. * @return the new query
  119564. */
  119565. createQuery(): WebGLQuery;
  119566. /**
  119567. * Delete and release a webGL query
  119568. * @param query defines the query to delete
  119569. * @return the current engine
  119570. */
  119571. deleteQuery(query: WebGLQuery): Engine;
  119572. /**
  119573. * Check if a given query has resolved and got its value
  119574. * @param query defines the query to check
  119575. * @returns true if the query got its value
  119576. */
  119577. isQueryResultAvailable(query: WebGLQuery): boolean;
  119578. /**
  119579. * Gets the value of a given query
  119580. * @param query defines the query to check
  119581. * @returns the value of the query
  119582. */
  119583. getQueryResult(query: WebGLQuery): number;
  119584. /**
  119585. * Initiates an occlusion query
  119586. * @param algorithmType defines the algorithm to use
  119587. * @param query defines the query to use
  119588. * @returns the current engine
  119589. * @see http://doc.babylonjs.com/features/occlusionquery
  119590. */
  119591. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  119592. /**
  119593. * Ends an occlusion query
  119594. * @see http://doc.babylonjs.com/features/occlusionquery
  119595. * @param algorithmType defines the algorithm to use
  119596. * @returns the current engine
  119597. */
  119598. endOcclusionQuery(algorithmType: number): Engine;
  119599. /**
  119600. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  119601. * Please note that only one query can be issued at a time
  119602. * @returns a time token used to track the time span
  119603. */
  119604. startTimeQuery(): Nullable<_TimeToken>;
  119605. /**
  119606. * Ends a time query
  119607. * @param token defines the token used to measure the time span
  119608. * @returns the time spent (in ns)
  119609. */
  119610. endTimeQuery(token: _TimeToken): int;
  119611. /** @hidden */
  119612. _currentNonTimestampToken: Nullable<_TimeToken>;
  119613. /** @hidden */
  119614. _createTimeQuery(): WebGLQuery;
  119615. /** @hidden */
  119616. _deleteTimeQuery(query: WebGLQuery): void;
  119617. /** @hidden */
  119618. _getGlAlgorithmType(algorithmType: number): number;
  119619. /** @hidden */
  119620. _getTimeQueryResult(query: WebGLQuery): any;
  119621. /** @hidden */
  119622. _getTimeQueryAvailability(query: WebGLQuery): any;
  119623. }
  119624. interface AbstractMesh {
  119625. /**
  119626. * Backing filed
  119627. * @hidden
  119628. */
  119629. __occlusionDataStorage: _OcclusionDataStorage;
  119630. /**
  119631. * Access property
  119632. * @hidden
  119633. */
  119634. _occlusionDataStorage: _OcclusionDataStorage;
  119635. /**
  119636. * 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.
  119637. * The default value is -1 which means don't break the query and wait till the result
  119638. * @see http://doc.babylonjs.com/features/occlusionquery
  119639. */
  119640. occlusionRetryCount: number;
  119641. /**
  119642. * 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:
  119643. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  119644. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  119645. * * 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.
  119646. * @see http://doc.babylonjs.com/features/occlusionquery
  119647. */
  119648. occlusionType: number;
  119649. /**
  119650. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  119651. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  119652. * * 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.
  119653. * @see http://doc.babylonjs.com/features/occlusionquery
  119654. */
  119655. occlusionQueryAlgorithmType: number;
  119656. /**
  119657. * 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
  119658. * @see http://doc.babylonjs.com/features/occlusionquery
  119659. */
  119660. isOccluded: boolean;
  119661. /**
  119662. * Flag to check the progress status of the query
  119663. * @see http://doc.babylonjs.com/features/occlusionquery
  119664. */
  119665. isOcclusionQueryInProgress: boolean;
  119666. }
  119667. }
  119668. declare module BABYLON {
  119669. /** @hidden */
  119670. export var _forceTransformFeedbackToBundle: boolean;
  119671. interface Engine {
  119672. /**
  119673. * Creates a webGL transform feedback object
  119674. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  119675. * @returns the webGL transform feedback object
  119676. */
  119677. createTransformFeedback(): WebGLTransformFeedback;
  119678. /**
  119679. * Delete a webGL transform feedback object
  119680. * @param value defines the webGL transform feedback object to delete
  119681. */
  119682. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  119683. /**
  119684. * Bind a webGL transform feedback object to the webgl context
  119685. * @param value defines the webGL transform feedback object to bind
  119686. */
  119687. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  119688. /**
  119689. * Begins a transform feedback operation
  119690. * @param usePoints defines if points or triangles must be used
  119691. */
  119692. beginTransformFeedback(usePoints: boolean): void;
  119693. /**
  119694. * Ends a transform feedback operation
  119695. */
  119696. endTransformFeedback(): void;
  119697. /**
  119698. * Specify the varyings to use with transform feedback
  119699. * @param program defines the associated webGL program
  119700. * @param value defines the list of strings representing the varying names
  119701. */
  119702. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  119703. /**
  119704. * Bind a webGL buffer for a transform feedback operation
  119705. * @param value defines the webGL buffer to bind
  119706. */
  119707. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  119708. }
  119709. }
  119710. declare module BABYLON {
  119711. /**
  119712. * Creation options of the multi render target texture.
  119713. */
  119714. export interface IMultiRenderTargetOptions {
  119715. /**
  119716. * Define if the texture needs to create mip maps after render.
  119717. */
  119718. generateMipMaps?: boolean;
  119719. /**
  119720. * Define the types of all the draw buffers we want to create
  119721. */
  119722. types?: number[];
  119723. /**
  119724. * Define the sampling modes of all the draw buffers we want to create
  119725. */
  119726. samplingModes?: number[];
  119727. /**
  119728. * Define if a depth buffer is required
  119729. */
  119730. generateDepthBuffer?: boolean;
  119731. /**
  119732. * Define if a stencil buffer is required
  119733. */
  119734. generateStencilBuffer?: boolean;
  119735. /**
  119736. * Define if a depth texture is required instead of a depth buffer
  119737. */
  119738. generateDepthTexture?: boolean;
  119739. /**
  119740. * Define the number of desired draw buffers
  119741. */
  119742. textureCount?: number;
  119743. /**
  119744. * Define if aspect ratio should be adapted to the texture or stay the scene one
  119745. */
  119746. doNotChangeAspectRatio?: boolean;
  119747. /**
  119748. * Define the default type of the buffers we are creating
  119749. */
  119750. defaultType?: number;
  119751. }
  119752. /**
  119753. * A multi render target, like a render target provides the ability to render to a texture.
  119754. * Unlike the render target, it can render to several draw buffers in one draw.
  119755. * This is specially interesting in deferred rendering or for any effects requiring more than
  119756. * just one color from a single pass.
  119757. */
  119758. export class MultiRenderTarget extends RenderTargetTexture {
  119759. private _internalTextures;
  119760. private _textures;
  119761. private _multiRenderTargetOptions;
  119762. /**
  119763. * Get if draw buffers are currently supported by the used hardware and browser.
  119764. */
  119765. get isSupported(): boolean;
  119766. /**
  119767. * Get the list of textures generated by the multi render target.
  119768. */
  119769. get textures(): Texture[];
  119770. /**
  119771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119772. */
  119773. get depthTexture(): Texture;
  119774. /**
  119775. * Set the wrapping mode on U of all the textures we are rendering to.
  119776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119777. */
  119778. set wrapU(wrap: number);
  119779. /**
  119780. * Set the wrapping mode on V of all the textures we are rendering to.
  119781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119782. */
  119783. set wrapV(wrap: number);
  119784. /**
  119785. * Instantiate a new multi render target texture.
  119786. * A multi render target, like a render target provides the ability to render to a texture.
  119787. * Unlike the render target, it can render to several draw buffers in one draw.
  119788. * This is specially interesting in deferred rendering or for any effects requiring more than
  119789. * just one color from a single pass.
  119790. * @param name Define the name of the texture
  119791. * @param size Define the size of the buffers to render to
  119792. * @param count Define the number of target we are rendering into
  119793. * @param scene Define the scene the texture belongs to
  119794. * @param options Define the options used to create the multi render target
  119795. */
  119796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  119797. /** @hidden */
  119798. _rebuild(): void;
  119799. private _createInternalTextures;
  119800. private _createTextures;
  119801. /**
  119802. * Define the number of samples used if MSAA is enabled.
  119803. */
  119804. get samples(): number;
  119805. set samples(value: number);
  119806. /**
  119807. * Resize all the textures in the multi render target.
  119808. * Be carrefull as it will recreate all the data in the new texture.
  119809. * @param size Define the new size
  119810. */
  119811. resize(size: any): void;
  119812. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119813. /**
  119814. * Dispose the render targets and their associated resources
  119815. */
  119816. dispose(): void;
  119817. /**
  119818. * Release all the underlying texture used as draw buffers.
  119819. */
  119820. releaseInternalTextures(): void;
  119821. }
  119822. }
  119823. declare module BABYLON {
  119824. interface ThinEngine {
  119825. /**
  119826. * Unbind a list of render target textures from the webGL context
  119827. * This is used only when drawBuffer extension or webGL2 are active
  119828. * @param textures defines the render target textures to unbind
  119829. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119830. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119831. */
  119832. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  119833. /**
  119834. * Create a multi render target texture
  119835. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  119836. * @param size defines the size of the texture
  119837. * @param options defines the creation options
  119838. * @returns the cube texture as an InternalTexture
  119839. */
  119840. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  119841. /**
  119842. * Update the sample count for a given multiple render target texture
  119843. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  119844. * @param textures defines the textures to update
  119845. * @param samples defines the sample count to set
  119846. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  119847. */
  119848. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  119849. }
  119850. }
  119851. declare module BABYLON {
  119852. /**
  119853. * Class used to define an additional view for the engine
  119854. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119855. */
  119856. export class EngineView {
  119857. /** Defines the canvas where to render the view */
  119858. target: HTMLCanvasElement;
  119859. /** Defines an optional camera used to render the view (will use active camera else) */
  119860. camera?: Camera;
  119861. }
  119862. interface Engine {
  119863. /**
  119864. * Gets or sets the HTML element to use for attaching events
  119865. */
  119866. inputElement: Nullable<HTMLElement>;
  119867. /**
  119868. * Gets the current engine view
  119869. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119870. */
  119871. activeView: Nullable<EngineView>;
  119872. /** Gets or sets the list of views */
  119873. views: EngineView[];
  119874. /**
  119875. * Register a new child canvas
  119876. * @param canvas defines the canvas to register
  119877. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  119878. * @returns the associated view
  119879. */
  119880. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  119881. /**
  119882. * Remove a registered child canvas
  119883. * @param canvas defines the canvas to remove
  119884. * @returns the current engine
  119885. */
  119886. unRegisterView(canvas: HTMLCanvasElement): Engine;
  119887. }
  119888. }
  119889. declare module BABYLON {
  119890. /**
  119891. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  119892. */
  119893. export interface CubeMapInfo {
  119894. /**
  119895. * The pixel array for the front face.
  119896. * This is stored in format, left to right, up to down format.
  119897. */
  119898. front: Nullable<ArrayBufferView>;
  119899. /**
  119900. * The pixel array for the back face.
  119901. * This is stored in format, left to right, up to down format.
  119902. */
  119903. back: Nullable<ArrayBufferView>;
  119904. /**
  119905. * The pixel array for the left face.
  119906. * This is stored in format, left to right, up to down format.
  119907. */
  119908. left: Nullable<ArrayBufferView>;
  119909. /**
  119910. * The pixel array for the right face.
  119911. * This is stored in format, left to right, up to down format.
  119912. */
  119913. right: Nullable<ArrayBufferView>;
  119914. /**
  119915. * The pixel array for the up face.
  119916. * This is stored in format, left to right, up to down format.
  119917. */
  119918. up: Nullable<ArrayBufferView>;
  119919. /**
  119920. * The pixel array for the down face.
  119921. * This is stored in format, left to right, up to down format.
  119922. */
  119923. down: Nullable<ArrayBufferView>;
  119924. /**
  119925. * The size of the cubemap stored.
  119926. *
  119927. * Each faces will be size * size pixels.
  119928. */
  119929. size: number;
  119930. /**
  119931. * The format of the texture.
  119932. *
  119933. * RGBA, RGB.
  119934. */
  119935. format: number;
  119936. /**
  119937. * The type of the texture data.
  119938. *
  119939. * UNSIGNED_INT, FLOAT.
  119940. */
  119941. type: number;
  119942. /**
  119943. * Specifies whether the texture is in gamma space.
  119944. */
  119945. gammaSpace: boolean;
  119946. }
  119947. /**
  119948. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  119949. */
  119950. export class PanoramaToCubeMapTools {
  119951. private static FACE_FRONT;
  119952. private static FACE_BACK;
  119953. private static FACE_RIGHT;
  119954. private static FACE_LEFT;
  119955. private static FACE_DOWN;
  119956. private static FACE_UP;
  119957. /**
  119958. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  119959. *
  119960. * @param float32Array The source data.
  119961. * @param inputWidth The width of the input panorama.
  119962. * @param inputHeight The height of the input panorama.
  119963. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  119964. * @return The cubemap data
  119965. */
  119966. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  119967. private static CreateCubemapTexture;
  119968. private static CalcProjectionSpherical;
  119969. }
  119970. }
  119971. declare module BABYLON {
  119972. /**
  119973. * Helper class dealing with the extraction of spherical polynomial dataArray
  119974. * from a cube map.
  119975. */
  119976. export class CubeMapToSphericalPolynomialTools {
  119977. private static FileFaces;
  119978. /**
  119979. * Converts a texture to the according Spherical Polynomial data.
  119980. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119981. *
  119982. * @param texture The texture to extract the information from.
  119983. * @return The Spherical Polynomial data.
  119984. */
  119985. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  119986. /**
  119987. * Converts a cubemap to the according Spherical Polynomial data.
  119988. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119989. *
  119990. * @param cubeInfo The Cube map to extract the information from.
  119991. * @return The Spherical Polynomial data.
  119992. */
  119993. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  119994. }
  119995. }
  119996. declare module BABYLON {
  119997. interface BaseTexture {
  119998. /**
  119999. * Get the polynomial representation of the texture data.
  120000. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120001. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120002. */
  120003. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120004. }
  120005. }
  120006. declare module BABYLON {
  120007. /** @hidden */
  120008. export var rgbdEncodePixelShader: {
  120009. name: string;
  120010. shader: string;
  120011. };
  120012. }
  120013. declare module BABYLON {
  120014. /** @hidden */
  120015. export var rgbdDecodePixelShader: {
  120016. name: string;
  120017. shader: string;
  120018. };
  120019. }
  120020. declare module BABYLON {
  120021. /**
  120022. * Raw texture data and descriptor sufficient for WebGL texture upload
  120023. */
  120024. export interface EnvironmentTextureInfo {
  120025. /**
  120026. * Version of the environment map
  120027. */
  120028. version: number;
  120029. /**
  120030. * Width of image
  120031. */
  120032. width: number;
  120033. /**
  120034. * Irradiance information stored in the file.
  120035. */
  120036. irradiance: any;
  120037. /**
  120038. * Specular information stored in the file.
  120039. */
  120040. specular: any;
  120041. }
  120042. /**
  120043. * Defines One Image in the file. It requires only the position in the file
  120044. * as well as the length.
  120045. */
  120046. interface BufferImageData {
  120047. /**
  120048. * Length of the image data.
  120049. */
  120050. length: number;
  120051. /**
  120052. * Position of the data from the null terminator delimiting the end of the JSON.
  120053. */
  120054. position: number;
  120055. }
  120056. /**
  120057. * Defines the specular data enclosed in the file.
  120058. * This corresponds to the version 1 of the data.
  120059. */
  120060. export interface EnvironmentTextureSpecularInfoV1 {
  120061. /**
  120062. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120063. */
  120064. specularDataPosition?: number;
  120065. /**
  120066. * This contains all the images data needed to reconstruct the cubemap.
  120067. */
  120068. mipmaps: Array<BufferImageData>;
  120069. /**
  120070. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120071. */
  120072. lodGenerationScale: number;
  120073. }
  120074. /**
  120075. * Sets of helpers addressing the serialization and deserialization of environment texture
  120076. * stored in a BabylonJS env file.
  120077. * Those files are usually stored as .env files.
  120078. */
  120079. export class EnvironmentTextureTools {
  120080. /**
  120081. * Magic number identifying the env file.
  120082. */
  120083. private static _MagicBytes;
  120084. /**
  120085. * Gets the environment info from an env file.
  120086. * @param data The array buffer containing the .env bytes.
  120087. * @returns the environment file info (the json header) if successfully parsed.
  120088. */
  120089. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  120090. /**
  120091. * Creates an environment texture from a loaded cube texture.
  120092. * @param texture defines the cube texture to convert in env file
  120093. * @return a promise containing the environment data if succesfull.
  120094. */
  120095. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120096. /**
  120097. * Creates a JSON representation of the spherical data.
  120098. * @param texture defines the texture containing the polynomials
  120099. * @return the JSON representation of the spherical info
  120100. */
  120101. private static _CreateEnvTextureIrradiance;
  120102. /**
  120103. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120104. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  120105. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120106. * @return the views described by info providing access to the underlying buffer
  120107. */
  120108. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120109. /**
  120110. * Uploads the texture info contained in the env file to the GPU.
  120111. * @param texture defines the internal texture to upload to
  120112. * @param arrayBuffer defines the buffer cotaining the data to load
  120113. * @param info defines the texture info retrieved through the GetEnvInfo method
  120114. * @returns a promise
  120115. */
  120116. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  120117. private static _OnImageReadyAsync;
  120118. /**
  120119. * Uploads the levels of image data to the GPU.
  120120. * @param texture defines the internal texture to upload to
  120121. * @param imageData defines the array buffer views of image data [mipmap][face]
  120122. * @returns a promise
  120123. */
  120124. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120125. /**
  120126. * Uploads spherical polynomials information to the texture.
  120127. * @param texture defines the texture we are trying to upload the information to
  120128. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120129. */
  120130. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120131. /** @hidden */
  120132. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120133. }
  120134. }
  120135. declare module BABYLON {
  120136. /**
  120137. * Contains position and normal vectors for a vertex
  120138. */
  120139. export class PositionNormalVertex {
  120140. /** the position of the vertex (defaut: 0,0,0) */
  120141. position: Vector3;
  120142. /** the normal of the vertex (defaut: 0,1,0) */
  120143. normal: Vector3;
  120144. /**
  120145. * Creates a PositionNormalVertex
  120146. * @param position the position of the vertex (defaut: 0,0,0)
  120147. * @param normal the normal of the vertex (defaut: 0,1,0)
  120148. */
  120149. constructor(
  120150. /** the position of the vertex (defaut: 0,0,0) */
  120151. position?: Vector3,
  120152. /** the normal of the vertex (defaut: 0,1,0) */
  120153. normal?: Vector3);
  120154. /**
  120155. * Clones the PositionNormalVertex
  120156. * @returns the cloned PositionNormalVertex
  120157. */
  120158. clone(): PositionNormalVertex;
  120159. }
  120160. /**
  120161. * Contains position, normal and uv vectors for a vertex
  120162. */
  120163. export class PositionNormalTextureVertex {
  120164. /** the position of the vertex (defaut: 0,0,0) */
  120165. position: Vector3;
  120166. /** the normal of the vertex (defaut: 0,1,0) */
  120167. normal: Vector3;
  120168. /** the uv of the vertex (default: 0,0) */
  120169. uv: Vector2;
  120170. /**
  120171. * Creates a PositionNormalTextureVertex
  120172. * @param position the position of the vertex (defaut: 0,0,0)
  120173. * @param normal the normal of the vertex (defaut: 0,1,0)
  120174. * @param uv the uv of the vertex (default: 0,0)
  120175. */
  120176. constructor(
  120177. /** the position of the vertex (defaut: 0,0,0) */
  120178. position?: Vector3,
  120179. /** the normal of the vertex (defaut: 0,1,0) */
  120180. normal?: Vector3,
  120181. /** the uv of the vertex (default: 0,0) */
  120182. uv?: Vector2);
  120183. /**
  120184. * Clones the PositionNormalTextureVertex
  120185. * @returns the cloned PositionNormalTextureVertex
  120186. */
  120187. clone(): PositionNormalTextureVertex;
  120188. }
  120189. }
  120190. declare module BABYLON {
  120191. /** @hidden */
  120192. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120193. private _genericAttributeLocation;
  120194. private _varyingLocationCount;
  120195. private _varyingLocationMap;
  120196. private _replacements;
  120197. private _textureCount;
  120198. private _uniforms;
  120199. lineProcessor(line: string): string;
  120200. attributeProcessor(attribute: string): string;
  120201. varyingProcessor(varying: string, isFragment: boolean): string;
  120202. uniformProcessor(uniform: string): string;
  120203. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120204. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120205. }
  120206. }
  120207. declare module BABYLON {
  120208. /**
  120209. * Container for accessors for natively-stored mesh data buffers.
  120210. */
  120211. class NativeDataBuffer extends DataBuffer {
  120212. /**
  120213. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120214. */
  120215. nativeIndexBuffer?: any;
  120216. /**
  120217. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120218. */
  120219. nativeVertexBuffer?: any;
  120220. }
  120221. /** @hidden */
  120222. class NativeTexture extends InternalTexture {
  120223. getInternalTexture(): InternalTexture;
  120224. getViewCount(): number;
  120225. }
  120226. /** @hidden */
  120227. export class NativeEngine extends Engine {
  120228. private readonly _native;
  120229. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120230. private readonly INVALID_HANDLE;
  120231. getHardwareScalingLevel(): number;
  120232. constructor();
  120233. /**
  120234. * Can be used to override the current requestAnimationFrame requester.
  120235. * @hidden
  120236. */
  120237. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120238. /**
  120239. * Override default engine behavior.
  120240. * @param color
  120241. * @param backBuffer
  120242. * @param depth
  120243. * @param stencil
  120244. */
  120245. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120246. /**
  120247. * Gets host document
  120248. * @returns the host document object
  120249. */
  120250. getHostDocument(): Nullable<Document>;
  120251. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120252. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120253. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120254. recordVertexArrayObject(vertexBuffers: {
  120255. [key: string]: VertexBuffer;
  120256. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120257. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120258. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120259. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120260. /**
  120261. * Draw a list of indexed primitives
  120262. * @param fillMode defines the primitive to use
  120263. * @param indexStart defines the starting index
  120264. * @param indexCount defines the number of index to draw
  120265. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120266. */
  120267. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120268. /**
  120269. * Draw a list of unindexed primitives
  120270. * @param fillMode defines the primitive to use
  120271. * @param verticesStart defines the index of first vertex to draw
  120272. * @param verticesCount defines the count of vertices to draw
  120273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120274. */
  120275. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120276. createPipelineContext(): IPipelineContext;
  120277. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120278. /** @hidden */
  120279. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120280. /** @hidden */
  120281. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120282. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120283. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120284. protected _setProgram(program: WebGLProgram): void;
  120285. _releaseEffect(effect: Effect): void;
  120286. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120287. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120288. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120289. bindSamplers(effect: Effect): void;
  120290. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120291. getRenderWidth(useScreen?: boolean): number;
  120292. getRenderHeight(useScreen?: boolean): number;
  120293. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120294. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120295. /**
  120296. * Set the z offset to apply to current rendering
  120297. * @param value defines the offset to apply
  120298. */
  120299. setZOffset(value: number): void;
  120300. /**
  120301. * Gets the current value of the zOffset
  120302. * @returns the current zOffset state
  120303. */
  120304. getZOffset(): number;
  120305. /**
  120306. * Enable or disable depth buffering
  120307. * @param enable defines the state to set
  120308. */
  120309. setDepthBuffer(enable: boolean): void;
  120310. /**
  120311. * Gets a boolean indicating if depth writing is enabled
  120312. * @returns the current depth writing state
  120313. */
  120314. getDepthWrite(): boolean;
  120315. /**
  120316. * Enable or disable depth writing
  120317. * @param enable defines the state to set
  120318. */
  120319. setDepthWrite(enable: boolean): void;
  120320. /**
  120321. * Enable or disable color writing
  120322. * @param enable defines the state to set
  120323. */
  120324. setColorWrite(enable: boolean): void;
  120325. /**
  120326. * Gets a boolean indicating if color writing is enabled
  120327. * @returns the current color writing state
  120328. */
  120329. getColorWrite(): boolean;
  120330. /**
  120331. * Sets alpha constants used by some alpha blending modes
  120332. * @param r defines the red component
  120333. * @param g defines the green component
  120334. * @param b defines the blue component
  120335. * @param a defines the alpha component
  120336. */
  120337. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120338. /**
  120339. * Sets the current alpha mode
  120340. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120341. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120342. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120343. */
  120344. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120345. /**
  120346. * Gets the current alpha mode
  120347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120348. * @returns the current alpha mode
  120349. */
  120350. getAlphaMode(): number;
  120351. setInt(uniform: WebGLUniformLocation, int: number): void;
  120352. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120353. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120354. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120355. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120356. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120357. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120358. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120359. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120360. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120361. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120362. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120363. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120364. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120365. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120366. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120367. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120368. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120369. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120370. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120371. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120372. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120373. wipeCaches(bruteForce?: boolean): void;
  120374. _createTexture(): WebGLTexture;
  120375. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120376. /**
  120377. * Usually called from BABYLON.Texture.ts.
  120378. * Passed information to create a WebGLTexture
  120379. * @param urlArg defines a value which contains one of the following:
  120380. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120381. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120382. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120383. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120384. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120385. * @param scene needed for loading to the correct scene
  120386. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120387. * @param onLoad optional callback to be called upon successful completion
  120388. * @param onError optional callback to be called upon failure
  120389. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120390. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120391. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120392. * @param forcedExtension defines the extension to use to pick the right loader
  120393. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120394. */
  120395. 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;
  120396. /**
  120397. * Creates a cube texture
  120398. * @param rootUrl defines the url where the files to load is located
  120399. * @param scene defines the current scene
  120400. * @param files defines the list of files to load (1 per face)
  120401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120402. * @param onLoad defines an optional callback raised when the texture is loaded
  120403. * @param onError defines an optional callback raised if there is an issue to load the texture
  120404. * @param format defines the format of the data
  120405. * @param forcedExtension defines the extension to use to pick the right loader
  120406. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120407. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120408. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120409. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120410. * @returns the cube texture as an InternalTexture
  120411. */
  120412. 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;
  120413. private _getSamplingFilter;
  120414. private static _GetNativeTextureFormat;
  120415. createRenderTargetTexture(size: number | {
  120416. width: number;
  120417. height: number;
  120418. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120419. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120420. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120421. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120422. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120423. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120424. /**
  120425. * Updates a dynamic vertex buffer.
  120426. * @param vertexBuffer the vertex buffer to update
  120427. * @param data the data used to update the vertex buffer
  120428. * @param byteOffset the byte offset of the data (optional)
  120429. * @param byteLength the byte length of the data (optional)
  120430. */
  120431. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120432. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120433. private _updateAnisotropicLevel;
  120434. private _getAddressMode;
  120435. /** @hidden */
  120436. _bindTexture(channel: number, texture: InternalTexture): void;
  120437. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120438. releaseEffects(): void;
  120439. /** @hidden */
  120440. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120441. /** @hidden */
  120442. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120443. /** @hidden */
  120444. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120445. /** @hidden */
  120446. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120447. }
  120448. }
  120449. declare module BABYLON {
  120450. /**
  120451. * Gather the list of clipboard event types as constants.
  120452. */
  120453. export class ClipboardEventTypes {
  120454. /**
  120455. * The clipboard event is fired when a copy command is active (pressed).
  120456. */
  120457. static readonly COPY: number;
  120458. /**
  120459. * The clipboard event is fired when a cut command is active (pressed).
  120460. */
  120461. static readonly CUT: number;
  120462. /**
  120463. * The clipboard event is fired when a paste command is active (pressed).
  120464. */
  120465. static readonly PASTE: number;
  120466. }
  120467. /**
  120468. * This class is used to store clipboard related info for the onClipboardObservable event.
  120469. */
  120470. export class ClipboardInfo {
  120471. /**
  120472. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120473. */
  120474. type: number;
  120475. /**
  120476. * Defines the related dom event
  120477. */
  120478. event: ClipboardEvent;
  120479. /**
  120480. *Creates an instance of ClipboardInfo.
  120481. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120482. * @param event Defines the related dom event
  120483. */
  120484. constructor(
  120485. /**
  120486. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120487. */
  120488. type: number,
  120489. /**
  120490. * Defines the related dom event
  120491. */
  120492. event: ClipboardEvent);
  120493. /**
  120494. * Get the clipboard event's type from the keycode.
  120495. * @param keyCode Defines the keyCode for the current keyboard event.
  120496. * @return {number}
  120497. */
  120498. static GetTypeFromCharacter(keyCode: number): number;
  120499. }
  120500. }
  120501. declare module BABYLON {
  120502. /**
  120503. * Google Daydream controller
  120504. */
  120505. export class DaydreamController extends WebVRController {
  120506. /**
  120507. * Base Url for the controller model.
  120508. */
  120509. static MODEL_BASE_URL: string;
  120510. /**
  120511. * File name for the controller model.
  120512. */
  120513. static MODEL_FILENAME: string;
  120514. /**
  120515. * Gamepad Id prefix used to identify Daydream Controller.
  120516. */
  120517. static readonly GAMEPAD_ID_PREFIX: string;
  120518. /**
  120519. * Creates a new DaydreamController from a gamepad
  120520. * @param vrGamepad the gamepad that the controller should be created from
  120521. */
  120522. constructor(vrGamepad: any);
  120523. /**
  120524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120525. * @param scene scene in which to add meshes
  120526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120527. */
  120528. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120529. /**
  120530. * Called once for each button that changed state since the last frame
  120531. * @param buttonIdx Which button index changed
  120532. * @param state New state of the button
  120533. * @param changes Which properties on the state changed since last frame
  120534. */
  120535. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120536. }
  120537. }
  120538. declare module BABYLON {
  120539. /**
  120540. * Gear VR Controller
  120541. */
  120542. export class GearVRController extends WebVRController {
  120543. /**
  120544. * Base Url for the controller model.
  120545. */
  120546. static MODEL_BASE_URL: string;
  120547. /**
  120548. * File name for the controller model.
  120549. */
  120550. static MODEL_FILENAME: string;
  120551. /**
  120552. * Gamepad Id prefix used to identify this controller.
  120553. */
  120554. static readonly GAMEPAD_ID_PREFIX: string;
  120555. private readonly _buttonIndexToObservableNameMap;
  120556. /**
  120557. * Creates a new GearVRController from a gamepad
  120558. * @param vrGamepad the gamepad that the controller should be created from
  120559. */
  120560. constructor(vrGamepad: any);
  120561. /**
  120562. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120563. * @param scene scene in which to add meshes
  120564. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120565. */
  120566. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120567. /**
  120568. * Called once for each button that changed state since the last frame
  120569. * @param buttonIdx Which button index changed
  120570. * @param state New state of the button
  120571. * @param changes Which properties on the state changed since last frame
  120572. */
  120573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120574. }
  120575. }
  120576. declare module BABYLON {
  120577. /**
  120578. * Generic Controller
  120579. */
  120580. export class GenericController extends WebVRController {
  120581. /**
  120582. * Base Url for the controller model.
  120583. */
  120584. static readonly MODEL_BASE_URL: string;
  120585. /**
  120586. * File name for the controller model.
  120587. */
  120588. static readonly MODEL_FILENAME: string;
  120589. /**
  120590. * Creates a new GenericController from a gamepad
  120591. * @param vrGamepad the gamepad that the controller should be created from
  120592. */
  120593. constructor(vrGamepad: any);
  120594. /**
  120595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120596. * @param scene scene in which to add meshes
  120597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120598. */
  120599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120600. /**
  120601. * Called once for each button that changed state since the last frame
  120602. * @param buttonIdx Which button index changed
  120603. * @param state New state of the button
  120604. * @param changes Which properties on the state changed since last frame
  120605. */
  120606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120607. }
  120608. }
  120609. declare module BABYLON {
  120610. /**
  120611. * Oculus Touch Controller
  120612. */
  120613. export class OculusTouchController extends WebVRController {
  120614. /**
  120615. * Base Url for the controller model.
  120616. */
  120617. static MODEL_BASE_URL: string;
  120618. /**
  120619. * File name for the left controller model.
  120620. */
  120621. static MODEL_LEFT_FILENAME: string;
  120622. /**
  120623. * File name for the right controller model.
  120624. */
  120625. static MODEL_RIGHT_FILENAME: string;
  120626. /**
  120627. * Base Url for the Quest controller model.
  120628. */
  120629. static QUEST_MODEL_BASE_URL: string;
  120630. /**
  120631. * @hidden
  120632. * If the controllers are running on a device that needs the updated Quest controller models
  120633. */
  120634. static _IsQuest: boolean;
  120635. /**
  120636. * Fired when the secondary trigger on this controller is modified
  120637. */
  120638. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  120639. /**
  120640. * Fired when the thumb rest on this controller is modified
  120641. */
  120642. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  120643. /**
  120644. * Creates a new OculusTouchController from a gamepad
  120645. * @param vrGamepad the gamepad that the controller should be created from
  120646. */
  120647. constructor(vrGamepad: any);
  120648. /**
  120649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120650. * @param scene scene in which to add meshes
  120651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120652. */
  120653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120654. /**
  120655. * Fired when the A button on this controller is modified
  120656. */
  120657. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120658. /**
  120659. * Fired when the B button on this controller is modified
  120660. */
  120661. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120662. /**
  120663. * Fired when the X button on this controller is modified
  120664. */
  120665. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120666. /**
  120667. * Fired when the Y button on this controller is modified
  120668. */
  120669. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120670. /**
  120671. * Called once for each button that changed state since the last frame
  120672. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  120673. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  120674. * 2) secondary trigger (same)
  120675. * 3) A (right) X (left), touch, pressed = value
  120676. * 4) B / Y
  120677. * 5) thumb rest
  120678. * @param buttonIdx Which button index changed
  120679. * @param state New state of the button
  120680. * @param changes Which properties on the state changed since last frame
  120681. */
  120682. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120683. }
  120684. }
  120685. declare module BABYLON {
  120686. /**
  120687. * Vive Controller
  120688. */
  120689. export class ViveController extends WebVRController {
  120690. /**
  120691. * Base Url for the controller model.
  120692. */
  120693. static MODEL_BASE_URL: string;
  120694. /**
  120695. * File name for the controller model.
  120696. */
  120697. static MODEL_FILENAME: string;
  120698. /**
  120699. * Creates a new ViveController from a gamepad
  120700. * @param vrGamepad the gamepad that the controller should be created from
  120701. */
  120702. constructor(vrGamepad: any);
  120703. /**
  120704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120705. * @param scene scene in which to add meshes
  120706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120707. */
  120708. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120709. /**
  120710. * Fired when the left button on this controller is modified
  120711. */
  120712. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120713. /**
  120714. * Fired when the right button on this controller is modified
  120715. */
  120716. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120717. /**
  120718. * Fired when the menu button on this controller is modified
  120719. */
  120720. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120721. /**
  120722. * Called once for each button that changed state since the last frame
  120723. * Vive mapping:
  120724. * 0: touchpad
  120725. * 1: trigger
  120726. * 2: left AND right buttons
  120727. * 3: menu button
  120728. * @param buttonIdx Which button index changed
  120729. * @param state New state of the button
  120730. * @param changes Which properties on the state changed since last frame
  120731. */
  120732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120733. }
  120734. }
  120735. declare module BABYLON {
  120736. /**
  120737. * Defines the WindowsMotionController object that the state of the windows motion controller
  120738. */
  120739. export class WindowsMotionController extends WebVRController {
  120740. /**
  120741. * The base url used to load the left and right controller models
  120742. */
  120743. static MODEL_BASE_URL: string;
  120744. /**
  120745. * The name of the left controller model file
  120746. */
  120747. static MODEL_LEFT_FILENAME: string;
  120748. /**
  120749. * The name of the right controller model file
  120750. */
  120751. static MODEL_RIGHT_FILENAME: string;
  120752. /**
  120753. * The controller name prefix for this controller type
  120754. */
  120755. static readonly GAMEPAD_ID_PREFIX: string;
  120756. /**
  120757. * The controller id pattern for this controller type
  120758. */
  120759. private static readonly GAMEPAD_ID_PATTERN;
  120760. private _loadedMeshInfo;
  120761. protected readonly _mapping: {
  120762. buttons: string[];
  120763. buttonMeshNames: {
  120764. 'trigger': string;
  120765. 'menu': string;
  120766. 'grip': string;
  120767. 'thumbstick': string;
  120768. 'trackpad': string;
  120769. };
  120770. buttonObservableNames: {
  120771. 'trigger': string;
  120772. 'menu': string;
  120773. 'grip': string;
  120774. 'thumbstick': string;
  120775. 'trackpad': string;
  120776. };
  120777. axisMeshNames: string[];
  120778. pointingPoseMeshName: string;
  120779. };
  120780. /**
  120781. * Fired when the trackpad on this controller is clicked
  120782. */
  120783. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120784. /**
  120785. * Fired when the trackpad on this controller is modified
  120786. */
  120787. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120788. /**
  120789. * The current x and y values of this controller's trackpad
  120790. */
  120791. trackpad: StickValues;
  120792. /**
  120793. * Creates a new WindowsMotionController from a gamepad
  120794. * @param vrGamepad the gamepad that the controller should be created from
  120795. */
  120796. constructor(vrGamepad: any);
  120797. /**
  120798. * Fired when the trigger on this controller is modified
  120799. */
  120800. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120801. /**
  120802. * Fired when the menu button on this controller is modified
  120803. */
  120804. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120805. /**
  120806. * Fired when the grip button on this controller is modified
  120807. */
  120808. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120809. /**
  120810. * Fired when the thumbstick button on this controller is modified
  120811. */
  120812. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120813. /**
  120814. * Fired when the touchpad button on this controller is modified
  120815. */
  120816. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120817. /**
  120818. * Fired when the touchpad values on this controller are modified
  120819. */
  120820. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  120821. protected _updateTrackpad(): void;
  120822. /**
  120823. * Called once per frame by the engine.
  120824. */
  120825. update(): void;
  120826. /**
  120827. * Called once for each button that changed state since the last frame
  120828. * @param buttonIdx Which button index changed
  120829. * @param state New state of the button
  120830. * @param changes Which properties on the state changed since last frame
  120831. */
  120832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120833. /**
  120834. * Moves the buttons on the controller mesh based on their current state
  120835. * @param buttonName the name of the button to move
  120836. * @param buttonValue the value of the button which determines the buttons new position
  120837. */
  120838. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  120839. /**
  120840. * Moves the axis on the controller mesh based on its current state
  120841. * @param axis the index of the axis
  120842. * @param axisValue the value of the axis which determines the meshes new position
  120843. * @hidden
  120844. */
  120845. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  120846. /**
  120847. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120848. * @param scene scene in which to add meshes
  120849. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120850. */
  120851. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  120852. /**
  120853. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  120854. * can be transformed by button presses and axes values, based on this._mapping.
  120855. *
  120856. * @param scene scene in which the meshes exist
  120857. * @param meshes list of meshes that make up the controller model to process
  120858. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  120859. */
  120860. private processModel;
  120861. private createMeshInfo;
  120862. /**
  120863. * Gets the ray of the controller in the direction the controller is pointing
  120864. * @param length the length the resulting ray should be
  120865. * @returns a ray in the direction the controller is pointing
  120866. */
  120867. getForwardRay(length?: number): Ray;
  120868. /**
  120869. * Disposes of the controller
  120870. */
  120871. dispose(): void;
  120872. }
  120873. /**
  120874. * This class represents a new windows motion controller in XR.
  120875. */
  120876. export class XRWindowsMotionController extends WindowsMotionController {
  120877. /**
  120878. * Changing the original WIndowsMotionController mapping to fir the new mapping
  120879. */
  120880. protected readonly _mapping: {
  120881. buttons: string[];
  120882. buttonMeshNames: {
  120883. 'trigger': string;
  120884. 'menu': string;
  120885. 'grip': string;
  120886. 'thumbstick': string;
  120887. 'trackpad': string;
  120888. };
  120889. buttonObservableNames: {
  120890. 'trigger': string;
  120891. 'menu': string;
  120892. 'grip': string;
  120893. 'thumbstick': string;
  120894. 'trackpad': string;
  120895. };
  120896. axisMeshNames: string[];
  120897. pointingPoseMeshName: string;
  120898. };
  120899. /**
  120900. * Construct a new XR-Based windows motion controller
  120901. *
  120902. * @param gamepadInfo the gamepad object from the browser
  120903. */
  120904. constructor(gamepadInfo: any);
  120905. /**
  120906. * holds the thumbstick values (X,Y)
  120907. */
  120908. thumbstickValues: StickValues;
  120909. /**
  120910. * Fired when the thumbstick on this controller is clicked
  120911. */
  120912. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  120913. /**
  120914. * Fired when the thumbstick on this controller is modified
  120915. */
  120916. onThumbstickValuesChangedObservable: Observable<StickValues>;
  120917. /**
  120918. * Fired when the touchpad button on this controller is modified
  120919. */
  120920. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120921. /**
  120922. * Fired when the touchpad values on this controller are modified
  120923. */
  120924. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120925. /**
  120926. * Fired when the thumbstick button on this controller is modified
  120927. * here to prevent breaking changes
  120928. */
  120929. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120930. /**
  120931. * updating the thumbstick(!) and not the trackpad.
  120932. * This is named this way due to the difference between WebVR and XR and to avoid
  120933. * changing the parent class.
  120934. */
  120935. protected _updateTrackpad(): void;
  120936. /**
  120937. * Disposes the class with joy
  120938. */
  120939. dispose(): void;
  120940. }
  120941. }
  120942. declare module BABYLON {
  120943. /**
  120944. * Class containing static functions to help procedurally build meshes
  120945. */
  120946. export class PolyhedronBuilder {
  120947. /**
  120948. * Creates a polyhedron mesh
  120949. * * 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
  120950. * * The parameter `size` (positive float, default 1) sets the polygon size
  120951. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120952. * * 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`
  120953. * * 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
  120954. * * 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)`)
  120955. * * 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
  120956. * * 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
  120957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120960. * @param name defines the name of the mesh
  120961. * @param options defines the options used to create the mesh
  120962. * @param scene defines the hosting scene
  120963. * @returns the polyhedron mesh
  120964. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120965. */
  120966. static CreatePolyhedron(name: string, options: {
  120967. type?: number;
  120968. size?: number;
  120969. sizeX?: number;
  120970. sizeY?: number;
  120971. sizeZ?: number;
  120972. custom?: any;
  120973. faceUV?: Vector4[];
  120974. faceColors?: Color4[];
  120975. flat?: boolean;
  120976. updatable?: boolean;
  120977. sideOrientation?: number;
  120978. frontUVs?: Vector4;
  120979. backUVs?: Vector4;
  120980. }, scene?: Nullable<Scene>): Mesh;
  120981. }
  120982. }
  120983. declare module BABYLON {
  120984. /**
  120985. * Gizmo that enables scaling a mesh along 3 axis
  120986. */
  120987. export class ScaleGizmo extends Gizmo {
  120988. /**
  120989. * Internal gizmo used for interactions on the x axis
  120990. */
  120991. xGizmo: AxisScaleGizmo;
  120992. /**
  120993. * Internal gizmo used for interactions on the y axis
  120994. */
  120995. yGizmo: AxisScaleGizmo;
  120996. /**
  120997. * Internal gizmo used for interactions on the z axis
  120998. */
  120999. zGizmo: AxisScaleGizmo;
  121000. /**
  121001. * Internal gizmo used to scale all axis equally
  121002. */
  121003. uniformScaleGizmo: AxisScaleGizmo;
  121004. private _meshAttached;
  121005. private _updateGizmoRotationToMatchAttachedMesh;
  121006. private _snapDistance;
  121007. private _scaleRatio;
  121008. private _uniformScalingMesh;
  121009. private _octahedron;
  121010. private _sensitivity;
  121011. /** Fires an event when any of it's sub gizmos are dragged */
  121012. onDragStartObservable: Observable<unknown>;
  121013. /** Fires an event when any of it's sub gizmos are released from dragging */
  121014. onDragEndObservable: Observable<unknown>;
  121015. get attachedMesh(): Nullable<AbstractMesh>;
  121016. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121017. /**
  121018. * Creates a ScaleGizmo
  121019. * @param gizmoLayer The utility layer the gizmo will be added to
  121020. */
  121021. constructor(gizmoLayer?: UtilityLayerRenderer);
  121022. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121023. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121024. /**
  121025. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121026. */
  121027. set snapDistance(value: number);
  121028. get snapDistance(): number;
  121029. /**
  121030. * Ratio for the scale of the gizmo (Default: 1)
  121031. */
  121032. set scaleRatio(value: number);
  121033. get scaleRatio(): number;
  121034. /**
  121035. * Sensitivity factor for dragging (Default: 1)
  121036. */
  121037. set sensitivity(value: number);
  121038. get sensitivity(): number;
  121039. /**
  121040. * Disposes of the gizmo
  121041. */
  121042. dispose(): void;
  121043. }
  121044. }
  121045. declare module BABYLON {
  121046. /**
  121047. * Single axis scale gizmo
  121048. */
  121049. export class AxisScaleGizmo extends Gizmo {
  121050. /**
  121051. * Drag behavior responsible for the gizmos dragging interactions
  121052. */
  121053. dragBehavior: PointerDragBehavior;
  121054. private _pointerObserver;
  121055. /**
  121056. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121057. */
  121058. snapDistance: number;
  121059. /**
  121060. * Event that fires each time the gizmo snaps to a new location.
  121061. * * snapDistance is the the change in distance
  121062. */
  121063. onSnapObservable: Observable<{
  121064. snapDistance: number;
  121065. }>;
  121066. /**
  121067. * If the scaling operation should be done on all axis (default: false)
  121068. */
  121069. uniformScaling: boolean;
  121070. /**
  121071. * Custom sensitivity value for the drag strength
  121072. */
  121073. sensitivity: number;
  121074. private _isEnabled;
  121075. private _parent;
  121076. private _arrow;
  121077. private _coloredMaterial;
  121078. private _hoverMaterial;
  121079. /**
  121080. * Creates an AxisScaleGizmo
  121081. * @param gizmoLayer The utility layer the gizmo will be added to
  121082. * @param dragAxis The axis which the gizmo will be able to scale on
  121083. * @param color The color of the gizmo
  121084. */
  121085. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121086. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121087. /**
  121088. * If the gizmo is enabled
  121089. */
  121090. set isEnabled(value: boolean);
  121091. get isEnabled(): boolean;
  121092. /**
  121093. * Disposes of the gizmo
  121094. */
  121095. dispose(): void;
  121096. /**
  121097. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121098. * @param mesh The mesh to replace the default mesh of the gizmo
  121099. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121100. */
  121101. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Bounding box gizmo
  121107. */
  121108. export class BoundingBoxGizmo extends Gizmo {
  121109. private _lineBoundingBox;
  121110. private _rotateSpheresParent;
  121111. private _scaleBoxesParent;
  121112. private _boundingDimensions;
  121113. private _renderObserver;
  121114. private _pointerObserver;
  121115. private _scaleDragSpeed;
  121116. private _tmpQuaternion;
  121117. private _tmpVector;
  121118. private _tmpRotationMatrix;
  121119. /**
  121120. * 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)
  121121. */
  121122. ignoreChildren: boolean;
  121123. /**
  121124. * 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)
  121125. */
  121126. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121127. /**
  121128. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121129. */
  121130. rotationSphereSize: number;
  121131. /**
  121132. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121133. */
  121134. scaleBoxSize: number;
  121135. /**
  121136. * 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)
  121137. */
  121138. fixedDragMeshScreenSize: boolean;
  121139. /**
  121140. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121141. */
  121142. fixedDragMeshScreenSizeDistanceFactor: number;
  121143. /**
  121144. * Fired when a rotation sphere or scale box is dragged
  121145. */
  121146. onDragStartObservable: Observable<{}>;
  121147. /**
  121148. * Fired when a scale box is dragged
  121149. */
  121150. onScaleBoxDragObservable: Observable<{}>;
  121151. /**
  121152. * Fired when a scale box drag is ended
  121153. */
  121154. onScaleBoxDragEndObservable: Observable<{}>;
  121155. /**
  121156. * Fired when a rotation sphere is dragged
  121157. */
  121158. onRotationSphereDragObservable: Observable<{}>;
  121159. /**
  121160. * Fired when a rotation sphere drag is ended
  121161. */
  121162. onRotationSphereDragEndObservable: Observable<{}>;
  121163. /**
  121164. * 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)
  121165. */
  121166. scalePivot: Nullable<Vector3>;
  121167. /**
  121168. * Mesh used as a pivot to rotate the attached mesh
  121169. */
  121170. private _anchorMesh;
  121171. private _existingMeshScale;
  121172. private _dragMesh;
  121173. private pointerDragBehavior;
  121174. private coloredMaterial;
  121175. private hoverColoredMaterial;
  121176. /**
  121177. * Sets the color of the bounding box gizmo
  121178. * @param color the color to set
  121179. */
  121180. setColor(color: Color3): void;
  121181. /**
  121182. * Creates an BoundingBoxGizmo
  121183. * @param gizmoLayer The utility layer the gizmo will be added to
  121184. * @param color The color of the gizmo
  121185. */
  121186. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121188. private _selectNode;
  121189. /**
  121190. * Updates the bounding box information for the Gizmo
  121191. */
  121192. updateBoundingBox(): void;
  121193. private _updateRotationSpheres;
  121194. private _updateScaleBoxes;
  121195. /**
  121196. * Enables rotation on the specified axis and disables rotation on the others
  121197. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121198. */
  121199. setEnabledRotationAxis(axis: string): void;
  121200. /**
  121201. * Enables/disables scaling
  121202. * @param enable if scaling should be enabled
  121203. */
  121204. setEnabledScaling(enable: boolean): void;
  121205. private _updateDummy;
  121206. /**
  121207. * Enables a pointer drag behavior on the bounding box of the gizmo
  121208. */
  121209. enableDragBehavior(): void;
  121210. /**
  121211. * Disposes of the gizmo
  121212. */
  121213. dispose(): void;
  121214. /**
  121215. * 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)
  121216. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121217. * @returns the bounding box mesh with the passed in mesh as a child
  121218. */
  121219. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121220. /**
  121221. * CustomMeshes are not supported by this gizmo
  121222. * @param mesh The mesh to replace the default mesh of the gizmo
  121223. */
  121224. setCustomMesh(mesh: Mesh): void;
  121225. }
  121226. }
  121227. declare module BABYLON {
  121228. /**
  121229. * Single plane rotation gizmo
  121230. */
  121231. export class PlaneRotationGizmo extends Gizmo {
  121232. /**
  121233. * Drag behavior responsible for the gizmos dragging interactions
  121234. */
  121235. dragBehavior: PointerDragBehavior;
  121236. private _pointerObserver;
  121237. /**
  121238. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121239. */
  121240. snapDistance: number;
  121241. /**
  121242. * Event that fires each time the gizmo snaps to a new location.
  121243. * * snapDistance is the the change in distance
  121244. */
  121245. onSnapObservable: Observable<{
  121246. snapDistance: number;
  121247. }>;
  121248. private _isEnabled;
  121249. private _parent;
  121250. /**
  121251. * Creates a PlaneRotationGizmo
  121252. * @param gizmoLayer The utility layer the gizmo will be added to
  121253. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121254. * @param color The color of the gizmo
  121255. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121256. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121257. */
  121258. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121259. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121260. /**
  121261. * If the gizmo is enabled
  121262. */
  121263. set isEnabled(value: boolean);
  121264. get isEnabled(): boolean;
  121265. /**
  121266. * Disposes of the gizmo
  121267. */
  121268. dispose(): void;
  121269. }
  121270. }
  121271. declare module BABYLON {
  121272. /**
  121273. * Gizmo that enables rotating a mesh along 3 axis
  121274. */
  121275. export class RotationGizmo extends Gizmo {
  121276. /**
  121277. * Internal gizmo used for interactions on the x axis
  121278. */
  121279. xGizmo: PlaneRotationGizmo;
  121280. /**
  121281. * Internal gizmo used for interactions on the y axis
  121282. */
  121283. yGizmo: PlaneRotationGizmo;
  121284. /**
  121285. * Internal gizmo used for interactions on the z axis
  121286. */
  121287. zGizmo: PlaneRotationGizmo;
  121288. /** Fires an event when any of it's sub gizmos are dragged */
  121289. onDragStartObservable: Observable<unknown>;
  121290. /** Fires an event when any of it's sub gizmos are released from dragging */
  121291. onDragEndObservable: Observable<unknown>;
  121292. private _meshAttached;
  121293. get attachedMesh(): Nullable<AbstractMesh>;
  121294. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121295. /**
  121296. * Creates a RotationGizmo
  121297. * @param gizmoLayer The utility layer the gizmo will be added to
  121298. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121299. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121300. */
  121301. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121302. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121303. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121304. /**
  121305. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121306. */
  121307. set snapDistance(value: number);
  121308. get snapDistance(): number;
  121309. /**
  121310. * Ratio for the scale of the gizmo (Default: 1)
  121311. */
  121312. set scaleRatio(value: number);
  121313. get scaleRatio(): number;
  121314. /**
  121315. * Disposes of the gizmo
  121316. */
  121317. dispose(): void;
  121318. /**
  121319. * CustomMeshes are not supported by this gizmo
  121320. * @param mesh The mesh to replace the default mesh of the gizmo
  121321. */
  121322. setCustomMesh(mesh: Mesh): void;
  121323. }
  121324. }
  121325. declare module BABYLON {
  121326. /**
  121327. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121328. */
  121329. export class GizmoManager implements IDisposable {
  121330. private scene;
  121331. /**
  121332. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121333. */
  121334. gizmos: {
  121335. positionGizmo: Nullable<PositionGizmo>;
  121336. rotationGizmo: Nullable<RotationGizmo>;
  121337. scaleGizmo: Nullable<ScaleGizmo>;
  121338. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121339. };
  121340. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121341. clearGizmoOnEmptyPointerEvent: boolean;
  121342. /** Fires an event when the manager is attached to a mesh */
  121343. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121344. private _gizmosEnabled;
  121345. private _pointerObserver;
  121346. private _attachedMesh;
  121347. private _boundingBoxColor;
  121348. private _defaultUtilityLayer;
  121349. private _defaultKeepDepthUtilityLayer;
  121350. /**
  121351. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121352. */
  121353. boundingBoxDragBehavior: SixDofDragBehavior;
  121354. /**
  121355. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121356. */
  121357. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121358. /**
  121359. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121360. */
  121361. usePointerToAttachGizmos: boolean;
  121362. /**
  121363. * Utility layer that the bounding box gizmo belongs to
  121364. */
  121365. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121366. /**
  121367. * Utility layer that all gizmos besides bounding box belong to
  121368. */
  121369. get utilityLayer(): UtilityLayerRenderer;
  121370. /**
  121371. * Instatiates a gizmo manager
  121372. * @param scene the scene to overlay the gizmos on top of
  121373. */
  121374. constructor(scene: Scene);
  121375. /**
  121376. * Attaches a set of gizmos to the specified mesh
  121377. * @param mesh The mesh the gizmo's should be attached to
  121378. */
  121379. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121380. /**
  121381. * If the position gizmo is enabled
  121382. */
  121383. set positionGizmoEnabled(value: boolean);
  121384. get positionGizmoEnabled(): boolean;
  121385. /**
  121386. * If the rotation gizmo is enabled
  121387. */
  121388. set rotationGizmoEnabled(value: boolean);
  121389. get rotationGizmoEnabled(): boolean;
  121390. /**
  121391. * If the scale gizmo is enabled
  121392. */
  121393. set scaleGizmoEnabled(value: boolean);
  121394. get scaleGizmoEnabled(): boolean;
  121395. /**
  121396. * If the boundingBox gizmo is enabled
  121397. */
  121398. set boundingBoxGizmoEnabled(value: boolean);
  121399. get boundingBoxGizmoEnabled(): boolean;
  121400. /**
  121401. * Disposes of the gizmo manager
  121402. */
  121403. dispose(): void;
  121404. }
  121405. }
  121406. declare module BABYLON {
  121407. /**
  121408. * A directional light is defined by a direction (what a surprise!).
  121409. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121410. * 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.
  121411. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121412. */
  121413. export class DirectionalLight extends ShadowLight {
  121414. private _shadowFrustumSize;
  121415. /**
  121416. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121417. */
  121418. get shadowFrustumSize(): number;
  121419. /**
  121420. * Specifies a fix frustum size for the shadow generation.
  121421. */
  121422. set shadowFrustumSize(value: number);
  121423. private _shadowOrthoScale;
  121424. /**
  121425. * Gets the shadow projection scale against the optimal computed one.
  121426. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121427. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121428. */
  121429. get shadowOrthoScale(): number;
  121430. /**
  121431. * Sets the shadow projection scale against the optimal computed one.
  121432. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121433. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121434. */
  121435. set shadowOrthoScale(value: number);
  121436. /**
  121437. * Automatically compute the projection matrix to best fit (including all the casters)
  121438. * on each frame.
  121439. */
  121440. autoUpdateExtends: boolean;
  121441. /**
  121442. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121443. * on each frame. autoUpdateExtends must be set to true for this to work
  121444. */
  121445. autoCalcShadowZBounds: boolean;
  121446. private _orthoLeft;
  121447. private _orthoRight;
  121448. private _orthoTop;
  121449. private _orthoBottom;
  121450. /**
  121451. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121452. * The directional light is emitted from everywhere in the given direction.
  121453. * It can cast shadows.
  121454. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121455. * @param name The friendly name of the light
  121456. * @param direction The direction of the light
  121457. * @param scene The scene the light belongs to
  121458. */
  121459. constructor(name: string, direction: Vector3, scene: Scene);
  121460. /**
  121461. * Returns the string "DirectionalLight".
  121462. * @return The class name
  121463. */
  121464. getClassName(): string;
  121465. /**
  121466. * Returns the integer 1.
  121467. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121468. */
  121469. getTypeID(): number;
  121470. /**
  121471. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121472. * Returns the DirectionalLight Shadow projection matrix.
  121473. */
  121474. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121475. /**
  121476. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121477. * Returns the DirectionalLight Shadow projection matrix.
  121478. */
  121479. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121480. /**
  121481. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121482. * Returns the DirectionalLight Shadow projection matrix.
  121483. */
  121484. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121485. protected _buildUniformLayout(): void;
  121486. /**
  121487. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121488. * @param effect The effect to update
  121489. * @param lightIndex The index of the light in the effect to update
  121490. * @returns The directional light
  121491. */
  121492. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121493. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121494. /**
  121495. * Gets the minZ used for shadow according to both the scene and the light.
  121496. *
  121497. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121498. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121499. * @param activeCamera The camera we are returning the min for
  121500. * @returns the depth min z
  121501. */
  121502. getDepthMinZ(activeCamera: Camera): number;
  121503. /**
  121504. * Gets the maxZ used for shadow according to both the scene and the light.
  121505. *
  121506. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121507. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121508. * @param activeCamera The camera we are returning the max for
  121509. * @returns the depth max z
  121510. */
  121511. getDepthMaxZ(activeCamera: Camera): number;
  121512. /**
  121513. * Prepares the list of defines specific to the light type.
  121514. * @param defines the list of defines
  121515. * @param lightIndex defines the index of the light for the effect
  121516. */
  121517. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121518. }
  121519. }
  121520. declare module BABYLON {
  121521. /**
  121522. * Class containing static functions to help procedurally build meshes
  121523. */
  121524. export class HemisphereBuilder {
  121525. /**
  121526. * Creates a hemisphere mesh
  121527. * @param name defines the name of the mesh
  121528. * @param options defines the options used to create the mesh
  121529. * @param scene defines the hosting scene
  121530. * @returns the hemisphere mesh
  121531. */
  121532. static CreateHemisphere(name: string, options: {
  121533. segments?: number;
  121534. diameter?: number;
  121535. sideOrientation?: number;
  121536. }, scene: any): Mesh;
  121537. }
  121538. }
  121539. declare module BABYLON {
  121540. /**
  121541. * A spot light is defined by a position, a direction, an angle, and an exponent.
  121542. * These values define a cone of light starting from the position, emitting toward the direction.
  121543. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  121544. * and the exponent defines the speed of the decay of the light with distance (reach).
  121545. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121546. */
  121547. export class SpotLight extends ShadowLight {
  121548. private _angle;
  121549. private _innerAngle;
  121550. private _cosHalfAngle;
  121551. private _lightAngleScale;
  121552. private _lightAngleOffset;
  121553. /**
  121554. * Gets the cone angle of the spot light in Radians.
  121555. */
  121556. get angle(): number;
  121557. /**
  121558. * Sets the cone angle of the spot light in Radians.
  121559. */
  121560. set angle(value: number);
  121561. /**
  121562. * Only used in gltf falloff mode, this defines the angle where
  121563. * the directional falloff will start before cutting at angle which could be seen
  121564. * as outer angle.
  121565. */
  121566. get innerAngle(): number;
  121567. /**
  121568. * Only used in gltf falloff mode, this defines the angle where
  121569. * the directional falloff will start before cutting at angle which could be seen
  121570. * as outer angle.
  121571. */
  121572. set innerAngle(value: number);
  121573. private _shadowAngleScale;
  121574. /**
  121575. * Allows scaling the angle of the light for shadow generation only.
  121576. */
  121577. get shadowAngleScale(): number;
  121578. /**
  121579. * Allows scaling the angle of the light for shadow generation only.
  121580. */
  121581. set shadowAngleScale(value: number);
  121582. /**
  121583. * The light decay speed with the distance from the emission spot.
  121584. */
  121585. exponent: number;
  121586. private _projectionTextureMatrix;
  121587. /**
  121588. * Allows reading the projecton texture
  121589. */
  121590. get projectionTextureMatrix(): Matrix;
  121591. protected _projectionTextureLightNear: number;
  121592. /**
  121593. * Gets the near clip of the Spotlight for texture projection.
  121594. */
  121595. get projectionTextureLightNear(): number;
  121596. /**
  121597. * Sets the near clip of the Spotlight for texture projection.
  121598. */
  121599. set projectionTextureLightNear(value: number);
  121600. protected _projectionTextureLightFar: number;
  121601. /**
  121602. * Gets the far clip of the Spotlight for texture projection.
  121603. */
  121604. get projectionTextureLightFar(): number;
  121605. /**
  121606. * Sets the far clip of the Spotlight for texture projection.
  121607. */
  121608. set projectionTextureLightFar(value: number);
  121609. protected _projectionTextureUpDirection: Vector3;
  121610. /**
  121611. * Gets the Up vector of the Spotlight for texture projection.
  121612. */
  121613. get projectionTextureUpDirection(): Vector3;
  121614. /**
  121615. * Sets the Up vector of the Spotlight for texture projection.
  121616. */
  121617. set projectionTextureUpDirection(value: Vector3);
  121618. private _projectionTexture;
  121619. /**
  121620. * Gets the projection texture of the light.
  121621. */
  121622. get projectionTexture(): Nullable<BaseTexture>;
  121623. /**
  121624. * Sets the projection texture of the light.
  121625. */
  121626. set projectionTexture(value: Nullable<BaseTexture>);
  121627. private _projectionTextureViewLightDirty;
  121628. private _projectionTextureProjectionLightDirty;
  121629. private _projectionTextureDirty;
  121630. private _projectionTextureViewTargetVector;
  121631. private _projectionTextureViewLightMatrix;
  121632. private _projectionTextureProjectionLightMatrix;
  121633. private _projectionTextureScalingMatrix;
  121634. /**
  121635. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  121636. * It can cast shadows.
  121637. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121638. * @param name The light friendly name
  121639. * @param position The position of the spot light in the scene
  121640. * @param direction The direction of the light in the scene
  121641. * @param angle The cone angle of the light in Radians
  121642. * @param exponent The light decay speed with the distance from the emission spot
  121643. * @param scene The scene the lights belongs to
  121644. */
  121645. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  121646. /**
  121647. * Returns the string "SpotLight".
  121648. * @returns the class name
  121649. */
  121650. getClassName(): string;
  121651. /**
  121652. * Returns the integer 2.
  121653. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121654. */
  121655. getTypeID(): number;
  121656. /**
  121657. * Overrides the direction setter to recompute the projection texture view light Matrix.
  121658. */
  121659. protected _setDirection(value: Vector3): void;
  121660. /**
  121661. * Overrides the position setter to recompute the projection texture view light Matrix.
  121662. */
  121663. protected _setPosition(value: Vector3): void;
  121664. /**
  121665. * 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.
  121666. * Returns the SpotLight.
  121667. */
  121668. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121669. protected _computeProjectionTextureViewLightMatrix(): void;
  121670. protected _computeProjectionTextureProjectionLightMatrix(): void;
  121671. /**
  121672. * Main function for light texture projection matrix computing.
  121673. */
  121674. protected _computeProjectionTextureMatrix(): void;
  121675. protected _buildUniformLayout(): void;
  121676. private _computeAngleValues;
  121677. /**
  121678. * Sets the passed Effect "effect" with the Light textures.
  121679. * @param effect The effect to update
  121680. * @param lightIndex The index of the light in the effect to update
  121681. * @returns The light
  121682. */
  121683. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  121684. /**
  121685. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  121686. * @param effect The effect to update
  121687. * @param lightIndex The index of the light in the effect to update
  121688. * @returns The spot light
  121689. */
  121690. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  121691. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121692. /**
  121693. * Disposes the light and the associated resources.
  121694. */
  121695. dispose(): void;
  121696. /**
  121697. * Prepares the list of defines specific to the light type.
  121698. * @param defines the list of defines
  121699. * @param lightIndex defines the index of the light for the effect
  121700. */
  121701. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121702. }
  121703. }
  121704. declare module BABYLON {
  121705. /**
  121706. * Gizmo that enables viewing a light
  121707. */
  121708. export class LightGizmo extends Gizmo {
  121709. private _lightMesh;
  121710. private _material;
  121711. private _cachedPosition;
  121712. private _cachedForward;
  121713. private _attachedMeshParent;
  121714. /**
  121715. * Creates a LightGizmo
  121716. * @param gizmoLayer The utility layer the gizmo will be added to
  121717. */
  121718. constructor(gizmoLayer?: UtilityLayerRenderer);
  121719. private _light;
  121720. /**
  121721. * The light that the gizmo is attached to
  121722. */
  121723. set light(light: Nullable<Light>);
  121724. get light(): Nullable<Light>;
  121725. /**
  121726. * Gets the material used to render the light gizmo
  121727. */
  121728. get material(): StandardMaterial;
  121729. /**
  121730. * @hidden
  121731. * Updates the gizmo to match the attached mesh's position/rotation
  121732. */
  121733. protected _update(): void;
  121734. private static _Scale;
  121735. /**
  121736. * Creates the lines for a light mesh
  121737. */
  121738. private static _CreateLightLines;
  121739. /**
  121740. * Disposes of the light gizmo
  121741. */
  121742. dispose(): void;
  121743. private static _CreateHemisphericLightMesh;
  121744. private static _CreatePointLightMesh;
  121745. private static _CreateSpotLightMesh;
  121746. private static _CreateDirectionalLightMesh;
  121747. }
  121748. }
  121749. declare module BABYLON {
  121750. /** @hidden */
  121751. export var backgroundFragmentDeclaration: {
  121752. name: string;
  121753. shader: string;
  121754. };
  121755. }
  121756. declare module BABYLON {
  121757. /** @hidden */
  121758. export var backgroundUboDeclaration: {
  121759. name: string;
  121760. shader: string;
  121761. };
  121762. }
  121763. declare module BABYLON {
  121764. /** @hidden */
  121765. export var backgroundPixelShader: {
  121766. name: string;
  121767. shader: string;
  121768. };
  121769. }
  121770. declare module BABYLON {
  121771. /** @hidden */
  121772. export var backgroundVertexDeclaration: {
  121773. name: string;
  121774. shader: string;
  121775. };
  121776. }
  121777. declare module BABYLON {
  121778. /** @hidden */
  121779. export var backgroundVertexShader: {
  121780. name: string;
  121781. shader: string;
  121782. };
  121783. }
  121784. declare module BABYLON {
  121785. /**
  121786. * Background material used to create an efficient environement around your scene.
  121787. */
  121788. export class BackgroundMaterial extends PushMaterial {
  121789. /**
  121790. * Standard reflectance value at parallel view angle.
  121791. */
  121792. static StandardReflectance0: number;
  121793. /**
  121794. * Standard reflectance value at grazing angle.
  121795. */
  121796. static StandardReflectance90: number;
  121797. protected _primaryColor: Color3;
  121798. /**
  121799. * Key light Color (multiply against the environement texture)
  121800. */
  121801. primaryColor: Color3;
  121802. protected __perceptualColor: Nullable<Color3>;
  121803. /**
  121804. * Experimental Internal Use Only.
  121805. *
  121806. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  121807. * This acts as a helper to set the primary color to a more "human friendly" value.
  121808. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  121809. * output color as close as possible from the chosen value.
  121810. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  121811. * part of lighting setup.)
  121812. */
  121813. get _perceptualColor(): Nullable<Color3>;
  121814. set _perceptualColor(value: Nullable<Color3>);
  121815. protected _primaryColorShadowLevel: float;
  121816. /**
  121817. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  121818. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  121819. */
  121820. get primaryColorShadowLevel(): float;
  121821. set primaryColorShadowLevel(value: float);
  121822. protected _primaryColorHighlightLevel: float;
  121823. /**
  121824. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  121825. * The primary color is used at the level chosen to define what the white area would look.
  121826. */
  121827. get primaryColorHighlightLevel(): float;
  121828. set primaryColorHighlightLevel(value: float);
  121829. protected _reflectionTexture: Nullable<BaseTexture>;
  121830. /**
  121831. * Reflection Texture used in the material.
  121832. * Should be author in a specific way for the best result (refer to the documentation).
  121833. */
  121834. reflectionTexture: Nullable<BaseTexture>;
  121835. protected _reflectionBlur: float;
  121836. /**
  121837. * Reflection Texture level of blur.
  121838. *
  121839. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  121840. * texture twice.
  121841. */
  121842. reflectionBlur: float;
  121843. protected _diffuseTexture: Nullable<BaseTexture>;
  121844. /**
  121845. * Diffuse Texture used in the material.
  121846. * Should be author in a specific way for the best result (refer to the documentation).
  121847. */
  121848. diffuseTexture: Nullable<BaseTexture>;
  121849. protected _shadowLights: Nullable<IShadowLight[]>;
  121850. /**
  121851. * Specify the list of lights casting shadow on the material.
  121852. * All scene shadow lights will be included if null.
  121853. */
  121854. shadowLights: Nullable<IShadowLight[]>;
  121855. protected _shadowLevel: float;
  121856. /**
  121857. * Helps adjusting the shadow to a softer level if required.
  121858. * 0 means black shadows and 1 means no shadows.
  121859. */
  121860. shadowLevel: float;
  121861. protected _sceneCenter: Vector3;
  121862. /**
  121863. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  121864. * It is usually zero but might be interesting to modify according to your setup.
  121865. */
  121866. sceneCenter: Vector3;
  121867. protected _opacityFresnel: boolean;
  121868. /**
  121869. * This helps specifying that the material is falling off to the sky box at grazing angle.
  121870. * This helps ensuring a nice transition when the camera goes under the ground.
  121871. */
  121872. opacityFresnel: boolean;
  121873. protected _reflectionFresnel: boolean;
  121874. /**
  121875. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  121876. * This helps adding a mirror texture on the ground.
  121877. */
  121878. reflectionFresnel: boolean;
  121879. protected _reflectionFalloffDistance: number;
  121880. /**
  121881. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  121882. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  121883. */
  121884. reflectionFalloffDistance: number;
  121885. protected _reflectionAmount: number;
  121886. /**
  121887. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  121888. */
  121889. reflectionAmount: number;
  121890. protected _reflectionReflectance0: number;
  121891. /**
  121892. * This specifies the weight of the reflection at grazing angle.
  121893. */
  121894. reflectionReflectance0: number;
  121895. protected _reflectionReflectance90: number;
  121896. /**
  121897. * This specifies the weight of the reflection at a perpendicular point of view.
  121898. */
  121899. reflectionReflectance90: number;
  121900. /**
  121901. * Sets the reflection reflectance fresnel values according to the default standard
  121902. * empirically know to work well :-)
  121903. */
  121904. set reflectionStandardFresnelWeight(value: number);
  121905. protected _useRGBColor: boolean;
  121906. /**
  121907. * Helps to directly use the maps channels instead of their level.
  121908. */
  121909. useRGBColor: boolean;
  121910. protected _enableNoise: boolean;
  121911. /**
  121912. * This helps reducing the banding effect that could occur on the background.
  121913. */
  121914. enableNoise: boolean;
  121915. /**
  121916. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121917. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  121918. * Recommended to be keep at 1.0 except for special cases.
  121919. */
  121920. get fovMultiplier(): number;
  121921. set fovMultiplier(value: number);
  121922. private _fovMultiplier;
  121923. /**
  121924. * Enable the FOV adjustment feature controlled by fovMultiplier.
  121925. */
  121926. useEquirectangularFOV: boolean;
  121927. private _maxSimultaneousLights;
  121928. /**
  121929. * Number of Simultaneous lights allowed on the material.
  121930. */
  121931. maxSimultaneousLights: int;
  121932. /**
  121933. * Default configuration related to image processing available in the Background Material.
  121934. */
  121935. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121936. /**
  121937. * Keep track of the image processing observer to allow dispose and replace.
  121938. */
  121939. private _imageProcessingObserver;
  121940. /**
  121941. * Attaches a new image processing configuration to the PBR Material.
  121942. * @param configuration (if null the scene configuration will be use)
  121943. */
  121944. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121945. /**
  121946. * Gets the image processing configuration used either in this material.
  121947. */
  121948. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  121949. /**
  121950. * Sets the Default image processing configuration used either in the this material.
  121951. *
  121952. * If sets to null, the scene one is in use.
  121953. */
  121954. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  121955. /**
  121956. * Gets wether the color curves effect is enabled.
  121957. */
  121958. get cameraColorCurvesEnabled(): boolean;
  121959. /**
  121960. * Sets wether the color curves effect is enabled.
  121961. */
  121962. set cameraColorCurvesEnabled(value: boolean);
  121963. /**
  121964. * Gets wether the color grading effect is enabled.
  121965. */
  121966. get cameraColorGradingEnabled(): boolean;
  121967. /**
  121968. * Gets wether the color grading effect is enabled.
  121969. */
  121970. set cameraColorGradingEnabled(value: boolean);
  121971. /**
  121972. * Gets wether tonemapping is enabled or not.
  121973. */
  121974. get cameraToneMappingEnabled(): boolean;
  121975. /**
  121976. * Sets wether tonemapping is enabled or not
  121977. */
  121978. set cameraToneMappingEnabled(value: boolean);
  121979. /**
  121980. * The camera exposure used on this material.
  121981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121982. * This corresponds to a photographic exposure.
  121983. */
  121984. get cameraExposure(): float;
  121985. /**
  121986. * The camera exposure used on this material.
  121987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121988. * This corresponds to a photographic exposure.
  121989. */
  121990. set cameraExposure(value: float);
  121991. /**
  121992. * Gets The camera contrast used on this material.
  121993. */
  121994. get cameraContrast(): float;
  121995. /**
  121996. * Sets The camera contrast used on this material.
  121997. */
  121998. set cameraContrast(value: float);
  121999. /**
  122000. * Gets the Color Grading 2D Lookup Texture.
  122001. */
  122002. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122003. /**
  122004. * Sets the Color Grading 2D Lookup Texture.
  122005. */
  122006. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122007. /**
  122008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122010. * 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;
  122011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122012. */
  122013. get cameraColorCurves(): Nullable<ColorCurves>;
  122014. /**
  122015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122017. * 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;
  122018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122019. */
  122020. set cameraColorCurves(value: Nullable<ColorCurves>);
  122021. /**
  122022. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122023. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122024. */
  122025. switchToBGR: boolean;
  122026. private _renderTargets;
  122027. private _reflectionControls;
  122028. private _white;
  122029. private _primaryShadowColor;
  122030. private _primaryHighlightColor;
  122031. /**
  122032. * Instantiates a Background Material in the given scene
  122033. * @param name The friendly name of the material
  122034. * @param scene The scene to add the material to
  122035. */
  122036. constructor(name: string, scene: Scene);
  122037. /**
  122038. * Gets a boolean indicating that current material needs to register RTT
  122039. */
  122040. get hasRenderTargetTextures(): boolean;
  122041. /**
  122042. * The entire material has been created in order to prevent overdraw.
  122043. * @returns false
  122044. */
  122045. needAlphaTesting(): boolean;
  122046. /**
  122047. * The entire material has been created in order to prevent overdraw.
  122048. * @returns true if blending is enable
  122049. */
  122050. needAlphaBlending(): boolean;
  122051. /**
  122052. * Checks wether the material is ready to be rendered for a given mesh.
  122053. * @param mesh The mesh to render
  122054. * @param subMesh The submesh to check against
  122055. * @param useInstances Specify wether or not the material is used with instances
  122056. * @returns true if all the dependencies are ready (Textures, Effects...)
  122057. */
  122058. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122059. /**
  122060. * Compute the primary color according to the chosen perceptual color.
  122061. */
  122062. private _computePrimaryColorFromPerceptualColor;
  122063. /**
  122064. * Compute the highlights and shadow colors according to their chosen levels.
  122065. */
  122066. private _computePrimaryColors;
  122067. /**
  122068. * Build the uniform buffer used in the material.
  122069. */
  122070. buildUniformLayout(): void;
  122071. /**
  122072. * Unbind the material.
  122073. */
  122074. unbind(): void;
  122075. /**
  122076. * Bind only the world matrix to the material.
  122077. * @param world The world matrix to bind.
  122078. */
  122079. bindOnlyWorldMatrix(world: Matrix): void;
  122080. /**
  122081. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122082. * @param world The world matrix to bind.
  122083. * @param subMesh The submesh to bind for.
  122084. */
  122085. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122086. /**
  122087. * Checks to see if a texture is used in the material.
  122088. * @param texture - Base texture to use.
  122089. * @returns - Boolean specifying if a texture is used in the material.
  122090. */
  122091. hasTexture(texture: BaseTexture): boolean;
  122092. /**
  122093. * Dispose the material.
  122094. * @param forceDisposeEffect Force disposal of the associated effect.
  122095. * @param forceDisposeTextures Force disposal of the associated textures.
  122096. */
  122097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122098. /**
  122099. * Clones the material.
  122100. * @param name The cloned name.
  122101. * @returns The cloned material.
  122102. */
  122103. clone(name: string): BackgroundMaterial;
  122104. /**
  122105. * Serializes the current material to its JSON representation.
  122106. * @returns The JSON representation.
  122107. */
  122108. serialize(): any;
  122109. /**
  122110. * Gets the class name of the material
  122111. * @returns "BackgroundMaterial"
  122112. */
  122113. getClassName(): string;
  122114. /**
  122115. * Parse a JSON input to create back a background material.
  122116. * @param source The JSON data to parse
  122117. * @param scene The scene to create the parsed material in
  122118. * @param rootUrl The root url of the assets the material depends upon
  122119. * @returns the instantiated BackgroundMaterial.
  122120. */
  122121. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122122. }
  122123. }
  122124. declare module BABYLON {
  122125. /**
  122126. * Represents the different options available during the creation of
  122127. * a Environment helper.
  122128. *
  122129. * This can control the default ground, skybox and image processing setup of your scene.
  122130. */
  122131. export interface IEnvironmentHelperOptions {
  122132. /**
  122133. * Specifies wether or not to create a ground.
  122134. * True by default.
  122135. */
  122136. createGround: boolean;
  122137. /**
  122138. * Specifies the ground size.
  122139. * 15 by default.
  122140. */
  122141. groundSize: number;
  122142. /**
  122143. * The texture used on the ground for the main color.
  122144. * Comes from the BabylonJS CDN by default.
  122145. *
  122146. * Remarks: Can be either a texture or a url.
  122147. */
  122148. groundTexture: string | BaseTexture;
  122149. /**
  122150. * The color mixed in the ground texture by default.
  122151. * BabylonJS clearColor by default.
  122152. */
  122153. groundColor: Color3;
  122154. /**
  122155. * Specifies the ground opacity.
  122156. * 1 by default.
  122157. */
  122158. groundOpacity: number;
  122159. /**
  122160. * Enables the ground to receive shadows.
  122161. * True by default.
  122162. */
  122163. enableGroundShadow: boolean;
  122164. /**
  122165. * Helps preventing the shadow to be fully black on the ground.
  122166. * 0.5 by default.
  122167. */
  122168. groundShadowLevel: number;
  122169. /**
  122170. * Creates a mirror texture attach to the ground.
  122171. * false by default.
  122172. */
  122173. enableGroundMirror: boolean;
  122174. /**
  122175. * Specifies the ground mirror size ratio.
  122176. * 0.3 by default as the default kernel is 64.
  122177. */
  122178. groundMirrorSizeRatio: number;
  122179. /**
  122180. * Specifies the ground mirror blur kernel size.
  122181. * 64 by default.
  122182. */
  122183. groundMirrorBlurKernel: number;
  122184. /**
  122185. * Specifies the ground mirror visibility amount.
  122186. * 1 by default
  122187. */
  122188. groundMirrorAmount: number;
  122189. /**
  122190. * Specifies the ground mirror reflectance weight.
  122191. * This uses the standard weight of the background material to setup the fresnel effect
  122192. * of the mirror.
  122193. * 1 by default.
  122194. */
  122195. groundMirrorFresnelWeight: number;
  122196. /**
  122197. * Specifies the ground mirror Falloff distance.
  122198. * This can helps reducing the size of the reflection.
  122199. * 0 by Default.
  122200. */
  122201. groundMirrorFallOffDistance: number;
  122202. /**
  122203. * Specifies the ground mirror texture type.
  122204. * Unsigned Int by Default.
  122205. */
  122206. groundMirrorTextureType: number;
  122207. /**
  122208. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122209. * the shown objects.
  122210. */
  122211. groundYBias: number;
  122212. /**
  122213. * Specifies wether or not to create a skybox.
  122214. * True by default.
  122215. */
  122216. createSkybox: boolean;
  122217. /**
  122218. * Specifies the skybox size.
  122219. * 20 by default.
  122220. */
  122221. skyboxSize: number;
  122222. /**
  122223. * The texture used on the skybox for the main color.
  122224. * Comes from the BabylonJS CDN by default.
  122225. *
  122226. * Remarks: Can be either a texture or a url.
  122227. */
  122228. skyboxTexture: string | BaseTexture;
  122229. /**
  122230. * The color mixed in the skybox texture by default.
  122231. * BabylonJS clearColor by default.
  122232. */
  122233. skyboxColor: Color3;
  122234. /**
  122235. * The background rotation around the Y axis of the scene.
  122236. * This helps aligning the key lights of your scene with the background.
  122237. * 0 by default.
  122238. */
  122239. backgroundYRotation: number;
  122240. /**
  122241. * Compute automatically the size of the elements to best fit with the scene.
  122242. */
  122243. sizeAuto: boolean;
  122244. /**
  122245. * Default position of the rootMesh if autoSize is not true.
  122246. */
  122247. rootPosition: Vector3;
  122248. /**
  122249. * Sets up the image processing in the scene.
  122250. * true by default.
  122251. */
  122252. setupImageProcessing: boolean;
  122253. /**
  122254. * The texture used as your environment texture in the scene.
  122255. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122256. *
  122257. * Remarks: Can be either a texture or a url.
  122258. */
  122259. environmentTexture: string | BaseTexture;
  122260. /**
  122261. * The value of the exposure to apply to the scene.
  122262. * 0.6 by default if setupImageProcessing is true.
  122263. */
  122264. cameraExposure: number;
  122265. /**
  122266. * The value of the contrast to apply to the scene.
  122267. * 1.6 by default if setupImageProcessing is true.
  122268. */
  122269. cameraContrast: number;
  122270. /**
  122271. * Specifies wether or not tonemapping should be enabled in the scene.
  122272. * true by default if setupImageProcessing is true.
  122273. */
  122274. toneMappingEnabled: boolean;
  122275. }
  122276. /**
  122277. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122278. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122279. * It also helps with the default setup of your imageProcessing configuration.
  122280. */
  122281. export class EnvironmentHelper {
  122282. /**
  122283. * Default ground texture URL.
  122284. */
  122285. private static _groundTextureCDNUrl;
  122286. /**
  122287. * Default skybox texture URL.
  122288. */
  122289. private static _skyboxTextureCDNUrl;
  122290. /**
  122291. * Default environment texture URL.
  122292. */
  122293. private static _environmentTextureCDNUrl;
  122294. /**
  122295. * Creates the default options for the helper.
  122296. */
  122297. private static _getDefaultOptions;
  122298. private _rootMesh;
  122299. /**
  122300. * Gets the root mesh created by the helper.
  122301. */
  122302. get rootMesh(): Mesh;
  122303. private _skybox;
  122304. /**
  122305. * Gets the skybox created by the helper.
  122306. */
  122307. get skybox(): Nullable<Mesh>;
  122308. private _skyboxTexture;
  122309. /**
  122310. * Gets the skybox texture created by the helper.
  122311. */
  122312. get skyboxTexture(): Nullable<BaseTexture>;
  122313. private _skyboxMaterial;
  122314. /**
  122315. * Gets the skybox material created by the helper.
  122316. */
  122317. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122318. private _ground;
  122319. /**
  122320. * Gets the ground mesh created by the helper.
  122321. */
  122322. get ground(): Nullable<Mesh>;
  122323. private _groundTexture;
  122324. /**
  122325. * Gets the ground texture created by the helper.
  122326. */
  122327. get groundTexture(): Nullable<BaseTexture>;
  122328. private _groundMirror;
  122329. /**
  122330. * Gets the ground mirror created by the helper.
  122331. */
  122332. get groundMirror(): Nullable<MirrorTexture>;
  122333. /**
  122334. * Gets the ground mirror render list to helps pushing the meshes
  122335. * you wish in the ground reflection.
  122336. */
  122337. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122338. private _groundMaterial;
  122339. /**
  122340. * Gets the ground material created by the helper.
  122341. */
  122342. get groundMaterial(): Nullable<BackgroundMaterial>;
  122343. /**
  122344. * Stores the creation options.
  122345. */
  122346. private readonly _scene;
  122347. private _options;
  122348. /**
  122349. * This observable will be notified with any error during the creation of the environment,
  122350. * mainly texture creation errors.
  122351. */
  122352. onErrorObservable: Observable<{
  122353. message?: string;
  122354. exception?: any;
  122355. }>;
  122356. /**
  122357. * constructor
  122358. * @param options Defines the options we want to customize the helper
  122359. * @param scene The scene to add the material to
  122360. */
  122361. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122362. /**
  122363. * Updates the background according to the new options
  122364. * @param options
  122365. */
  122366. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122367. /**
  122368. * Sets the primary color of all the available elements.
  122369. * @param color the main color to affect to the ground and the background
  122370. */
  122371. setMainColor(color: Color3): void;
  122372. /**
  122373. * Setup the image processing according to the specified options.
  122374. */
  122375. private _setupImageProcessing;
  122376. /**
  122377. * Setup the environment texture according to the specified options.
  122378. */
  122379. private _setupEnvironmentTexture;
  122380. /**
  122381. * Setup the background according to the specified options.
  122382. */
  122383. private _setupBackground;
  122384. /**
  122385. * Get the scene sizes according to the setup.
  122386. */
  122387. private _getSceneSize;
  122388. /**
  122389. * Setup the ground according to the specified options.
  122390. */
  122391. private _setupGround;
  122392. /**
  122393. * Setup the ground material according to the specified options.
  122394. */
  122395. private _setupGroundMaterial;
  122396. /**
  122397. * Setup the ground diffuse texture according to the specified options.
  122398. */
  122399. private _setupGroundDiffuseTexture;
  122400. /**
  122401. * Setup the ground mirror texture according to the specified options.
  122402. */
  122403. private _setupGroundMirrorTexture;
  122404. /**
  122405. * Setup the ground to receive the mirror texture.
  122406. */
  122407. private _setupMirrorInGroundMaterial;
  122408. /**
  122409. * Setup the skybox according to the specified options.
  122410. */
  122411. private _setupSkybox;
  122412. /**
  122413. * Setup the skybox material according to the specified options.
  122414. */
  122415. private _setupSkyboxMaterial;
  122416. /**
  122417. * Setup the skybox reflection texture according to the specified options.
  122418. */
  122419. private _setupSkyboxReflectionTexture;
  122420. private _errorHandler;
  122421. /**
  122422. * Dispose all the elements created by the Helper.
  122423. */
  122424. dispose(): void;
  122425. }
  122426. }
  122427. declare module BABYLON {
  122428. /**
  122429. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122430. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122431. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122432. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122433. */
  122434. export class PhotoDome extends TransformNode {
  122435. /**
  122436. * Define the image as a Monoscopic panoramic 360 image.
  122437. */
  122438. static readonly MODE_MONOSCOPIC: number;
  122439. /**
  122440. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122441. */
  122442. static readonly MODE_TOPBOTTOM: number;
  122443. /**
  122444. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122445. */
  122446. static readonly MODE_SIDEBYSIDE: number;
  122447. private _useDirectMapping;
  122448. /**
  122449. * The texture being displayed on the sphere
  122450. */
  122451. protected _photoTexture: Texture;
  122452. /**
  122453. * Gets or sets the texture being displayed on the sphere
  122454. */
  122455. get photoTexture(): Texture;
  122456. set photoTexture(value: Texture);
  122457. /**
  122458. * Observable raised when an error occured while loading the 360 image
  122459. */
  122460. onLoadErrorObservable: Observable<string>;
  122461. /**
  122462. * The skybox material
  122463. */
  122464. protected _material: BackgroundMaterial;
  122465. /**
  122466. * The surface used for the skybox
  122467. */
  122468. protected _mesh: Mesh;
  122469. /**
  122470. * Gets the mesh used for the skybox.
  122471. */
  122472. get mesh(): Mesh;
  122473. /**
  122474. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122475. * Also see the options.resolution property.
  122476. */
  122477. get fovMultiplier(): number;
  122478. set fovMultiplier(value: number);
  122479. private _imageMode;
  122480. /**
  122481. * Gets or set the current video mode for the video. It can be:
  122482. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122483. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122484. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122485. */
  122486. get imageMode(): number;
  122487. set imageMode(value: number);
  122488. /**
  122489. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122490. * @param name Element's name, child elements will append suffixes for their own names.
  122491. * @param urlsOfPhoto defines the url of the photo to display
  122492. * @param options defines an object containing optional or exposed sub element properties
  122493. * @param onError defines a callback called when an error occured while loading the texture
  122494. */
  122495. constructor(name: string, urlOfPhoto: string, options: {
  122496. resolution?: number;
  122497. size?: number;
  122498. useDirectMapping?: boolean;
  122499. faceForward?: boolean;
  122500. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  122501. private _onBeforeCameraRenderObserver;
  122502. private _changeImageMode;
  122503. /**
  122504. * Releases resources associated with this node.
  122505. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122506. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122507. */
  122508. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122509. }
  122510. }
  122511. declare module BABYLON {
  122512. /**
  122513. * Class used to host RGBD texture specific utilities
  122514. */
  122515. export class RGBDTextureTools {
  122516. /**
  122517. * Expand the RGBD Texture from RGBD to Half Float if possible.
  122518. * @param texture the texture to expand.
  122519. */
  122520. static ExpandRGBDTexture(texture: Texture): void;
  122521. }
  122522. }
  122523. declare module BABYLON {
  122524. /**
  122525. * Class used to host texture specific utilities
  122526. */
  122527. export class BRDFTextureTools {
  122528. /**
  122529. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  122530. * @param scene defines the hosting scene
  122531. * @returns the environment BRDF texture
  122532. */
  122533. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  122534. private static _environmentBRDFBase64Texture;
  122535. }
  122536. }
  122537. declare module BABYLON {
  122538. /**
  122539. * @hidden
  122540. */
  122541. export interface IMaterialClearCoatDefines {
  122542. CLEARCOAT: boolean;
  122543. CLEARCOAT_DEFAULTIOR: boolean;
  122544. CLEARCOAT_TEXTURE: boolean;
  122545. CLEARCOAT_TEXTUREDIRECTUV: number;
  122546. CLEARCOAT_BUMP: boolean;
  122547. CLEARCOAT_BUMPDIRECTUV: number;
  122548. CLEARCOAT_TINT: boolean;
  122549. CLEARCOAT_TINT_TEXTURE: boolean;
  122550. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122551. /** @hidden */
  122552. _areTexturesDirty: boolean;
  122553. }
  122554. /**
  122555. * Define the code related to the clear coat parameters of the pbr material.
  122556. */
  122557. export class PBRClearCoatConfiguration {
  122558. /**
  122559. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122560. * The default fits with a polyurethane material.
  122561. */
  122562. private static readonly _DefaultIndexOfRefraction;
  122563. private _isEnabled;
  122564. /**
  122565. * Defines if the clear coat is enabled in the material.
  122566. */
  122567. isEnabled: boolean;
  122568. /**
  122569. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  122570. */
  122571. intensity: number;
  122572. /**
  122573. * Defines the clear coat layer roughness.
  122574. */
  122575. roughness: number;
  122576. private _indexOfRefraction;
  122577. /**
  122578. * Defines the index of refraction of the clear coat.
  122579. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122580. * The default fits with a polyurethane material.
  122581. * Changing the default value is more performance intensive.
  122582. */
  122583. indexOfRefraction: number;
  122584. private _texture;
  122585. /**
  122586. * Stores the clear coat values in a texture.
  122587. */
  122588. texture: Nullable<BaseTexture>;
  122589. private _bumpTexture;
  122590. /**
  122591. * Define the clear coat specific bump texture.
  122592. */
  122593. bumpTexture: Nullable<BaseTexture>;
  122594. private _isTintEnabled;
  122595. /**
  122596. * Defines if the clear coat tint is enabled in the material.
  122597. */
  122598. isTintEnabled: boolean;
  122599. /**
  122600. * Defines the clear coat tint of the material.
  122601. * This is only use if tint is enabled
  122602. */
  122603. tintColor: Color3;
  122604. /**
  122605. * Defines the distance at which the tint color should be found in the
  122606. * clear coat media.
  122607. * This is only use if tint is enabled
  122608. */
  122609. tintColorAtDistance: number;
  122610. /**
  122611. * Defines the clear coat layer thickness.
  122612. * This is only use if tint is enabled
  122613. */
  122614. tintThickness: number;
  122615. private _tintTexture;
  122616. /**
  122617. * Stores the clear tint values in a texture.
  122618. * rgb is tint
  122619. * a is a thickness factor
  122620. */
  122621. tintTexture: Nullable<BaseTexture>;
  122622. /** @hidden */
  122623. private _internalMarkAllSubMeshesAsTexturesDirty;
  122624. /** @hidden */
  122625. _markAllSubMeshesAsTexturesDirty(): void;
  122626. /**
  122627. * Instantiate a new istance of clear coat configuration.
  122628. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122629. */
  122630. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122631. /**
  122632. * Gets wehter the submesh is ready to be used or not.
  122633. * @param defines the list of "defines" to update.
  122634. * @param scene defines the scene the material belongs to.
  122635. * @param engine defines the engine the material belongs to.
  122636. * @param disableBumpMap defines wether the material disables bump or not.
  122637. * @returns - boolean indicating that the submesh is ready or not.
  122638. */
  122639. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  122640. /**
  122641. * Checks to see if a texture is used in the material.
  122642. * @param defines the list of "defines" to update.
  122643. * @param scene defines the scene to the material belongs to.
  122644. */
  122645. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  122646. /**
  122647. * Binds the material data.
  122648. * @param uniformBuffer defines the Uniform buffer to fill in.
  122649. * @param scene defines the scene the material belongs to.
  122650. * @param engine defines the engine the material belongs to.
  122651. * @param disableBumpMap defines wether the material disables bump or not.
  122652. * @param isFrozen defines wether the material is frozen or not.
  122653. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122654. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122655. */
  122656. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  122657. /**
  122658. * Checks to see if a texture is used in the material.
  122659. * @param texture - Base texture to use.
  122660. * @returns - Boolean specifying if a texture is used in the material.
  122661. */
  122662. hasTexture(texture: BaseTexture): boolean;
  122663. /**
  122664. * Returns an array of the actively used textures.
  122665. * @param activeTextures Array of BaseTextures
  122666. */
  122667. getActiveTextures(activeTextures: BaseTexture[]): void;
  122668. /**
  122669. * Returns the animatable textures.
  122670. * @param animatables Array of animatable textures.
  122671. */
  122672. getAnimatables(animatables: IAnimatable[]): void;
  122673. /**
  122674. * Disposes the resources of the material.
  122675. * @param forceDisposeTextures - Forces the disposal of all textures.
  122676. */
  122677. dispose(forceDisposeTextures?: boolean): void;
  122678. /**
  122679. * Get the current class name of the texture useful for serialization or dynamic coding.
  122680. * @returns "PBRClearCoatConfiguration"
  122681. */
  122682. getClassName(): string;
  122683. /**
  122684. * Add fallbacks to the effect fallbacks list.
  122685. * @param defines defines the Base texture to use.
  122686. * @param fallbacks defines the current fallback list.
  122687. * @param currentRank defines the current fallback rank.
  122688. * @returns the new fallback rank.
  122689. */
  122690. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122691. /**
  122692. * Add the required uniforms to the current list.
  122693. * @param uniforms defines the current uniform list.
  122694. */
  122695. static AddUniforms(uniforms: string[]): void;
  122696. /**
  122697. * Add the required samplers to the current list.
  122698. * @param samplers defines the current sampler list.
  122699. */
  122700. static AddSamplers(samplers: string[]): void;
  122701. /**
  122702. * Add the required uniforms to the current buffer.
  122703. * @param uniformBuffer defines the current uniform buffer.
  122704. */
  122705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122706. /**
  122707. * Makes a duplicate of the current configuration into another one.
  122708. * @param clearCoatConfiguration define the config where to copy the info
  122709. */
  122710. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  122711. /**
  122712. * Serializes this clear coat configuration.
  122713. * @returns - An object with the serialized config.
  122714. */
  122715. serialize(): any;
  122716. /**
  122717. * Parses a anisotropy Configuration from a serialized object.
  122718. * @param source - Serialized object.
  122719. * @param scene Defines the scene we are parsing for
  122720. * @param rootUrl Defines the rootUrl to load from
  122721. */
  122722. parse(source: any, scene: Scene, rootUrl: string): void;
  122723. }
  122724. }
  122725. declare module BABYLON {
  122726. /**
  122727. * @hidden
  122728. */
  122729. export interface IMaterialAnisotropicDefines {
  122730. ANISOTROPIC: boolean;
  122731. ANISOTROPIC_TEXTURE: boolean;
  122732. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122733. MAINUV1: boolean;
  122734. _areTexturesDirty: boolean;
  122735. _needUVs: boolean;
  122736. }
  122737. /**
  122738. * Define the code related to the anisotropic parameters of the pbr material.
  122739. */
  122740. export class PBRAnisotropicConfiguration {
  122741. private _isEnabled;
  122742. /**
  122743. * Defines if the anisotropy is enabled in the material.
  122744. */
  122745. isEnabled: boolean;
  122746. /**
  122747. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  122748. */
  122749. intensity: number;
  122750. /**
  122751. * Defines if the effect is along the tangents, bitangents or in between.
  122752. * By default, the effect is "strectching" the highlights along the tangents.
  122753. */
  122754. direction: Vector2;
  122755. private _texture;
  122756. /**
  122757. * Stores the anisotropy values in a texture.
  122758. * rg is direction (like normal from -1 to 1)
  122759. * b is a intensity
  122760. */
  122761. texture: Nullable<BaseTexture>;
  122762. /** @hidden */
  122763. private _internalMarkAllSubMeshesAsTexturesDirty;
  122764. /** @hidden */
  122765. _markAllSubMeshesAsTexturesDirty(): void;
  122766. /**
  122767. * Instantiate a new istance of anisotropy configuration.
  122768. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122769. */
  122770. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122771. /**
  122772. * Specifies that the submesh is ready to be used.
  122773. * @param defines the list of "defines" to update.
  122774. * @param scene defines the scene the material belongs to.
  122775. * @returns - boolean indicating that the submesh is ready or not.
  122776. */
  122777. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  122778. /**
  122779. * Checks to see if a texture is used in the material.
  122780. * @param defines the list of "defines" to update.
  122781. * @param mesh the mesh we are preparing the defines for.
  122782. * @param scene defines the scene the material belongs to.
  122783. */
  122784. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  122785. /**
  122786. * Binds the material data.
  122787. * @param uniformBuffer defines the Uniform buffer to fill in.
  122788. * @param scene defines the scene the material belongs to.
  122789. * @param isFrozen defines wether the material is frozen or not.
  122790. */
  122791. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122792. /**
  122793. * Checks to see if a texture is used in the material.
  122794. * @param texture - Base texture to use.
  122795. * @returns - Boolean specifying if a texture is used in the material.
  122796. */
  122797. hasTexture(texture: BaseTexture): boolean;
  122798. /**
  122799. * Returns an array of the actively used textures.
  122800. * @param activeTextures Array of BaseTextures
  122801. */
  122802. getActiveTextures(activeTextures: BaseTexture[]): void;
  122803. /**
  122804. * Returns the animatable textures.
  122805. * @param animatables Array of animatable textures.
  122806. */
  122807. getAnimatables(animatables: IAnimatable[]): void;
  122808. /**
  122809. * Disposes the resources of the material.
  122810. * @param forceDisposeTextures - Forces the disposal of all textures.
  122811. */
  122812. dispose(forceDisposeTextures?: boolean): void;
  122813. /**
  122814. * Get the current class name of the texture useful for serialization or dynamic coding.
  122815. * @returns "PBRAnisotropicConfiguration"
  122816. */
  122817. getClassName(): string;
  122818. /**
  122819. * Add fallbacks to the effect fallbacks list.
  122820. * @param defines defines the Base texture to use.
  122821. * @param fallbacks defines the current fallback list.
  122822. * @param currentRank defines the current fallback rank.
  122823. * @returns the new fallback rank.
  122824. */
  122825. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122826. /**
  122827. * Add the required uniforms to the current list.
  122828. * @param uniforms defines the current uniform list.
  122829. */
  122830. static AddUniforms(uniforms: string[]): void;
  122831. /**
  122832. * Add the required uniforms to the current buffer.
  122833. * @param uniformBuffer defines the current uniform buffer.
  122834. */
  122835. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122836. /**
  122837. * Add the required samplers to the current list.
  122838. * @param samplers defines the current sampler list.
  122839. */
  122840. static AddSamplers(samplers: string[]): void;
  122841. /**
  122842. * Makes a duplicate of the current configuration into another one.
  122843. * @param anisotropicConfiguration define the config where to copy the info
  122844. */
  122845. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  122846. /**
  122847. * Serializes this anisotropy configuration.
  122848. * @returns - An object with the serialized config.
  122849. */
  122850. serialize(): any;
  122851. /**
  122852. * Parses a anisotropy Configuration from a serialized object.
  122853. * @param source - Serialized object.
  122854. * @param scene Defines the scene we are parsing for
  122855. * @param rootUrl Defines the rootUrl to load from
  122856. */
  122857. parse(source: any, scene: Scene, rootUrl: string): void;
  122858. }
  122859. }
  122860. declare module BABYLON {
  122861. /**
  122862. * @hidden
  122863. */
  122864. export interface IMaterialBRDFDefines {
  122865. BRDF_V_HEIGHT_CORRELATED: boolean;
  122866. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122867. SPHERICAL_HARMONICS: boolean;
  122868. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122869. /** @hidden */
  122870. _areMiscDirty: boolean;
  122871. }
  122872. /**
  122873. * Define the code related to the BRDF parameters of the pbr material.
  122874. */
  122875. export class PBRBRDFConfiguration {
  122876. /**
  122877. * Default value used for the energy conservation.
  122878. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122879. */
  122880. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  122881. /**
  122882. * Default value used for the Smith Visibility Height Correlated mode.
  122883. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122884. */
  122885. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  122886. /**
  122887. * Default value used for the IBL diffuse part.
  122888. * This can help switching back to the polynomials mode globally which is a tiny bit
  122889. * less GPU intensive at the drawback of a lower quality.
  122890. */
  122891. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  122892. /**
  122893. * Default value used for activating energy conservation for the specular workflow.
  122894. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122895. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122896. */
  122897. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  122898. private _useEnergyConservation;
  122899. /**
  122900. * Defines if the material uses energy conservation.
  122901. */
  122902. useEnergyConservation: boolean;
  122903. private _useSmithVisibilityHeightCorrelated;
  122904. /**
  122905. * LEGACY Mode set to false
  122906. * Defines if the material uses height smith correlated visibility term.
  122907. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  122908. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  122909. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  122910. * Not relying on height correlated will also disable energy conservation.
  122911. */
  122912. useSmithVisibilityHeightCorrelated: boolean;
  122913. private _useSphericalHarmonics;
  122914. /**
  122915. * LEGACY Mode set to false
  122916. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  122917. * diffuse part of the IBL.
  122918. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  122919. * to the ground truth.
  122920. */
  122921. useSphericalHarmonics: boolean;
  122922. private _useSpecularGlossinessInputEnergyConservation;
  122923. /**
  122924. * Defines if the material uses energy conservation, when the specular workflow is active.
  122925. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122926. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122927. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  122928. */
  122929. useSpecularGlossinessInputEnergyConservation: boolean;
  122930. /** @hidden */
  122931. private _internalMarkAllSubMeshesAsMiscDirty;
  122932. /** @hidden */
  122933. _markAllSubMeshesAsMiscDirty(): void;
  122934. /**
  122935. * Instantiate a new istance of clear coat configuration.
  122936. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  122937. */
  122938. constructor(markAllSubMeshesAsMiscDirty: () => void);
  122939. /**
  122940. * Checks to see if a texture is used in the material.
  122941. * @param defines the list of "defines" to update.
  122942. */
  122943. prepareDefines(defines: IMaterialBRDFDefines): void;
  122944. /**
  122945. * Get the current class name of the texture useful for serialization or dynamic coding.
  122946. * @returns "PBRClearCoatConfiguration"
  122947. */
  122948. getClassName(): string;
  122949. /**
  122950. * Makes a duplicate of the current configuration into another one.
  122951. * @param brdfConfiguration define the config where to copy the info
  122952. */
  122953. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  122954. /**
  122955. * Serializes this BRDF configuration.
  122956. * @returns - An object with the serialized config.
  122957. */
  122958. serialize(): any;
  122959. /**
  122960. * Parses a anisotropy Configuration from a serialized object.
  122961. * @param source - Serialized object.
  122962. * @param scene Defines the scene we are parsing for
  122963. * @param rootUrl Defines the rootUrl to load from
  122964. */
  122965. parse(source: any, scene: Scene, rootUrl: string): void;
  122966. }
  122967. }
  122968. declare module BABYLON {
  122969. /**
  122970. * @hidden
  122971. */
  122972. export interface IMaterialSheenDefines {
  122973. SHEEN: boolean;
  122974. SHEEN_TEXTURE: boolean;
  122975. SHEEN_TEXTUREDIRECTUV: number;
  122976. SHEEN_LINKWITHALBEDO: boolean;
  122977. /** @hidden */
  122978. _areTexturesDirty: boolean;
  122979. }
  122980. /**
  122981. * Define the code related to the Sheen parameters of the pbr material.
  122982. */
  122983. export class PBRSheenConfiguration {
  122984. private _isEnabled;
  122985. /**
  122986. * Defines if the material uses sheen.
  122987. */
  122988. isEnabled: boolean;
  122989. private _linkSheenWithAlbedo;
  122990. /**
  122991. * Defines if the sheen is linked to the sheen color.
  122992. */
  122993. linkSheenWithAlbedo: boolean;
  122994. /**
  122995. * Defines the sheen intensity.
  122996. */
  122997. intensity: number;
  122998. /**
  122999. * Defines the sheen color.
  123000. */
  123001. color: Color3;
  123002. private _texture;
  123003. /**
  123004. * Stores the sheen tint values in a texture.
  123005. * rgb is tint
  123006. * a is a intensity
  123007. */
  123008. texture: Nullable<BaseTexture>;
  123009. /** @hidden */
  123010. private _internalMarkAllSubMeshesAsTexturesDirty;
  123011. /** @hidden */
  123012. _markAllSubMeshesAsTexturesDirty(): void;
  123013. /**
  123014. * Instantiate a new istance of clear coat configuration.
  123015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123016. */
  123017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123018. /**
  123019. * Specifies that the submesh is ready to be used.
  123020. * @param defines the list of "defines" to update.
  123021. * @param scene defines the scene the material belongs to.
  123022. * @returns - boolean indicating that the submesh is ready or not.
  123023. */
  123024. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123025. /**
  123026. * Checks to see if a texture is used in the material.
  123027. * @param defines the list of "defines" to update.
  123028. * @param scene defines the scene the material belongs to.
  123029. */
  123030. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123031. /**
  123032. * Binds the material data.
  123033. * @param uniformBuffer defines the Uniform buffer to fill in.
  123034. * @param scene defines the scene the material belongs to.
  123035. * @param isFrozen defines wether the material is frozen or not.
  123036. */
  123037. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123038. /**
  123039. * Checks to see if a texture is used in the material.
  123040. * @param texture - Base texture to use.
  123041. * @returns - Boolean specifying if a texture is used in the material.
  123042. */
  123043. hasTexture(texture: BaseTexture): boolean;
  123044. /**
  123045. * Returns an array of the actively used textures.
  123046. * @param activeTextures Array of BaseTextures
  123047. */
  123048. getActiveTextures(activeTextures: BaseTexture[]): void;
  123049. /**
  123050. * Returns the animatable textures.
  123051. * @param animatables Array of animatable textures.
  123052. */
  123053. getAnimatables(animatables: IAnimatable[]): void;
  123054. /**
  123055. * Disposes the resources of the material.
  123056. * @param forceDisposeTextures - Forces the disposal of all textures.
  123057. */
  123058. dispose(forceDisposeTextures?: boolean): void;
  123059. /**
  123060. * Get the current class name of the texture useful for serialization or dynamic coding.
  123061. * @returns "PBRSheenConfiguration"
  123062. */
  123063. getClassName(): string;
  123064. /**
  123065. * Add fallbacks to the effect fallbacks list.
  123066. * @param defines defines the Base texture to use.
  123067. * @param fallbacks defines the current fallback list.
  123068. * @param currentRank defines the current fallback rank.
  123069. * @returns the new fallback rank.
  123070. */
  123071. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123072. /**
  123073. * Add the required uniforms to the current list.
  123074. * @param uniforms defines the current uniform list.
  123075. */
  123076. static AddUniforms(uniforms: string[]): void;
  123077. /**
  123078. * Add the required uniforms to the current buffer.
  123079. * @param uniformBuffer defines the current uniform buffer.
  123080. */
  123081. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123082. /**
  123083. * Add the required samplers to the current list.
  123084. * @param samplers defines the current sampler list.
  123085. */
  123086. static AddSamplers(samplers: string[]): void;
  123087. /**
  123088. * Makes a duplicate of the current configuration into another one.
  123089. * @param sheenConfiguration define the config where to copy the info
  123090. */
  123091. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123092. /**
  123093. * Serializes this BRDF configuration.
  123094. * @returns - An object with the serialized config.
  123095. */
  123096. serialize(): any;
  123097. /**
  123098. * Parses a anisotropy Configuration from a serialized object.
  123099. * @param source - Serialized object.
  123100. * @param scene Defines the scene we are parsing for
  123101. * @param rootUrl Defines the rootUrl to load from
  123102. */
  123103. parse(source: any, scene: Scene, rootUrl: string): void;
  123104. }
  123105. }
  123106. declare module BABYLON {
  123107. /**
  123108. * @hidden
  123109. */
  123110. export interface IMaterialSubSurfaceDefines {
  123111. SUBSURFACE: boolean;
  123112. SS_REFRACTION: boolean;
  123113. SS_TRANSLUCENCY: boolean;
  123114. SS_SCATERRING: boolean;
  123115. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123116. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123117. SS_REFRACTIONMAP_3D: boolean;
  123118. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123119. SS_LODINREFRACTIONALPHA: boolean;
  123120. SS_GAMMAREFRACTION: boolean;
  123121. SS_RGBDREFRACTION: boolean;
  123122. SS_LINEARSPECULARREFRACTION: boolean;
  123123. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123124. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123125. /** @hidden */
  123126. _areTexturesDirty: boolean;
  123127. }
  123128. /**
  123129. * Define the code related to the sub surface parameters of the pbr material.
  123130. */
  123131. export class PBRSubSurfaceConfiguration {
  123132. private _isRefractionEnabled;
  123133. /**
  123134. * Defines if the refraction is enabled in the material.
  123135. */
  123136. isRefractionEnabled: boolean;
  123137. private _isTranslucencyEnabled;
  123138. /**
  123139. * Defines if the translucency is enabled in the material.
  123140. */
  123141. isTranslucencyEnabled: boolean;
  123142. private _isScatteringEnabled;
  123143. /**
  123144. * Defines the refraction intensity of the material.
  123145. * The refraction when enabled replaces the Diffuse part of the material.
  123146. * The intensity helps transitionning between diffuse and refraction.
  123147. */
  123148. refractionIntensity: number;
  123149. /**
  123150. * Defines the translucency intensity of the material.
  123151. * When translucency has been enabled, this defines how much of the "translucency"
  123152. * is addded to the diffuse part of the material.
  123153. */
  123154. translucencyIntensity: number;
  123155. /**
  123156. * Defines the scattering intensity of the material.
  123157. * When scattering has been enabled, this defines how much of the "scattered light"
  123158. * is addded to the diffuse part of the material.
  123159. */
  123160. scatteringIntensity: number;
  123161. private _thicknessTexture;
  123162. /**
  123163. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123164. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123165. * 0 would mean minimumThickness
  123166. * 1 would mean maximumThickness
  123167. * The other channels might be use as a mask to vary the different effects intensity.
  123168. */
  123169. thicknessTexture: Nullable<BaseTexture>;
  123170. private _refractionTexture;
  123171. /**
  123172. * Defines the texture to use for refraction.
  123173. */
  123174. refractionTexture: Nullable<BaseTexture>;
  123175. private _indexOfRefraction;
  123176. /**
  123177. * Defines the index of refraction used in the material.
  123178. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123179. */
  123180. indexOfRefraction: number;
  123181. private _invertRefractionY;
  123182. /**
  123183. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123184. */
  123185. invertRefractionY: boolean;
  123186. private _linkRefractionWithTransparency;
  123187. /**
  123188. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123189. * Materials half opaque for instance using refraction could benefit from this control.
  123190. */
  123191. linkRefractionWithTransparency: boolean;
  123192. /**
  123193. * Defines the minimum thickness stored in the thickness map.
  123194. * If no thickness map is defined, this value will be used to simulate thickness.
  123195. */
  123196. minimumThickness: number;
  123197. /**
  123198. * Defines the maximum thickness stored in the thickness map.
  123199. */
  123200. maximumThickness: number;
  123201. /**
  123202. * Defines the volume tint of the material.
  123203. * This is used for both translucency and scattering.
  123204. */
  123205. tintColor: Color3;
  123206. /**
  123207. * Defines the distance at which the tint color should be found in the media.
  123208. * This is used for refraction only.
  123209. */
  123210. tintColorAtDistance: number;
  123211. /**
  123212. * Defines how far each channel transmit through the media.
  123213. * It is defined as a color to simplify it selection.
  123214. */
  123215. diffusionDistance: Color3;
  123216. private _useMaskFromThicknessTexture;
  123217. /**
  123218. * Stores the intensity of the different subsurface effects in the thickness texture.
  123219. * * the green channel is the translucency intensity.
  123220. * * the blue channel is the scattering intensity.
  123221. * * the alpha channel is the refraction intensity.
  123222. */
  123223. useMaskFromThicknessTexture: boolean;
  123224. /** @hidden */
  123225. private _internalMarkAllSubMeshesAsTexturesDirty;
  123226. /** @hidden */
  123227. _markAllSubMeshesAsTexturesDirty(): void;
  123228. /**
  123229. * Instantiate a new istance of sub surface configuration.
  123230. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123231. */
  123232. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123233. /**
  123234. * Gets wehter the submesh is ready to be used or not.
  123235. * @param defines the list of "defines" to update.
  123236. * @param scene defines the scene the material belongs to.
  123237. * @returns - boolean indicating that the submesh is ready or not.
  123238. */
  123239. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123240. /**
  123241. * Checks to see if a texture is used in the material.
  123242. * @param defines the list of "defines" to update.
  123243. * @param scene defines the scene to the material belongs to.
  123244. */
  123245. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123246. /**
  123247. * Binds the material data.
  123248. * @param uniformBuffer defines the Uniform buffer to fill in.
  123249. * @param scene defines the scene the material belongs to.
  123250. * @param engine defines the engine the material belongs to.
  123251. * @param isFrozen defines wether the material is frozen or not.
  123252. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123253. */
  123254. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123255. /**
  123256. * Unbinds the material from the mesh.
  123257. * @param activeEffect defines the effect that should be unbound from.
  123258. * @returns true if unbound, otherwise false
  123259. */
  123260. unbind(activeEffect: Effect): boolean;
  123261. /**
  123262. * Returns the texture used for refraction or null if none is used.
  123263. * @param scene defines the scene the material belongs to.
  123264. * @returns - Refraction texture if present. If no refraction texture and refraction
  123265. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123266. */
  123267. private _getRefractionTexture;
  123268. /**
  123269. * Returns true if alpha blending should be disabled.
  123270. */
  123271. get disableAlphaBlending(): boolean;
  123272. /**
  123273. * Fills the list of render target textures.
  123274. * @param renderTargets the list of render targets to update
  123275. */
  123276. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123277. /**
  123278. * Checks to see if a texture is used in the material.
  123279. * @param texture - Base texture to use.
  123280. * @returns - Boolean specifying if a texture is used in the material.
  123281. */
  123282. hasTexture(texture: BaseTexture): boolean;
  123283. /**
  123284. * Gets a boolean indicating that current material needs to register RTT
  123285. * @returns true if this uses a render target otherwise false.
  123286. */
  123287. hasRenderTargetTextures(): boolean;
  123288. /**
  123289. * Returns an array of the actively used textures.
  123290. * @param activeTextures Array of BaseTextures
  123291. */
  123292. getActiveTextures(activeTextures: BaseTexture[]): void;
  123293. /**
  123294. * Returns the animatable textures.
  123295. * @param animatables Array of animatable textures.
  123296. */
  123297. getAnimatables(animatables: IAnimatable[]): void;
  123298. /**
  123299. * Disposes the resources of the material.
  123300. * @param forceDisposeTextures - Forces the disposal of all textures.
  123301. */
  123302. dispose(forceDisposeTextures?: boolean): void;
  123303. /**
  123304. * Get the current class name of the texture useful for serialization or dynamic coding.
  123305. * @returns "PBRSubSurfaceConfiguration"
  123306. */
  123307. getClassName(): string;
  123308. /**
  123309. * Add fallbacks to the effect fallbacks list.
  123310. * @param defines defines the Base texture to use.
  123311. * @param fallbacks defines the current fallback list.
  123312. * @param currentRank defines the current fallback rank.
  123313. * @returns the new fallback rank.
  123314. */
  123315. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123316. /**
  123317. * Add the required uniforms to the current list.
  123318. * @param uniforms defines the current uniform list.
  123319. */
  123320. static AddUniforms(uniforms: string[]): void;
  123321. /**
  123322. * Add the required samplers to the current list.
  123323. * @param samplers defines the current sampler list.
  123324. */
  123325. static AddSamplers(samplers: string[]): void;
  123326. /**
  123327. * Add the required uniforms to the current buffer.
  123328. * @param uniformBuffer defines the current uniform buffer.
  123329. */
  123330. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123331. /**
  123332. * Makes a duplicate of the current configuration into another one.
  123333. * @param configuration define the config where to copy the info
  123334. */
  123335. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123336. /**
  123337. * Serializes this Sub Surface configuration.
  123338. * @returns - An object with the serialized config.
  123339. */
  123340. serialize(): any;
  123341. /**
  123342. * Parses a anisotropy Configuration from a serialized object.
  123343. * @param source - Serialized object.
  123344. * @param scene Defines the scene we are parsing for
  123345. * @param rootUrl Defines the rootUrl to load from
  123346. */
  123347. parse(source: any, scene: Scene, rootUrl: string): void;
  123348. }
  123349. }
  123350. declare module BABYLON {
  123351. /** @hidden */
  123352. export var pbrFragmentDeclaration: {
  123353. name: string;
  123354. shader: string;
  123355. };
  123356. }
  123357. declare module BABYLON {
  123358. /** @hidden */
  123359. export var pbrUboDeclaration: {
  123360. name: string;
  123361. shader: string;
  123362. };
  123363. }
  123364. declare module BABYLON {
  123365. /** @hidden */
  123366. export var pbrFragmentExtraDeclaration: {
  123367. name: string;
  123368. shader: string;
  123369. };
  123370. }
  123371. declare module BABYLON {
  123372. /** @hidden */
  123373. export var pbrFragmentSamplersDeclaration: {
  123374. name: string;
  123375. shader: string;
  123376. };
  123377. }
  123378. declare module BABYLON {
  123379. /** @hidden */
  123380. export var pbrHelperFunctions: {
  123381. name: string;
  123382. shader: string;
  123383. };
  123384. }
  123385. declare module BABYLON {
  123386. /** @hidden */
  123387. export var harmonicsFunctions: {
  123388. name: string;
  123389. shader: string;
  123390. };
  123391. }
  123392. declare module BABYLON {
  123393. /** @hidden */
  123394. export var pbrDirectLightingSetupFunctions: {
  123395. name: string;
  123396. shader: string;
  123397. };
  123398. }
  123399. declare module BABYLON {
  123400. /** @hidden */
  123401. export var pbrDirectLightingFalloffFunctions: {
  123402. name: string;
  123403. shader: string;
  123404. };
  123405. }
  123406. declare module BABYLON {
  123407. /** @hidden */
  123408. export var pbrBRDFFunctions: {
  123409. name: string;
  123410. shader: string;
  123411. };
  123412. }
  123413. declare module BABYLON {
  123414. /** @hidden */
  123415. export var pbrDirectLightingFunctions: {
  123416. name: string;
  123417. shader: string;
  123418. };
  123419. }
  123420. declare module BABYLON {
  123421. /** @hidden */
  123422. export var pbrIBLFunctions: {
  123423. name: string;
  123424. shader: string;
  123425. };
  123426. }
  123427. declare module BABYLON {
  123428. /** @hidden */
  123429. export var pbrDebug: {
  123430. name: string;
  123431. shader: string;
  123432. };
  123433. }
  123434. declare module BABYLON {
  123435. /** @hidden */
  123436. export var pbrPixelShader: {
  123437. name: string;
  123438. shader: string;
  123439. };
  123440. }
  123441. declare module BABYLON {
  123442. /** @hidden */
  123443. export var pbrVertexDeclaration: {
  123444. name: string;
  123445. shader: string;
  123446. };
  123447. }
  123448. declare module BABYLON {
  123449. /** @hidden */
  123450. export var pbrVertexShader: {
  123451. name: string;
  123452. shader: string;
  123453. };
  123454. }
  123455. declare module BABYLON {
  123456. /**
  123457. * Manages the defines for the PBR Material.
  123458. * @hidden
  123459. */
  123460. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123461. PBR: boolean;
  123462. MAINUV1: boolean;
  123463. MAINUV2: boolean;
  123464. UV1: boolean;
  123465. UV2: boolean;
  123466. ALBEDO: boolean;
  123467. ALBEDODIRECTUV: number;
  123468. VERTEXCOLOR: boolean;
  123469. AMBIENT: boolean;
  123470. AMBIENTDIRECTUV: number;
  123471. AMBIENTINGRAYSCALE: boolean;
  123472. OPACITY: boolean;
  123473. VERTEXALPHA: boolean;
  123474. OPACITYDIRECTUV: number;
  123475. OPACITYRGB: boolean;
  123476. ALPHATEST: boolean;
  123477. DEPTHPREPASS: boolean;
  123478. ALPHABLEND: boolean;
  123479. ALPHAFROMALBEDO: boolean;
  123480. ALPHATESTVALUE: string;
  123481. SPECULAROVERALPHA: boolean;
  123482. RADIANCEOVERALPHA: boolean;
  123483. ALPHAFRESNEL: boolean;
  123484. LINEARALPHAFRESNEL: boolean;
  123485. PREMULTIPLYALPHA: boolean;
  123486. EMISSIVE: boolean;
  123487. EMISSIVEDIRECTUV: number;
  123488. REFLECTIVITY: boolean;
  123489. REFLECTIVITYDIRECTUV: number;
  123490. SPECULARTERM: boolean;
  123491. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123492. MICROSURFACEAUTOMATIC: boolean;
  123493. LODBASEDMICROSFURACE: boolean;
  123494. MICROSURFACEMAP: boolean;
  123495. MICROSURFACEMAPDIRECTUV: number;
  123496. METALLICWORKFLOW: boolean;
  123497. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  123498. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  123499. METALLNESSSTOREINMETALMAPBLUE: boolean;
  123500. AOSTOREINMETALMAPRED: boolean;
  123501. METALLICF0FACTORFROMMETALLICMAP: boolean;
  123502. ENVIRONMENTBRDF: boolean;
  123503. ENVIRONMENTBRDF_RGBD: boolean;
  123504. NORMAL: boolean;
  123505. TANGENT: boolean;
  123506. BUMP: boolean;
  123507. BUMPDIRECTUV: number;
  123508. OBJECTSPACE_NORMALMAP: boolean;
  123509. PARALLAX: boolean;
  123510. PARALLAXOCCLUSION: boolean;
  123511. NORMALXYSCALE: boolean;
  123512. LIGHTMAP: boolean;
  123513. LIGHTMAPDIRECTUV: number;
  123514. USELIGHTMAPASSHADOWMAP: boolean;
  123515. GAMMALIGHTMAP: boolean;
  123516. RGBDLIGHTMAP: boolean;
  123517. REFLECTION: boolean;
  123518. REFLECTIONMAP_3D: boolean;
  123519. REFLECTIONMAP_SPHERICAL: boolean;
  123520. REFLECTIONMAP_PLANAR: boolean;
  123521. REFLECTIONMAP_CUBIC: boolean;
  123522. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  123523. REFLECTIONMAP_PROJECTION: boolean;
  123524. REFLECTIONMAP_SKYBOX: boolean;
  123525. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  123526. REFLECTIONMAP_EXPLICIT: boolean;
  123527. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  123528. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  123529. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  123530. INVERTCUBICMAP: boolean;
  123531. USESPHERICALFROMREFLECTIONMAP: boolean;
  123532. USEIRRADIANCEMAP: boolean;
  123533. SPHERICAL_HARMONICS: boolean;
  123534. USESPHERICALINVERTEX: boolean;
  123535. REFLECTIONMAP_OPPOSITEZ: boolean;
  123536. LODINREFLECTIONALPHA: boolean;
  123537. GAMMAREFLECTION: boolean;
  123538. RGBDREFLECTION: boolean;
  123539. LINEARSPECULARREFLECTION: boolean;
  123540. RADIANCEOCCLUSION: boolean;
  123541. HORIZONOCCLUSION: boolean;
  123542. INSTANCES: boolean;
  123543. NUM_BONE_INFLUENCERS: number;
  123544. BonesPerMesh: number;
  123545. BONETEXTURE: boolean;
  123546. NONUNIFORMSCALING: boolean;
  123547. MORPHTARGETS: boolean;
  123548. MORPHTARGETS_NORMAL: boolean;
  123549. MORPHTARGETS_TANGENT: boolean;
  123550. MORPHTARGETS_UV: boolean;
  123551. NUM_MORPH_INFLUENCERS: number;
  123552. IMAGEPROCESSING: boolean;
  123553. VIGNETTE: boolean;
  123554. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123555. VIGNETTEBLENDMODEOPAQUE: boolean;
  123556. TONEMAPPING: boolean;
  123557. TONEMAPPING_ACES: boolean;
  123558. CONTRAST: boolean;
  123559. COLORCURVES: boolean;
  123560. COLORGRADING: boolean;
  123561. COLORGRADING3D: boolean;
  123562. SAMPLER3DGREENDEPTH: boolean;
  123563. SAMPLER3DBGRMAP: boolean;
  123564. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123565. EXPOSURE: boolean;
  123566. MULTIVIEW: boolean;
  123567. USEPHYSICALLIGHTFALLOFF: boolean;
  123568. USEGLTFLIGHTFALLOFF: boolean;
  123569. TWOSIDEDLIGHTING: boolean;
  123570. SHADOWFLOAT: boolean;
  123571. CLIPPLANE: boolean;
  123572. CLIPPLANE2: boolean;
  123573. CLIPPLANE3: boolean;
  123574. CLIPPLANE4: boolean;
  123575. CLIPPLANE5: boolean;
  123576. CLIPPLANE6: boolean;
  123577. POINTSIZE: boolean;
  123578. FOG: boolean;
  123579. LOGARITHMICDEPTH: boolean;
  123580. FORCENORMALFORWARD: boolean;
  123581. SPECULARAA: boolean;
  123582. CLEARCOAT: boolean;
  123583. CLEARCOAT_DEFAULTIOR: boolean;
  123584. CLEARCOAT_TEXTURE: boolean;
  123585. CLEARCOAT_TEXTUREDIRECTUV: number;
  123586. CLEARCOAT_BUMP: boolean;
  123587. CLEARCOAT_BUMPDIRECTUV: number;
  123588. CLEARCOAT_TINT: boolean;
  123589. CLEARCOAT_TINT_TEXTURE: boolean;
  123590. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123591. ANISOTROPIC: boolean;
  123592. ANISOTROPIC_TEXTURE: boolean;
  123593. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123594. BRDF_V_HEIGHT_CORRELATED: boolean;
  123595. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123596. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123597. SHEEN: boolean;
  123598. SHEEN_TEXTURE: boolean;
  123599. SHEEN_TEXTUREDIRECTUV: number;
  123600. SHEEN_LINKWITHALBEDO: boolean;
  123601. SUBSURFACE: boolean;
  123602. SS_REFRACTION: boolean;
  123603. SS_TRANSLUCENCY: boolean;
  123604. SS_SCATERRING: boolean;
  123605. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123606. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123607. SS_REFRACTIONMAP_3D: boolean;
  123608. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123609. SS_LODINREFRACTIONALPHA: boolean;
  123610. SS_GAMMAREFRACTION: boolean;
  123611. SS_RGBDREFRACTION: boolean;
  123612. SS_LINEARSPECULARREFRACTION: boolean;
  123613. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123614. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123615. UNLIT: boolean;
  123616. DEBUGMODE: number;
  123617. /**
  123618. * Initializes the PBR Material defines.
  123619. */
  123620. constructor();
  123621. /**
  123622. * Resets the PBR Material defines.
  123623. */
  123624. reset(): void;
  123625. }
  123626. /**
  123627. * The Physically based material base class of BJS.
  123628. *
  123629. * This offers the main features of a standard PBR material.
  123630. * For more information, please refer to the documentation :
  123631. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123632. */
  123633. export abstract class PBRBaseMaterial extends PushMaterial {
  123634. /**
  123635. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123636. */
  123637. static readonly PBRMATERIAL_OPAQUE: number;
  123638. /**
  123639. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123640. */
  123641. static readonly PBRMATERIAL_ALPHATEST: number;
  123642. /**
  123643. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123644. */
  123645. static readonly PBRMATERIAL_ALPHABLEND: number;
  123646. /**
  123647. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123648. * They are also discarded below the alpha cutoff threshold to improve performances.
  123649. */
  123650. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123651. /**
  123652. * Defines the default value of how much AO map is occluding the analytical lights
  123653. * (point spot...).
  123654. */
  123655. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  123656. /**
  123657. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  123658. */
  123659. static readonly LIGHTFALLOFF_PHYSICAL: number;
  123660. /**
  123661. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  123662. * to enhance interoperability with other engines.
  123663. */
  123664. static readonly LIGHTFALLOFF_GLTF: number;
  123665. /**
  123666. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  123667. * to enhance interoperability with other materials.
  123668. */
  123669. static readonly LIGHTFALLOFF_STANDARD: number;
  123670. /**
  123671. * Intensity of the direct lights e.g. the four lights available in your scene.
  123672. * This impacts both the direct diffuse and specular highlights.
  123673. */
  123674. protected _directIntensity: number;
  123675. /**
  123676. * Intensity of the emissive part of the material.
  123677. * This helps controlling the emissive effect without modifying the emissive color.
  123678. */
  123679. protected _emissiveIntensity: number;
  123680. /**
  123681. * Intensity of the environment e.g. how much the environment will light the object
  123682. * either through harmonics for rough material or through the refelction for shiny ones.
  123683. */
  123684. protected _environmentIntensity: number;
  123685. /**
  123686. * This is a special control allowing the reduction of the specular highlights coming from the
  123687. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  123688. */
  123689. protected _specularIntensity: number;
  123690. /**
  123691. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  123692. */
  123693. private _lightingInfos;
  123694. /**
  123695. * Debug Control allowing disabling the bump map on this material.
  123696. */
  123697. protected _disableBumpMap: boolean;
  123698. /**
  123699. * AKA Diffuse Texture in standard nomenclature.
  123700. */
  123701. protected _albedoTexture: Nullable<BaseTexture>;
  123702. /**
  123703. * AKA Occlusion Texture in other nomenclature.
  123704. */
  123705. protected _ambientTexture: Nullable<BaseTexture>;
  123706. /**
  123707. * AKA Occlusion Texture Intensity in other nomenclature.
  123708. */
  123709. protected _ambientTextureStrength: number;
  123710. /**
  123711. * Defines how much the AO map is occluding the analytical lights (point spot...).
  123712. * 1 means it completely occludes it
  123713. * 0 mean it has no impact
  123714. */
  123715. protected _ambientTextureImpactOnAnalyticalLights: number;
  123716. /**
  123717. * Stores the alpha values in a texture.
  123718. */
  123719. protected _opacityTexture: Nullable<BaseTexture>;
  123720. /**
  123721. * Stores the reflection values in a texture.
  123722. */
  123723. protected _reflectionTexture: Nullable<BaseTexture>;
  123724. /**
  123725. * Stores the emissive values in a texture.
  123726. */
  123727. protected _emissiveTexture: Nullable<BaseTexture>;
  123728. /**
  123729. * AKA Specular texture in other nomenclature.
  123730. */
  123731. protected _reflectivityTexture: Nullable<BaseTexture>;
  123732. /**
  123733. * Used to switch from specular/glossiness to metallic/roughness workflow.
  123734. */
  123735. protected _metallicTexture: Nullable<BaseTexture>;
  123736. /**
  123737. * Specifies the metallic scalar of the metallic/roughness workflow.
  123738. * Can also be used to scale the metalness values of the metallic texture.
  123739. */
  123740. protected _metallic: Nullable<number>;
  123741. /**
  123742. * Specifies the roughness scalar of the metallic/roughness workflow.
  123743. * Can also be used to scale the roughness values of the metallic texture.
  123744. */
  123745. protected _roughness: Nullable<number>;
  123746. /**
  123747. * Specifies the an F0 factor to help configuring the material F0.
  123748. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  123749. * to 0.5 the previously hard coded value stays the same.
  123750. * Can also be used to scale the F0 values of the metallic texture.
  123751. */
  123752. protected _metallicF0Factor: number;
  123753. /**
  123754. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  123755. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  123756. * your expectation as it multiplies with the texture data.
  123757. */
  123758. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  123759. /**
  123760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  123761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  123762. */
  123763. protected _microSurfaceTexture: Nullable<BaseTexture>;
  123764. /**
  123765. * Stores surface normal data used to displace a mesh in a texture.
  123766. */
  123767. protected _bumpTexture: Nullable<BaseTexture>;
  123768. /**
  123769. * Stores the pre-calculated light information of a mesh in a texture.
  123770. */
  123771. protected _lightmapTexture: Nullable<BaseTexture>;
  123772. /**
  123773. * The color of a material in ambient lighting.
  123774. */
  123775. protected _ambientColor: Color3;
  123776. /**
  123777. * AKA Diffuse Color in other nomenclature.
  123778. */
  123779. protected _albedoColor: Color3;
  123780. /**
  123781. * AKA Specular Color in other nomenclature.
  123782. */
  123783. protected _reflectivityColor: Color3;
  123784. /**
  123785. * The color applied when light is reflected from a material.
  123786. */
  123787. protected _reflectionColor: Color3;
  123788. /**
  123789. * The color applied when light is emitted from a material.
  123790. */
  123791. protected _emissiveColor: Color3;
  123792. /**
  123793. * AKA Glossiness in other nomenclature.
  123794. */
  123795. protected _microSurface: number;
  123796. /**
  123797. * Specifies that the material will use the light map as a show map.
  123798. */
  123799. protected _useLightmapAsShadowmap: boolean;
  123800. /**
  123801. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  123802. * makes the reflect vector face the model (under horizon).
  123803. */
  123804. protected _useHorizonOcclusion: boolean;
  123805. /**
  123806. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  123807. * too much the area relying on ambient texture to define their ambient occlusion.
  123808. */
  123809. protected _useRadianceOcclusion: boolean;
  123810. /**
  123811. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  123812. */
  123813. protected _useAlphaFromAlbedoTexture: boolean;
  123814. /**
  123815. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  123816. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  123817. */
  123818. protected _useSpecularOverAlpha: boolean;
  123819. /**
  123820. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  123821. */
  123822. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  123823. /**
  123824. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  123825. */
  123826. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  123827. /**
  123828. * Specifies if the metallic texture contains the roughness information in its green channel.
  123829. */
  123830. protected _useRoughnessFromMetallicTextureGreen: boolean;
  123831. /**
  123832. * Specifies if the metallic texture contains the metallness information in its blue channel.
  123833. */
  123834. protected _useMetallnessFromMetallicTextureBlue: boolean;
  123835. /**
  123836. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  123837. */
  123838. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  123839. /**
  123840. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  123841. */
  123842. protected _useAmbientInGrayScale: boolean;
  123843. /**
  123844. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  123845. * The material will try to infer what glossiness each pixel should be.
  123846. */
  123847. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  123848. /**
  123849. * Defines the falloff type used in this material.
  123850. * It by default is Physical.
  123851. */
  123852. protected _lightFalloff: number;
  123853. /**
  123854. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  123855. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  123856. */
  123857. protected _useRadianceOverAlpha: boolean;
  123858. /**
  123859. * Allows using an object space normal map (instead of tangent space).
  123860. */
  123861. protected _useObjectSpaceNormalMap: boolean;
  123862. /**
  123863. * Allows using the bump map in parallax mode.
  123864. */
  123865. protected _useParallax: boolean;
  123866. /**
  123867. * Allows using the bump map in parallax occlusion mode.
  123868. */
  123869. protected _useParallaxOcclusion: boolean;
  123870. /**
  123871. * Controls the scale bias of the parallax mode.
  123872. */
  123873. protected _parallaxScaleBias: number;
  123874. /**
  123875. * If sets to true, disables all the lights affecting the material.
  123876. */
  123877. protected _disableLighting: boolean;
  123878. /**
  123879. * Number of Simultaneous lights allowed on the material.
  123880. */
  123881. protected _maxSimultaneousLights: number;
  123882. /**
  123883. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123884. */
  123885. protected _invertNormalMapX: boolean;
  123886. /**
  123887. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123888. */
  123889. protected _invertNormalMapY: boolean;
  123890. /**
  123891. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  123892. */
  123893. protected _twoSidedLighting: boolean;
  123894. /**
  123895. * Defines the alpha limits in alpha test mode.
  123896. */
  123897. protected _alphaCutOff: number;
  123898. /**
  123899. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  123900. */
  123901. protected _forceAlphaTest: boolean;
  123902. /**
  123903. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123904. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  123905. */
  123906. protected _useAlphaFresnel: boolean;
  123907. /**
  123908. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123909. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  123910. */
  123911. protected _useLinearAlphaFresnel: boolean;
  123912. /**
  123913. * The transparency mode of the material.
  123914. */
  123915. protected _transparencyMode: Nullable<number>;
  123916. /**
  123917. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  123918. * from cos thetav and roughness:
  123919. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  123920. */
  123921. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  123922. /**
  123923. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  123924. */
  123925. protected _forceIrradianceInFragment: boolean;
  123926. /**
  123927. * Force normal to face away from face.
  123928. */
  123929. protected _forceNormalForward: boolean;
  123930. /**
  123931. * Enables specular anti aliasing in the PBR shader.
  123932. * It will both interacts on the Geometry for analytical and IBL lighting.
  123933. * It also prefilter the roughness map based on the bump values.
  123934. */
  123935. protected _enableSpecularAntiAliasing: boolean;
  123936. /**
  123937. * Default configuration related to image processing available in the PBR Material.
  123938. */
  123939. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123940. /**
  123941. * Keep track of the image processing observer to allow dispose and replace.
  123942. */
  123943. private _imageProcessingObserver;
  123944. /**
  123945. * Attaches a new image processing configuration to the PBR Material.
  123946. * @param configuration
  123947. */
  123948. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123949. /**
  123950. * Stores the available render targets.
  123951. */
  123952. private _renderTargets;
  123953. /**
  123954. * Sets the global ambient color for the material used in lighting calculations.
  123955. */
  123956. private _globalAmbientColor;
  123957. /**
  123958. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  123959. */
  123960. private _useLogarithmicDepth;
  123961. /**
  123962. * If set to true, no lighting calculations will be applied.
  123963. */
  123964. private _unlit;
  123965. private _debugMode;
  123966. /**
  123967. * @hidden
  123968. * This is reserved for the inspector.
  123969. * Defines the material debug mode.
  123970. * It helps seeing only some components of the material while troubleshooting.
  123971. */
  123972. debugMode: number;
  123973. /**
  123974. * @hidden
  123975. * This is reserved for the inspector.
  123976. * Specify from where on screen the debug mode should start.
  123977. * The value goes from -1 (full screen) to 1 (not visible)
  123978. * It helps with side by side comparison against the final render
  123979. * This defaults to -1
  123980. */
  123981. private debugLimit;
  123982. /**
  123983. * @hidden
  123984. * This is reserved for the inspector.
  123985. * As the default viewing range might not be enough (if the ambient is really small for instance)
  123986. * You can use the factor to better multiply the final value.
  123987. */
  123988. private debugFactor;
  123989. /**
  123990. * Defines the clear coat layer parameters for the material.
  123991. */
  123992. readonly clearCoat: PBRClearCoatConfiguration;
  123993. /**
  123994. * Defines the anisotropic parameters for the material.
  123995. */
  123996. readonly anisotropy: PBRAnisotropicConfiguration;
  123997. /**
  123998. * Defines the BRDF parameters for the material.
  123999. */
  124000. readonly brdf: PBRBRDFConfiguration;
  124001. /**
  124002. * Defines the Sheen parameters for the material.
  124003. */
  124004. readonly sheen: PBRSheenConfiguration;
  124005. /**
  124006. * Defines the SubSurface parameters for the material.
  124007. */
  124008. readonly subSurface: PBRSubSurfaceConfiguration;
  124009. /**
  124010. * Custom callback helping to override the default shader used in the material.
  124011. */
  124012. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124013. protected _rebuildInParallel: boolean;
  124014. /**
  124015. * Instantiates a new PBRMaterial instance.
  124016. *
  124017. * @param name The material name
  124018. * @param scene The scene the material will be use in.
  124019. */
  124020. constructor(name: string, scene: Scene);
  124021. /**
  124022. * Gets a boolean indicating that current material needs to register RTT
  124023. */
  124024. get hasRenderTargetTextures(): boolean;
  124025. /**
  124026. * Gets the name of the material class.
  124027. */
  124028. getClassName(): string;
  124029. /**
  124030. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124031. */
  124032. get useLogarithmicDepth(): boolean;
  124033. /**
  124034. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124035. */
  124036. set useLogarithmicDepth(value: boolean);
  124037. /**
  124038. * Gets the current transparency mode.
  124039. */
  124040. get transparencyMode(): Nullable<number>;
  124041. /**
  124042. * Sets the transparency mode of the material.
  124043. *
  124044. * | Value | Type | Description |
  124045. * | ----- | ----------------------------------- | ----------- |
  124046. * | 0 | OPAQUE | |
  124047. * | 1 | ALPHATEST | |
  124048. * | 2 | ALPHABLEND | |
  124049. * | 3 | ALPHATESTANDBLEND | |
  124050. *
  124051. */
  124052. set transparencyMode(value: Nullable<number>);
  124053. /**
  124054. * Returns true if alpha blending should be disabled.
  124055. */
  124056. private get _disableAlphaBlending();
  124057. /**
  124058. * Specifies whether or not this material should be rendered in alpha blend mode.
  124059. */
  124060. needAlphaBlending(): boolean;
  124061. /**
  124062. * Specifies if the mesh will require alpha blending.
  124063. * @param mesh - BJS mesh.
  124064. */
  124065. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124066. /**
  124067. * Specifies whether or not this material should be rendered in alpha test mode.
  124068. */
  124069. needAlphaTesting(): boolean;
  124070. /**
  124071. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124072. */
  124073. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124074. /**
  124075. * Gets the texture used for the alpha test.
  124076. */
  124077. getAlphaTestTexture(): Nullable<BaseTexture>;
  124078. /**
  124079. * Specifies that the submesh is ready to be used.
  124080. * @param mesh - BJS mesh.
  124081. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124082. * @param useInstances - Specifies that instances should be used.
  124083. * @returns - boolean indicating that the submesh is ready or not.
  124084. */
  124085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124086. /**
  124087. * Specifies if the material uses metallic roughness workflow.
  124088. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124089. */
  124090. isMetallicWorkflow(): boolean;
  124091. private _prepareEffect;
  124092. private _prepareDefines;
  124093. /**
  124094. * Force shader compilation
  124095. */
  124096. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124097. /**
  124098. * Initializes the uniform buffer layout for the shader.
  124099. */
  124100. buildUniformLayout(): void;
  124101. /**
  124102. * Unbinds the material from the mesh
  124103. */
  124104. unbind(): void;
  124105. /**
  124106. * Binds the submesh data.
  124107. * @param world - The world matrix.
  124108. * @param mesh - The BJS mesh.
  124109. * @param subMesh - A submesh of the BJS mesh.
  124110. */
  124111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124112. /**
  124113. * Returns the animatable textures.
  124114. * @returns - Array of animatable textures.
  124115. */
  124116. getAnimatables(): IAnimatable[];
  124117. /**
  124118. * Returns the texture used for reflections.
  124119. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124120. */
  124121. private _getReflectionTexture;
  124122. /**
  124123. * Returns an array of the actively used textures.
  124124. * @returns - Array of BaseTextures
  124125. */
  124126. getActiveTextures(): BaseTexture[];
  124127. /**
  124128. * Checks to see if a texture is used in the material.
  124129. * @param texture - Base texture to use.
  124130. * @returns - Boolean specifying if a texture is used in the material.
  124131. */
  124132. hasTexture(texture: BaseTexture): boolean;
  124133. /**
  124134. * Disposes the resources of the material.
  124135. * @param forceDisposeEffect - Forces the disposal of effects.
  124136. * @param forceDisposeTextures - Forces the disposal of all textures.
  124137. */
  124138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124139. }
  124140. }
  124141. declare module BABYLON {
  124142. /**
  124143. * The Physically based material of BJS.
  124144. *
  124145. * This offers the main features of a standard PBR material.
  124146. * For more information, please refer to the documentation :
  124147. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124148. */
  124149. export class PBRMaterial extends PBRBaseMaterial {
  124150. /**
  124151. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124152. */
  124153. static readonly PBRMATERIAL_OPAQUE: number;
  124154. /**
  124155. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124156. */
  124157. static readonly PBRMATERIAL_ALPHATEST: number;
  124158. /**
  124159. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124160. */
  124161. static readonly PBRMATERIAL_ALPHABLEND: number;
  124162. /**
  124163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124164. * They are also discarded below the alpha cutoff threshold to improve performances.
  124165. */
  124166. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124167. /**
  124168. * Defines the default value of how much AO map is occluding the analytical lights
  124169. * (point spot...).
  124170. */
  124171. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124172. /**
  124173. * Intensity of the direct lights e.g. the four lights available in your scene.
  124174. * This impacts both the direct diffuse and specular highlights.
  124175. */
  124176. directIntensity: number;
  124177. /**
  124178. * Intensity of the emissive part of the material.
  124179. * This helps controlling the emissive effect without modifying the emissive color.
  124180. */
  124181. emissiveIntensity: number;
  124182. /**
  124183. * Intensity of the environment e.g. how much the environment will light the object
  124184. * either through harmonics for rough material or through the refelction for shiny ones.
  124185. */
  124186. environmentIntensity: number;
  124187. /**
  124188. * This is a special control allowing the reduction of the specular highlights coming from the
  124189. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124190. */
  124191. specularIntensity: number;
  124192. /**
  124193. * Debug Control allowing disabling the bump map on this material.
  124194. */
  124195. disableBumpMap: boolean;
  124196. /**
  124197. * AKA Diffuse Texture in standard nomenclature.
  124198. */
  124199. albedoTexture: BaseTexture;
  124200. /**
  124201. * AKA Occlusion Texture in other nomenclature.
  124202. */
  124203. ambientTexture: BaseTexture;
  124204. /**
  124205. * AKA Occlusion Texture Intensity in other nomenclature.
  124206. */
  124207. ambientTextureStrength: number;
  124208. /**
  124209. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124210. * 1 means it completely occludes it
  124211. * 0 mean it has no impact
  124212. */
  124213. ambientTextureImpactOnAnalyticalLights: number;
  124214. /**
  124215. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124216. */
  124217. opacityTexture: BaseTexture;
  124218. /**
  124219. * Stores the reflection values in a texture.
  124220. */
  124221. reflectionTexture: Nullable<BaseTexture>;
  124222. /**
  124223. * Stores the emissive values in a texture.
  124224. */
  124225. emissiveTexture: BaseTexture;
  124226. /**
  124227. * AKA Specular texture in other nomenclature.
  124228. */
  124229. reflectivityTexture: BaseTexture;
  124230. /**
  124231. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124232. */
  124233. metallicTexture: BaseTexture;
  124234. /**
  124235. * Specifies the metallic scalar of the metallic/roughness workflow.
  124236. * Can also be used to scale the metalness values of the metallic texture.
  124237. */
  124238. metallic: Nullable<number>;
  124239. /**
  124240. * Specifies the roughness scalar of the metallic/roughness workflow.
  124241. * Can also be used to scale the roughness values of the metallic texture.
  124242. */
  124243. roughness: Nullable<number>;
  124244. /**
  124245. * Specifies the an F0 factor to help configuring the material F0.
  124246. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124247. * to 0.5 the previously hard coded value stays the same.
  124248. * Can also be used to scale the F0 values of the metallic texture.
  124249. */
  124250. metallicF0Factor: number;
  124251. /**
  124252. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124253. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124254. * your expectation as it multiplies with the texture data.
  124255. */
  124256. useMetallicF0FactorFromMetallicTexture: boolean;
  124257. /**
  124258. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124259. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124260. */
  124261. microSurfaceTexture: BaseTexture;
  124262. /**
  124263. * Stores surface normal data used to displace a mesh in a texture.
  124264. */
  124265. bumpTexture: BaseTexture;
  124266. /**
  124267. * Stores the pre-calculated light information of a mesh in a texture.
  124268. */
  124269. lightmapTexture: BaseTexture;
  124270. /**
  124271. * Stores the refracted light information in a texture.
  124272. */
  124273. get refractionTexture(): Nullable<BaseTexture>;
  124274. set refractionTexture(value: Nullable<BaseTexture>);
  124275. /**
  124276. * The color of a material in ambient lighting.
  124277. */
  124278. ambientColor: Color3;
  124279. /**
  124280. * AKA Diffuse Color in other nomenclature.
  124281. */
  124282. albedoColor: Color3;
  124283. /**
  124284. * AKA Specular Color in other nomenclature.
  124285. */
  124286. reflectivityColor: Color3;
  124287. /**
  124288. * The color reflected from the material.
  124289. */
  124290. reflectionColor: Color3;
  124291. /**
  124292. * The color emitted from the material.
  124293. */
  124294. emissiveColor: Color3;
  124295. /**
  124296. * AKA Glossiness in other nomenclature.
  124297. */
  124298. microSurface: number;
  124299. /**
  124300. * source material index of refraction (IOR)' / 'destination material IOR.
  124301. */
  124302. get indexOfRefraction(): number;
  124303. set indexOfRefraction(value: number);
  124304. /**
  124305. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124306. */
  124307. get invertRefractionY(): boolean;
  124308. set invertRefractionY(value: boolean);
  124309. /**
  124310. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124311. * Materials half opaque for instance using refraction could benefit from this control.
  124312. */
  124313. get linkRefractionWithTransparency(): boolean;
  124314. set linkRefractionWithTransparency(value: boolean);
  124315. /**
  124316. * If true, the light map contains occlusion information instead of lighting info.
  124317. */
  124318. useLightmapAsShadowmap: boolean;
  124319. /**
  124320. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124321. */
  124322. useAlphaFromAlbedoTexture: boolean;
  124323. /**
  124324. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124325. */
  124326. forceAlphaTest: boolean;
  124327. /**
  124328. * Defines the alpha limits in alpha test mode.
  124329. */
  124330. alphaCutOff: number;
  124331. /**
  124332. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124333. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124334. */
  124335. useSpecularOverAlpha: boolean;
  124336. /**
  124337. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124338. */
  124339. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124340. /**
  124341. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124342. */
  124343. useRoughnessFromMetallicTextureAlpha: boolean;
  124344. /**
  124345. * Specifies if the metallic texture contains the roughness information in its green channel.
  124346. */
  124347. useRoughnessFromMetallicTextureGreen: boolean;
  124348. /**
  124349. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124350. */
  124351. useMetallnessFromMetallicTextureBlue: boolean;
  124352. /**
  124353. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124354. */
  124355. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124356. /**
  124357. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124358. */
  124359. useAmbientInGrayScale: boolean;
  124360. /**
  124361. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124362. * The material will try to infer what glossiness each pixel should be.
  124363. */
  124364. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124365. /**
  124366. * BJS is using an harcoded light falloff based on a manually sets up range.
  124367. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124368. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124369. */
  124370. get usePhysicalLightFalloff(): boolean;
  124371. /**
  124372. * BJS is using an harcoded light falloff based on a manually sets up range.
  124373. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124374. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124375. */
  124376. set usePhysicalLightFalloff(value: boolean);
  124377. /**
  124378. * In order to support the falloff compatibility with gltf, a special mode has been added
  124379. * to reproduce the gltf light falloff.
  124380. */
  124381. get useGLTFLightFalloff(): boolean;
  124382. /**
  124383. * In order to support the falloff compatibility with gltf, a special mode has been added
  124384. * to reproduce the gltf light falloff.
  124385. */
  124386. set useGLTFLightFalloff(value: boolean);
  124387. /**
  124388. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124389. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124390. */
  124391. useRadianceOverAlpha: boolean;
  124392. /**
  124393. * Allows using an object space normal map (instead of tangent space).
  124394. */
  124395. useObjectSpaceNormalMap: boolean;
  124396. /**
  124397. * Allows using the bump map in parallax mode.
  124398. */
  124399. useParallax: boolean;
  124400. /**
  124401. * Allows using the bump map in parallax occlusion mode.
  124402. */
  124403. useParallaxOcclusion: boolean;
  124404. /**
  124405. * Controls the scale bias of the parallax mode.
  124406. */
  124407. parallaxScaleBias: number;
  124408. /**
  124409. * If sets to true, disables all the lights affecting the material.
  124410. */
  124411. disableLighting: boolean;
  124412. /**
  124413. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124414. */
  124415. forceIrradianceInFragment: boolean;
  124416. /**
  124417. * Number of Simultaneous lights allowed on the material.
  124418. */
  124419. maxSimultaneousLights: number;
  124420. /**
  124421. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124422. */
  124423. invertNormalMapX: boolean;
  124424. /**
  124425. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124426. */
  124427. invertNormalMapY: boolean;
  124428. /**
  124429. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124430. */
  124431. twoSidedLighting: boolean;
  124432. /**
  124433. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124434. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124435. */
  124436. useAlphaFresnel: boolean;
  124437. /**
  124438. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124439. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124440. */
  124441. useLinearAlphaFresnel: boolean;
  124442. /**
  124443. * Let user defines the brdf lookup texture used for IBL.
  124444. * A default 8bit version is embedded but you could point at :
  124445. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124446. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124447. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124448. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124449. */
  124450. environmentBRDFTexture: Nullable<BaseTexture>;
  124451. /**
  124452. * Force normal to face away from face.
  124453. */
  124454. forceNormalForward: boolean;
  124455. /**
  124456. * Enables specular anti aliasing in the PBR shader.
  124457. * It will both interacts on the Geometry for analytical and IBL lighting.
  124458. * It also prefilter the roughness map based on the bump values.
  124459. */
  124460. enableSpecularAntiAliasing: boolean;
  124461. /**
  124462. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124463. * makes the reflect vector face the model (under horizon).
  124464. */
  124465. useHorizonOcclusion: boolean;
  124466. /**
  124467. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124468. * too much the area relying on ambient texture to define their ambient occlusion.
  124469. */
  124470. useRadianceOcclusion: boolean;
  124471. /**
  124472. * If set to true, no lighting calculations will be applied.
  124473. */
  124474. unlit: boolean;
  124475. /**
  124476. * Gets the image processing configuration used either in this material.
  124477. */
  124478. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124479. /**
  124480. * Sets the Default image processing configuration used either in the this material.
  124481. *
  124482. * If sets to null, the scene one is in use.
  124483. */
  124484. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124485. /**
  124486. * Gets wether the color curves effect is enabled.
  124487. */
  124488. get cameraColorCurvesEnabled(): boolean;
  124489. /**
  124490. * Sets wether the color curves effect is enabled.
  124491. */
  124492. set cameraColorCurvesEnabled(value: boolean);
  124493. /**
  124494. * Gets wether the color grading effect is enabled.
  124495. */
  124496. get cameraColorGradingEnabled(): boolean;
  124497. /**
  124498. * Gets wether the color grading effect is enabled.
  124499. */
  124500. set cameraColorGradingEnabled(value: boolean);
  124501. /**
  124502. * Gets wether tonemapping is enabled or not.
  124503. */
  124504. get cameraToneMappingEnabled(): boolean;
  124505. /**
  124506. * Sets wether tonemapping is enabled or not
  124507. */
  124508. set cameraToneMappingEnabled(value: boolean);
  124509. /**
  124510. * The camera exposure used on this material.
  124511. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124512. * This corresponds to a photographic exposure.
  124513. */
  124514. get cameraExposure(): number;
  124515. /**
  124516. * The camera exposure used on this material.
  124517. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124518. * This corresponds to a photographic exposure.
  124519. */
  124520. set cameraExposure(value: number);
  124521. /**
  124522. * Gets The camera contrast used on this material.
  124523. */
  124524. get cameraContrast(): number;
  124525. /**
  124526. * Sets The camera contrast used on this material.
  124527. */
  124528. set cameraContrast(value: number);
  124529. /**
  124530. * Gets the Color Grading 2D Lookup Texture.
  124531. */
  124532. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124533. /**
  124534. * Sets the Color Grading 2D Lookup Texture.
  124535. */
  124536. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124537. /**
  124538. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124539. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124540. * 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;
  124541. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124542. */
  124543. get cameraColorCurves(): Nullable<ColorCurves>;
  124544. /**
  124545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124547. * 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;
  124548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124549. */
  124550. set cameraColorCurves(value: Nullable<ColorCurves>);
  124551. /**
  124552. * Instantiates a new PBRMaterial instance.
  124553. *
  124554. * @param name The material name
  124555. * @param scene The scene the material will be use in.
  124556. */
  124557. constructor(name: string, scene: Scene);
  124558. /**
  124559. * Returns the name of this material class.
  124560. */
  124561. getClassName(): string;
  124562. /**
  124563. * Makes a duplicate of the current material.
  124564. * @param name - name to use for the new material.
  124565. */
  124566. clone(name: string): PBRMaterial;
  124567. /**
  124568. * Serializes this PBR Material.
  124569. * @returns - An object with the serialized material.
  124570. */
  124571. serialize(): any;
  124572. /**
  124573. * Parses a PBR Material from a serialized object.
  124574. * @param source - Serialized object.
  124575. * @param scene - BJS scene instance.
  124576. * @param rootUrl - url for the scene object
  124577. * @returns - PBRMaterial
  124578. */
  124579. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  124580. }
  124581. }
  124582. declare module BABYLON {
  124583. /**
  124584. * Direct draw surface info
  124585. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  124586. */
  124587. export interface DDSInfo {
  124588. /**
  124589. * Width of the texture
  124590. */
  124591. width: number;
  124592. /**
  124593. * Width of the texture
  124594. */
  124595. height: number;
  124596. /**
  124597. * Number of Mipmaps for the texture
  124598. * @see https://en.wikipedia.org/wiki/Mipmap
  124599. */
  124600. mipmapCount: number;
  124601. /**
  124602. * If the textures format is a known fourCC format
  124603. * @see https://www.fourcc.org/
  124604. */
  124605. isFourCC: boolean;
  124606. /**
  124607. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  124608. */
  124609. isRGB: boolean;
  124610. /**
  124611. * If the texture is a lumincance format
  124612. */
  124613. isLuminance: boolean;
  124614. /**
  124615. * If this is a cube texture
  124616. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  124617. */
  124618. isCube: boolean;
  124619. /**
  124620. * If the texture is a compressed format eg. FOURCC_DXT1
  124621. */
  124622. isCompressed: boolean;
  124623. /**
  124624. * The dxgiFormat of the texture
  124625. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  124626. */
  124627. dxgiFormat: number;
  124628. /**
  124629. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  124630. */
  124631. textureType: number;
  124632. /**
  124633. * Sphericle polynomial created for the dds texture
  124634. */
  124635. sphericalPolynomial?: SphericalPolynomial;
  124636. }
  124637. /**
  124638. * Class used to provide DDS decompression tools
  124639. */
  124640. export class DDSTools {
  124641. /**
  124642. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  124643. */
  124644. static StoreLODInAlphaChannel: boolean;
  124645. /**
  124646. * Gets DDS information from an array buffer
  124647. * @param arrayBuffer defines the array buffer to read data from
  124648. * @returns the DDS information
  124649. */
  124650. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  124651. private static _FloatView;
  124652. private static _Int32View;
  124653. private static _ToHalfFloat;
  124654. private static _FromHalfFloat;
  124655. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  124656. private static _GetHalfFloatRGBAArrayBuffer;
  124657. private static _GetFloatRGBAArrayBuffer;
  124658. private static _GetFloatAsUIntRGBAArrayBuffer;
  124659. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  124660. private static _GetRGBAArrayBuffer;
  124661. private static _ExtractLongWordOrder;
  124662. private static _GetRGBArrayBuffer;
  124663. private static _GetLuminanceArrayBuffer;
  124664. /**
  124665. * Uploads DDS Levels to a Babylon Texture
  124666. * @hidden
  124667. */
  124668. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  124669. }
  124670. interface ThinEngine {
  124671. /**
  124672. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  124673. * @param rootUrl defines the url where the file to load is located
  124674. * @param scene defines the current scene
  124675. * @param lodScale defines scale to apply to the mip map selection
  124676. * @param lodOffset defines offset to apply to the mip map selection
  124677. * @param onLoad defines an optional callback raised when the texture is loaded
  124678. * @param onError defines an optional callback raised if there is an issue to load the texture
  124679. * @param format defines the format of the data
  124680. * @param forcedExtension defines the extension to use to pick the right loader
  124681. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  124682. * @returns the cube texture as an InternalTexture
  124683. */
  124684. 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;
  124685. }
  124686. }
  124687. declare module BABYLON {
  124688. /**
  124689. * Implementation of the DDS Texture Loader.
  124690. * @hidden
  124691. */
  124692. export class _DDSTextureLoader implements IInternalTextureLoader {
  124693. /**
  124694. * Defines wether the loader supports cascade loading the different faces.
  124695. */
  124696. readonly supportCascades: boolean;
  124697. /**
  124698. * This returns if the loader support the current file information.
  124699. * @param extension defines the file extension of the file being loaded
  124700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124701. * @param fallback defines the fallback internal texture if any
  124702. * @param isBase64 defines whether the texture is encoded as a base64
  124703. * @param isBuffer defines whether the texture data are stored as a buffer
  124704. * @returns true if the loader can load the specified file
  124705. */
  124706. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124707. /**
  124708. * Transform the url before loading if required.
  124709. * @param rootUrl the url of the texture
  124710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124711. * @returns the transformed texture
  124712. */
  124713. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124714. /**
  124715. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124716. * @param rootUrl the url of the texture
  124717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124718. * @returns the fallback texture
  124719. */
  124720. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124721. /**
  124722. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124723. * @param data contains the texture data
  124724. * @param texture defines the BabylonJS internal texture
  124725. * @param createPolynomials will be true if polynomials have been requested
  124726. * @param onLoad defines the callback to trigger once the texture is ready
  124727. * @param onError defines the callback to trigger in case of error
  124728. */
  124729. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124730. /**
  124731. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124732. * @param data contains the texture data
  124733. * @param texture defines the BabylonJS internal texture
  124734. * @param callback defines the method to call once ready to upload
  124735. */
  124736. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124737. }
  124738. }
  124739. declare module BABYLON {
  124740. /**
  124741. * Implementation of the ENV Texture Loader.
  124742. * @hidden
  124743. */
  124744. export class _ENVTextureLoader implements IInternalTextureLoader {
  124745. /**
  124746. * Defines wether the loader supports cascade loading the different faces.
  124747. */
  124748. readonly supportCascades: boolean;
  124749. /**
  124750. * This returns if the loader support the current file information.
  124751. * @param extension defines the file extension of the file being loaded
  124752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124753. * @param fallback defines the fallback internal texture if any
  124754. * @param isBase64 defines whether the texture is encoded as a base64
  124755. * @param isBuffer defines whether the texture data are stored as a buffer
  124756. * @returns true if the loader can load the specified file
  124757. */
  124758. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124759. /**
  124760. * Transform the url before loading if required.
  124761. * @param rootUrl the url of the texture
  124762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124763. * @returns the transformed texture
  124764. */
  124765. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124766. /**
  124767. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124768. * @param rootUrl the url of the texture
  124769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124770. * @returns the fallback texture
  124771. */
  124772. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124773. /**
  124774. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124775. * @param data contains the texture data
  124776. * @param texture defines the BabylonJS internal texture
  124777. * @param createPolynomials will be true if polynomials have been requested
  124778. * @param onLoad defines the callback to trigger once the texture is ready
  124779. * @param onError defines the callback to trigger in case of error
  124780. */
  124781. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124782. /**
  124783. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124784. * @param data contains the texture data
  124785. * @param texture defines the BabylonJS internal texture
  124786. * @param callback defines the method to call once ready to upload
  124787. */
  124788. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124789. }
  124790. }
  124791. declare module BABYLON {
  124792. /**
  124793. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124794. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124795. */
  124796. export class KhronosTextureContainer {
  124797. /** contents of the KTX container file */
  124798. arrayBuffer: any;
  124799. private static HEADER_LEN;
  124800. private static COMPRESSED_2D;
  124801. private static COMPRESSED_3D;
  124802. private static TEX_2D;
  124803. private static TEX_3D;
  124804. /**
  124805. * Gets the openGL type
  124806. */
  124807. glType: number;
  124808. /**
  124809. * Gets the openGL type size
  124810. */
  124811. glTypeSize: number;
  124812. /**
  124813. * Gets the openGL format
  124814. */
  124815. glFormat: number;
  124816. /**
  124817. * Gets the openGL internal format
  124818. */
  124819. glInternalFormat: number;
  124820. /**
  124821. * Gets the base internal format
  124822. */
  124823. glBaseInternalFormat: number;
  124824. /**
  124825. * Gets image width in pixel
  124826. */
  124827. pixelWidth: number;
  124828. /**
  124829. * Gets image height in pixel
  124830. */
  124831. pixelHeight: number;
  124832. /**
  124833. * Gets image depth in pixels
  124834. */
  124835. pixelDepth: number;
  124836. /**
  124837. * Gets the number of array elements
  124838. */
  124839. numberOfArrayElements: number;
  124840. /**
  124841. * Gets the number of faces
  124842. */
  124843. numberOfFaces: number;
  124844. /**
  124845. * Gets the number of mipmap levels
  124846. */
  124847. numberOfMipmapLevels: number;
  124848. /**
  124849. * Gets the bytes of key value data
  124850. */
  124851. bytesOfKeyValueData: number;
  124852. /**
  124853. * Gets the load type
  124854. */
  124855. loadType: number;
  124856. /**
  124857. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  124858. */
  124859. isInvalid: boolean;
  124860. /**
  124861. * Creates a new KhronosTextureContainer
  124862. * @param arrayBuffer contents of the KTX container file
  124863. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  124864. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  124865. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  124866. */
  124867. constructor(
  124868. /** contents of the KTX container file */
  124869. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  124870. /**
  124871. * Uploads KTX content to a Babylon Texture.
  124872. * It is assumed that the texture has already been created & is currently bound
  124873. * @hidden
  124874. */
  124875. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  124876. private _upload2DCompressedLevels;
  124877. }
  124878. }
  124879. declare module BABYLON {
  124880. /**
  124881. * Implementation of the KTX Texture Loader.
  124882. * @hidden
  124883. */
  124884. export class _KTXTextureLoader implements IInternalTextureLoader {
  124885. /**
  124886. * Defines wether the loader supports cascade loading the different faces.
  124887. */
  124888. readonly supportCascades: boolean;
  124889. /**
  124890. * This returns if the loader support the current file information.
  124891. * @param extension defines the file extension of the file being loaded
  124892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124893. * @param fallback defines the fallback internal texture if any
  124894. * @param isBase64 defines whether the texture is encoded as a base64
  124895. * @param isBuffer defines whether the texture data are stored as a buffer
  124896. * @returns true if the loader can load the specified file
  124897. */
  124898. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124899. /**
  124900. * Transform the url before loading if required.
  124901. * @param rootUrl the url of the texture
  124902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124903. * @returns the transformed texture
  124904. */
  124905. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124906. /**
  124907. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124908. * @param rootUrl the url of the texture
  124909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124910. * @returns the fallback texture
  124911. */
  124912. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124913. /**
  124914. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124915. * @param data contains the texture data
  124916. * @param texture defines the BabylonJS internal texture
  124917. * @param createPolynomials will be true if polynomials have been requested
  124918. * @param onLoad defines the callback to trigger once the texture is ready
  124919. * @param onError defines the callback to trigger in case of error
  124920. */
  124921. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124922. /**
  124923. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124924. * @param data contains the texture data
  124925. * @param texture defines the BabylonJS internal texture
  124926. * @param callback defines the method to call once ready to upload
  124927. */
  124928. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  124929. }
  124930. }
  124931. declare module BABYLON {
  124932. /** @hidden */
  124933. export var _forceSceneHelpersToBundle: boolean;
  124934. interface Scene {
  124935. /**
  124936. * Creates a default light for the scene.
  124937. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  124938. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  124939. */
  124940. createDefaultLight(replace?: boolean): void;
  124941. /**
  124942. * Creates a default camera for the scene.
  124943. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  124944. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124945. * @param replace has default false, when true replaces the active camera in the scene
  124946. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  124947. */
  124948. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124949. /**
  124950. * Creates a default camera and a default light.
  124951. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  124952. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124953. * @param replace has the default false, when true replaces the active camera/light in the scene
  124954. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  124955. */
  124956. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124957. /**
  124958. * Creates a new sky box
  124959. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  124960. * @param environmentTexture defines the texture to use as environment texture
  124961. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  124962. * @param scale defines the overall scale of the skybox
  124963. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  124964. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  124965. * @returns a new mesh holding the sky box
  124966. */
  124967. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  124968. /**
  124969. * Creates a new environment
  124970. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  124971. * @param options defines the options you can use to configure the environment
  124972. * @returns the new EnvironmentHelper
  124973. */
  124974. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  124975. /**
  124976. * Creates a new VREXperienceHelper
  124977. * @see http://doc.babylonjs.com/how_to/webvr_helper
  124978. * @param webVROptions defines the options used to create the new VREXperienceHelper
  124979. * @returns a new VREXperienceHelper
  124980. */
  124981. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  124982. /**
  124983. * Creates a new WebXRDefaultExperience
  124984. * @see http://doc.babylonjs.com/how_to/webxr
  124985. * @param options experience options
  124986. * @returns a promise for a new WebXRDefaultExperience
  124987. */
  124988. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  124989. }
  124990. }
  124991. declare module BABYLON {
  124992. /**
  124993. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  124994. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  124995. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  124996. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124997. */
  124998. export class VideoDome extends TransformNode {
  124999. /**
  125000. * Define the video source as a Monoscopic panoramic 360 video.
  125001. */
  125002. static readonly MODE_MONOSCOPIC: number;
  125003. /**
  125004. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125005. */
  125006. static readonly MODE_TOPBOTTOM: number;
  125007. /**
  125008. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125009. */
  125010. static readonly MODE_SIDEBYSIDE: number;
  125011. private _halfDome;
  125012. private _useDirectMapping;
  125013. /**
  125014. * The video texture being displayed on the sphere
  125015. */
  125016. protected _videoTexture: VideoTexture;
  125017. /**
  125018. * Gets the video texture being displayed on the sphere
  125019. */
  125020. get videoTexture(): VideoTexture;
  125021. /**
  125022. * The skybox material
  125023. */
  125024. protected _material: BackgroundMaterial;
  125025. /**
  125026. * The surface used for the skybox
  125027. */
  125028. protected _mesh: Mesh;
  125029. /**
  125030. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125031. */
  125032. private _halfDomeMask;
  125033. /**
  125034. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125035. * Also see the options.resolution property.
  125036. */
  125037. get fovMultiplier(): number;
  125038. set fovMultiplier(value: number);
  125039. private _videoMode;
  125040. /**
  125041. * Gets or set the current video mode for the video. It can be:
  125042. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125043. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125044. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125045. */
  125046. get videoMode(): number;
  125047. set videoMode(value: number);
  125048. /**
  125049. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125050. *
  125051. */
  125052. get halfDome(): boolean;
  125053. /**
  125054. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125055. */
  125056. set halfDome(enabled: boolean);
  125057. /**
  125058. * Oberserver used in Stereoscopic VR Mode.
  125059. */
  125060. private _onBeforeCameraRenderObserver;
  125061. /**
  125062. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125063. * @param name Element's name, child elements will append suffixes for their own names.
  125064. * @param urlsOrVideo defines the url(s) or the video element to use
  125065. * @param options An object containing optional or exposed sub element properties
  125066. */
  125067. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125068. resolution?: number;
  125069. clickToPlay?: boolean;
  125070. autoPlay?: boolean;
  125071. loop?: boolean;
  125072. size?: number;
  125073. poster?: string;
  125074. faceForward?: boolean;
  125075. useDirectMapping?: boolean;
  125076. halfDomeMode?: boolean;
  125077. }, scene: Scene);
  125078. private _changeVideoMode;
  125079. /**
  125080. * Releases resources associated with this node.
  125081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125083. */
  125084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125085. }
  125086. }
  125087. declare module BABYLON {
  125088. /**
  125089. * This class can be used to get instrumentation data from a Babylon engine
  125090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125091. */
  125092. export class EngineInstrumentation implements IDisposable {
  125093. /**
  125094. * Define the instrumented engine.
  125095. */
  125096. engine: Engine;
  125097. private _captureGPUFrameTime;
  125098. private _gpuFrameTimeToken;
  125099. private _gpuFrameTime;
  125100. private _captureShaderCompilationTime;
  125101. private _shaderCompilationTime;
  125102. private _onBeginFrameObserver;
  125103. private _onEndFrameObserver;
  125104. private _onBeforeShaderCompilationObserver;
  125105. private _onAfterShaderCompilationObserver;
  125106. /**
  125107. * Gets the perf counter used for GPU frame time
  125108. */
  125109. get gpuFrameTimeCounter(): PerfCounter;
  125110. /**
  125111. * Gets the GPU frame time capture status
  125112. */
  125113. get captureGPUFrameTime(): boolean;
  125114. /**
  125115. * Enable or disable the GPU frame time capture
  125116. */
  125117. set captureGPUFrameTime(value: boolean);
  125118. /**
  125119. * Gets the perf counter used for shader compilation time
  125120. */
  125121. get shaderCompilationTimeCounter(): PerfCounter;
  125122. /**
  125123. * Gets the shader compilation time capture status
  125124. */
  125125. get captureShaderCompilationTime(): boolean;
  125126. /**
  125127. * Enable or disable the shader compilation time capture
  125128. */
  125129. set captureShaderCompilationTime(value: boolean);
  125130. /**
  125131. * Instantiates a new engine instrumentation.
  125132. * This class can be used to get instrumentation data from a Babylon engine
  125133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125134. * @param engine Defines the engine to instrument
  125135. */
  125136. constructor(
  125137. /**
  125138. * Define the instrumented engine.
  125139. */
  125140. engine: Engine);
  125141. /**
  125142. * Dispose and release associated resources.
  125143. */
  125144. dispose(): void;
  125145. }
  125146. }
  125147. declare module BABYLON {
  125148. /**
  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#sceneinstrumentation
  125151. */
  125152. export class SceneInstrumentation implements IDisposable {
  125153. /**
  125154. * Defines the scene to instrument
  125155. */
  125156. scene: Scene;
  125157. private _captureActiveMeshesEvaluationTime;
  125158. private _activeMeshesEvaluationTime;
  125159. private _captureRenderTargetsRenderTime;
  125160. private _renderTargetsRenderTime;
  125161. private _captureFrameTime;
  125162. private _frameTime;
  125163. private _captureRenderTime;
  125164. private _renderTime;
  125165. private _captureInterFrameTime;
  125166. private _interFrameTime;
  125167. private _captureParticlesRenderTime;
  125168. private _particlesRenderTime;
  125169. private _captureSpritesRenderTime;
  125170. private _spritesRenderTime;
  125171. private _capturePhysicsTime;
  125172. private _physicsTime;
  125173. private _captureAnimationsTime;
  125174. private _animationsTime;
  125175. private _captureCameraRenderTime;
  125176. private _cameraRenderTime;
  125177. private _onBeforeActiveMeshesEvaluationObserver;
  125178. private _onAfterActiveMeshesEvaluationObserver;
  125179. private _onBeforeRenderTargetsRenderObserver;
  125180. private _onAfterRenderTargetsRenderObserver;
  125181. private _onAfterRenderObserver;
  125182. private _onBeforeDrawPhaseObserver;
  125183. private _onAfterDrawPhaseObserver;
  125184. private _onBeforeAnimationsObserver;
  125185. private _onBeforeParticlesRenderingObserver;
  125186. private _onAfterParticlesRenderingObserver;
  125187. private _onBeforeSpritesRenderingObserver;
  125188. private _onAfterSpritesRenderingObserver;
  125189. private _onBeforePhysicsObserver;
  125190. private _onAfterPhysicsObserver;
  125191. private _onAfterAnimationsObserver;
  125192. private _onBeforeCameraRenderObserver;
  125193. private _onAfterCameraRenderObserver;
  125194. /**
  125195. * Gets the perf counter used for active meshes evaluation time
  125196. */
  125197. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125198. /**
  125199. * Gets the active meshes evaluation time capture status
  125200. */
  125201. get captureActiveMeshesEvaluationTime(): boolean;
  125202. /**
  125203. * Enable or disable the active meshes evaluation time capture
  125204. */
  125205. set captureActiveMeshesEvaluationTime(value: boolean);
  125206. /**
  125207. * Gets the perf counter used for render targets render time
  125208. */
  125209. get renderTargetsRenderTimeCounter(): PerfCounter;
  125210. /**
  125211. * Gets the render targets render time capture status
  125212. */
  125213. get captureRenderTargetsRenderTime(): boolean;
  125214. /**
  125215. * Enable or disable the render targets render time capture
  125216. */
  125217. set captureRenderTargetsRenderTime(value: boolean);
  125218. /**
  125219. * Gets the perf counter used for particles render time
  125220. */
  125221. get particlesRenderTimeCounter(): PerfCounter;
  125222. /**
  125223. * Gets the particles render time capture status
  125224. */
  125225. get captureParticlesRenderTime(): boolean;
  125226. /**
  125227. * Enable or disable the particles render time capture
  125228. */
  125229. set captureParticlesRenderTime(value: boolean);
  125230. /**
  125231. * Gets the perf counter used for sprites render time
  125232. */
  125233. get spritesRenderTimeCounter(): PerfCounter;
  125234. /**
  125235. * Gets the sprites render time capture status
  125236. */
  125237. get captureSpritesRenderTime(): boolean;
  125238. /**
  125239. * Enable or disable the sprites render time capture
  125240. */
  125241. set captureSpritesRenderTime(value: boolean);
  125242. /**
  125243. * Gets the perf counter used for physics time
  125244. */
  125245. get physicsTimeCounter(): PerfCounter;
  125246. /**
  125247. * Gets the physics time capture status
  125248. */
  125249. get capturePhysicsTime(): boolean;
  125250. /**
  125251. * Enable or disable the physics time capture
  125252. */
  125253. set capturePhysicsTime(value: boolean);
  125254. /**
  125255. * Gets the perf counter used for animations time
  125256. */
  125257. get animationsTimeCounter(): PerfCounter;
  125258. /**
  125259. * Gets the animations time capture status
  125260. */
  125261. get captureAnimationsTime(): boolean;
  125262. /**
  125263. * Enable or disable the animations time capture
  125264. */
  125265. set captureAnimationsTime(value: boolean);
  125266. /**
  125267. * Gets the perf counter used for frame time capture
  125268. */
  125269. get frameTimeCounter(): PerfCounter;
  125270. /**
  125271. * Gets the frame time capture status
  125272. */
  125273. get captureFrameTime(): boolean;
  125274. /**
  125275. * Enable or disable the frame time capture
  125276. */
  125277. set captureFrameTime(value: boolean);
  125278. /**
  125279. * Gets the perf counter used for inter-frames time capture
  125280. */
  125281. get interFrameTimeCounter(): PerfCounter;
  125282. /**
  125283. * Gets the inter-frames time capture status
  125284. */
  125285. get captureInterFrameTime(): boolean;
  125286. /**
  125287. * Enable or disable the inter-frames time capture
  125288. */
  125289. set captureInterFrameTime(value: boolean);
  125290. /**
  125291. * Gets the perf counter used for render time capture
  125292. */
  125293. get renderTimeCounter(): PerfCounter;
  125294. /**
  125295. * Gets the render time capture status
  125296. */
  125297. get captureRenderTime(): boolean;
  125298. /**
  125299. * Enable or disable the render time capture
  125300. */
  125301. set captureRenderTime(value: boolean);
  125302. /**
  125303. * Gets the perf counter used for camera render time capture
  125304. */
  125305. get cameraRenderTimeCounter(): PerfCounter;
  125306. /**
  125307. * Gets the camera render time capture status
  125308. */
  125309. get captureCameraRenderTime(): boolean;
  125310. /**
  125311. * Enable or disable the camera render time capture
  125312. */
  125313. set captureCameraRenderTime(value: boolean);
  125314. /**
  125315. * Gets the perf counter used for draw calls
  125316. */
  125317. get drawCallsCounter(): PerfCounter;
  125318. /**
  125319. * Instantiates a new scene instrumentation.
  125320. * This class can be used to get instrumentation data from a Babylon engine
  125321. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125322. * @param scene Defines the scene to instrument
  125323. */
  125324. constructor(
  125325. /**
  125326. * Defines the scene to instrument
  125327. */
  125328. scene: Scene);
  125329. /**
  125330. * Dispose and release associated resources.
  125331. */
  125332. dispose(): void;
  125333. }
  125334. }
  125335. declare module BABYLON {
  125336. /** @hidden */
  125337. export var glowMapGenerationPixelShader: {
  125338. name: string;
  125339. shader: string;
  125340. };
  125341. }
  125342. declare module BABYLON {
  125343. /** @hidden */
  125344. export var glowMapGenerationVertexShader: {
  125345. name: string;
  125346. shader: string;
  125347. };
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * Effect layer options. This helps customizing the behaviour
  125352. * of the effect layer.
  125353. */
  125354. export interface IEffectLayerOptions {
  125355. /**
  125356. * Multiplication factor apply to the canvas size to compute the render target size
  125357. * used to generated the objects (the smaller the faster).
  125358. */
  125359. mainTextureRatio: number;
  125360. /**
  125361. * Enforces a fixed size texture to ensure effect stability across devices.
  125362. */
  125363. mainTextureFixedSize?: number;
  125364. /**
  125365. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125366. */
  125367. alphaBlendingMode: number;
  125368. /**
  125369. * The camera attached to the layer.
  125370. */
  125371. camera: Nullable<Camera>;
  125372. /**
  125373. * The rendering group to draw the layer in.
  125374. */
  125375. renderingGroupId: number;
  125376. }
  125377. /**
  125378. * The effect layer Helps adding post process effect blended with the main pass.
  125379. *
  125380. * This can be for instance use to generate glow or higlight effects on the scene.
  125381. *
  125382. * The effect layer class can not be used directly and is intented to inherited from to be
  125383. * customized per effects.
  125384. */
  125385. export abstract class EffectLayer {
  125386. private _vertexBuffers;
  125387. private _indexBuffer;
  125388. private _cachedDefines;
  125389. private _effectLayerMapGenerationEffect;
  125390. private _effectLayerOptions;
  125391. private _mergeEffect;
  125392. protected _scene: Scene;
  125393. protected _engine: Engine;
  125394. protected _maxSize: number;
  125395. protected _mainTextureDesiredSize: ISize;
  125396. protected _mainTexture: RenderTargetTexture;
  125397. protected _shouldRender: boolean;
  125398. protected _postProcesses: PostProcess[];
  125399. protected _textures: BaseTexture[];
  125400. protected _emissiveTextureAndColor: {
  125401. texture: Nullable<BaseTexture>;
  125402. color: Color4;
  125403. };
  125404. /**
  125405. * The name of the layer
  125406. */
  125407. name: string;
  125408. /**
  125409. * The clear color of the texture used to generate the glow map.
  125410. */
  125411. neutralColor: Color4;
  125412. /**
  125413. * Specifies wether the highlight layer is enabled or not.
  125414. */
  125415. isEnabled: boolean;
  125416. /**
  125417. * Gets the camera attached to the layer.
  125418. */
  125419. get camera(): Nullable<Camera>;
  125420. /**
  125421. * Gets the rendering group id the layer should render in.
  125422. */
  125423. get renderingGroupId(): number;
  125424. set renderingGroupId(renderingGroupId: number);
  125425. /**
  125426. * An event triggered when the effect layer has been disposed.
  125427. */
  125428. onDisposeObservable: Observable<EffectLayer>;
  125429. /**
  125430. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125431. */
  125432. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125433. /**
  125434. * An event triggered when the generated texture is being merged in the scene.
  125435. */
  125436. onBeforeComposeObservable: Observable<EffectLayer>;
  125437. /**
  125438. * An event triggered when the mesh is rendered into the effect render target.
  125439. */
  125440. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125441. /**
  125442. * An event triggered after the mesh has been rendered into the effect render target.
  125443. */
  125444. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125445. /**
  125446. * An event triggered when the generated texture has been merged in the scene.
  125447. */
  125448. onAfterComposeObservable: Observable<EffectLayer>;
  125449. /**
  125450. * An event triggered when the efffect layer changes its size.
  125451. */
  125452. onSizeChangedObservable: Observable<EffectLayer>;
  125453. /** @hidden */
  125454. static _SceneComponentInitialization: (scene: Scene) => void;
  125455. /**
  125456. * Instantiates a new effect Layer and references it in the scene.
  125457. * @param name The name of the layer
  125458. * @param scene The scene to use the layer in
  125459. */
  125460. constructor(
  125461. /** The Friendly of the effect in the scene */
  125462. name: string, scene: Scene);
  125463. /**
  125464. * Get the effect name of the layer.
  125465. * @return The effect name
  125466. */
  125467. abstract getEffectName(): string;
  125468. /**
  125469. * Checks for the readiness of the element composing the layer.
  125470. * @param subMesh the mesh to check for
  125471. * @param useInstances specify wether or not to use instances to render the mesh
  125472. * @return true if ready otherwise, false
  125473. */
  125474. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125475. /**
  125476. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125477. * @returns true if the effect requires stencil during the main canvas render pass.
  125478. */
  125479. abstract needStencil(): boolean;
  125480. /**
  125481. * Create the merge effect. This is the shader use to blit the information back
  125482. * to the main canvas at the end of the scene rendering.
  125483. * @returns The effect containing the shader used to merge the effect on the main canvas
  125484. */
  125485. protected abstract _createMergeEffect(): Effect;
  125486. /**
  125487. * Creates the render target textures and post processes used in the effect layer.
  125488. */
  125489. protected abstract _createTextureAndPostProcesses(): void;
  125490. /**
  125491. * Implementation specific of rendering the generating effect on the main canvas.
  125492. * @param effect The effect used to render through
  125493. */
  125494. protected abstract _internalRender(effect: Effect): void;
  125495. /**
  125496. * Sets the required values for both the emissive texture and and the main color.
  125497. */
  125498. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125499. /**
  125500. * Free any resources and references associated to a mesh.
  125501. * Internal use
  125502. * @param mesh The mesh to free.
  125503. */
  125504. abstract _disposeMesh(mesh: Mesh): void;
  125505. /**
  125506. * Serializes this layer (Glow or Highlight for example)
  125507. * @returns a serialized layer object
  125508. */
  125509. abstract serialize?(): any;
  125510. /**
  125511. * Initializes the effect layer with the required options.
  125512. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125513. */
  125514. protected _init(options: Partial<IEffectLayerOptions>): void;
  125515. /**
  125516. * Generates the index buffer of the full screen quad blending to the main canvas.
  125517. */
  125518. private _generateIndexBuffer;
  125519. /**
  125520. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  125521. */
  125522. private _generateVertexBuffer;
  125523. /**
  125524. * Sets the main texture desired size which is the closest power of two
  125525. * of the engine canvas size.
  125526. */
  125527. private _setMainTextureSize;
  125528. /**
  125529. * Creates the main texture for the effect layer.
  125530. */
  125531. protected _createMainTexture(): void;
  125532. /**
  125533. * Adds specific effects defines.
  125534. * @param defines The defines to add specifics to.
  125535. */
  125536. protected _addCustomEffectDefines(defines: string[]): void;
  125537. /**
  125538. * Checks for the readiness of the element composing the layer.
  125539. * @param subMesh the mesh to check for
  125540. * @param useInstances specify wether or not to use instances to render the mesh
  125541. * @param emissiveTexture the associated emissive texture used to generate the glow
  125542. * @return true if ready otherwise, false
  125543. */
  125544. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  125545. /**
  125546. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  125547. */
  125548. render(): void;
  125549. /**
  125550. * Determine if a given mesh will be used in the current effect.
  125551. * @param mesh mesh to test
  125552. * @returns true if the mesh will be used
  125553. */
  125554. hasMesh(mesh: AbstractMesh): boolean;
  125555. /**
  125556. * Returns true if the layer contains information to display, otherwise false.
  125557. * @returns true if the glow layer should be rendered
  125558. */
  125559. shouldRender(): boolean;
  125560. /**
  125561. * Returns true if the mesh should render, otherwise false.
  125562. * @param mesh The mesh to render
  125563. * @returns true if it should render otherwise false
  125564. */
  125565. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  125566. /**
  125567. * Returns true if the mesh can be rendered, otherwise false.
  125568. * @param mesh The mesh to render
  125569. * @param material The material used on the mesh
  125570. * @returns true if it can be rendered otherwise false
  125571. */
  125572. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125573. /**
  125574. * Returns true if the mesh should render, otherwise false.
  125575. * @param mesh The mesh to render
  125576. * @returns true if it should render otherwise false
  125577. */
  125578. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  125579. /**
  125580. * Renders the submesh passed in parameter to the generation map.
  125581. */
  125582. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  125583. /**
  125584. * Defines wether the current material of the mesh should be use to render the effect.
  125585. * @param mesh defines the current mesh to render
  125586. */
  125587. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125588. /**
  125589. * Rebuild the required buffers.
  125590. * @hidden Internal use only.
  125591. */
  125592. _rebuild(): void;
  125593. /**
  125594. * Dispose only the render target textures and post process.
  125595. */
  125596. private _disposeTextureAndPostProcesses;
  125597. /**
  125598. * Dispose the highlight layer and free resources.
  125599. */
  125600. dispose(): void;
  125601. /**
  125602. * Gets the class name of the effect layer
  125603. * @returns the string with the class name of the effect layer
  125604. */
  125605. getClassName(): string;
  125606. /**
  125607. * Creates an effect layer from parsed effect layer data
  125608. * @param parsedEffectLayer defines effect layer data
  125609. * @param scene defines the current scene
  125610. * @param rootUrl defines the root URL containing the effect layer information
  125611. * @returns a parsed effect Layer
  125612. */
  125613. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  125614. }
  125615. }
  125616. declare module BABYLON {
  125617. interface AbstractScene {
  125618. /**
  125619. * The list of effect layers (highlights/glow) added to the scene
  125620. * @see http://doc.babylonjs.com/how_to/highlight_layer
  125621. * @see http://doc.babylonjs.com/how_to/glow_layer
  125622. */
  125623. effectLayers: Array<EffectLayer>;
  125624. /**
  125625. * Removes the given effect layer from this scene.
  125626. * @param toRemove defines the effect layer to remove
  125627. * @returns the index of the removed effect layer
  125628. */
  125629. removeEffectLayer(toRemove: EffectLayer): number;
  125630. /**
  125631. * Adds the given effect layer to this scene
  125632. * @param newEffectLayer defines the effect layer to add
  125633. */
  125634. addEffectLayer(newEffectLayer: EffectLayer): void;
  125635. }
  125636. /**
  125637. * Defines the layer scene component responsible to manage any effect layers
  125638. * in a given scene.
  125639. */
  125640. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  125641. /**
  125642. * The component name helpfull to identify the component in the list of scene components.
  125643. */
  125644. readonly name: string;
  125645. /**
  125646. * The scene the component belongs to.
  125647. */
  125648. scene: Scene;
  125649. private _engine;
  125650. private _renderEffects;
  125651. private _needStencil;
  125652. private _previousStencilState;
  125653. /**
  125654. * Creates a new instance of the component for the given scene
  125655. * @param scene Defines the scene to register the component in
  125656. */
  125657. constructor(scene: Scene);
  125658. /**
  125659. * Registers the component in a given scene
  125660. */
  125661. register(): void;
  125662. /**
  125663. * Rebuilds the elements related to this component in case of
  125664. * context lost for instance.
  125665. */
  125666. rebuild(): void;
  125667. /**
  125668. * Serializes the component data to the specified json object
  125669. * @param serializationObject The object to serialize to
  125670. */
  125671. serialize(serializationObject: any): void;
  125672. /**
  125673. * Adds all the elements from the container to the scene
  125674. * @param container the container holding the elements
  125675. */
  125676. addFromContainer(container: AbstractScene): void;
  125677. /**
  125678. * Removes all the elements in the container from the scene
  125679. * @param container contains the elements to remove
  125680. * @param dispose if the removed element should be disposed (default: false)
  125681. */
  125682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125683. /**
  125684. * Disposes the component and the associated ressources.
  125685. */
  125686. dispose(): void;
  125687. private _isReadyForMesh;
  125688. private _renderMainTexture;
  125689. private _setStencil;
  125690. private _setStencilBack;
  125691. private _draw;
  125692. private _drawCamera;
  125693. private _drawRenderingGroup;
  125694. }
  125695. }
  125696. declare module BABYLON {
  125697. /** @hidden */
  125698. export var glowMapMergePixelShader: {
  125699. name: string;
  125700. shader: string;
  125701. };
  125702. }
  125703. declare module BABYLON {
  125704. /** @hidden */
  125705. export var glowMapMergeVertexShader: {
  125706. name: string;
  125707. shader: string;
  125708. };
  125709. }
  125710. declare module BABYLON {
  125711. interface AbstractScene {
  125712. /**
  125713. * Return a the first highlight layer of the scene with a given name.
  125714. * @param name The name of the highlight layer to look for.
  125715. * @return The highlight layer if found otherwise null.
  125716. */
  125717. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  125718. }
  125719. /**
  125720. * Glow layer options. This helps customizing the behaviour
  125721. * of the glow layer.
  125722. */
  125723. export interface IGlowLayerOptions {
  125724. /**
  125725. * Multiplication factor apply to the canvas size to compute the render target size
  125726. * used to generated the glowing objects (the smaller the faster).
  125727. */
  125728. mainTextureRatio: number;
  125729. /**
  125730. * Enforces a fixed size texture to ensure resize independant blur.
  125731. */
  125732. mainTextureFixedSize?: number;
  125733. /**
  125734. * How big is the kernel of the blur texture.
  125735. */
  125736. blurKernelSize: number;
  125737. /**
  125738. * The camera attached to the layer.
  125739. */
  125740. camera: Nullable<Camera>;
  125741. /**
  125742. * Enable MSAA by chosing the number of samples.
  125743. */
  125744. mainTextureSamples?: number;
  125745. /**
  125746. * The rendering group to draw the layer in.
  125747. */
  125748. renderingGroupId: number;
  125749. }
  125750. /**
  125751. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  125752. *
  125753. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  125754. *
  125755. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  125756. */
  125757. export class GlowLayer extends EffectLayer {
  125758. /**
  125759. * Effect Name of the layer.
  125760. */
  125761. static readonly EffectName: string;
  125762. /**
  125763. * The default blur kernel size used for the glow.
  125764. */
  125765. static DefaultBlurKernelSize: number;
  125766. /**
  125767. * The default texture size ratio used for the glow.
  125768. */
  125769. static DefaultTextureRatio: number;
  125770. /**
  125771. * Sets the kernel size of the blur.
  125772. */
  125773. set blurKernelSize(value: number);
  125774. /**
  125775. * Gets the kernel size of the blur.
  125776. */
  125777. get blurKernelSize(): number;
  125778. /**
  125779. * Sets the glow intensity.
  125780. */
  125781. set intensity(value: number);
  125782. /**
  125783. * Gets the glow intensity.
  125784. */
  125785. get intensity(): number;
  125786. private _options;
  125787. private _intensity;
  125788. private _horizontalBlurPostprocess1;
  125789. private _verticalBlurPostprocess1;
  125790. private _horizontalBlurPostprocess2;
  125791. private _verticalBlurPostprocess2;
  125792. private _blurTexture1;
  125793. private _blurTexture2;
  125794. private _postProcesses1;
  125795. private _postProcesses2;
  125796. private _includedOnlyMeshes;
  125797. private _excludedMeshes;
  125798. private _meshesUsingTheirOwnMaterials;
  125799. /**
  125800. * Callback used to let the user override the color selection on a per mesh basis
  125801. */
  125802. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  125803. /**
  125804. * Callback used to let the user override the texture selection on a per mesh basis
  125805. */
  125806. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  125807. /**
  125808. * Instantiates a new glow Layer and references it to the scene.
  125809. * @param name The name of the layer
  125810. * @param scene The scene to use the layer in
  125811. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  125812. */
  125813. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  125814. /**
  125815. * Get the effect name of the layer.
  125816. * @return The effect name
  125817. */
  125818. getEffectName(): string;
  125819. /**
  125820. * Create the merge effect. This is the shader use to blit the information back
  125821. * to the main canvas at the end of the scene rendering.
  125822. */
  125823. protected _createMergeEffect(): Effect;
  125824. /**
  125825. * Creates the render target textures and post processes used in the glow layer.
  125826. */
  125827. protected _createTextureAndPostProcesses(): void;
  125828. /**
  125829. * Checks for the readiness of the element composing the layer.
  125830. * @param subMesh the mesh to check for
  125831. * @param useInstances specify wether or not to use instances to render the mesh
  125832. * @param emissiveTexture the associated emissive texture used to generate the glow
  125833. * @return true if ready otherwise, false
  125834. */
  125835. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125836. /**
  125837. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125838. */
  125839. needStencil(): boolean;
  125840. /**
  125841. * Returns true if the mesh can be rendered, otherwise false.
  125842. * @param mesh The mesh to render
  125843. * @param material The material used on the mesh
  125844. * @returns true if it can be rendered otherwise false
  125845. */
  125846. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125847. /**
  125848. * Implementation specific of rendering the generating effect on the main canvas.
  125849. * @param effect The effect used to render through
  125850. */
  125851. protected _internalRender(effect: Effect): void;
  125852. /**
  125853. * Sets the required values for both the emissive texture and and the main color.
  125854. */
  125855. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125856. /**
  125857. * Returns true if the mesh should render, otherwise false.
  125858. * @param mesh The mesh to render
  125859. * @returns true if it should render otherwise false
  125860. */
  125861. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125862. /**
  125863. * Adds specific effects defines.
  125864. * @param defines The defines to add specifics to.
  125865. */
  125866. protected _addCustomEffectDefines(defines: string[]): void;
  125867. /**
  125868. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  125869. * @param mesh The mesh to exclude from the glow layer
  125870. */
  125871. addExcludedMesh(mesh: Mesh): void;
  125872. /**
  125873. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  125874. * @param mesh The mesh to remove
  125875. */
  125876. removeExcludedMesh(mesh: Mesh): void;
  125877. /**
  125878. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  125879. * @param mesh The mesh to include in the glow layer
  125880. */
  125881. addIncludedOnlyMesh(mesh: Mesh): void;
  125882. /**
  125883. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  125884. * @param mesh The mesh to remove
  125885. */
  125886. removeIncludedOnlyMesh(mesh: Mesh): void;
  125887. /**
  125888. * Determine if a given mesh will be used in the glow layer
  125889. * @param mesh The mesh to test
  125890. * @returns true if the mesh will be highlighted by the current glow layer
  125891. */
  125892. hasMesh(mesh: AbstractMesh): boolean;
  125893. /**
  125894. * Defines wether the current material of the mesh should be use to render the effect.
  125895. * @param mesh defines the current mesh to render
  125896. */
  125897. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125898. /**
  125899. * Add a mesh to be rendered through its own material and not with emissive only.
  125900. * @param mesh The mesh for which we need to use its material
  125901. */
  125902. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  125903. /**
  125904. * Remove a mesh from being rendered through its own material and not with emissive only.
  125905. * @param mesh The mesh for which we need to not use its material
  125906. */
  125907. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  125908. /**
  125909. * Free any resources and references associated to a mesh.
  125910. * Internal use
  125911. * @param mesh The mesh to free.
  125912. * @hidden
  125913. */
  125914. _disposeMesh(mesh: Mesh): void;
  125915. /**
  125916. * Gets the class name of the effect layer
  125917. * @returns the string with the class name of the effect layer
  125918. */
  125919. getClassName(): string;
  125920. /**
  125921. * Serializes this glow layer
  125922. * @returns a serialized glow layer object
  125923. */
  125924. serialize(): any;
  125925. /**
  125926. * Creates a Glow Layer from parsed glow layer data
  125927. * @param parsedGlowLayer defines glow layer data
  125928. * @param scene defines the current scene
  125929. * @param rootUrl defines the root URL containing the glow layer information
  125930. * @returns a parsed Glow Layer
  125931. */
  125932. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  125933. }
  125934. }
  125935. declare module BABYLON {
  125936. /** @hidden */
  125937. export var glowBlurPostProcessPixelShader: {
  125938. name: string;
  125939. shader: string;
  125940. };
  125941. }
  125942. declare module BABYLON {
  125943. interface AbstractScene {
  125944. /**
  125945. * Return a the first highlight layer of the scene with a given name.
  125946. * @param name The name of the highlight layer to look for.
  125947. * @return The highlight layer if found otherwise null.
  125948. */
  125949. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  125950. }
  125951. /**
  125952. * Highlight layer options. This helps customizing the behaviour
  125953. * of the highlight layer.
  125954. */
  125955. export interface IHighlightLayerOptions {
  125956. /**
  125957. * Multiplication factor apply to the canvas size to compute the render target size
  125958. * used to generated the glowing objects (the smaller the faster).
  125959. */
  125960. mainTextureRatio: number;
  125961. /**
  125962. * Enforces a fixed size texture to ensure resize independant blur.
  125963. */
  125964. mainTextureFixedSize?: number;
  125965. /**
  125966. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  125967. * of the picture to blur (the smaller the faster).
  125968. */
  125969. blurTextureSizeRatio: number;
  125970. /**
  125971. * How big in texel of the blur texture is the vertical blur.
  125972. */
  125973. blurVerticalSize: number;
  125974. /**
  125975. * How big in texel of the blur texture is the horizontal blur.
  125976. */
  125977. blurHorizontalSize: number;
  125978. /**
  125979. * Alpha blending mode used to apply the blur. Default is combine.
  125980. */
  125981. alphaBlendingMode: number;
  125982. /**
  125983. * The camera attached to the layer.
  125984. */
  125985. camera: Nullable<Camera>;
  125986. /**
  125987. * Should we display highlight as a solid stroke?
  125988. */
  125989. isStroke?: boolean;
  125990. /**
  125991. * The rendering group to draw the layer in.
  125992. */
  125993. renderingGroupId: number;
  125994. }
  125995. /**
  125996. * The highlight layer Helps adding a glow effect around a mesh.
  125997. *
  125998. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  125999. * glowy meshes to your scene.
  126000. *
  126001. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126002. */
  126003. export class HighlightLayer extends EffectLayer {
  126004. name: string;
  126005. /**
  126006. * Effect Name of the highlight layer.
  126007. */
  126008. static readonly EffectName: string;
  126009. /**
  126010. * The neutral color used during the preparation of the glow effect.
  126011. * This is black by default as the blend operation is a blend operation.
  126012. */
  126013. static NeutralColor: Color4;
  126014. /**
  126015. * Stencil value used for glowing meshes.
  126016. */
  126017. static GlowingMeshStencilReference: number;
  126018. /**
  126019. * Stencil value used for the other meshes in the scene.
  126020. */
  126021. static NormalMeshStencilReference: number;
  126022. /**
  126023. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126024. */
  126025. innerGlow: boolean;
  126026. /**
  126027. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126028. */
  126029. outerGlow: boolean;
  126030. /**
  126031. * Specifies the horizontal size of the blur.
  126032. */
  126033. set blurHorizontalSize(value: number);
  126034. /**
  126035. * Specifies the vertical size of the blur.
  126036. */
  126037. set blurVerticalSize(value: number);
  126038. /**
  126039. * Gets the horizontal size of the blur.
  126040. */
  126041. get blurHorizontalSize(): number;
  126042. /**
  126043. * Gets the vertical size of the blur.
  126044. */
  126045. get blurVerticalSize(): number;
  126046. /**
  126047. * An event triggered when the highlight layer is being blurred.
  126048. */
  126049. onBeforeBlurObservable: Observable<HighlightLayer>;
  126050. /**
  126051. * An event triggered when the highlight layer has been blurred.
  126052. */
  126053. onAfterBlurObservable: Observable<HighlightLayer>;
  126054. private _instanceGlowingMeshStencilReference;
  126055. private _options;
  126056. private _downSamplePostprocess;
  126057. private _horizontalBlurPostprocess;
  126058. private _verticalBlurPostprocess;
  126059. private _blurTexture;
  126060. private _meshes;
  126061. private _excludedMeshes;
  126062. /**
  126063. * Instantiates a new highlight Layer and references it to the scene..
  126064. * @param name The name of the layer
  126065. * @param scene The scene to use the layer in
  126066. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126067. */
  126068. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126069. /**
  126070. * Get the effect name of the layer.
  126071. * @return The effect name
  126072. */
  126073. getEffectName(): string;
  126074. /**
  126075. * Create the merge effect. This is the shader use to blit the information back
  126076. * to the main canvas at the end of the scene rendering.
  126077. */
  126078. protected _createMergeEffect(): Effect;
  126079. /**
  126080. * Creates the render target textures and post processes used in the highlight layer.
  126081. */
  126082. protected _createTextureAndPostProcesses(): void;
  126083. /**
  126084. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126085. */
  126086. needStencil(): boolean;
  126087. /**
  126088. * Checks for the readiness of the element composing the layer.
  126089. * @param subMesh the mesh to check for
  126090. * @param useInstances specify wether or not to use instances to render the mesh
  126091. * @param emissiveTexture the associated emissive texture used to generate the glow
  126092. * @return true if ready otherwise, false
  126093. */
  126094. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126095. /**
  126096. * Implementation specific of rendering the generating effect on the main canvas.
  126097. * @param effect The effect used to render through
  126098. */
  126099. protected _internalRender(effect: Effect): void;
  126100. /**
  126101. * Returns true if the layer contains information to display, otherwise false.
  126102. */
  126103. shouldRender(): boolean;
  126104. /**
  126105. * Returns true if the mesh should render, otherwise false.
  126106. * @param mesh The mesh to render
  126107. * @returns true if it should render otherwise false
  126108. */
  126109. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126110. /**
  126111. * Sets the required values for both the emissive texture and and the main color.
  126112. */
  126113. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126114. /**
  126115. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126116. * @param mesh The mesh to exclude from the highlight layer
  126117. */
  126118. addExcludedMesh(mesh: Mesh): void;
  126119. /**
  126120. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126121. * @param mesh The mesh to highlight
  126122. */
  126123. removeExcludedMesh(mesh: Mesh): void;
  126124. /**
  126125. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126126. * @param mesh mesh to test
  126127. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126128. */
  126129. hasMesh(mesh: AbstractMesh): boolean;
  126130. /**
  126131. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126132. * @param mesh The mesh to highlight
  126133. * @param color The color of the highlight
  126134. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126135. */
  126136. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126137. /**
  126138. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126139. * @param mesh The mesh to highlight
  126140. */
  126141. removeMesh(mesh: Mesh): void;
  126142. /**
  126143. * Force the stencil to the normal expected value for none glowing parts
  126144. */
  126145. private _defaultStencilReference;
  126146. /**
  126147. * Free any resources and references associated to a mesh.
  126148. * Internal use
  126149. * @param mesh The mesh to free.
  126150. * @hidden
  126151. */
  126152. _disposeMesh(mesh: Mesh): void;
  126153. /**
  126154. * Dispose the highlight layer and free resources.
  126155. */
  126156. dispose(): void;
  126157. /**
  126158. * Gets the class name of the effect layer
  126159. * @returns the string with the class name of the effect layer
  126160. */
  126161. getClassName(): string;
  126162. /**
  126163. * Serializes this Highlight layer
  126164. * @returns a serialized Highlight layer object
  126165. */
  126166. serialize(): any;
  126167. /**
  126168. * Creates a Highlight layer from parsed Highlight layer data
  126169. * @param parsedHightlightLayer defines the Highlight layer data
  126170. * @param scene defines the current scene
  126171. * @param rootUrl defines the root URL containing the Highlight layer information
  126172. * @returns a parsed Highlight layer
  126173. */
  126174. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126175. }
  126176. }
  126177. declare module BABYLON {
  126178. interface AbstractScene {
  126179. /**
  126180. * The list of layers (background and foreground) of the scene
  126181. */
  126182. layers: Array<Layer>;
  126183. }
  126184. /**
  126185. * Defines the layer scene component responsible to manage any layers
  126186. * in a given scene.
  126187. */
  126188. export class LayerSceneComponent implements ISceneComponent {
  126189. /**
  126190. * The component name helpfull to identify the component in the list of scene components.
  126191. */
  126192. readonly name: string;
  126193. /**
  126194. * The scene the component belongs to.
  126195. */
  126196. scene: Scene;
  126197. private _engine;
  126198. /**
  126199. * Creates a new instance of the component for the given scene
  126200. * @param scene Defines the scene to register the component in
  126201. */
  126202. constructor(scene: Scene);
  126203. /**
  126204. * Registers the component in a given scene
  126205. */
  126206. register(): void;
  126207. /**
  126208. * Rebuilds the elements related to this component in case of
  126209. * context lost for instance.
  126210. */
  126211. rebuild(): void;
  126212. /**
  126213. * Disposes the component and the associated ressources.
  126214. */
  126215. dispose(): void;
  126216. private _draw;
  126217. private _drawCameraPredicate;
  126218. private _drawCameraBackground;
  126219. private _drawCameraForeground;
  126220. private _drawRenderTargetPredicate;
  126221. private _drawRenderTargetBackground;
  126222. private _drawRenderTargetForeground;
  126223. /**
  126224. * Adds all the elements from the container to the scene
  126225. * @param container the container holding the elements
  126226. */
  126227. addFromContainer(container: AbstractScene): void;
  126228. /**
  126229. * Removes all the elements in the container from the scene
  126230. * @param container contains the elements to remove
  126231. * @param dispose if the removed element should be disposed (default: false)
  126232. */
  126233. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126234. }
  126235. }
  126236. declare module BABYLON {
  126237. /** @hidden */
  126238. export var layerPixelShader: {
  126239. name: string;
  126240. shader: string;
  126241. };
  126242. }
  126243. declare module BABYLON {
  126244. /** @hidden */
  126245. export var layerVertexShader: {
  126246. name: string;
  126247. shader: string;
  126248. };
  126249. }
  126250. declare module BABYLON {
  126251. /**
  126252. * This represents a full screen 2d layer.
  126253. * This can be useful to display a picture in the background of your scene for instance.
  126254. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126255. */
  126256. export class Layer {
  126257. /**
  126258. * Define the name of the layer.
  126259. */
  126260. name: string;
  126261. /**
  126262. * Define the texture the layer should display.
  126263. */
  126264. texture: Nullable<Texture>;
  126265. /**
  126266. * Is the layer in background or foreground.
  126267. */
  126268. isBackground: boolean;
  126269. /**
  126270. * Define the color of the layer (instead of texture).
  126271. */
  126272. color: Color4;
  126273. /**
  126274. * Define the scale of the layer in order to zoom in out of the texture.
  126275. */
  126276. scale: Vector2;
  126277. /**
  126278. * Define an offset for the layer in order to shift the texture.
  126279. */
  126280. offset: Vector2;
  126281. /**
  126282. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126283. */
  126284. alphaBlendingMode: number;
  126285. /**
  126286. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126287. * Alpha test will not mix with the background color in case of transparency.
  126288. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126289. */
  126290. alphaTest: boolean;
  126291. /**
  126292. * Define a mask to restrict the layer to only some of the scene cameras.
  126293. */
  126294. layerMask: number;
  126295. /**
  126296. * Define the list of render target the layer is visible into.
  126297. */
  126298. renderTargetTextures: RenderTargetTexture[];
  126299. /**
  126300. * Define if the layer is only used in renderTarget or if it also
  126301. * renders in the main frame buffer of the canvas.
  126302. */
  126303. renderOnlyInRenderTargetTextures: boolean;
  126304. private _scene;
  126305. private _vertexBuffers;
  126306. private _indexBuffer;
  126307. private _effect;
  126308. private _previousDefines;
  126309. /**
  126310. * An event triggered when the layer is disposed.
  126311. */
  126312. onDisposeObservable: Observable<Layer>;
  126313. private _onDisposeObserver;
  126314. /**
  126315. * Back compatibility with callback before the onDisposeObservable existed.
  126316. * The set callback will be triggered when the layer has been disposed.
  126317. */
  126318. set onDispose(callback: () => void);
  126319. /**
  126320. * An event triggered before rendering the scene
  126321. */
  126322. onBeforeRenderObservable: Observable<Layer>;
  126323. private _onBeforeRenderObserver;
  126324. /**
  126325. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126326. * The set callback will be triggered just before rendering the layer.
  126327. */
  126328. set onBeforeRender(callback: () => void);
  126329. /**
  126330. * An event triggered after rendering the scene
  126331. */
  126332. onAfterRenderObservable: Observable<Layer>;
  126333. private _onAfterRenderObserver;
  126334. /**
  126335. * Back compatibility with callback before the onAfterRenderObservable existed.
  126336. * The set callback will be triggered just after rendering the layer.
  126337. */
  126338. set onAfterRender(callback: () => void);
  126339. /**
  126340. * Instantiates a new layer.
  126341. * This represents a full screen 2d layer.
  126342. * This can be useful to display a picture in the background of your scene for instance.
  126343. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126344. * @param name Define the name of the layer in the scene
  126345. * @param imgUrl Define the url of the texture to display in the layer
  126346. * @param scene Define the scene the layer belongs to
  126347. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126348. * @param color Defines a color for the layer
  126349. */
  126350. constructor(
  126351. /**
  126352. * Define the name of the layer.
  126353. */
  126354. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126355. private _createIndexBuffer;
  126356. /** @hidden */
  126357. _rebuild(): void;
  126358. /**
  126359. * Renders the layer in the scene.
  126360. */
  126361. render(): void;
  126362. /**
  126363. * Disposes and releases the associated ressources.
  126364. */
  126365. dispose(): void;
  126366. }
  126367. }
  126368. declare module BABYLON {
  126369. /** @hidden */
  126370. export var lensFlarePixelShader: {
  126371. name: string;
  126372. shader: string;
  126373. };
  126374. }
  126375. declare module BABYLON {
  126376. /** @hidden */
  126377. export var lensFlareVertexShader: {
  126378. name: string;
  126379. shader: string;
  126380. };
  126381. }
  126382. declare module BABYLON {
  126383. /**
  126384. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126385. * It is usually composed of several `lensFlare`.
  126386. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126387. */
  126388. export class LensFlareSystem {
  126389. /**
  126390. * Define the name of the lens flare system
  126391. */
  126392. name: string;
  126393. /**
  126394. * List of lens flares used in this system.
  126395. */
  126396. lensFlares: LensFlare[];
  126397. /**
  126398. * Define a limit from the border the lens flare can be visible.
  126399. */
  126400. borderLimit: number;
  126401. /**
  126402. * Define a viewport border we do not want to see the lens flare in.
  126403. */
  126404. viewportBorder: number;
  126405. /**
  126406. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126407. */
  126408. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126409. /**
  126410. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126411. */
  126412. layerMask: number;
  126413. /**
  126414. * Define the id of the lens flare system in the scene.
  126415. * (equal to name by default)
  126416. */
  126417. id: string;
  126418. private _scene;
  126419. private _emitter;
  126420. private _vertexBuffers;
  126421. private _indexBuffer;
  126422. private _effect;
  126423. private _positionX;
  126424. private _positionY;
  126425. private _isEnabled;
  126426. /** @hidden */
  126427. static _SceneComponentInitialization: (scene: Scene) => void;
  126428. /**
  126429. * Instantiates a lens flare system.
  126430. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126431. * It is usually composed of several `lensFlare`.
  126432. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126433. * @param name Define the name of the lens flare system in the scene
  126434. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126435. * @param scene Define the scene the lens flare system belongs to
  126436. */
  126437. constructor(
  126438. /**
  126439. * Define the name of the lens flare system
  126440. */
  126441. name: string, emitter: any, scene: Scene);
  126442. /**
  126443. * Define if the lens flare system is enabled.
  126444. */
  126445. get isEnabled(): boolean;
  126446. set isEnabled(value: boolean);
  126447. /**
  126448. * Get the scene the effects belongs to.
  126449. * @returns the scene holding the lens flare system
  126450. */
  126451. getScene(): Scene;
  126452. /**
  126453. * Get the emitter of the lens flare system.
  126454. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126455. * @returns the emitter of the lens flare system
  126456. */
  126457. getEmitter(): any;
  126458. /**
  126459. * Set the emitter of the lens flare system.
  126460. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126461. * @param newEmitter Define the new emitter of the system
  126462. */
  126463. setEmitter(newEmitter: any): void;
  126464. /**
  126465. * Get the lens flare system emitter position.
  126466. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126467. * @returns the position
  126468. */
  126469. getEmitterPosition(): Vector3;
  126470. /**
  126471. * @hidden
  126472. */
  126473. computeEffectivePosition(globalViewport: Viewport): boolean;
  126474. /** @hidden */
  126475. _isVisible(): boolean;
  126476. /**
  126477. * @hidden
  126478. */
  126479. render(): boolean;
  126480. /**
  126481. * Dispose and release the lens flare with its associated resources.
  126482. */
  126483. dispose(): void;
  126484. /**
  126485. * Parse a lens flare system from a JSON repressentation
  126486. * @param parsedLensFlareSystem Define the JSON to parse
  126487. * @param scene Define the scene the parsed system should be instantiated in
  126488. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126489. * @returns the parsed system
  126490. */
  126491. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126492. /**
  126493. * Serialize the current Lens Flare System into a JSON representation.
  126494. * @returns the serialized JSON
  126495. */
  126496. serialize(): any;
  126497. }
  126498. }
  126499. declare module BABYLON {
  126500. /**
  126501. * This represents one of the lens effect in a `lensFlareSystem`.
  126502. * It controls one of the indiviual texture used in the effect.
  126503. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126504. */
  126505. export class LensFlare {
  126506. /**
  126507. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126508. */
  126509. size: number;
  126510. /**
  126511. * 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.
  126512. */
  126513. position: number;
  126514. /**
  126515. * Define the lens color.
  126516. */
  126517. color: Color3;
  126518. /**
  126519. * Define the lens texture.
  126520. */
  126521. texture: Nullable<Texture>;
  126522. /**
  126523. * Define the alpha mode to render this particular lens.
  126524. */
  126525. alphaMode: number;
  126526. private _system;
  126527. /**
  126528. * Creates a new Lens Flare.
  126529. * This represents one of the lens effect in a `lensFlareSystem`.
  126530. * It controls one of the indiviual texture used in the effect.
  126531. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126532. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  126533. * @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.
  126534. * @param color Define the lens color
  126535. * @param imgUrl Define the lens texture url
  126536. * @param system Define the `lensFlareSystem` this flare is part of
  126537. * @returns The newly created Lens Flare
  126538. */
  126539. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  126540. /**
  126541. * Instantiates a new Lens Flare.
  126542. * This represents one of the lens effect in a `lensFlareSystem`.
  126543. * It controls one of the indiviual texture used in the effect.
  126544. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126545. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  126546. * @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.
  126547. * @param color Define the lens color
  126548. * @param imgUrl Define the lens texture url
  126549. * @param system Define the `lensFlareSystem` this flare is part of
  126550. */
  126551. constructor(
  126552. /**
  126553. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126554. */
  126555. size: number,
  126556. /**
  126557. * 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.
  126558. */
  126559. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  126560. /**
  126561. * Dispose and release the lens flare with its associated resources.
  126562. */
  126563. dispose(): void;
  126564. }
  126565. }
  126566. declare module BABYLON {
  126567. interface AbstractScene {
  126568. /**
  126569. * The list of lens flare system added to the scene
  126570. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126571. */
  126572. lensFlareSystems: Array<LensFlareSystem>;
  126573. /**
  126574. * Removes the given lens flare system from this scene.
  126575. * @param toRemove The lens flare system to remove
  126576. * @returns The index of the removed lens flare system
  126577. */
  126578. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  126579. /**
  126580. * Adds the given lens flare system to this scene
  126581. * @param newLensFlareSystem The lens flare system to add
  126582. */
  126583. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  126584. /**
  126585. * Gets a lens flare system using its name
  126586. * @param name defines the name to look for
  126587. * @returns the lens flare system or null if not found
  126588. */
  126589. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  126590. /**
  126591. * Gets a lens flare system using its id
  126592. * @param id defines the id to look for
  126593. * @returns the lens flare system or null if not found
  126594. */
  126595. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  126596. }
  126597. /**
  126598. * Defines the lens flare scene component responsible to manage any lens flares
  126599. * in a given scene.
  126600. */
  126601. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  126602. /**
  126603. * The component name helpfull to identify the component in the list of scene components.
  126604. */
  126605. readonly name: string;
  126606. /**
  126607. * The scene the component belongs to.
  126608. */
  126609. scene: Scene;
  126610. /**
  126611. * Creates a new instance of the component for the given scene
  126612. * @param scene Defines the scene to register the component in
  126613. */
  126614. constructor(scene: Scene);
  126615. /**
  126616. * Registers the component in a given scene
  126617. */
  126618. register(): void;
  126619. /**
  126620. * Rebuilds the elements related to this component in case of
  126621. * context lost for instance.
  126622. */
  126623. rebuild(): void;
  126624. /**
  126625. * Adds all the elements from the container to the scene
  126626. * @param container the container holding the elements
  126627. */
  126628. addFromContainer(container: AbstractScene): void;
  126629. /**
  126630. * Removes all the elements in the container from the scene
  126631. * @param container contains the elements to remove
  126632. * @param dispose if the removed element should be disposed (default: false)
  126633. */
  126634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126635. /**
  126636. * Serializes the component data to the specified json object
  126637. * @param serializationObject The object to serialize to
  126638. */
  126639. serialize(serializationObject: any): void;
  126640. /**
  126641. * Disposes the component and the associated ressources.
  126642. */
  126643. dispose(): void;
  126644. private _draw;
  126645. }
  126646. }
  126647. declare module BABYLON {
  126648. /** @hidden */
  126649. export var depthPixelShader: {
  126650. name: string;
  126651. shader: string;
  126652. };
  126653. }
  126654. declare module BABYLON {
  126655. /** @hidden */
  126656. export var depthVertexShader: {
  126657. name: string;
  126658. shader: string;
  126659. };
  126660. }
  126661. declare module BABYLON {
  126662. /**
  126663. * This represents a depth renderer in Babylon.
  126664. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126665. */
  126666. export class DepthRenderer {
  126667. private _scene;
  126668. private _depthMap;
  126669. private _effect;
  126670. private readonly _storeNonLinearDepth;
  126671. private readonly _clearColor;
  126672. /** Get if the depth renderer is using packed depth or not */
  126673. readonly isPacked: boolean;
  126674. private _cachedDefines;
  126675. private _camera;
  126676. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  126677. enabled: boolean;
  126678. /**
  126679. * Specifiess that the depth renderer will only be used within
  126680. * the camera it is created for.
  126681. * This can help forcing its rendering during the camera processing.
  126682. */
  126683. useOnlyInActiveCamera: boolean;
  126684. /** @hidden */
  126685. static _SceneComponentInitialization: (scene: Scene) => void;
  126686. /**
  126687. * Instantiates a depth renderer
  126688. * @param scene The scene the renderer belongs to
  126689. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126690. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126691. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126692. */
  126693. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126694. /**
  126695. * Creates the depth rendering effect and checks if the effect is ready.
  126696. * @param subMesh The submesh to be used to render the depth map of
  126697. * @param useInstances If multiple world instances should be used
  126698. * @returns if the depth renderer is ready to render the depth map
  126699. */
  126700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126701. /**
  126702. * Gets the texture which the depth map will be written to.
  126703. * @returns The depth map texture
  126704. */
  126705. getDepthMap(): RenderTargetTexture;
  126706. /**
  126707. * Disposes of the depth renderer.
  126708. */
  126709. dispose(): void;
  126710. }
  126711. }
  126712. declare module BABYLON {
  126713. /** @hidden */
  126714. export var minmaxReduxPixelShader: {
  126715. name: string;
  126716. shader: string;
  126717. };
  126718. }
  126719. declare module BABYLON {
  126720. /**
  126721. * This class computes a min/max reduction from a texture: it means it computes the minimum
  126722. * and maximum values from all values of the texture.
  126723. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  126724. * The source values are read from the red channel of the texture.
  126725. */
  126726. export class MinMaxReducer {
  126727. /**
  126728. * Observable triggered when the computation has been performed
  126729. */
  126730. onAfterReductionPerformed: Observable<{
  126731. min: number;
  126732. max: number;
  126733. }>;
  126734. protected _camera: Camera;
  126735. protected _sourceTexture: Nullable<RenderTargetTexture>;
  126736. protected _reductionSteps: Nullable<Array<PostProcess>>;
  126737. protected _postProcessManager: PostProcessManager;
  126738. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  126739. protected _forceFullscreenViewport: boolean;
  126740. /**
  126741. * Creates a min/max reducer
  126742. * @param camera The camera to use for the post processes
  126743. */
  126744. constructor(camera: Camera);
  126745. /**
  126746. * Gets the texture used to read the values from.
  126747. */
  126748. get sourceTexture(): Nullable<RenderTargetTexture>;
  126749. /**
  126750. * Sets the source texture to read the values from.
  126751. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  126752. * because in such textures '1' value must not be taken into account to compute the maximum
  126753. * as this value is used to clear the texture.
  126754. * Note that the computation is not activated by calling this function, you must call activate() for that!
  126755. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  126756. * @param depthRedux Indicates if the texture is a depth texture or not
  126757. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  126758. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126759. */
  126760. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126761. /**
  126762. * Defines the refresh rate of the computation.
  126763. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126764. */
  126765. get refreshRate(): number;
  126766. set refreshRate(value: number);
  126767. protected _activated: boolean;
  126768. /**
  126769. * Gets the activation status of the reducer
  126770. */
  126771. get activated(): boolean;
  126772. /**
  126773. * Activates the reduction computation.
  126774. * When activated, the observers registered in onAfterReductionPerformed are
  126775. * called after the compuation is performed
  126776. */
  126777. activate(): void;
  126778. /**
  126779. * Deactivates the reduction computation.
  126780. */
  126781. deactivate(): void;
  126782. /**
  126783. * Disposes the min/max reducer
  126784. * @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.
  126785. */
  126786. dispose(disposeAll?: boolean): void;
  126787. }
  126788. }
  126789. declare module BABYLON {
  126790. /**
  126791. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  126792. */
  126793. export class DepthReducer extends MinMaxReducer {
  126794. private _depthRenderer;
  126795. private _depthRendererId;
  126796. /**
  126797. * Gets the depth renderer used for the computation.
  126798. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  126799. */
  126800. get depthRenderer(): Nullable<DepthRenderer>;
  126801. /**
  126802. * Creates a depth reducer
  126803. * @param camera The camera used to render the depth texture
  126804. */
  126805. constructor(camera: Camera);
  126806. /**
  126807. * Sets the depth renderer to use to generate the depth map
  126808. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  126809. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  126810. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126811. */
  126812. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  126813. /** @hidden */
  126814. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126815. /**
  126816. * Activates the reduction computation.
  126817. * When activated, the observers registered in onAfterReductionPerformed are
  126818. * called after the compuation is performed
  126819. */
  126820. activate(): void;
  126821. /**
  126822. * Deactivates the reduction computation.
  126823. */
  126824. deactivate(): void;
  126825. /**
  126826. * Disposes the depth reducer
  126827. * @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.
  126828. */
  126829. dispose(disposeAll?: boolean): void;
  126830. }
  126831. }
  126832. declare module BABYLON {
  126833. /**
  126834. * A CSM implementation allowing casting shadows on large scenes.
  126835. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126836. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  126837. */
  126838. export class CascadedShadowGenerator extends ShadowGenerator {
  126839. private static readonly frustumCornersNDCSpace;
  126840. /**
  126841. * Name of the CSM class
  126842. */
  126843. static CLASSNAME: string;
  126844. /**
  126845. * Defines the default number of cascades used by the CSM.
  126846. */
  126847. static readonly DEFAULT_CASCADES_COUNT: number;
  126848. /**
  126849. * Defines the minimum number of cascades used by the CSM.
  126850. */
  126851. static readonly MIN_CASCADES_COUNT: number;
  126852. /**
  126853. * Defines the maximum number of cascades used by the CSM.
  126854. */
  126855. static readonly MAX_CASCADES_COUNT: number;
  126856. protected _validateFilter(filter: number): number;
  126857. /**
  126858. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  126859. */
  126860. penumbraDarkness: number;
  126861. private _numCascades;
  126862. /**
  126863. * Gets or set the number of cascades used by the CSM.
  126864. */
  126865. get numCascades(): number;
  126866. set numCascades(value: number);
  126867. /**
  126868. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  126869. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  126870. */
  126871. stabilizeCascades: boolean;
  126872. private _freezeShadowCastersBoundingInfo;
  126873. private _freezeShadowCastersBoundingInfoObservable;
  126874. /**
  126875. * Enables or disables the shadow casters bounding info computation.
  126876. * If your shadow casters don't move, you can disable this feature.
  126877. * If it is enabled, the bounding box computation is done every frame.
  126878. */
  126879. get freezeShadowCastersBoundingInfo(): boolean;
  126880. set freezeShadowCastersBoundingInfo(freeze: boolean);
  126881. private _scbiMin;
  126882. private _scbiMax;
  126883. protected _computeShadowCastersBoundingInfo(): void;
  126884. protected _shadowCastersBoundingInfo: BoundingInfo;
  126885. /**
  126886. * Gets or sets the shadow casters bounding info.
  126887. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  126888. * so that the system won't overwrite the bounds you provide
  126889. */
  126890. get shadowCastersBoundingInfo(): BoundingInfo;
  126891. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  126892. protected _breaksAreDirty: boolean;
  126893. protected _minDistance: number;
  126894. protected _maxDistance: number;
  126895. /**
  126896. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  126897. *
  126898. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  126899. * If you don't know these values, simply leave them to their defaults and don't call this function.
  126900. * @param min minimal distance for the breaks (default to 0.)
  126901. * @param max maximal distance for the breaks (default to 1.)
  126902. */
  126903. setMinMaxDistance(min: number, max: number): void;
  126904. /** Gets the minimal distance used in the cascade break computation */
  126905. get minDistance(): number;
  126906. /** Gets the maximal distance used in the cascade break computation */
  126907. get maxDistance(): number;
  126908. /**
  126909. * Gets the class name of that object
  126910. * @returns "CascadedShadowGenerator"
  126911. */
  126912. getClassName(): string;
  126913. private _cascadeMinExtents;
  126914. private _cascadeMaxExtents;
  126915. /**
  126916. * Gets a cascade minimum extents
  126917. * @param cascadeIndex index of the cascade
  126918. * @returns the minimum cascade extents
  126919. */
  126920. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  126921. /**
  126922. * Gets a cascade maximum extents
  126923. * @param cascadeIndex index of the cascade
  126924. * @returns the maximum cascade extents
  126925. */
  126926. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  126927. private _cascades;
  126928. private _currentLayer;
  126929. private _viewSpaceFrustumsZ;
  126930. private _viewMatrices;
  126931. private _projectionMatrices;
  126932. private _transformMatrices;
  126933. private _transformMatricesAsArray;
  126934. private _frustumLengths;
  126935. private _lightSizeUVCorrection;
  126936. private _depthCorrection;
  126937. private _frustumCornersWorldSpace;
  126938. private _frustumCenter;
  126939. private _shadowCameraPos;
  126940. private _shadowMaxZ;
  126941. /**
  126942. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  126943. * It defaults to camera.maxZ
  126944. */
  126945. get shadowMaxZ(): number;
  126946. /**
  126947. * Sets the shadow max z distance.
  126948. */
  126949. set shadowMaxZ(value: number);
  126950. protected _debug: boolean;
  126951. /**
  126952. * Gets or sets the debug flag.
  126953. * When enabled, the cascades are materialized by different colors on the screen.
  126954. */
  126955. get debug(): boolean;
  126956. set debug(dbg: boolean);
  126957. private _depthClamp;
  126958. /**
  126959. * Gets or sets the depth clamping value.
  126960. *
  126961. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  126962. * to account for the shadow casters far away.
  126963. *
  126964. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  126965. */
  126966. get depthClamp(): boolean;
  126967. set depthClamp(value: boolean);
  126968. private _cascadeBlendPercentage;
  126969. /**
  126970. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  126971. * It defaults to 0.1 (10% blending).
  126972. */
  126973. get cascadeBlendPercentage(): number;
  126974. set cascadeBlendPercentage(value: number);
  126975. private _lambda;
  126976. /**
  126977. * Gets or set the lambda parameter.
  126978. * This parameter is used to split the camera frustum and create the cascades.
  126979. * 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.
  126980. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  126981. */
  126982. get lambda(): number;
  126983. set lambda(value: number);
  126984. /**
  126985. * Gets the view matrix corresponding to a given cascade
  126986. * @param cascadeNum cascade to retrieve the view matrix from
  126987. * @returns the cascade view matrix
  126988. */
  126989. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  126990. /**
  126991. * Gets the projection matrix corresponding to a given cascade
  126992. * @param cascadeNum cascade to retrieve the projection matrix from
  126993. * @returns the cascade projection matrix
  126994. */
  126995. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  126996. /**
  126997. * Gets the transformation matrix corresponding to a given cascade
  126998. * @param cascadeNum cascade to retrieve the transformation matrix from
  126999. * @returns the cascade transformation matrix
  127000. */
  127001. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127002. private _depthRenderer;
  127003. /**
  127004. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127005. *
  127006. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127007. *
  127008. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127009. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127010. * @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
  127011. */
  127012. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127013. private _depthReducer;
  127014. private _autoCalcDepthBounds;
  127015. /**
  127016. * Gets or sets the autoCalcDepthBounds property.
  127017. *
  127018. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127019. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127020. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127021. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127022. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127023. */
  127024. get autoCalcDepthBounds(): boolean;
  127025. set autoCalcDepthBounds(value: boolean);
  127026. /**
  127027. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127028. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127029. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127030. * for setting the refresh rate on the renderer yourself!
  127031. */
  127032. get autoCalcDepthBoundsRefreshRate(): number;
  127033. set autoCalcDepthBoundsRefreshRate(value: number);
  127034. /**
  127035. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127036. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127037. * you change the camera near/far planes!
  127038. */
  127039. splitFrustum(): void;
  127040. private _splitFrustum;
  127041. private _computeMatrices;
  127042. private _computeFrustumInWorldSpace;
  127043. private _computeCascadeFrustum;
  127044. /** @hidden */
  127045. static _SceneComponentInitialization: (scene: Scene) => void;
  127046. /**
  127047. * Creates a Cascaded Shadow Generator object.
  127048. * A ShadowGenerator is the required tool to use the shadows.
  127049. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127050. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127051. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127052. * @param light The directional light object generating the shadows.
  127053. * @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.
  127054. */
  127055. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127056. protected _initializeGenerator(): void;
  127057. protected _createTargetRenderTexture(): void;
  127058. protected _initializeShadowMap(): void;
  127059. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127060. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127061. /**
  127062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127063. * @param defines Defines of the material we want to update
  127064. * @param lightIndex Index of the light in the enabled light list of the material
  127065. */
  127066. prepareDefines(defines: any, lightIndex: number): void;
  127067. /**
  127068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127069. * defined in the generator but impacting the effect).
  127070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127071. * @param effect The effect we are binfing the information for
  127072. */
  127073. bindShadowLight(lightIndex: string, effect: Effect): void;
  127074. /**
  127075. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127076. * (eq to view projection * shadow projection matrices)
  127077. * @returns The transform matrix used to create the shadow map
  127078. */
  127079. getTransformMatrix(): Matrix;
  127080. /**
  127081. * Disposes the ShadowGenerator.
  127082. * Returns nothing.
  127083. */
  127084. dispose(): void;
  127085. /**
  127086. * Serializes the shadow generator setup to a json object.
  127087. * @returns The serialized JSON object
  127088. */
  127089. serialize(): any;
  127090. /**
  127091. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127092. * @param parsedShadowGenerator The JSON object to parse
  127093. * @param scene The scene to create the shadow map for
  127094. * @returns The parsed shadow generator
  127095. */
  127096. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127097. }
  127098. }
  127099. declare module BABYLON {
  127100. /**
  127101. * Defines the shadow generator component responsible to manage any shadow generators
  127102. * in a given scene.
  127103. */
  127104. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127105. /**
  127106. * The component name helpfull to identify the component in the list of scene components.
  127107. */
  127108. readonly name: string;
  127109. /**
  127110. * The scene the component belongs to.
  127111. */
  127112. scene: Scene;
  127113. /**
  127114. * Creates a new instance of the component for the given scene
  127115. * @param scene Defines the scene to register the component in
  127116. */
  127117. constructor(scene: Scene);
  127118. /**
  127119. * Registers the component in a given scene
  127120. */
  127121. register(): void;
  127122. /**
  127123. * Rebuilds the elements related to this component in case of
  127124. * context lost for instance.
  127125. */
  127126. rebuild(): void;
  127127. /**
  127128. * Serializes the component data to the specified json object
  127129. * @param serializationObject The object to serialize to
  127130. */
  127131. serialize(serializationObject: any): void;
  127132. /**
  127133. * Adds all the elements from the container to the scene
  127134. * @param container the container holding the elements
  127135. */
  127136. addFromContainer(container: AbstractScene): void;
  127137. /**
  127138. * Removes all the elements in the container from the scene
  127139. * @param container contains the elements to remove
  127140. * @param dispose if the removed element should be disposed (default: false)
  127141. */
  127142. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127143. /**
  127144. * Rebuilds the elements related to this component in case of
  127145. * context lost for instance.
  127146. */
  127147. dispose(): void;
  127148. private _gatherRenderTargets;
  127149. }
  127150. }
  127151. declare module BABYLON {
  127152. /**
  127153. * A point light is a light defined by an unique point in world space.
  127154. * The light is emitted in every direction from this point.
  127155. * A good example of a point light is a standard light bulb.
  127156. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127157. */
  127158. export class PointLight extends ShadowLight {
  127159. private _shadowAngle;
  127160. /**
  127161. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127162. * This specifies what angle the shadow will use to be created.
  127163. *
  127164. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127165. */
  127166. get shadowAngle(): number;
  127167. /**
  127168. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127169. * This specifies what angle the shadow will use to be created.
  127170. *
  127171. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127172. */
  127173. set shadowAngle(value: number);
  127174. /**
  127175. * Gets the direction if it has been set.
  127176. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127177. */
  127178. get direction(): Vector3;
  127179. /**
  127180. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127181. */
  127182. set direction(value: Vector3);
  127183. /**
  127184. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127185. * A PointLight emits the light in every direction.
  127186. * It can cast shadows.
  127187. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127188. * ```javascript
  127189. * var pointLight = new PointLight("pl", camera.position, scene);
  127190. * ```
  127191. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127192. * @param name The light friendly name
  127193. * @param position The position of the point light in the scene
  127194. * @param scene The scene the lights belongs to
  127195. */
  127196. constructor(name: string, position: Vector3, scene: Scene);
  127197. /**
  127198. * Returns the string "PointLight"
  127199. * @returns the class name
  127200. */
  127201. getClassName(): string;
  127202. /**
  127203. * Returns the integer 0.
  127204. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127205. */
  127206. getTypeID(): number;
  127207. /**
  127208. * Specifies wether or not the shadowmap should be a cube texture.
  127209. * @returns true if the shadowmap needs to be a cube texture.
  127210. */
  127211. needCube(): boolean;
  127212. /**
  127213. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127214. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127215. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127216. */
  127217. getShadowDirection(faceIndex?: number): Vector3;
  127218. /**
  127219. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127220. * - fov = PI / 2
  127221. * - aspect ratio : 1.0
  127222. * - z-near and far equal to the active camera minZ and maxZ.
  127223. * Returns the PointLight.
  127224. */
  127225. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127226. protected _buildUniformLayout(): void;
  127227. /**
  127228. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127229. * @param effect The effect to update
  127230. * @param lightIndex The index of the light in the effect to update
  127231. * @returns The point light
  127232. */
  127233. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127234. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127235. /**
  127236. * Prepares the list of defines specific to the light type.
  127237. * @param defines the list of defines
  127238. * @param lightIndex defines the index of the light for the effect
  127239. */
  127240. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127241. }
  127242. }
  127243. declare module BABYLON {
  127244. /**
  127245. * Header information of HDR texture files.
  127246. */
  127247. export interface HDRInfo {
  127248. /**
  127249. * The height of the texture in pixels.
  127250. */
  127251. height: number;
  127252. /**
  127253. * The width of the texture in pixels.
  127254. */
  127255. width: number;
  127256. /**
  127257. * The index of the beginning of the data in the binary file.
  127258. */
  127259. dataPosition: number;
  127260. }
  127261. /**
  127262. * This groups tools to convert HDR texture to native colors array.
  127263. */
  127264. export class HDRTools {
  127265. private static Ldexp;
  127266. private static Rgbe2float;
  127267. private static readStringLine;
  127268. /**
  127269. * Reads header information from an RGBE texture stored in a native array.
  127270. * More information on this format are available here:
  127271. * https://en.wikipedia.org/wiki/RGBE_image_format
  127272. *
  127273. * @param uint8array The binary file stored in native array.
  127274. * @return The header information.
  127275. */
  127276. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127277. /**
  127278. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127279. * This RGBE texture needs to store the information as a panorama.
  127280. *
  127281. * More information on this format are available here:
  127282. * https://en.wikipedia.org/wiki/RGBE_image_format
  127283. *
  127284. * @param buffer The binary file stored in an array buffer.
  127285. * @param size The expected size of the extracted cubemap.
  127286. * @return The Cube Map information.
  127287. */
  127288. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127289. /**
  127290. * Returns the pixels data extracted from an RGBE texture.
  127291. * This pixels will be stored left to right up to down in the R G B order in one array.
  127292. *
  127293. * More information on this format are available here:
  127294. * https://en.wikipedia.org/wiki/RGBE_image_format
  127295. *
  127296. * @param uint8array The binary file stored in an array buffer.
  127297. * @param hdrInfo The header information of the file.
  127298. * @return The pixels data in RGB right to left up to down order.
  127299. */
  127300. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127301. private static RGBE_ReadPixels_RLE;
  127302. }
  127303. }
  127304. declare module BABYLON {
  127305. /**
  127306. * This represents a texture coming from an HDR input.
  127307. *
  127308. * The only supported format is currently panorama picture stored in RGBE format.
  127309. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127310. */
  127311. export class HDRCubeTexture extends BaseTexture {
  127312. private static _facesMapping;
  127313. private _generateHarmonics;
  127314. private _noMipmap;
  127315. private _textureMatrix;
  127316. private _size;
  127317. private _onLoad;
  127318. private _onError;
  127319. /**
  127320. * The texture URL.
  127321. */
  127322. url: string;
  127323. /**
  127324. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127325. */
  127326. coordinatesMode: number;
  127327. protected _isBlocking: boolean;
  127328. /**
  127329. * Sets wether or not the texture is blocking during loading.
  127330. */
  127331. set isBlocking(value: boolean);
  127332. /**
  127333. * Gets wether or not the texture is blocking during loading.
  127334. */
  127335. get isBlocking(): boolean;
  127336. protected _rotationY: number;
  127337. /**
  127338. * Sets texture matrix rotation angle around Y axis in radians.
  127339. */
  127340. set rotationY(value: number);
  127341. /**
  127342. * Gets texture matrix rotation angle around Y axis radians.
  127343. */
  127344. get rotationY(): number;
  127345. /**
  127346. * Gets or sets the center of the bounding box associated with the cube texture
  127347. * It must define where the camera used to render the texture was set
  127348. */
  127349. boundingBoxPosition: Vector3;
  127350. private _boundingBoxSize;
  127351. /**
  127352. * Gets or sets the size of the bounding box associated with the cube texture
  127353. * When defined, the cubemap will switch to local mode
  127354. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127355. * @example https://www.babylonjs-playground.com/#RNASML
  127356. */
  127357. set boundingBoxSize(value: Vector3);
  127358. get boundingBoxSize(): Vector3;
  127359. /**
  127360. * Instantiates an HDRTexture from the following parameters.
  127361. *
  127362. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127363. * @param scene The scene the texture will be used in
  127364. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127365. * @param noMipmap Forces to not generate the mipmap if true
  127366. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127367. * @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)
  127368. * @param reserved Reserved flag for internal use.
  127369. */
  127370. 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>);
  127371. /**
  127372. * Get the current class name of the texture useful for serialization or dynamic coding.
  127373. * @returns "HDRCubeTexture"
  127374. */
  127375. getClassName(): string;
  127376. /**
  127377. * Occurs when the file is raw .hdr file.
  127378. */
  127379. private loadTexture;
  127380. clone(): HDRCubeTexture;
  127381. delayLoad(): void;
  127382. /**
  127383. * Get the texture reflection matrix used to rotate/transform the reflection.
  127384. * @returns the reflection matrix
  127385. */
  127386. getReflectionTextureMatrix(): Matrix;
  127387. /**
  127388. * Set the texture reflection matrix used to rotate/transform the reflection.
  127389. * @param value Define the reflection matrix to set
  127390. */
  127391. setReflectionTextureMatrix(value: Matrix): void;
  127392. /**
  127393. * Parses a JSON representation of an HDR Texture in order to create the texture
  127394. * @param parsedTexture Define the JSON representation
  127395. * @param scene Define the scene the texture should be created in
  127396. * @param rootUrl Define the root url in case we need to load relative dependencies
  127397. * @returns the newly created texture after parsing
  127398. */
  127399. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127400. serialize(): any;
  127401. }
  127402. }
  127403. declare module BABYLON {
  127404. /**
  127405. * Class used to control physics engine
  127406. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127407. */
  127408. export class PhysicsEngine implements IPhysicsEngine {
  127409. private _physicsPlugin;
  127410. /**
  127411. * Global value used to control the smallest number supported by the simulation
  127412. */
  127413. static Epsilon: number;
  127414. private _impostors;
  127415. private _joints;
  127416. private _subTimeStep;
  127417. /**
  127418. * Gets the gravity vector used by the simulation
  127419. */
  127420. gravity: Vector3;
  127421. /**
  127422. * Factory used to create the default physics plugin.
  127423. * @returns The default physics plugin
  127424. */
  127425. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127426. /**
  127427. * Creates a new Physics Engine
  127428. * @param gravity defines the gravity vector used by the simulation
  127429. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127430. */
  127431. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127432. /**
  127433. * Sets the gravity vector used by the simulation
  127434. * @param gravity defines the gravity vector to use
  127435. */
  127436. setGravity(gravity: Vector3): void;
  127437. /**
  127438. * Set the time step of the physics engine.
  127439. * Default is 1/60.
  127440. * To slow it down, enter 1/600 for example.
  127441. * To speed it up, 1/30
  127442. * @param newTimeStep defines the new timestep to apply to this world.
  127443. */
  127444. setTimeStep(newTimeStep?: number): void;
  127445. /**
  127446. * Get the time step of the physics engine.
  127447. * @returns the current time step
  127448. */
  127449. getTimeStep(): number;
  127450. /**
  127451. * Set the sub time step of the physics engine.
  127452. * Default is 0 meaning there is no sub steps
  127453. * To increase physics resolution precision, set a small value (like 1 ms)
  127454. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127455. */
  127456. setSubTimeStep(subTimeStep?: number): void;
  127457. /**
  127458. * Get the sub time step of the physics engine.
  127459. * @returns the current sub time step
  127460. */
  127461. getSubTimeStep(): number;
  127462. /**
  127463. * Release all resources
  127464. */
  127465. dispose(): void;
  127466. /**
  127467. * Gets the name of the current physics plugin
  127468. * @returns the name of the plugin
  127469. */
  127470. getPhysicsPluginName(): string;
  127471. /**
  127472. * Adding a new impostor for the impostor tracking.
  127473. * This will be done by the impostor itself.
  127474. * @param impostor the impostor to add
  127475. */
  127476. addImpostor(impostor: PhysicsImpostor): void;
  127477. /**
  127478. * Remove an impostor from the engine.
  127479. * This impostor and its mesh will not longer be updated by the physics engine.
  127480. * @param impostor the impostor to remove
  127481. */
  127482. removeImpostor(impostor: PhysicsImpostor): void;
  127483. /**
  127484. * Add a joint to the physics engine
  127485. * @param mainImpostor defines the main impostor to which the joint is added.
  127486. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127487. * @param joint defines the joint that will connect both impostors.
  127488. */
  127489. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127490. /**
  127491. * Removes a joint from the simulation
  127492. * @param mainImpostor defines the impostor used with the joint
  127493. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127494. * @param joint defines the joint to remove
  127495. */
  127496. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127497. /**
  127498. * Called by the scene. No need to call it.
  127499. * @param delta defines the timespam between frames
  127500. */
  127501. _step(delta: number): void;
  127502. /**
  127503. * Gets the current plugin used to run the simulation
  127504. * @returns current plugin
  127505. */
  127506. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127507. /**
  127508. * Gets the list of physic impostors
  127509. * @returns an array of PhysicsImpostor
  127510. */
  127511. getImpostors(): Array<PhysicsImpostor>;
  127512. /**
  127513. * Gets the impostor for a physics enabled object
  127514. * @param object defines the object impersonated by the impostor
  127515. * @returns the PhysicsImpostor or null if not found
  127516. */
  127517. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  127518. /**
  127519. * Gets the impostor for a physics body object
  127520. * @param body defines physics body used by the impostor
  127521. * @returns the PhysicsImpostor or null if not found
  127522. */
  127523. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  127524. /**
  127525. * Does a raycast in the physics world
  127526. * @param from when should the ray start?
  127527. * @param to when should the ray end?
  127528. * @returns PhysicsRaycastResult
  127529. */
  127530. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127531. }
  127532. }
  127533. declare module BABYLON {
  127534. /** @hidden */
  127535. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  127536. private _useDeltaForWorldStep;
  127537. world: any;
  127538. name: string;
  127539. private _physicsMaterials;
  127540. private _fixedTimeStep;
  127541. private _cannonRaycastResult;
  127542. private _raycastResult;
  127543. private _physicsBodysToRemoveAfterStep;
  127544. BJSCANNON: any;
  127545. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  127546. setGravity(gravity: Vector3): void;
  127547. setTimeStep(timeStep: number): void;
  127548. getTimeStep(): number;
  127549. executeStep(delta: number): void;
  127550. private _removeMarkedPhysicsBodiesFromWorld;
  127551. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127552. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127553. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127554. private _processChildMeshes;
  127555. removePhysicsBody(impostor: PhysicsImpostor): void;
  127556. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127557. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127558. private _addMaterial;
  127559. private _checkWithEpsilon;
  127560. private _createShape;
  127561. private _createHeightmap;
  127562. private _minus90X;
  127563. private _plus90X;
  127564. private _tmpPosition;
  127565. private _tmpDeltaPosition;
  127566. private _tmpUnityRotation;
  127567. private _updatePhysicsBodyTransformation;
  127568. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127569. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127570. isSupported(): boolean;
  127571. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127572. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127573. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127574. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127575. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127576. getBodyMass(impostor: PhysicsImpostor): number;
  127577. getBodyFriction(impostor: PhysicsImpostor): number;
  127578. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127579. getBodyRestitution(impostor: PhysicsImpostor): number;
  127580. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127581. sleepBody(impostor: PhysicsImpostor): void;
  127582. wakeUpBody(impostor: PhysicsImpostor): void;
  127583. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  127584. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  127585. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  127586. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127587. getRadius(impostor: PhysicsImpostor): number;
  127588. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127589. dispose(): void;
  127590. private _extendNamespace;
  127591. /**
  127592. * Does a raycast in the physics world
  127593. * @param from when should the ray start?
  127594. * @param to when should the ray end?
  127595. * @returns PhysicsRaycastResult
  127596. */
  127597. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127598. }
  127599. }
  127600. declare module BABYLON {
  127601. /** @hidden */
  127602. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  127603. world: any;
  127604. name: string;
  127605. BJSOIMO: any;
  127606. private _raycastResult;
  127607. constructor(iterations?: number, oimoInjection?: any);
  127608. setGravity(gravity: Vector3): void;
  127609. setTimeStep(timeStep: number): void;
  127610. getTimeStep(): number;
  127611. private _tmpImpostorsArray;
  127612. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127613. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127614. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127615. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127616. private _tmpPositionVector;
  127617. removePhysicsBody(impostor: PhysicsImpostor): void;
  127618. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127619. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127620. isSupported(): boolean;
  127621. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127622. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127623. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127624. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127625. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127626. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127627. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127628. getBodyMass(impostor: PhysicsImpostor): number;
  127629. getBodyFriction(impostor: PhysicsImpostor): number;
  127630. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127631. getBodyRestitution(impostor: PhysicsImpostor): number;
  127632. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127633. sleepBody(impostor: PhysicsImpostor): void;
  127634. wakeUpBody(impostor: PhysicsImpostor): void;
  127635. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  127636. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  127637. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  127638. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127639. getRadius(impostor: PhysicsImpostor): number;
  127640. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127641. dispose(): void;
  127642. /**
  127643. * Does a raycast in the physics world
  127644. * @param from when should the ray start?
  127645. * @param to when should the ray end?
  127646. * @returns PhysicsRaycastResult
  127647. */
  127648. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127649. }
  127650. }
  127651. declare module BABYLON {
  127652. /**
  127653. * Class containing static functions to help procedurally build meshes
  127654. */
  127655. export class RibbonBuilder {
  127656. /**
  127657. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127658. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127659. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127660. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127661. * * 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
  127662. * * 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
  127663. * * 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
  127664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127667. * * 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
  127668. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127669. * * 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
  127670. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127672. * @param name defines the name of the mesh
  127673. * @param options defines the options used to create the mesh
  127674. * @param scene defines the hosting scene
  127675. * @returns the ribbon mesh
  127676. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127677. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127678. */
  127679. static CreateRibbon(name: string, options: {
  127680. pathArray: Vector3[][];
  127681. closeArray?: boolean;
  127682. closePath?: boolean;
  127683. offset?: number;
  127684. updatable?: boolean;
  127685. sideOrientation?: number;
  127686. frontUVs?: Vector4;
  127687. backUVs?: Vector4;
  127688. instance?: Mesh;
  127689. invertUV?: boolean;
  127690. uvs?: Vector2[];
  127691. colors?: Color4[];
  127692. }, scene?: Nullable<Scene>): Mesh;
  127693. }
  127694. }
  127695. declare module BABYLON {
  127696. /**
  127697. * Class containing static functions to help procedurally build meshes
  127698. */
  127699. export class ShapeBuilder {
  127700. /**
  127701. * 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.
  127702. * * 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.
  127703. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127704. * * 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.
  127705. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127706. * * 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
  127707. * * 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
  127708. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127713. * @param name defines the name of the mesh
  127714. * @param options defines the options used to create the mesh
  127715. * @param scene defines the hosting scene
  127716. * @returns the extruded shape mesh
  127717. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127719. */
  127720. static ExtrudeShape(name: string, options: {
  127721. shape: Vector3[];
  127722. path: Vector3[];
  127723. scale?: number;
  127724. rotation?: number;
  127725. cap?: number;
  127726. updatable?: boolean;
  127727. sideOrientation?: number;
  127728. frontUVs?: Vector4;
  127729. backUVs?: Vector4;
  127730. instance?: Mesh;
  127731. invertUV?: boolean;
  127732. }, scene?: Nullable<Scene>): Mesh;
  127733. /**
  127734. * Creates an custom extruded shape mesh.
  127735. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127736. * * 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.
  127737. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127738. * * 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
  127739. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127740. * * 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
  127741. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127742. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127743. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127744. * * 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
  127745. * * 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
  127746. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127751. * @param name defines the name of the mesh
  127752. * @param options defines the options used to create the mesh
  127753. * @param scene defines the hosting scene
  127754. * @returns the custom extruded shape mesh
  127755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127758. */
  127759. static ExtrudeShapeCustom(name: string, options: {
  127760. shape: Vector3[];
  127761. path: Vector3[];
  127762. scaleFunction?: any;
  127763. rotationFunction?: any;
  127764. ribbonCloseArray?: boolean;
  127765. ribbonClosePath?: boolean;
  127766. cap?: number;
  127767. updatable?: boolean;
  127768. sideOrientation?: number;
  127769. frontUVs?: Vector4;
  127770. backUVs?: Vector4;
  127771. instance?: Mesh;
  127772. invertUV?: boolean;
  127773. }, scene?: Nullable<Scene>): Mesh;
  127774. private static _ExtrudeShapeGeneric;
  127775. }
  127776. }
  127777. declare module BABYLON {
  127778. /**
  127779. * AmmoJS Physics plugin
  127780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  127781. * @see https://github.com/kripken/ammo.js/
  127782. */
  127783. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  127784. private _useDeltaForWorldStep;
  127785. /**
  127786. * Reference to the Ammo library
  127787. */
  127788. bjsAMMO: any;
  127789. /**
  127790. * Created ammoJS world which physics bodies are added to
  127791. */
  127792. world: any;
  127793. /**
  127794. * Name of the plugin
  127795. */
  127796. name: string;
  127797. private _timeStep;
  127798. private _fixedTimeStep;
  127799. private _maxSteps;
  127800. private _tmpQuaternion;
  127801. private _tmpAmmoTransform;
  127802. private _tmpAmmoQuaternion;
  127803. private _tmpAmmoConcreteContactResultCallback;
  127804. private _collisionConfiguration;
  127805. private _dispatcher;
  127806. private _overlappingPairCache;
  127807. private _solver;
  127808. private _softBodySolver;
  127809. private _tmpAmmoVectorA;
  127810. private _tmpAmmoVectorB;
  127811. private _tmpAmmoVectorC;
  127812. private _tmpAmmoVectorD;
  127813. private _tmpContactCallbackResult;
  127814. private _tmpAmmoVectorRCA;
  127815. private _tmpAmmoVectorRCB;
  127816. private _raycastResult;
  127817. private static readonly DISABLE_COLLISION_FLAG;
  127818. private static readonly KINEMATIC_FLAG;
  127819. private static readonly DISABLE_DEACTIVATION_FLAG;
  127820. /**
  127821. * Initializes the ammoJS plugin
  127822. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  127823. * @param ammoInjection can be used to inject your own ammo reference
  127824. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  127825. */
  127826. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  127827. /**
  127828. * Sets the gravity of the physics world (m/(s^2))
  127829. * @param gravity Gravity to set
  127830. */
  127831. setGravity(gravity: Vector3): void;
  127832. /**
  127833. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  127834. * @param timeStep timestep to use in seconds
  127835. */
  127836. setTimeStep(timeStep: number): void;
  127837. /**
  127838. * 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)
  127839. * @param fixedTimeStep fixedTimeStep to use in seconds
  127840. */
  127841. setFixedTimeStep(fixedTimeStep: number): void;
  127842. /**
  127843. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  127844. * @param maxSteps the maximum number of steps by the physics engine per frame
  127845. */
  127846. setMaxSteps(maxSteps: number): void;
  127847. /**
  127848. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  127849. * @returns the current timestep in seconds
  127850. */
  127851. getTimeStep(): number;
  127852. /**
  127853. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  127854. */
  127855. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  127856. private _isImpostorInContact;
  127857. private _isImpostorPairInContact;
  127858. private _stepSimulation;
  127859. /**
  127860. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  127861. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  127862. * After the step the babylon meshes are set to the position of the physics imposters
  127863. * @param delta amount of time to step forward
  127864. * @param impostors array of imposters to update before/after the step
  127865. */
  127866. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127867. /**
  127868. * Update babylon mesh to match physics world object
  127869. * @param impostor imposter to match
  127870. */
  127871. private _afterSoftStep;
  127872. /**
  127873. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127874. * @param impostor imposter to match
  127875. */
  127876. private _ropeStep;
  127877. /**
  127878. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127879. * @param impostor imposter to match
  127880. */
  127881. private _softbodyOrClothStep;
  127882. private _tmpVector;
  127883. private _tmpMatrix;
  127884. /**
  127885. * Applies an impulse on the imposter
  127886. * @param impostor imposter to apply impulse to
  127887. * @param force amount of force to be applied to the imposter
  127888. * @param contactPoint the location to apply the impulse on the imposter
  127889. */
  127890. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127891. /**
  127892. * Applies a force on the imposter
  127893. * @param impostor imposter to apply force
  127894. * @param force amount of force to be applied to the imposter
  127895. * @param contactPoint the location to apply the force on the imposter
  127896. */
  127897. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127898. /**
  127899. * Creates a physics body using the plugin
  127900. * @param impostor the imposter to create the physics body on
  127901. */
  127902. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127903. /**
  127904. * Removes the physics body from the imposter and disposes of the body's memory
  127905. * @param impostor imposter to remove the physics body from
  127906. */
  127907. removePhysicsBody(impostor: PhysicsImpostor): void;
  127908. /**
  127909. * Generates a joint
  127910. * @param impostorJoint the imposter joint to create the joint with
  127911. */
  127912. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127913. /**
  127914. * Removes a joint
  127915. * @param impostorJoint the imposter joint to remove the joint from
  127916. */
  127917. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127918. private _addMeshVerts;
  127919. /**
  127920. * Initialise the soft body vertices to match its object's (mesh) vertices
  127921. * Softbody vertices (nodes) are in world space and to match this
  127922. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  127923. * @param impostor to create the softbody for
  127924. */
  127925. private _softVertexData;
  127926. /**
  127927. * Create an impostor's soft body
  127928. * @param impostor to create the softbody for
  127929. */
  127930. private _createSoftbody;
  127931. /**
  127932. * Create cloth for an impostor
  127933. * @param impostor to create the softbody for
  127934. */
  127935. private _createCloth;
  127936. /**
  127937. * Create rope for an impostor
  127938. * @param impostor to create the softbody for
  127939. */
  127940. private _createRope;
  127941. /**
  127942. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  127943. * @param impostor to create the custom physics shape for
  127944. */
  127945. private _createCustom;
  127946. private _addHullVerts;
  127947. private _createShape;
  127948. /**
  127949. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  127950. * @param impostor imposter containing the physics body and babylon object
  127951. */
  127952. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127953. /**
  127954. * Sets the babylon object's position/rotation from the physics body's position/rotation
  127955. * @param impostor imposter containing the physics body and babylon object
  127956. * @param newPosition new position
  127957. * @param newRotation new rotation
  127958. */
  127959. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127960. /**
  127961. * If this plugin is supported
  127962. * @returns true if its supported
  127963. */
  127964. isSupported(): boolean;
  127965. /**
  127966. * Sets the linear velocity of the physics body
  127967. * @param impostor imposter to set the velocity on
  127968. * @param velocity velocity to set
  127969. */
  127970. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127971. /**
  127972. * Sets the angular velocity of the physics body
  127973. * @param impostor imposter to set the velocity on
  127974. * @param velocity velocity to set
  127975. */
  127976. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127977. /**
  127978. * gets the linear velocity
  127979. * @param impostor imposter to get linear velocity from
  127980. * @returns linear velocity
  127981. */
  127982. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127983. /**
  127984. * gets the angular velocity
  127985. * @param impostor imposter to get angular velocity from
  127986. * @returns angular velocity
  127987. */
  127988. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127989. /**
  127990. * Sets the mass of physics body
  127991. * @param impostor imposter to set the mass on
  127992. * @param mass mass to set
  127993. */
  127994. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127995. /**
  127996. * Gets the mass of the physics body
  127997. * @param impostor imposter to get the mass from
  127998. * @returns mass
  127999. */
  128000. getBodyMass(impostor: PhysicsImpostor): number;
  128001. /**
  128002. * Gets friction of the impostor
  128003. * @param impostor impostor to get friction from
  128004. * @returns friction value
  128005. */
  128006. getBodyFriction(impostor: PhysicsImpostor): number;
  128007. /**
  128008. * Sets friction of the impostor
  128009. * @param impostor impostor to set friction on
  128010. * @param friction friction value
  128011. */
  128012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128013. /**
  128014. * Gets restitution of the impostor
  128015. * @param impostor impostor to get restitution from
  128016. * @returns restitution value
  128017. */
  128018. getBodyRestitution(impostor: PhysicsImpostor): number;
  128019. /**
  128020. * Sets resitution of the impostor
  128021. * @param impostor impostor to set resitution on
  128022. * @param restitution resitution value
  128023. */
  128024. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128025. /**
  128026. * Gets pressure inside the impostor
  128027. * @param impostor impostor to get pressure from
  128028. * @returns pressure value
  128029. */
  128030. getBodyPressure(impostor: PhysicsImpostor): number;
  128031. /**
  128032. * Sets pressure inside a soft body impostor
  128033. * Cloth and rope must remain 0 pressure
  128034. * @param impostor impostor to set pressure on
  128035. * @param pressure pressure value
  128036. */
  128037. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128038. /**
  128039. * Gets stiffness of the impostor
  128040. * @param impostor impostor to get stiffness from
  128041. * @returns pressure value
  128042. */
  128043. getBodyStiffness(impostor: PhysicsImpostor): number;
  128044. /**
  128045. * Sets stiffness of the impostor
  128046. * @param impostor impostor to set stiffness on
  128047. * @param stiffness stiffness value from 0 to 1
  128048. */
  128049. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128050. /**
  128051. * Gets velocityIterations of the impostor
  128052. * @param impostor impostor to get velocity iterations from
  128053. * @returns velocityIterations value
  128054. */
  128055. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128056. /**
  128057. * Sets velocityIterations of the impostor
  128058. * @param impostor impostor to set velocity iterations on
  128059. * @param velocityIterations velocityIterations value
  128060. */
  128061. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128062. /**
  128063. * Gets positionIterations of the impostor
  128064. * @param impostor impostor to get position iterations from
  128065. * @returns positionIterations value
  128066. */
  128067. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128068. /**
  128069. * Sets positionIterations of the impostor
  128070. * @param impostor impostor to set position on
  128071. * @param positionIterations positionIterations value
  128072. */
  128073. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128074. /**
  128075. * Append an anchor to a cloth object
  128076. * @param impostor is the cloth impostor to add anchor to
  128077. * @param otherImpostor is the rigid impostor to anchor to
  128078. * @param width ratio across width from 0 to 1
  128079. * @param height ratio up height from 0 to 1
  128080. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128081. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128082. */
  128083. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128084. /**
  128085. * Append an hook to a rope object
  128086. * @param impostor is the rope impostor to add hook to
  128087. * @param otherImpostor is the rigid impostor to hook to
  128088. * @param length ratio along the rope from 0 to 1
  128089. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128090. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128091. */
  128092. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128093. /**
  128094. * Sleeps the physics body and stops it from being active
  128095. * @param impostor impostor to sleep
  128096. */
  128097. sleepBody(impostor: PhysicsImpostor): void;
  128098. /**
  128099. * Activates the physics body
  128100. * @param impostor impostor to activate
  128101. */
  128102. wakeUpBody(impostor: PhysicsImpostor): void;
  128103. /**
  128104. * Updates the distance parameters of the joint
  128105. * @param joint joint to update
  128106. * @param maxDistance maximum distance of the joint
  128107. * @param minDistance minimum distance of the joint
  128108. */
  128109. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128110. /**
  128111. * Sets a motor on the joint
  128112. * @param joint joint to set motor on
  128113. * @param speed speed of the motor
  128114. * @param maxForce maximum force of the motor
  128115. * @param motorIndex index of the motor
  128116. */
  128117. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128118. /**
  128119. * Sets the motors limit
  128120. * @param joint joint to set limit on
  128121. * @param upperLimit upper limit
  128122. * @param lowerLimit lower limit
  128123. */
  128124. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128125. /**
  128126. * Syncs the position and rotation of a mesh with the impostor
  128127. * @param mesh mesh to sync
  128128. * @param impostor impostor to update the mesh with
  128129. */
  128130. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128131. /**
  128132. * Gets the radius of the impostor
  128133. * @param impostor impostor to get radius from
  128134. * @returns the radius
  128135. */
  128136. getRadius(impostor: PhysicsImpostor): number;
  128137. /**
  128138. * Gets the box size of the impostor
  128139. * @param impostor impostor to get box size from
  128140. * @param result the resulting box size
  128141. */
  128142. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128143. /**
  128144. * Disposes of the impostor
  128145. */
  128146. dispose(): void;
  128147. /**
  128148. * Does a raycast in the physics world
  128149. * @param from when should the ray start?
  128150. * @param to when should the ray end?
  128151. * @returns PhysicsRaycastResult
  128152. */
  128153. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128154. }
  128155. }
  128156. declare module BABYLON {
  128157. interface AbstractScene {
  128158. /**
  128159. * The list of reflection probes added to the scene
  128160. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128161. */
  128162. reflectionProbes: Array<ReflectionProbe>;
  128163. /**
  128164. * Removes the given reflection probe from this scene.
  128165. * @param toRemove The reflection probe to remove
  128166. * @returns The index of the removed reflection probe
  128167. */
  128168. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128169. /**
  128170. * Adds the given reflection probe to this scene.
  128171. * @param newReflectionProbe The reflection probe to add
  128172. */
  128173. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128174. }
  128175. /**
  128176. * Class used to generate realtime reflection / refraction cube textures
  128177. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128178. */
  128179. export class ReflectionProbe {
  128180. /** defines the name of the probe */
  128181. name: string;
  128182. private _scene;
  128183. private _renderTargetTexture;
  128184. private _projectionMatrix;
  128185. private _viewMatrix;
  128186. private _target;
  128187. private _add;
  128188. private _attachedMesh;
  128189. private _invertYAxis;
  128190. /** Gets or sets probe position (center of the cube map) */
  128191. position: Vector3;
  128192. /**
  128193. * Creates a new reflection probe
  128194. * @param name defines the name of the probe
  128195. * @param size defines the texture resolution (for each face)
  128196. * @param scene defines the hosting scene
  128197. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128198. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128199. */
  128200. constructor(
  128201. /** defines the name of the probe */
  128202. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128203. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128204. get samples(): number;
  128205. set samples(value: number);
  128206. /** Gets or sets the refresh rate to use (on every frame by default) */
  128207. get refreshRate(): number;
  128208. set refreshRate(value: number);
  128209. /**
  128210. * Gets the hosting scene
  128211. * @returns a Scene
  128212. */
  128213. getScene(): Scene;
  128214. /** Gets the internal CubeTexture used to render to */
  128215. get cubeTexture(): RenderTargetTexture;
  128216. /** Gets the list of meshes to render */
  128217. get renderList(): Nullable<AbstractMesh[]>;
  128218. /**
  128219. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128220. * @param mesh defines the mesh to attach to
  128221. */
  128222. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128223. /**
  128224. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128225. * @param renderingGroupId The rendering group id corresponding to its index
  128226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128227. */
  128228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128229. /**
  128230. * Clean all associated resources
  128231. */
  128232. dispose(): void;
  128233. /**
  128234. * Converts the reflection probe information to a readable string for debug purpose.
  128235. * @param fullDetails Supports for multiple levels of logging within scene loading
  128236. * @returns the human readable reflection probe info
  128237. */
  128238. toString(fullDetails?: boolean): string;
  128239. /**
  128240. * Get the class name of the relfection probe.
  128241. * @returns "ReflectionProbe"
  128242. */
  128243. getClassName(): string;
  128244. /**
  128245. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128246. * @returns The JSON representation of the texture
  128247. */
  128248. serialize(): any;
  128249. /**
  128250. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128251. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128252. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128253. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128254. * @returns The parsed reflection probe if successful
  128255. */
  128256. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128257. }
  128258. }
  128259. declare module BABYLON {
  128260. /** @hidden */
  128261. export var _BabylonLoaderRegistered: boolean;
  128262. /**
  128263. * Helps setting up some configuration for the babylon file loader.
  128264. */
  128265. export class BabylonFileLoaderConfiguration {
  128266. /**
  128267. * The loader does not allow injecting custom physix engine into the plugins.
  128268. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128269. * So you could set this variable to your engine import to make it work.
  128270. */
  128271. static LoaderInjectedPhysicsEngine: any;
  128272. }
  128273. }
  128274. declare module BABYLON {
  128275. /**
  128276. * The Physically based simple base material of BJS.
  128277. *
  128278. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128279. * It is used as the base class for both the specGloss and metalRough conventions.
  128280. */
  128281. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128282. /**
  128283. * Number of Simultaneous lights allowed on the material.
  128284. */
  128285. maxSimultaneousLights: number;
  128286. /**
  128287. * If sets to true, disables all the lights affecting the material.
  128288. */
  128289. disableLighting: boolean;
  128290. /**
  128291. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128292. */
  128293. environmentTexture: BaseTexture;
  128294. /**
  128295. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128296. */
  128297. invertNormalMapX: boolean;
  128298. /**
  128299. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128300. */
  128301. invertNormalMapY: boolean;
  128302. /**
  128303. * Normal map used in the model.
  128304. */
  128305. normalTexture: BaseTexture;
  128306. /**
  128307. * Emissivie color used to self-illuminate the model.
  128308. */
  128309. emissiveColor: Color3;
  128310. /**
  128311. * Emissivie texture used to self-illuminate the model.
  128312. */
  128313. emissiveTexture: BaseTexture;
  128314. /**
  128315. * Occlusion Channel Strenght.
  128316. */
  128317. occlusionStrength: number;
  128318. /**
  128319. * Occlusion Texture of the material (adding extra occlusion effects).
  128320. */
  128321. occlusionTexture: BaseTexture;
  128322. /**
  128323. * Defines the alpha limits in alpha test mode.
  128324. */
  128325. alphaCutOff: number;
  128326. /**
  128327. * Gets the current double sided mode.
  128328. */
  128329. get doubleSided(): boolean;
  128330. /**
  128331. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128332. */
  128333. set doubleSided(value: boolean);
  128334. /**
  128335. * Stores the pre-calculated light information of a mesh in a texture.
  128336. */
  128337. lightmapTexture: BaseTexture;
  128338. /**
  128339. * If true, the light map contains occlusion information instead of lighting info.
  128340. */
  128341. useLightmapAsShadowmap: boolean;
  128342. /**
  128343. * Instantiates a new PBRMaterial instance.
  128344. *
  128345. * @param name The material name
  128346. * @param scene The scene the material will be use in.
  128347. */
  128348. constructor(name: string, scene: Scene);
  128349. getClassName(): string;
  128350. }
  128351. }
  128352. declare module BABYLON {
  128353. /**
  128354. * The PBR material of BJS following the metal roughness convention.
  128355. *
  128356. * This fits to the PBR convention in the GLTF definition:
  128357. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128358. */
  128359. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128360. /**
  128361. * The base color has two different interpretations depending on the value of metalness.
  128362. * When the material is a metal, the base color is the specific measured reflectance value
  128363. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128364. * of the material.
  128365. */
  128366. baseColor: Color3;
  128367. /**
  128368. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128369. * well as opacity information in the alpha channel.
  128370. */
  128371. baseTexture: BaseTexture;
  128372. /**
  128373. * Specifies the metallic scalar value of the material.
  128374. * Can also be used to scale the metalness values of the metallic texture.
  128375. */
  128376. metallic: number;
  128377. /**
  128378. * Specifies the roughness scalar value of the material.
  128379. * Can also be used to scale the roughness values of the metallic texture.
  128380. */
  128381. roughness: number;
  128382. /**
  128383. * Texture containing both the metallic value in the B channel and the
  128384. * roughness value in the G channel to keep better precision.
  128385. */
  128386. metallicRoughnessTexture: BaseTexture;
  128387. /**
  128388. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128389. *
  128390. * @param name The material name
  128391. * @param scene The scene the material will be use in.
  128392. */
  128393. constructor(name: string, scene: Scene);
  128394. /**
  128395. * Return the currrent class name of the material.
  128396. */
  128397. getClassName(): string;
  128398. /**
  128399. * Makes a duplicate of the current material.
  128400. * @param name - name to use for the new material.
  128401. */
  128402. clone(name: string): PBRMetallicRoughnessMaterial;
  128403. /**
  128404. * Serialize the material to a parsable JSON object.
  128405. */
  128406. serialize(): any;
  128407. /**
  128408. * Parses a JSON object correponding to the serialize function.
  128409. */
  128410. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128411. }
  128412. }
  128413. declare module BABYLON {
  128414. /**
  128415. * The PBR material of BJS following the specular glossiness convention.
  128416. *
  128417. * This fits to the PBR convention in the GLTF definition:
  128418. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128419. */
  128420. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128421. /**
  128422. * Specifies the diffuse color of the material.
  128423. */
  128424. diffuseColor: Color3;
  128425. /**
  128426. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128427. * channel.
  128428. */
  128429. diffuseTexture: BaseTexture;
  128430. /**
  128431. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128432. */
  128433. specularColor: Color3;
  128434. /**
  128435. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128436. */
  128437. glossiness: number;
  128438. /**
  128439. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128440. */
  128441. specularGlossinessTexture: BaseTexture;
  128442. /**
  128443. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128444. *
  128445. * @param name The material name
  128446. * @param scene The scene the material will be use in.
  128447. */
  128448. constructor(name: string, scene: Scene);
  128449. /**
  128450. * Return the currrent class name of the material.
  128451. */
  128452. getClassName(): string;
  128453. /**
  128454. * Makes a duplicate of the current material.
  128455. * @param name - name to use for the new material.
  128456. */
  128457. clone(name: string): PBRSpecularGlossinessMaterial;
  128458. /**
  128459. * Serialize the material to a parsable JSON object.
  128460. */
  128461. serialize(): any;
  128462. /**
  128463. * Parses a JSON object correponding to the serialize function.
  128464. */
  128465. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128466. }
  128467. }
  128468. declare module BABYLON {
  128469. /**
  128470. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128471. * It can help converting any input color in a desired output one. This can then be used to create effects
  128472. * from sepia, black and white to sixties or futuristic rendering...
  128473. *
  128474. * The only supported format is currently 3dl.
  128475. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128476. */
  128477. export class ColorGradingTexture extends BaseTexture {
  128478. /**
  128479. * The current texture matrix. (will always be identity in color grading texture)
  128480. */
  128481. private _textureMatrix;
  128482. /**
  128483. * The texture URL.
  128484. */
  128485. url: string;
  128486. /**
  128487. * Empty line regex stored for GC.
  128488. */
  128489. private static _noneEmptyLineRegex;
  128490. private _engine;
  128491. /**
  128492. * Instantiates a ColorGradingTexture from the following parameters.
  128493. *
  128494. * @param url The location of the color gradind data (currently only supporting 3dl)
  128495. * @param scene The scene the texture will be used in
  128496. */
  128497. constructor(url: string, scene: Scene);
  128498. /**
  128499. * Returns the texture matrix used in most of the material.
  128500. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128501. */
  128502. getTextureMatrix(): Matrix;
  128503. /**
  128504. * Occurs when the file being loaded is a .3dl LUT file.
  128505. */
  128506. private load3dlTexture;
  128507. /**
  128508. * Starts the loading process of the texture.
  128509. */
  128510. private loadTexture;
  128511. /**
  128512. * Clones the color gradind texture.
  128513. */
  128514. clone(): ColorGradingTexture;
  128515. /**
  128516. * Called during delayed load for textures.
  128517. */
  128518. delayLoad(): void;
  128519. /**
  128520. * Parses a color grading texture serialized by Babylon.
  128521. * @param parsedTexture The texture information being parsedTexture
  128522. * @param scene The scene to load the texture in
  128523. * @param rootUrl The root url of the data assets to load
  128524. * @return A color gradind texture
  128525. */
  128526. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  128527. /**
  128528. * Serializes the LUT texture to json format.
  128529. */
  128530. serialize(): any;
  128531. }
  128532. }
  128533. declare module BABYLON {
  128534. /**
  128535. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  128536. */
  128537. export class EquiRectangularCubeTexture extends BaseTexture {
  128538. /** The six faces of the cube. */
  128539. private static _FacesMapping;
  128540. private _noMipmap;
  128541. private _onLoad;
  128542. private _onError;
  128543. /** The size of the cubemap. */
  128544. private _size;
  128545. /** The buffer of the image. */
  128546. private _buffer;
  128547. /** The width of the input image. */
  128548. private _width;
  128549. /** The height of the input image. */
  128550. private _height;
  128551. /** The URL to the image. */
  128552. url: string;
  128553. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  128554. coordinatesMode: number;
  128555. /**
  128556. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  128557. * @param url The location of the image
  128558. * @param scene The scene the texture will be used in
  128559. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128560. * @param noMipmap Forces to not generate the mipmap if true
  128561. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128562. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128563. * @param onLoad — defines a callback called when texture is loaded
  128564. * @param onError — defines a callback called if there is an error
  128565. */
  128566. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  128567. /**
  128568. * Load the image data, by putting the image on a canvas and extracting its buffer.
  128569. */
  128570. private loadImage;
  128571. /**
  128572. * Convert the image buffer into a cubemap and create a CubeTexture.
  128573. */
  128574. private loadTexture;
  128575. /**
  128576. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  128577. * @param buffer The ArrayBuffer that should be converted.
  128578. * @returns The buffer as Float32Array.
  128579. */
  128580. private getFloat32ArrayFromArrayBuffer;
  128581. /**
  128582. * Get the current class name of the texture useful for serialization or dynamic coding.
  128583. * @returns "EquiRectangularCubeTexture"
  128584. */
  128585. getClassName(): string;
  128586. /**
  128587. * Create a clone of the current EquiRectangularCubeTexture and return it.
  128588. * @returns A clone of the current EquiRectangularCubeTexture.
  128589. */
  128590. clone(): EquiRectangularCubeTexture;
  128591. }
  128592. }
  128593. declare module BABYLON {
  128594. /**
  128595. * Based on jsTGALoader - Javascript loader for TGA file
  128596. * By Vincent Thibault
  128597. * @see http://blog.robrowser.com/javascript-tga-loader.html
  128598. */
  128599. export class TGATools {
  128600. private static _TYPE_INDEXED;
  128601. private static _TYPE_RGB;
  128602. private static _TYPE_GREY;
  128603. private static _TYPE_RLE_INDEXED;
  128604. private static _TYPE_RLE_RGB;
  128605. private static _TYPE_RLE_GREY;
  128606. private static _ORIGIN_MASK;
  128607. private static _ORIGIN_SHIFT;
  128608. private static _ORIGIN_BL;
  128609. private static _ORIGIN_BR;
  128610. private static _ORIGIN_UL;
  128611. private static _ORIGIN_UR;
  128612. /**
  128613. * Gets the header of a TGA file
  128614. * @param data defines the TGA data
  128615. * @returns the header
  128616. */
  128617. static GetTGAHeader(data: Uint8Array): any;
  128618. /**
  128619. * Uploads TGA content to a Babylon Texture
  128620. * @hidden
  128621. */
  128622. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  128623. /** @hidden */
  128624. 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;
  128625. /** @hidden */
  128626. 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;
  128627. /** @hidden */
  128628. 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;
  128629. /** @hidden */
  128630. 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;
  128631. /** @hidden */
  128632. 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;
  128633. /** @hidden */
  128634. 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;
  128635. }
  128636. }
  128637. declare module BABYLON {
  128638. /**
  128639. * Implementation of the TGA Texture Loader.
  128640. * @hidden
  128641. */
  128642. export class _TGATextureLoader implements IInternalTextureLoader {
  128643. /**
  128644. * Defines wether the loader supports cascade loading the different faces.
  128645. */
  128646. readonly supportCascades: boolean;
  128647. /**
  128648. * This returns if the loader support the current file information.
  128649. * @param extension defines the file extension of the file being loaded
  128650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128651. * @param fallback defines the fallback internal texture if any
  128652. * @param isBase64 defines whether the texture is encoded as a base64
  128653. * @param isBuffer defines whether the texture data are stored as a buffer
  128654. * @returns true if the loader can load the specified file
  128655. */
  128656. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128657. /**
  128658. * Transform the url before loading if required.
  128659. * @param rootUrl the url of the texture
  128660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128661. * @returns the transformed texture
  128662. */
  128663. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128664. /**
  128665. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128666. * @param rootUrl the url of the texture
  128667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128668. * @returns the fallback texture
  128669. */
  128670. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128671. /**
  128672. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  128673. * @param data contains the texture data
  128674. * @param texture defines the BabylonJS internal texture
  128675. * @param createPolynomials will be true if polynomials have been requested
  128676. * @param onLoad defines the callback to trigger once the texture is ready
  128677. * @param onError defines the callback to trigger in case of error
  128678. */
  128679. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128680. /**
  128681. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128682. * @param data contains the texture data
  128683. * @param texture defines the BabylonJS internal texture
  128684. * @param callback defines the method to call once ready to upload
  128685. */
  128686. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128687. }
  128688. }
  128689. declare module BABYLON {
  128690. /**
  128691. * Info about the .basis files
  128692. */
  128693. class BasisFileInfo {
  128694. /**
  128695. * If the file has alpha
  128696. */
  128697. hasAlpha: boolean;
  128698. /**
  128699. * Info about each image of the basis file
  128700. */
  128701. images: Array<{
  128702. levels: Array<{
  128703. width: number;
  128704. height: number;
  128705. transcodedPixels: ArrayBufferView;
  128706. }>;
  128707. }>;
  128708. }
  128709. /**
  128710. * Result of transcoding a basis file
  128711. */
  128712. class TranscodeResult {
  128713. /**
  128714. * Info about the .basis file
  128715. */
  128716. fileInfo: BasisFileInfo;
  128717. /**
  128718. * Format to use when loading the file
  128719. */
  128720. format: number;
  128721. }
  128722. /**
  128723. * Configuration options for the Basis transcoder
  128724. */
  128725. export class BasisTranscodeConfiguration {
  128726. /**
  128727. * Supported compression formats used to determine the supported output format of the transcoder
  128728. */
  128729. supportedCompressionFormats?: {
  128730. /**
  128731. * etc1 compression format
  128732. */
  128733. etc1?: boolean;
  128734. /**
  128735. * s3tc compression format
  128736. */
  128737. s3tc?: boolean;
  128738. /**
  128739. * pvrtc compression format
  128740. */
  128741. pvrtc?: boolean;
  128742. /**
  128743. * etc2 compression format
  128744. */
  128745. etc2?: boolean;
  128746. };
  128747. /**
  128748. * If mipmap levels should be loaded for transcoded images (Default: true)
  128749. */
  128750. loadMipmapLevels?: boolean;
  128751. /**
  128752. * Index of a single image to load (Default: all images)
  128753. */
  128754. loadSingleImage?: number;
  128755. }
  128756. /**
  128757. * Used to load .Basis files
  128758. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  128759. */
  128760. export class BasisTools {
  128761. private static _IgnoreSupportedFormats;
  128762. /**
  128763. * URL to use when loading the basis transcoder
  128764. */
  128765. static JSModuleURL: string;
  128766. /**
  128767. * URL to use when loading the wasm module for the transcoder
  128768. */
  128769. static WasmModuleURL: string;
  128770. /**
  128771. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  128772. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  128773. * @returns internal format corresponding to the Basis format
  128774. */
  128775. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  128776. private static _WorkerPromise;
  128777. private static _Worker;
  128778. private static _actionId;
  128779. private static _CreateWorkerAsync;
  128780. /**
  128781. * Transcodes a loaded image file to compressed pixel data
  128782. * @param imageData image data to transcode
  128783. * @param config configuration options for the transcoding
  128784. * @returns a promise resulting in the transcoded image
  128785. */
  128786. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  128787. /**
  128788. * Loads a texture from the transcode result
  128789. * @param texture texture load to
  128790. * @param transcodeResult the result of transcoding the basis file to load from
  128791. */
  128792. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  128793. }
  128794. }
  128795. declare module BABYLON {
  128796. /**
  128797. * Loader for .basis file format
  128798. */
  128799. export class _BasisTextureLoader implements IInternalTextureLoader {
  128800. /**
  128801. * Defines whether the loader supports cascade loading the different faces.
  128802. */
  128803. readonly supportCascades: boolean;
  128804. /**
  128805. * This returns if the loader support the current file information.
  128806. * @param extension defines the file extension of the file being loaded
  128807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128808. * @param fallback defines the fallback internal texture if any
  128809. * @param isBase64 defines whether the texture is encoded as a base64
  128810. * @param isBuffer defines whether the texture data are stored as a buffer
  128811. * @returns true if the loader can load the specified file
  128812. */
  128813. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128814. /**
  128815. * Transform the url before loading if required.
  128816. * @param rootUrl the url of the texture
  128817. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128818. * @returns the transformed texture
  128819. */
  128820. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128821. /**
  128822. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128823. * @param rootUrl the url of the texture
  128824. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128825. * @returns the fallback texture
  128826. */
  128827. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128828. /**
  128829. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  128830. * @param data contains the texture data
  128831. * @param texture defines the BabylonJS internal texture
  128832. * @param createPolynomials will be true if polynomials have been requested
  128833. * @param onLoad defines the callback to trigger once the texture is ready
  128834. * @param onError defines the callback to trigger in case of error
  128835. */
  128836. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128837. /**
  128838. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128839. * @param data contains the texture data
  128840. * @param texture defines the BabylonJS internal texture
  128841. * @param callback defines the method to call once ready to upload
  128842. */
  128843. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128844. }
  128845. }
  128846. declare module BABYLON {
  128847. /**
  128848. * 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.
  128849. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128851. */
  128852. export class CustomProceduralTexture extends ProceduralTexture {
  128853. private _animate;
  128854. private _time;
  128855. private _config;
  128856. private _texturePath;
  128857. /**
  128858. * Instantiates a new Custom Procedural Texture.
  128859. * 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.
  128860. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128862. * @param name Define the name of the texture
  128863. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  128864. * @param size Define the size of the texture to create
  128865. * @param scene Define the scene the texture belongs to
  128866. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  128867. * @param generateMipMaps Define if the texture should creates mip maps or not
  128868. */
  128869. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128870. private _loadJson;
  128871. /**
  128872. * Is the texture ready to be used ? (rendered at least once)
  128873. * @returns true if ready, otherwise, false.
  128874. */
  128875. isReady(): boolean;
  128876. /**
  128877. * Render the texture to its associated render target.
  128878. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  128879. */
  128880. render(useCameraPostProcess?: boolean): void;
  128881. /**
  128882. * Update the list of dependant textures samplers in the shader.
  128883. */
  128884. updateTextures(): void;
  128885. /**
  128886. * Update the uniform values of the procedural texture in the shader.
  128887. */
  128888. updateShaderUniforms(): void;
  128889. /**
  128890. * Define if the texture animates or not.
  128891. */
  128892. get animate(): boolean;
  128893. set animate(value: boolean);
  128894. }
  128895. }
  128896. declare module BABYLON {
  128897. /** @hidden */
  128898. export var noisePixelShader: {
  128899. name: string;
  128900. shader: string;
  128901. };
  128902. }
  128903. declare module BABYLON {
  128904. /**
  128905. * Class used to generate noise procedural textures
  128906. */
  128907. export class NoiseProceduralTexture extends ProceduralTexture {
  128908. private _time;
  128909. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  128910. brightness: number;
  128911. /** Defines the number of octaves to process */
  128912. octaves: number;
  128913. /** Defines the level of persistence (0.8 by default) */
  128914. persistence: number;
  128915. /** Gets or sets animation speed factor (default is 1) */
  128916. animationSpeedFactor: number;
  128917. /**
  128918. * Creates a new NoiseProceduralTexture
  128919. * @param name defines the name fo the texture
  128920. * @param size defines the size of the texture (default is 256)
  128921. * @param scene defines the hosting scene
  128922. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  128923. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  128924. */
  128925. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128926. private _updateShaderUniforms;
  128927. protected _getDefines(): string;
  128928. /** Generate the current state of the procedural texture */
  128929. render(useCameraPostProcess?: boolean): void;
  128930. /**
  128931. * Serializes this noise procedural texture
  128932. * @returns a serialized noise procedural texture object
  128933. */
  128934. serialize(): any;
  128935. /**
  128936. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  128937. * @param parsedTexture defines parsed texture data
  128938. * @param scene defines the current scene
  128939. * @param rootUrl defines the root URL containing noise procedural texture information
  128940. * @returns a parsed NoiseProceduralTexture
  128941. */
  128942. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  128943. }
  128944. }
  128945. declare module BABYLON {
  128946. /**
  128947. * Raw cube texture where the raw buffers are passed in
  128948. */
  128949. export class RawCubeTexture extends CubeTexture {
  128950. /**
  128951. * Creates a cube texture where the raw buffers are passed in.
  128952. * @param scene defines the scene the texture is attached to
  128953. * @param data defines the array of data to use to create each face
  128954. * @param size defines the size of the textures
  128955. * @param format defines the format of the data
  128956. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  128957. * @param generateMipMaps defines if the engine should generate the mip levels
  128958. * @param invertY defines if data must be stored with Y axis inverted
  128959. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  128960. * @param compression defines the compression used (null by default)
  128961. */
  128962. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  128963. /**
  128964. * Updates the raw cube texture.
  128965. * @param data defines the data to store
  128966. * @param format defines the data format
  128967. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128968. * @param invertY defines if data must be stored with Y axis inverted
  128969. * @param compression defines the compression used (null by default)
  128970. * @param level defines which level of the texture to update
  128971. */
  128972. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  128973. /**
  128974. * Updates a raw cube texture with RGBD encoded data.
  128975. * @param data defines the array of data [mipmap][face] to use to create each face
  128976. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  128977. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128978. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128979. * @returns a promsie that resolves when the operation is complete
  128980. */
  128981. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  128982. /**
  128983. * Clones the raw cube texture.
  128984. * @return a new cube texture
  128985. */
  128986. clone(): CubeTexture;
  128987. /** @hidden */
  128988. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128989. }
  128990. }
  128991. declare module BABYLON {
  128992. /**
  128993. * Class used to store 3D textures containing user data
  128994. */
  128995. export class RawTexture3D extends Texture {
  128996. /** Gets or sets the texture format to use */
  128997. format: number;
  128998. private _engine;
  128999. /**
  129000. * Create a new RawTexture3D
  129001. * @param data defines the data of the texture
  129002. * @param width defines the width of the texture
  129003. * @param height defines the height of the texture
  129004. * @param depth defines the depth of the texture
  129005. * @param format defines the texture format to use
  129006. * @param scene defines the hosting scene
  129007. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129008. * @param invertY defines if texture must be stored with Y axis inverted
  129009. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129010. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129011. */
  129012. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129013. /** Gets or sets the texture format to use */
  129014. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129015. /**
  129016. * Update the texture with new data
  129017. * @param data defines the data to store in the texture
  129018. */
  129019. update(data: ArrayBufferView): void;
  129020. }
  129021. }
  129022. declare module BABYLON {
  129023. /**
  129024. * Class used to store 2D array textures containing user data
  129025. */
  129026. export class RawTexture2DArray extends Texture {
  129027. /** Gets or sets the texture format to use */
  129028. format: number;
  129029. private _engine;
  129030. /**
  129031. * Create a new RawTexture2DArray
  129032. * @param data defines the data of the texture
  129033. * @param width defines the width of the texture
  129034. * @param height defines the height of the texture
  129035. * @param depth defines the number of layers of the texture
  129036. * @param format defines the texture format to use
  129037. * @param scene defines the hosting scene
  129038. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129039. * @param invertY defines if texture must be stored with Y axis inverted
  129040. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129041. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129042. */
  129043. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129044. /** Gets or sets the texture format to use */
  129045. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129046. /**
  129047. * Update the texture with new data
  129048. * @param data defines the data to store in the texture
  129049. */
  129050. update(data: ArrayBufferView): void;
  129051. }
  129052. }
  129053. declare module BABYLON {
  129054. /**
  129055. * Creates a refraction texture used by refraction channel of the standard material.
  129056. * It is like a mirror but to see through a material.
  129057. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129058. */
  129059. export class RefractionTexture extends RenderTargetTexture {
  129060. /**
  129061. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129062. * 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.
  129063. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129064. */
  129065. refractionPlane: Plane;
  129066. /**
  129067. * Define how deep under the surface we should see.
  129068. */
  129069. depth: number;
  129070. /**
  129071. * Creates a refraction texture used by refraction channel of the standard material.
  129072. * It is like a mirror but to see through a material.
  129073. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129074. * @param name Define the texture name
  129075. * @param size Define the size of the underlying texture
  129076. * @param scene Define the scene the refraction belongs to
  129077. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129078. */
  129079. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129080. /**
  129081. * Clone the refraction texture.
  129082. * @returns the cloned texture
  129083. */
  129084. clone(): RefractionTexture;
  129085. /**
  129086. * Serialize the texture to a JSON representation you could use in Parse later on
  129087. * @returns the serialized JSON representation
  129088. */
  129089. serialize(): any;
  129090. }
  129091. }
  129092. declare module BABYLON {
  129093. /**
  129094. * Defines the options related to the creation of an HtmlElementTexture
  129095. */
  129096. export interface IHtmlElementTextureOptions {
  129097. /**
  129098. * Defines wether mip maps should be created or not.
  129099. */
  129100. generateMipMaps?: boolean;
  129101. /**
  129102. * Defines the sampling mode of the texture.
  129103. */
  129104. samplingMode?: number;
  129105. /**
  129106. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129107. */
  129108. engine: Nullable<ThinEngine>;
  129109. /**
  129110. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129111. */
  129112. scene: Nullable<Scene>;
  129113. }
  129114. /**
  129115. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129116. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129117. * is automatically managed.
  129118. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129119. * in your application.
  129120. *
  129121. * As the update is not automatic, you need to call them manually.
  129122. */
  129123. export class HtmlElementTexture extends BaseTexture {
  129124. /**
  129125. * The texture URL.
  129126. */
  129127. element: HTMLVideoElement | HTMLCanvasElement;
  129128. private static readonly DefaultOptions;
  129129. private _textureMatrix;
  129130. private _engine;
  129131. private _isVideo;
  129132. private _generateMipMaps;
  129133. private _samplingMode;
  129134. /**
  129135. * Instantiates a HtmlElementTexture from the following parameters.
  129136. *
  129137. * @param name Defines the name of the texture
  129138. * @param element Defines the video or canvas the texture is filled with
  129139. * @param options Defines the other none mandatory texture creation options
  129140. */
  129141. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129142. private _createInternalTexture;
  129143. /**
  129144. * Returns the texture matrix used in most of the material.
  129145. */
  129146. getTextureMatrix(): Matrix;
  129147. /**
  129148. * Updates the content of the texture.
  129149. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129150. */
  129151. update(invertY?: Nullable<boolean>): void;
  129152. }
  129153. }
  129154. declare module BABYLON {
  129155. /**
  129156. * Enum used to define the target of a block
  129157. */
  129158. export enum NodeMaterialBlockTargets {
  129159. /** Vertex shader */
  129160. Vertex = 1,
  129161. /** Fragment shader */
  129162. Fragment = 2,
  129163. /** Neutral */
  129164. Neutral = 4,
  129165. /** Vertex and Fragment */
  129166. VertexAndFragment = 3
  129167. }
  129168. }
  129169. declare module BABYLON {
  129170. /**
  129171. * Defines the kind of connection point for node based material
  129172. */
  129173. export enum NodeMaterialBlockConnectionPointTypes {
  129174. /** Float */
  129175. Float = 1,
  129176. /** Int */
  129177. Int = 2,
  129178. /** Vector2 */
  129179. Vector2 = 4,
  129180. /** Vector3 */
  129181. Vector3 = 8,
  129182. /** Vector4 */
  129183. Vector4 = 16,
  129184. /** Color3 */
  129185. Color3 = 32,
  129186. /** Color4 */
  129187. Color4 = 64,
  129188. /** Matrix */
  129189. Matrix = 128,
  129190. /** Detect type based on connection */
  129191. AutoDetect = 1024,
  129192. /** Output type that will be defined by input type */
  129193. BasedOnInput = 2048
  129194. }
  129195. }
  129196. declare module BABYLON {
  129197. /**
  129198. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129199. */
  129200. export enum NodeMaterialBlockConnectionPointMode {
  129201. /** Value is an uniform */
  129202. Uniform = 0,
  129203. /** Value is a mesh attribute */
  129204. Attribute = 1,
  129205. /** Value is a varying between vertex and fragment shaders */
  129206. Varying = 2,
  129207. /** Mode is undefined */
  129208. Undefined = 3
  129209. }
  129210. }
  129211. declare module BABYLON {
  129212. /**
  129213. * Enum used to define system values e.g. values automatically provided by the system
  129214. */
  129215. export enum NodeMaterialSystemValues {
  129216. /** World */
  129217. World = 1,
  129218. /** View */
  129219. View = 2,
  129220. /** Projection */
  129221. Projection = 3,
  129222. /** ViewProjection */
  129223. ViewProjection = 4,
  129224. /** WorldView */
  129225. WorldView = 5,
  129226. /** WorldViewProjection */
  129227. WorldViewProjection = 6,
  129228. /** CameraPosition */
  129229. CameraPosition = 7,
  129230. /** Fog Color */
  129231. FogColor = 8,
  129232. /** Delta time */
  129233. DeltaTime = 9
  129234. }
  129235. }
  129236. declare module BABYLON {
  129237. /**
  129238. * Root class for all node material optimizers
  129239. */
  129240. export class NodeMaterialOptimizer {
  129241. /**
  129242. * Function used to optimize a NodeMaterial graph
  129243. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129244. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129245. */
  129246. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129247. }
  129248. }
  129249. declare module BABYLON {
  129250. /**
  129251. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129252. */
  129253. export class TransformBlock extends NodeMaterialBlock {
  129254. /**
  129255. * Defines the value to use to complement W value to transform it to a Vector4
  129256. */
  129257. complementW: number;
  129258. /**
  129259. * Defines the value to use to complement z value to transform it to a Vector4
  129260. */
  129261. complementZ: number;
  129262. /**
  129263. * Creates a new TransformBlock
  129264. * @param name defines the block name
  129265. */
  129266. constructor(name: string);
  129267. /**
  129268. * Gets the current class name
  129269. * @returns the class name
  129270. */
  129271. getClassName(): string;
  129272. /**
  129273. * Gets the vector input
  129274. */
  129275. get vector(): NodeMaterialConnectionPoint;
  129276. /**
  129277. * Gets the output component
  129278. */
  129279. get output(): NodeMaterialConnectionPoint;
  129280. /**
  129281. * Gets the matrix transform input
  129282. */
  129283. get transform(): NodeMaterialConnectionPoint;
  129284. protected _buildBlock(state: NodeMaterialBuildState): this;
  129285. serialize(): any;
  129286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129287. protected _dumpPropertiesCode(): string;
  129288. }
  129289. }
  129290. declare module BABYLON {
  129291. /**
  129292. * Block used to output the vertex position
  129293. */
  129294. export class VertexOutputBlock extends NodeMaterialBlock {
  129295. /**
  129296. * Creates a new VertexOutputBlock
  129297. * @param name defines the block name
  129298. */
  129299. constructor(name: string);
  129300. /**
  129301. * Gets the current class name
  129302. * @returns the class name
  129303. */
  129304. getClassName(): string;
  129305. /**
  129306. * Gets the vector input component
  129307. */
  129308. get vector(): NodeMaterialConnectionPoint;
  129309. protected _buildBlock(state: NodeMaterialBuildState): this;
  129310. }
  129311. }
  129312. declare module BABYLON {
  129313. /**
  129314. * Block used to output the final color
  129315. */
  129316. export class FragmentOutputBlock extends NodeMaterialBlock {
  129317. /**
  129318. * Create a new FragmentOutputBlock
  129319. * @param name defines the block name
  129320. */
  129321. constructor(name: string);
  129322. /**
  129323. * Gets the current class name
  129324. * @returns the class name
  129325. */
  129326. getClassName(): string;
  129327. /**
  129328. * Gets the rgba input component
  129329. */
  129330. get rgba(): NodeMaterialConnectionPoint;
  129331. /**
  129332. * Gets the rgb input component
  129333. */
  129334. get rgb(): NodeMaterialConnectionPoint;
  129335. /**
  129336. * Gets the a input component
  129337. */
  129338. get a(): NodeMaterialConnectionPoint;
  129339. protected _buildBlock(state: NodeMaterialBuildState): this;
  129340. }
  129341. }
  129342. declare module BABYLON {
  129343. /**
  129344. * Block used to read a reflection texture from a sampler
  129345. */
  129346. export class ReflectionTextureBlock extends NodeMaterialBlock {
  129347. private _define3DName;
  129348. private _defineCubicName;
  129349. private _defineExplicitName;
  129350. private _defineProjectionName;
  129351. private _defineLocalCubicName;
  129352. private _defineSphericalName;
  129353. private _definePlanarName;
  129354. private _defineEquirectangularName;
  129355. private _defineMirroredEquirectangularFixedName;
  129356. private _defineEquirectangularFixedName;
  129357. private _defineSkyboxName;
  129358. private _cubeSamplerName;
  129359. private _2DSamplerName;
  129360. private _positionUVWName;
  129361. private _directionWName;
  129362. private _reflectionCoordsName;
  129363. private _reflection2DCoordsName;
  129364. private _reflectionColorName;
  129365. private _reflectionMatrixName;
  129366. /**
  129367. * Gets or sets the texture associated with the node
  129368. */
  129369. texture: Nullable<BaseTexture>;
  129370. /**
  129371. * Create a new TextureBlock
  129372. * @param name defines the block name
  129373. */
  129374. constructor(name: string);
  129375. /**
  129376. * Gets the current class name
  129377. * @returns the class name
  129378. */
  129379. getClassName(): string;
  129380. /**
  129381. * Gets the world position input component
  129382. */
  129383. get position(): NodeMaterialConnectionPoint;
  129384. /**
  129385. * Gets the world position input component
  129386. */
  129387. get worldPosition(): NodeMaterialConnectionPoint;
  129388. /**
  129389. * Gets the world normal input component
  129390. */
  129391. get worldNormal(): NodeMaterialConnectionPoint;
  129392. /**
  129393. * Gets the world input component
  129394. */
  129395. get world(): NodeMaterialConnectionPoint;
  129396. /**
  129397. * Gets the camera (or eye) position component
  129398. */
  129399. get cameraPosition(): NodeMaterialConnectionPoint;
  129400. /**
  129401. * Gets the view input component
  129402. */
  129403. get view(): NodeMaterialConnectionPoint;
  129404. /**
  129405. * Gets the rgb output component
  129406. */
  129407. get rgb(): NodeMaterialConnectionPoint;
  129408. /**
  129409. * Gets the r output component
  129410. */
  129411. get r(): NodeMaterialConnectionPoint;
  129412. /**
  129413. * Gets the g output component
  129414. */
  129415. get g(): NodeMaterialConnectionPoint;
  129416. /**
  129417. * Gets the b output component
  129418. */
  129419. get b(): NodeMaterialConnectionPoint;
  129420. autoConfigure(material: NodeMaterial): void;
  129421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129422. isReady(): boolean;
  129423. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129424. private _injectVertexCode;
  129425. private _writeOutput;
  129426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129427. protected _dumpPropertiesCode(): string;
  129428. serialize(): any;
  129429. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129430. }
  129431. }
  129432. declare module BABYLON {
  129433. /**
  129434. * Interface used to configure the node material editor
  129435. */
  129436. export interface INodeMaterialEditorOptions {
  129437. /** Define the URl to load node editor script */
  129438. editorURL?: string;
  129439. }
  129440. /** @hidden */
  129441. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  129442. NORMAL: boolean;
  129443. TANGENT: boolean;
  129444. UV1: boolean;
  129445. /** BONES */
  129446. NUM_BONE_INFLUENCERS: number;
  129447. BonesPerMesh: number;
  129448. BONETEXTURE: boolean;
  129449. /** MORPH TARGETS */
  129450. MORPHTARGETS: boolean;
  129451. MORPHTARGETS_NORMAL: boolean;
  129452. MORPHTARGETS_TANGENT: boolean;
  129453. MORPHTARGETS_UV: boolean;
  129454. NUM_MORPH_INFLUENCERS: number;
  129455. /** IMAGE PROCESSING */
  129456. IMAGEPROCESSING: boolean;
  129457. VIGNETTE: boolean;
  129458. VIGNETTEBLENDMODEMULTIPLY: boolean;
  129459. VIGNETTEBLENDMODEOPAQUE: boolean;
  129460. TONEMAPPING: boolean;
  129461. TONEMAPPING_ACES: boolean;
  129462. CONTRAST: boolean;
  129463. EXPOSURE: boolean;
  129464. COLORCURVES: boolean;
  129465. COLORGRADING: boolean;
  129466. COLORGRADING3D: boolean;
  129467. SAMPLER3DGREENDEPTH: boolean;
  129468. SAMPLER3DBGRMAP: boolean;
  129469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  129470. /** MISC. */
  129471. BUMPDIRECTUV: number;
  129472. constructor();
  129473. setValue(name: string, value: boolean): void;
  129474. }
  129475. /**
  129476. * Class used to configure NodeMaterial
  129477. */
  129478. export interface INodeMaterialOptions {
  129479. /**
  129480. * Defines if blocks should emit comments
  129481. */
  129482. emitComments: boolean;
  129483. }
  129484. /**
  129485. * Class used to create a node based material built by assembling shader blocks
  129486. */
  129487. export class NodeMaterial extends PushMaterial {
  129488. private static _BuildIdGenerator;
  129489. private _options;
  129490. private _vertexCompilationState;
  129491. private _fragmentCompilationState;
  129492. private _sharedData;
  129493. private _buildId;
  129494. private _buildWasSuccessful;
  129495. private _cachedWorldViewMatrix;
  129496. private _cachedWorldViewProjectionMatrix;
  129497. private _optimizers;
  129498. private _animationFrame;
  129499. /** Define the Url to load node editor script */
  129500. static EditorURL: string;
  129501. /** Define the Url to load snippets */
  129502. static SnippetUrl: string;
  129503. private BJSNODEMATERIALEDITOR;
  129504. /** Get the inspector from bundle or global */
  129505. private _getGlobalNodeMaterialEditor;
  129506. /**
  129507. * Gets or sets data used by visual editor
  129508. * @see https://nme.babylonjs.com
  129509. */
  129510. editorData: any;
  129511. /**
  129512. * 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)
  129513. */
  129514. ignoreAlpha: boolean;
  129515. /**
  129516. * Defines the maximum number of lights that can be used in the material
  129517. */
  129518. maxSimultaneousLights: number;
  129519. /**
  129520. * Observable raised when the material is built
  129521. */
  129522. onBuildObservable: Observable<NodeMaterial>;
  129523. /**
  129524. * Gets or sets the root nodes of the material vertex shader
  129525. */
  129526. _vertexOutputNodes: NodeMaterialBlock[];
  129527. /**
  129528. * Gets or sets the root nodes of the material fragment (pixel) shader
  129529. */
  129530. _fragmentOutputNodes: NodeMaterialBlock[];
  129531. /** Gets or sets options to control the node material overall behavior */
  129532. get options(): INodeMaterialOptions;
  129533. set options(options: INodeMaterialOptions);
  129534. /**
  129535. * Default configuration related to image processing available in the standard Material.
  129536. */
  129537. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129538. /**
  129539. * Gets the image processing configuration used either in this material.
  129540. */
  129541. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  129542. /**
  129543. * Sets the Default image processing configuration used either in the this material.
  129544. *
  129545. * If sets to null, the scene one is in use.
  129546. */
  129547. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  129548. /**
  129549. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  129550. */
  129551. attachedBlocks: NodeMaterialBlock[];
  129552. /**
  129553. * Create a new node based material
  129554. * @param name defines the material name
  129555. * @param scene defines the hosting scene
  129556. * @param options defines creation option
  129557. */
  129558. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  129559. /**
  129560. * Gets the current class name of the material e.g. "NodeMaterial"
  129561. * @returns the class name
  129562. */
  129563. getClassName(): string;
  129564. /**
  129565. * Keep track of the image processing observer to allow dispose and replace.
  129566. */
  129567. private _imageProcessingObserver;
  129568. /**
  129569. * Attaches a new image processing configuration to the Standard Material.
  129570. * @param configuration
  129571. */
  129572. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129573. /**
  129574. * Get a block by its name
  129575. * @param name defines the name of the block to retrieve
  129576. * @returns the required block or null if not found
  129577. */
  129578. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  129579. /**
  129580. * Get a block by its name
  129581. * @param predicate defines the predicate used to find the good candidate
  129582. * @returns the required block or null if not found
  129583. */
  129584. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  129585. /**
  129586. * Get an input block by its name
  129587. * @param predicate defines the predicate used to find the good candidate
  129588. * @returns the required input block or null if not found
  129589. */
  129590. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  129591. /**
  129592. * Gets the list of input blocks attached to this material
  129593. * @returns an array of InputBlocks
  129594. */
  129595. getInputBlocks(): InputBlock[];
  129596. /**
  129597. * Adds a new optimizer to the list of optimizers
  129598. * @param optimizer defines the optimizers to add
  129599. * @returns the current material
  129600. */
  129601. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129602. /**
  129603. * Remove an optimizer from the list of optimizers
  129604. * @param optimizer defines the optimizers to remove
  129605. * @returns the current material
  129606. */
  129607. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129608. /**
  129609. * Add a new block to the list of output nodes
  129610. * @param node defines the node to add
  129611. * @returns the current material
  129612. */
  129613. addOutputNode(node: NodeMaterialBlock): this;
  129614. /**
  129615. * Remove a block from the list of root nodes
  129616. * @param node defines the node to remove
  129617. * @returns the current material
  129618. */
  129619. removeOutputNode(node: NodeMaterialBlock): this;
  129620. private _addVertexOutputNode;
  129621. private _removeVertexOutputNode;
  129622. private _addFragmentOutputNode;
  129623. private _removeFragmentOutputNode;
  129624. /**
  129625. * Specifies if the material will require alpha blending
  129626. * @returns a boolean specifying if alpha blending is needed
  129627. */
  129628. needAlphaBlending(): boolean;
  129629. /**
  129630. * Specifies if this material should be rendered in alpha test mode
  129631. * @returns a boolean specifying if an alpha test is needed.
  129632. */
  129633. needAlphaTesting(): boolean;
  129634. private _initializeBlock;
  129635. private _resetDualBlocks;
  129636. /**
  129637. * Remove a block from the current node material
  129638. * @param block defines the block to remove
  129639. */
  129640. removeBlock(block: NodeMaterialBlock): void;
  129641. /**
  129642. * Build the material and generates the inner effect
  129643. * @param verbose defines if the build should log activity
  129644. */
  129645. build(verbose?: boolean): void;
  129646. /**
  129647. * Runs an otpimization phase to try to improve the shader code
  129648. */
  129649. optimize(): void;
  129650. private _prepareDefinesForAttributes;
  129651. /**
  129652. * Get if the submesh is ready to be used and all its information available.
  129653. * Child classes can use it to update shaders
  129654. * @param mesh defines the mesh to check
  129655. * @param subMesh defines which submesh to check
  129656. * @param useInstances specifies that instances should be used
  129657. * @returns a boolean indicating that the submesh is ready or not
  129658. */
  129659. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129660. /**
  129661. * Get a string representing the shaders built by the current node graph
  129662. */
  129663. get compiledShaders(): string;
  129664. /**
  129665. * Binds the world matrix to the material
  129666. * @param world defines the world transformation matrix
  129667. */
  129668. bindOnlyWorldMatrix(world: Matrix): void;
  129669. /**
  129670. * Binds the submesh to this material by preparing the effect and shader to draw
  129671. * @param world defines the world transformation matrix
  129672. * @param mesh defines the mesh containing the submesh
  129673. * @param subMesh defines the submesh to bind the material to
  129674. */
  129675. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129676. /**
  129677. * Gets the active textures from the material
  129678. * @returns an array of textures
  129679. */
  129680. getActiveTextures(): BaseTexture[];
  129681. /**
  129682. * Gets the list of texture blocks
  129683. * @returns an array of texture blocks
  129684. */
  129685. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  129686. /**
  129687. * Specifies if the material uses a texture
  129688. * @param texture defines the texture to check against the material
  129689. * @returns a boolean specifying if the material uses the texture
  129690. */
  129691. hasTexture(texture: BaseTexture): boolean;
  129692. /**
  129693. * Disposes the material
  129694. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  129695. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  129696. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  129697. */
  129698. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  129699. /** Creates the node editor window. */
  129700. private _createNodeEditor;
  129701. /**
  129702. * Launch the node material editor
  129703. * @param config Define the configuration of the editor
  129704. * @return a promise fulfilled when the node editor is visible
  129705. */
  129706. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  129707. /**
  129708. * Clear the current material
  129709. */
  129710. clear(): void;
  129711. /**
  129712. * Clear the current material and set it to a default state
  129713. */
  129714. setToDefault(): void;
  129715. /**
  129716. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  129717. * @param url defines the url to load from
  129718. * @returns a promise that will fullfil when the material is fully loaded
  129719. */
  129720. loadAsync(url: string): Promise<void>;
  129721. private _gatherBlocks;
  129722. /**
  129723. * Generate a string containing the code declaration required to create an equivalent of this material
  129724. * @returns a string
  129725. */
  129726. generateCode(): string;
  129727. /**
  129728. * Serializes this material in a JSON representation
  129729. * @returns the serialized material object
  129730. */
  129731. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  129732. private _restoreConnections;
  129733. /**
  129734. * Clear the current graph and load a new one from a serialization object
  129735. * @param source defines the JSON representation of the material
  129736. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129737. */
  129738. loadFromSerialization(source: any, rootUrl?: string): void;
  129739. /**
  129740. * Creates a node material from parsed material data
  129741. * @param source defines the JSON representation of the material
  129742. * @param scene defines the hosting scene
  129743. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129744. * @returns a new node material
  129745. */
  129746. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  129747. /**
  129748. * Creates a node material from a snippet saved by the node material editor
  129749. * @param snippetId defines the snippet to load
  129750. * @param scene defines the hosting scene
  129751. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129752. * @returns a promise that will resolve to the new node material
  129753. */
  129754. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  129755. /**
  129756. * Creates a new node material set to default basic configuration
  129757. * @param name defines the name of the material
  129758. * @param scene defines the hosting scene
  129759. * @returns a new NodeMaterial
  129760. */
  129761. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  129762. }
  129763. }
  129764. declare module BABYLON {
  129765. /**
  129766. * Block used to read a texture from a sampler
  129767. */
  129768. export class TextureBlock extends NodeMaterialBlock {
  129769. private _defineName;
  129770. private _linearDefineName;
  129771. private _tempTextureRead;
  129772. private _samplerName;
  129773. private _transformedUVName;
  129774. private _textureTransformName;
  129775. private _textureInfoName;
  129776. private _mainUVName;
  129777. private _mainUVDefineName;
  129778. /**
  129779. * Gets or sets the texture associated with the node
  129780. */
  129781. texture: Nullable<Texture>;
  129782. /**
  129783. * Create a new TextureBlock
  129784. * @param name defines the block name
  129785. */
  129786. constructor(name: string);
  129787. /**
  129788. * Gets the current class name
  129789. * @returns the class name
  129790. */
  129791. getClassName(): string;
  129792. /**
  129793. * Gets the uv input component
  129794. */
  129795. get uv(): NodeMaterialConnectionPoint;
  129796. /**
  129797. * Gets the rgba output component
  129798. */
  129799. get rgba(): NodeMaterialConnectionPoint;
  129800. /**
  129801. * Gets the rgb output component
  129802. */
  129803. get rgb(): NodeMaterialConnectionPoint;
  129804. /**
  129805. * Gets the r output component
  129806. */
  129807. get r(): NodeMaterialConnectionPoint;
  129808. /**
  129809. * Gets the g output component
  129810. */
  129811. get g(): NodeMaterialConnectionPoint;
  129812. /**
  129813. * Gets the b output component
  129814. */
  129815. get b(): NodeMaterialConnectionPoint;
  129816. /**
  129817. * Gets the a output component
  129818. */
  129819. get a(): NodeMaterialConnectionPoint;
  129820. get target(): NodeMaterialBlockTargets;
  129821. autoConfigure(material: NodeMaterial): void;
  129822. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  129823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129824. isReady(): boolean;
  129825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129826. private get _isMixed();
  129827. private _injectVertexCode;
  129828. private _writeTextureRead;
  129829. private _writeOutput;
  129830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129831. protected _dumpPropertiesCode(): string;
  129832. serialize(): any;
  129833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129834. }
  129835. }
  129836. declare module BABYLON {
  129837. /**
  129838. * Class used to store shared data between 2 NodeMaterialBuildState
  129839. */
  129840. export class NodeMaterialBuildStateSharedData {
  129841. /**
  129842. * Gets the list of emitted varyings
  129843. */
  129844. temps: string[];
  129845. /**
  129846. * Gets the list of emitted varyings
  129847. */
  129848. varyings: string[];
  129849. /**
  129850. * Gets the varying declaration string
  129851. */
  129852. varyingDeclaration: string;
  129853. /**
  129854. * Input blocks
  129855. */
  129856. inputBlocks: InputBlock[];
  129857. /**
  129858. * Input blocks
  129859. */
  129860. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  129861. /**
  129862. * Bindable blocks (Blocks that need to set data to the effect)
  129863. */
  129864. bindableBlocks: NodeMaterialBlock[];
  129865. /**
  129866. * List of blocks that can provide a compilation fallback
  129867. */
  129868. blocksWithFallbacks: NodeMaterialBlock[];
  129869. /**
  129870. * List of blocks that can provide a define update
  129871. */
  129872. blocksWithDefines: NodeMaterialBlock[];
  129873. /**
  129874. * List of blocks that can provide a repeatable content
  129875. */
  129876. repeatableContentBlocks: NodeMaterialBlock[];
  129877. /**
  129878. * List of blocks that can provide a dynamic list of uniforms
  129879. */
  129880. dynamicUniformBlocks: NodeMaterialBlock[];
  129881. /**
  129882. * List of blocks that can block the isReady function for the material
  129883. */
  129884. blockingBlocks: NodeMaterialBlock[];
  129885. /**
  129886. * Gets the list of animated inputs
  129887. */
  129888. animatedInputs: InputBlock[];
  129889. /**
  129890. * Build Id used to avoid multiple recompilations
  129891. */
  129892. buildId: number;
  129893. /** List of emitted variables */
  129894. variableNames: {
  129895. [key: string]: number;
  129896. };
  129897. /** List of emitted defines */
  129898. defineNames: {
  129899. [key: string]: number;
  129900. };
  129901. /** Should emit comments? */
  129902. emitComments: boolean;
  129903. /** Emit build activity */
  129904. verbose: boolean;
  129905. /** Gets or sets the hosting scene */
  129906. scene: Scene;
  129907. /**
  129908. * Gets the compilation hints emitted at compilation time
  129909. */
  129910. hints: {
  129911. needWorldViewMatrix: boolean;
  129912. needWorldViewProjectionMatrix: boolean;
  129913. needAlphaBlending: boolean;
  129914. needAlphaTesting: boolean;
  129915. };
  129916. /**
  129917. * List of compilation checks
  129918. */
  129919. checks: {
  129920. emitVertex: boolean;
  129921. emitFragment: boolean;
  129922. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  129923. };
  129924. /** Creates a new shared data */
  129925. constructor();
  129926. /**
  129927. * Emits console errors and exceptions if there is a failing check
  129928. */
  129929. emitErrors(): void;
  129930. }
  129931. }
  129932. declare module BABYLON {
  129933. /**
  129934. * Class used to store node based material build state
  129935. */
  129936. export class NodeMaterialBuildState {
  129937. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  129938. supportUniformBuffers: boolean;
  129939. /**
  129940. * Gets the list of emitted attributes
  129941. */
  129942. attributes: string[];
  129943. /**
  129944. * Gets the list of emitted uniforms
  129945. */
  129946. uniforms: string[];
  129947. /**
  129948. * Gets the list of emitted constants
  129949. */
  129950. constants: string[];
  129951. /**
  129952. * Gets the list of emitted samplers
  129953. */
  129954. samplers: string[];
  129955. /**
  129956. * Gets the list of emitted functions
  129957. */
  129958. functions: {
  129959. [key: string]: string;
  129960. };
  129961. /**
  129962. * Gets the list of emitted extensions
  129963. */
  129964. extensions: {
  129965. [key: string]: string;
  129966. };
  129967. /**
  129968. * Gets the target of the compilation state
  129969. */
  129970. target: NodeMaterialBlockTargets;
  129971. /**
  129972. * Gets the list of emitted counters
  129973. */
  129974. counters: {
  129975. [key: string]: number;
  129976. };
  129977. /**
  129978. * Shared data between multiple NodeMaterialBuildState instances
  129979. */
  129980. sharedData: NodeMaterialBuildStateSharedData;
  129981. /** @hidden */
  129982. _vertexState: NodeMaterialBuildState;
  129983. /** @hidden */
  129984. _attributeDeclaration: string;
  129985. /** @hidden */
  129986. _uniformDeclaration: string;
  129987. /** @hidden */
  129988. _constantDeclaration: string;
  129989. /** @hidden */
  129990. _samplerDeclaration: string;
  129991. /** @hidden */
  129992. _varyingTransfer: string;
  129993. private _repeatableContentAnchorIndex;
  129994. /** @hidden */
  129995. _builtCompilationString: string;
  129996. /**
  129997. * Gets the emitted compilation strings
  129998. */
  129999. compilationString: string;
  130000. /**
  130001. * Finalize the compilation strings
  130002. * @param state defines the current compilation state
  130003. */
  130004. finalize(state: NodeMaterialBuildState): void;
  130005. /** @hidden */
  130006. get _repeatableContentAnchor(): string;
  130007. /** @hidden */
  130008. _getFreeVariableName(prefix: string): string;
  130009. /** @hidden */
  130010. _getFreeDefineName(prefix: string): string;
  130011. /** @hidden */
  130012. _excludeVariableName(name: string): void;
  130013. /** @hidden */
  130014. _emit2DSampler(name: string): void;
  130015. /** @hidden */
  130016. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130017. /** @hidden */
  130018. _emitExtension(name: string, extension: string): void;
  130019. /** @hidden */
  130020. _emitFunction(name: string, code: string, comments: string): void;
  130021. /** @hidden */
  130022. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130023. replaceStrings?: {
  130024. search: RegExp;
  130025. replace: string;
  130026. }[];
  130027. repeatKey?: string;
  130028. }): string;
  130029. /** @hidden */
  130030. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130031. repeatKey?: string;
  130032. removeAttributes?: boolean;
  130033. removeUniforms?: boolean;
  130034. removeVaryings?: boolean;
  130035. removeIfDef?: boolean;
  130036. replaceStrings?: {
  130037. search: RegExp;
  130038. replace: string;
  130039. }[];
  130040. }, storeKey?: string): void;
  130041. /** @hidden */
  130042. _registerTempVariable(name: string): boolean;
  130043. /** @hidden */
  130044. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130045. /** @hidden */
  130046. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130047. /** @hidden */
  130048. _emitFloat(value: number): string;
  130049. }
  130050. }
  130051. declare module BABYLON {
  130052. /**
  130053. * Defines a block that can be used inside a node based material
  130054. */
  130055. export class NodeMaterialBlock {
  130056. private _buildId;
  130057. private _buildTarget;
  130058. private _target;
  130059. private _isFinalMerger;
  130060. private _isInput;
  130061. protected _isUnique: boolean;
  130062. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130063. inputsAreExclusive: boolean;
  130064. /** @hidden */
  130065. _codeVariableName: string;
  130066. /** @hidden */
  130067. _inputs: NodeMaterialConnectionPoint[];
  130068. /** @hidden */
  130069. _outputs: NodeMaterialConnectionPoint[];
  130070. /** @hidden */
  130071. _preparationId: number;
  130072. /**
  130073. * Gets or sets the name of the block
  130074. */
  130075. name: string;
  130076. /**
  130077. * Gets or sets the unique id of the node
  130078. */
  130079. uniqueId: number;
  130080. /**
  130081. * Gets or sets the comments associated with this block
  130082. */
  130083. comments: string;
  130084. /**
  130085. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130086. */
  130087. get isUnique(): boolean;
  130088. /**
  130089. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130090. */
  130091. get isFinalMerger(): boolean;
  130092. /**
  130093. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130094. */
  130095. get isInput(): boolean;
  130096. /**
  130097. * Gets or sets the build Id
  130098. */
  130099. get buildId(): number;
  130100. set buildId(value: number);
  130101. /**
  130102. * Gets or sets the target of the block
  130103. */
  130104. get target(): NodeMaterialBlockTargets;
  130105. set target(value: NodeMaterialBlockTargets);
  130106. /**
  130107. * Gets the list of input points
  130108. */
  130109. get inputs(): NodeMaterialConnectionPoint[];
  130110. /** Gets the list of output points */
  130111. get outputs(): NodeMaterialConnectionPoint[];
  130112. /**
  130113. * Find an input by its name
  130114. * @param name defines the name of the input to look for
  130115. * @returns the input or null if not found
  130116. */
  130117. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130118. /**
  130119. * Find an output by its name
  130120. * @param name defines the name of the outputto look for
  130121. * @returns the output or null if not found
  130122. */
  130123. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130124. /**
  130125. * Creates a new NodeMaterialBlock
  130126. * @param name defines the block name
  130127. * @param target defines the target of that block (Vertex by default)
  130128. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130129. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130130. */
  130131. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130132. /**
  130133. * Initialize the block and prepare the context for build
  130134. * @param state defines the state that will be used for the build
  130135. */
  130136. initialize(state: NodeMaterialBuildState): void;
  130137. /**
  130138. * Bind data to effect. Will only be called for blocks with isBindable === true
  130139. * @param effect defines the effect to bind data to
  130140. * @param nodeMaterial defines the hosting NodeMaterial
  130141. * @param mesh defines the mesh that will be rendered
  130142. */
  130143. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130144. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130145. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130146. protected _writeFloat(value: number): string;
  130147. /**
  130148. * Gets the current class name e.g. "NodeMaterialBlock"
  130149. * @returns the class name
  130150. */
  130151. getClassName(): string;
  130152. /**
  130153. * Register a new input. Must be called inside a block constructor
  130154. * @param name defines the connection point name
  130155. * @param type defines the connection point type
  130156. * @param isOptional defines a boolean indicating that this input can be omitted
  130157. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130158. * @returns the current block
  130159. */
  130160. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130161. /**
  130162. * Register a new output. Must be called inside a block constructor
  130163. * @param name defines the connection point name
  130164. * @param type defines the connection point type
  130165. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130166. * @returns the current block
  130167. */
  130168. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130169. /**
  130170. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130171. * @param forOutput defines an optional connection point to check compatibility with
  130172. * @returns the first available input or null
  130173. */
  130174. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130175. /**
  130176. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130177. * @param forBlock defines an optional block to check compatibility with
  130178. * @returns the first available input or null
  130179. */
  130180. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130181. /**
  130182. * Gets the sibling of the given output
  130183. * @param current defines the current output
  130184. * @returns the next output in the list or null
  130185. */
  130186. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130187. /**
  130188. * Connect current block with another block
  130189. * @param other defines the block to connect with
  130190. * @param options define the various options to help pick the right connections
  130191. * @returns the current block
  130192. */
  130193. connectTo(other: NodeMaterialBlock, options?: {
  130194. input?: string;
  130195. output?: string;
  130196. outputSwizzle?: string;
  130197. }): this | undefined;
  130198. protected _buildBlock(state: NodeMaterialBuildState): void;
  130199. /**
  130200. * Add uniforms, samplers and uniform buffers at compilation time
  130201. * @param state defines the state to update
  130202. * @param nodeMaterial defines the node material requesting the update
  130203. * @param defines defines the material defines to update
  130204. * @param uniformBuffers defines the list of uniform buffer names
  130205. */
  130206. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130207. /**
  130208. * Add potential fallbacks if shader compilation fails
  130209. * @param mesh defines the mesh to be rendered
  130210. * @param fallbacks defines the current prioritized list of fallbacks
  130211. */
  130212. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130213. /**
  130214. * Initialize defines for shader compilation
  130215. * @param mesh defines the mesh to be rendered
  130216. * @param nodeMaterial defines the node material requesting the update
  130217. * @param defines defines the material defines to update
  130218. * @param useInstances specifies that instances should be used
  130219. */
  130220. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130221. /**
  130222. * Update defines for shader compilation
  130223. * @param mesh defines the mesh to be rendered
  130224. * @param nodeMaterial defines the node material requesting the update
  130225. * @param defines defines the material defines to update
  130226. * @param useInstances specifies that instances should be used
  130227. */
  130228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130229. /**
  130230. * Lets the block try to connect some inputs automatically
  130231. * @param material defines the hosting NodeMaterial
  130232. */
  130233. autoConfigure(material: NodeMaterial): void;
  130234. /**
  130235. * Function called when a block is declared as repeatable content generator
  130236. * @param vertexShaderState defines the current compilation state for the vertex shader
  130237. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130238. * @param mesh defines the mesh to be rendered
  130239. * @param defines defines the material defines to update
  130240. */
  130241. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130242. /**
  130243. * Checks if the block is ready
  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. * @returns true if the block is ready
  130249. */
  130250. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130251. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130252. private _processBuild;
  130253. /**
  130254. * Compile the current node and generate the shader code
  130255. * @param state defines the current compilation state (uniforms, samplers, current string)
  130256. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130257. * @returns true if already built
  130258. */
  130259. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130260. protected _inputRename(name: string): string;
  130261. protected _outputRename(name: string): string;
  130262. protected _dumpPropertiesCode(): string;
  130263. /** @hidden */
  130264. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130265. /** @hidden */
  130266. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130267. /**
  130268. * Clone the current block to a new identical block
  130269. * @param scene defines the hosting scene
  130270. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130271. * @returns a copy of the current block
  130272. */
  130273. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130274. /**
  130275. * Serializes this block in a JSON representation
  130276. * @returns the serialized block object
  130277. */
  130278. serialize(): any;
  130279. /** @hidden */
  130280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130281. /**
  130282. * Release resources
  130283. */
  130284. dispose(): void;
  130285. }
  130286. }
  130287. declare module BABYLON {
  130288. /**
  130289. * Enum defining the type of animations supported by InputBlock
  130290. */
  130291. export enum AnimatedInputBlockTypes {
  130292. /** No animation */
  130293. None = 0,
  130294. /** Time based animation. Will only work for floats */
  130295. Time = 1
  130296. }
  130297. }
  130298. declare module BABYLON {
  130299. /**
  130300. * Block used to expose an input value
  130301. */
  130302. export class InputBlock extends NodeMaterialBlock {
  130303. private _mode;
  130304. private _associatedVariableName;
  130305. private _storedValue;
  130306. private _valueCallback;
  130307. private _type;
  130308. private _animationType;
  130309. /** Gets or set a value used to limit the range of float values */
  130310. min: number;
  130311. /** Gets or set a value used to limit the range of float values */
  130312. max: number;
  130313. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  130314. isBoolean: boolean;
  130315. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  130316. matrixMode: number;
  130317. /** @hidden */
  130318. _systemValue: Nullable<NodeMaterialSystemValues>;
  130319. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  130320. visibleInInspector: boolean;
  130321. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  130322. isConstant: boolean;
  130323. /** Gets or sets the group to use to display this block in the Inspector */
  130324. groupInInspector: string;
  130325. /**
  130326. * Gets or sets the connection point type (default is float)
  130327. */
  130328. get type(): NodeMaterialBlockConnectionPointTypes;
  130329. /**
  130330. * Creates a new InputBlock
  130331. * @param name defines the block name
  130332. * @param target defines the target of that block (Vertex by default)
  130333. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  130334. */
  130335. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  130336. /**
  130337. * Gets the output component
  130338. */
  130339. get output(): NodeMaterialConnectionPoint;
  130340. /**
  130341. * Set the source of this connection point to a vertex attribute
  130342. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  130343. * @returns the current connection point
  130344. */
  130345. setAsAttribute(attributeName?: string): InputBlock;
  130346. /**
  130347. * Set the source of this connection point to a system value
  130348. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  130349. * @returns the current connection point
  130350. */
  130351. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  130352. /**
  130353. * Gets or sets the value of that point.
  130354. * Please note that this value will be ignored if valueCallback is defined
  130355. */
  130356. get value(): any;
  130357. set value(value: any);
  130358. /**
  130359. * Gets or sets a callback used to get the value of that point.
  130360. * Please note that setting this value will force the connection point to ignore the value property
  130361. */
  130362. get valueCallback(): () => any;
  130363. set valueCallback(value: () => any);
  130364. /**
  130365. * Gets or sets the associated variable name in the shader
  130366. */
  130367. get associatedVariableName(): string;
  130368. set associatedVariableName(value: string);
  130369. /** Gets or sets the type of animation applied to the input */
  130370. get animationType(): AnimatedInputBlockTypes;
  130371. set animationType(value: AnimatedInputBlockTypes);
  130372. /**
  130373. * Gets a boolean indicating that this connection point not defined yet
  130374. */
  130375. get isUndefined(): boolean;
  130376. /**
  130377. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  130378. * In this case the connection point name must be the name of the uniform to use.
  130379. * Can only be set on inputs
  130380. */
  130381. get isUniform(): boolean;
  130382. set isUniform(value: boolean);
  130383. /**
  130384. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  130385. * In this case the connection point name must be the name of the attribute to use
  130386. * Can only be set on inputs
  130387. */
  130388. get isAttribute(): boolean;
  130389. set isAttribute(value: boolean);
  130390. /**
  130391. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  130392. * Can only be set on exit points
  130393. */
  130394. get isVarying(): boolean;
  130395. set isVarying(value: boolean);
  130396. /**
  130397. * Gets a boolean indicating that the current connection point is a system value
  130398. */
  130399. get isSystemValue(): boolean;
  130400. /**
  130401. * Gets or sets the current well known value or null if not defined as a system value
  130402. */
  130403. get systemValue(): Nullable<NodeMaterialSystemValues>;
  130404. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  130405. /**
  130406. * Gets the current class name
  130407. * @returns the class name
  130408. */
  130409. getClassName(): string;
  130410. /**
  130411. * Animate the input if animationType !== None
  130412. * @param scene defines the rendering scene
  130413. */
  130414. animate(scene: Scene): void;
  130415. private _emitDefine;
  130416. initialize(state: NodeMaterialBuildState): void;
  130417. /**
  130418. * Set the input block to its default value (based on its type)
  130419. */
  130420. setDefaultValue(): void;
  130421. private _emitConstant;
  130422. private _emit;
  130423. /** @hidden */
  130424. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  130425. /** @hidden */
  130426. _transmit(effect: Effect, scene: Scene): void;
  130427. protected _buildBlock(state: NodeMaterialBuildState): void;
  130428. protected _dumpPropertiesCode(): string;
  130429. serialize(): any;
  130430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130431. }
  130432. }
  130433. declare module BABYLON {
  130434. /**
  130435. * Enum used to define the compatibility state between two connection points
  130436. */
  130437. export enum NodeMaterialConnectionPointCompatibilityStates {
  130438. /** Points are compatibles */
  130439. Compatible = 0,
  130440. /** Points are incompatible because of their types */
  130441. TypeIncompatible = 1,
  130442. /** Points are incompatible because of their targets (vertex vs fragment) */
  130443. TargetIncompatible = 2
  130444. }
  130445. /**
  130446. * Defines the direction of a connection point
  130447. */
  130448. export enum NodeMaterialConnectionPointDirection {
  130449. /** Input */
  130450. Input = 0,
  130451. /** Output */
  130452. Output = 1
  130453. }
  130454. /**
  130455. * Defines a connection point for a block
  130456. */
  130457. export class NodeMaterialConnectionPoint {
  130458. /** @hidden */
  130459. _ownerBlock: NodeMaterialBlock;
  130460. /** @hidden */
  130461. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  130462. private _endpoints;
  130463. private _associatedVariableName;
  130464. private _direction;
  130465. /** @hidden */
  130466. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130467. /** @hidden */
  130468. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130469. private _type;
  130470. /** @hidden */
  130471. _enforceAssociatedVariableName: boolean;
  130472. /** Gets the direction of the point */
  130473. get direction(): NodeMaterialConnectionPointDirection;
  130474. /**
  130475. * Gets or sets the additional types supported by this connection point
  130476. */
  130477. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130478. /**
  130479. * Gets or sets the additional types excluded by this connection point
  130480. */
  130481. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130482. /**
  130483. * Observable triggered when this point is connected
  130484. */
  130485. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  130486. /**
  130487. * Gets or sets the associated variable name in the shader
  130488. */
  130489. get associatedVariableName(): string;
  130490. set associatedVariableName(value: string);
  130491. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  130492. get innerType(): NodeMaterialBlockConnectionPointTypes;
  130493. /**
  130494. * Gets or sets the connection point type (default is float)
  130495. */
  130496. get type(): NodeMaterialBlockConnectionPointTypes;
  130497. set type(value: NodeMaterialBlockConnectionPointTypes);
  130498. /**
  130499. * Gets or sets the connection point name
  130500. */
  130501. name: string;
  130502. /**
  130503. * Gets or sets a boolean indicating that this connection point can be omitted
  130504. */
  130505. isOptional: boolean;
  130506. /**
  130507. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  130508. */
  130509. define: string;
  130510. /** @hidden */
  130511. _prioritizeVertex: boolean;
  130512. private _target;
  130513. /** Gets or sets the target of that connection point */
  130514. get target(): NodeMaterialBlockTargets;
  130515. set target(value: NodeMaterialBlockTargets);
  130516. /**
  130517. * Gets a boolean indicating that the current point is connected
  130518. */
  130519. get isConnected(): boolean;
  130520. /**
  130521. * Gets a boolean indicating that the current point is connected to an input block
  130522. */
  130523. get isConnectedToInputBlock(): boolean;
  130524. /**
  130525. * Gets a the connected input block (if any)
  130526. */
  130527. get connectInputBlock(): Nullable<InputBlock>;
  130528. /** Get the other side of the connection (if any) */
  130529. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  130530. /** Get the block that owns this connection point */
  130531. get ownerBlock(): NodeMaterialBlock;
  130532. /** Get the block connected on the other side of this connection (if any) */
  130533. get sourceBlock(): Nullable<NodeMaterialBlock>;
  130534. /** Get the block connected on the endpoints of this connection (if any) */
  130535. get connectedBlocks(): Array<NodeMaterialBlock>;
  130536. /** Gets the list of connected endpoints */
  130537. get endpoints(): NodeMaterialConnectionPoint[];
  130538. /** Gets a boolean indicating if that output point is connected to at least one input */
  130539. get hasEndpoints(): boolean;
  130540. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  130541. get isConnectedInVertexShader(): boolean;
  130542. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  130543. get isConnectedInFragmentShader(): boolean;
  130544. /**
  130545. * Creates a new connection point
  130546. * @param name defines the connection point name
  130547. * @param ownerBlock defines the block hosting this connection point
  130548. * @param direction defines the direction of the connection point
  130549. */
  130550. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  130551. /**
  130552. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  130553. * @returns the class name
  130554. */
  130555. getClassName(): string;
  130556. /**
  130557. * Gets a boolean indicating if the current point can be connected to another point
  130558. * @param connectionPoint defines the other connection point
  130559. * @returns a boolean
  130560. */
  130561. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  130562. /**
  130563. * Gets a number indicating if the current point can be connected to another point
  130564. * @param connectionPoint defines the other connection point
  130565. * @returns a number defining the compatibility state
  130566. */
  130567. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  130568. /**
  130569. * Connect this point to another connection point
  130570. * @param connectionPoint defines the other connection point
  130571. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  130572. * @returns the current connection point
  130573. */
  130574. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  130575. /**
  130576. * Disconnect this point from one of his endpoint
  130577. * @param endpoint defines the other connection point
  130578. * @returns the current connection point
  130579. */
  130580. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  130581. /**
  130582. * Serializes this point in a JSON representation
  130583. * @returns the serialized point object
  130584. */
  130585. serialize(): any;
  130586. /**
  130587. * Release resources
  130588. */
  130589. dispose(): void;
  130590. }
  130591. }
  130592. declare module BABYLON {
  130593. /**
  130594. * Block used to add support for vertex skinning (bones)
  130595. */
  130596. export class BonesBlock extends NodeMaterialBlock {
  130597. /**
  130598. * Creates a new BonesBlock
  130599. * @param name defines the block name
  130600. */
  130601. constructor(name: string);
  130602. /**
  130603. * Initialize the block and prepare the context for build
  130604. * @param state defines the state that will be used for the build
  130605. */
  130606. initialize(state: NodeMaterialBuildState): void;
  130607. /**
  130608. * Gets the current class name
  130609. * @returns the class name
  130610. */
  130611. getClassName(): string;
  130612. /**
  130613. * Gets the matrix indices input component
  130614. */
  130615. get matricesIndices(): NodeMaterialConnectionPoint;
  130616. /**
  130617. * Gets the matrix weights input component
  130618. */
  130619. get matricesWeights(): NodeMaterialConnectionPoint;
  130620. /**
  130621. * Gets the extra matrix indices input component
  130622. */
  130623. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  130624. /**
  130625. * Gets the extra matrix weights input component
  130626. */
  130627. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  130628. /**
  130629. * Gets the world input component
  130630. */
  130631. get world(): NodeMaterialConnectionPoint;
  130632. /**
  130633. * Gets the output component
  130634. */
  130635. get output(): NodeMaterialConnectionPoint;
  130636. autoConfigure(material: NodeMaterial): void;
  130637. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130638. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130640. protected _buildBlock(state: NodeMaterialBuildState): this;
  130641. }
  130642. }
  130643. declare module BABYLON {
  130644. /**
  130645. * Block used to add support for instances
  130646. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  130647. */
  130648. export class InstancesBlock extends NodeMaterialBlock {
  130649. /**
  130650. * Creates a new InstancesBlock
  130651. * @param name defines the block name
  130652. */
  130653. constructor(name: string);
  130654. /**
  130655. * Gets the current class name
  130656. * @returns the class name
  130657. */
  130658. getClassName(): string;
  130659. /**
  130660. * Gets the first world row input component
  130661. */
  130662. get world0(): NodeMaterialConnectionPoint;
  130663. /**
  130664. * Gets the second world row input component
  130665. */
  130666. get world1(): NodeMaterialConnectionPoint;
  130667. /**
  130668. * Gets the third world row input component
  130669. */
  130670. get world2(): NodeMaterialConnectionPoint;
  130671. /**
  130672. * Gets the forth world row input component
  130673. */
  130674. get world3(): NodeMaterialConnectionPoint;
  130675. /**
  130676. * Gets the world input component
  130677. */
  130678. get world(): NodeMaterialConnectionPoint;
  130679. /**
  130680. * Gets the output component
  130681. */
  130682. get output(): NodeMaterialConnectionPoint;
  130683. autoConfigure(material: NodeMaterial): void;
  130684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130685. protected _buildBlock(state: NodeMaterialBuildState): this;
  130686. }
  130687. }
  130688. declare module BABYLON {
  130689. /**
  130690. * Block used to add morph targets support to vertex shader
  130691. */
  130692. export class MorphTargetsBlock extends NodeMaterialBlock {
  130693. private _repeatableContentAnchor;
  130694. /**
  130695. * Create a new MorphTargetsBlock
  130696. * @param name defines the block name
  130697. */
  130698. constructor(name: string);
  130699. /**
  130700. * Gets the current class name
  130701. * @returns the class name
  130702. */
  130703. getClassName(): string;
  130704. /**
  130705. * Gets the position input component
  130706. */
  130707. get position(): NodeMaterialConnectionPoint;
  130708. /**
  130709. * Gets the normal input component
  130710. */
  130711. get normal(): NodeMaterialConnectionPoint;
  130712. /**
  130713. * Gets the tangent input component
  130714. */
  130715. get tangent(): NodeMaterialConnectionPoint;
  130716. /**
  130717. * Gets the tangent input component
  130718. */
  130719. get uv(): NodeMaterialConnectionPoint;
  130720. /**
  130721. * Gets the position output component
  130722. */
  130723. get positionOutput(): NodeMaterialConnectionPoint;
  130724. /**
  130725. * Gets the normal output component
  130726. */
  130727. get normalOutput(): NodeMaterialConnectionPoint;
  130728. /**
  130729. * Gets the tangent output component
  130730. */
  130731. get tangentOutput(): NodeMaterialConnectionPoint;
  130732. /**
  130733. * Gets the tangent output component
  130734. */
  130735. get uvOutput(): NodeMaterialConnectionPoint;
  130736. initialize(state: NodeMaterialBuildState): void;
  130737. autoConfigure(material: NodeMaterial): void;
  130738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130740. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130741. protected _buildBlock(state: NodeMaterialBuildState): this;
  130742. }
  130743. }
  130744. declare module BABYLON {
  130745. /**
  130746. * Block used to get data information from a light
  130747. */
  130748. export class LightInformationBlock extends NodeMaterialBlock {
  130749. private _lightDataUniformName;
  130750. private _lightColorUniformName;
  130751. private _lightTypeDefineName;
  130752. /**
  130753. * Gets or sets the light associated with this block
  130754. */
  130755. light: Nullable<Light>;
  130756. /**
  130757. * Creates a new LightInformationBlock
  130758. * @param name defines the block name
  130759. */
  130760. constructor(name: string);
  130761. /**
  130762. * Gets the current class name
  130763. * @returns the class name
  130764. */
  130765. getClassName(): string;
  130766. /**
  130767. * Gets the world position input component
  130768. */
  130769. get worldPosition(): NodeMaterialConnectionPoint;
  130770. /**
  130771. * Gets the direction output component
  130772. */
  130773. get direction(): NodeMaterialConnectionPoint;
  130774. /**
  130775. * Gets the direction output component
  130776. */
  130777. get color(): NodeMaterialConnectionPoint;
  130778. /**
  130779. * Gets the direction output component
  130780. */
  130781. get intensity(): NodeMaterialConnectionPoint;
  130782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130784. protected _buildBlock(state: NodeMaterialBuildState): this;
  130785. serialize(): any;
  130786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130787. }
  130788. }
  130789. declare module BABYLON {
  130790. /**
  130791. * Block used to add image processing support to fragment shader
  130792. */
  130793. export class ImageProcessingBlock extends NodeMaterialBlock {
  130794. /**
  130795. * Create a new ImageProcessingBlock
  130796. * @param name defines the block name
  130797. */
  130798. constructor(name: string);
  130799. /**
  130800. * Gets the current class name
  130801. * @returns the class name
  130802. */
  130803. getClassName(): string;
  130804. /**
  130805. * Gets the color input component
  130806. */
  130807. get color(): NodeMaterialConnectionPoint;
  130808. /**
  130809. * Gets the output component
  130810. */
  130811. get output(): NodeMaterialConnectionPoint;
  130812. /**
  130813. * Initialize the block and prepare the context for build
  130814. * @param state defines the state that will be used for the build
  130815. */
  130816. initialize(state: NodeMaterialBuildState): void;
  130817. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  130818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130820. protected _buildBlock(state: NodeMaterialBuildState): this;
  130821. }
  130822. }
  130823. declare module BABYLON {
  130824. /**
  130825. * Block used to pertub normals based on a normal map
  130826. */
  130827. export class PerturbNormalBlock extends NodeMaterialBlock {
  130828. private _tangentSpaceParameterName;
  130829. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130830. invertX: boolean;
  130831. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  130832. invertY: boolean;
  130833. /**
  130834. * Create a new PerturbNormalBlock
  130835. * @param name defines the block name
  130836. */
  130837. constructor(name: string);
  130838. /**
  130839. * Gets the current class name
  130840. * @returns the class name
  130841. */
  130842. getClassName(): string;
  130843. /**
  130844. * Gets the world position input component
  130845. */
  130846. get worldPosition(): NodeMaterialConnectionPoint;
  130847. /**
  130848. * Gets the world normal input component
  130849. */
  130850. get worldNormal(): NodeMaterialConnectionPoint;
  130851. /**
  130852. * Gets the uv input component
  130853. */
  130854. get uv(): NodeMaterialConnectionPoint;
  130855. /**
  130856. * Gets the normal map color input component
  130857. */
  130858. get normalMapColor(): NodeMaterialConnectionPoint;
  130859. /**
  130860. * Gets the strength input component
  130861. */
  130862. get strength(): NodeMaterialConnectionPoint;
  130863. /**
  130864. * Gets the output component
  130865. */
  130866. get output(): NodeMaterialConnectionPoint;
  130867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130868. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130869. autoConfigure(material: NodeMaterial): void;
  130870. protected _buildBlock(state: NodeMaterialBuildState): this;
  130871. protected _dumpPropertiesCode(): string;
  130872. serialize(): any;
  130873. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130874. }
  130875. }
  130876. declare module BABYLON {
  130877. /**
  130878. * Block used to discard a pixel if a value is smaller than a cutoff
  130879. */
  130880. export class DiscardBlock extends NodeMaterialBlock {
  130881. /**
  130882. * Create a new DiscardBlock
  130883. * @param name defines the block name
  130884. */
  130885. constructor(name: string);
  130886. /**
  130887. * Gets the current class name
  130888. * @returns the class name
  130889. */
  130890. getClassName(): string;
  130891. /**
  130892. * Gets the color input component
  130893. */
  130894. get value(): NodeMaterialConnectionPoint;
  130895. /**
  130896. * Gets the cutoff input component
  130897. */
  130898. get cutoff(): NodeMaterialConnectionPoint;
  130899. protected _buildBlock(state: NodeMaterialBuildState): this;
  130900. }
  130901. }
  130902. declare module BABYLON {
  130903. /**
  130904. * Block used to test if the fragment shader is front facing
  130905. */
  130906. export class FrontFacingBlock extends NodeMaterialBlock {
  130907. /**
  130908. * Creates a new FrontFacingBlock
  130909. * @param name defines the block name
  130910. */
  130911. constructor(name: string);
  130912. /**
  130913. * Gets the current class name
  130914. * @returns the class name
  130915. */
  130916. getClassName(): string;
  130917. /**
  130918. * Gets the output component
  130919. */
  130920. get output(): NodeMaterialConnectionPoint;
  130921. protected _buildBlock(state: NodeMaterialBuildState): this;
  130922. }
  130923. }
  130924. declare module BABYLON {
  130925. /**
  130926. * Block used to get the derivative value on x and y of a given input
  130927. */
  130928. export class DerivativeBlock extends NodeMaterialBlock {
  130929. /**
  130930. * Create a new DerivativeBlock
  130931. * @param name defines the block name
  130932. */
  130933. constructor(name: string);
  130934. /**
  130935. * Gets the current class name
  130936. * @returns the class name
  130937. */
  130938. getClassName(): string;
  130939. /**
  130940. * Gets the input component
  130941. */
  130942. get input(): NodeMaterialConnectionPoint;
  130943. /**
  130944. * Gets the derivative output on x
  130945. */
  130946. get dx(): NodeMaterialConnectionPoint;
  130947. /**
  130948. * Gets the derivative output on y
  130949. */
  130950. get dy(): NodeMaterialConnectionPoint;
  130951. protected _buildBlock(state: NodeMaterialBuildState): this;
  130952. }
  130953. }
  130954. declare module BABYLON {
  130955. /**
  130956. * Block used to add support for scene fog
  130957. */
  130958. export class FogBlock extends NodeMaterialBlock {
  130959. private _fogDistanceName;
  130960. private _fogParameters;
  130961. /**
  130962. * Create a new FogBlock
  130963. * @param name defines the block name
  130964. */
  130965. constructor(name: string);
  130966. /**
  130967. * Gets the current class name
  130968. * @returns the class name
  130969. */
  130970. getClassName(): string;
  130971. /**
  130972. * Gets the world position input component
  130973. */
  130974. get worldPosition(): NodeMaterialConnectionPoint;
  130975. /**
  130976. * Gets the view input component
  130977. */
  130978. get view(): NodeMaterialConnectionPoint;
  130979. /**
  130980. * Gets the color input component
  130981. */
  130982. get input(): NodeMaterialConnectionPoint;
  130983. /**
  130984. * Gets the fog color input component
  130985. */
  130986. get fogColor(): NodeMaterialConnectionPoint;
  130987. /**
  130988. * Gets the output component
  130989. */
  130990. get output(): NodeMaterialConnectionPoint;
  130991. autoConfigure(material: NodeMaterial): void;
  130992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130994. protected _buildBlock(state: NodeMaterialBuildState): this;
  130995. }
  130996. }
  130997. declare module BABYLON {
  130998. /**
  130999. * Block used to add light in the fragment shader
  131000. */
  131001. export class LightBlock extends NodeMaterialBlock {
  131002. private _lightId;
  131003. /**
  131004. * Gets or sets the light associated with this block
  131005. */
  131006. light: Nullable<Light>;
  131007. /**
  131008. * Create a new LightBlock
  131009. * @param name defines the block name
  131010. */
  131011. constructor(name: string);
  131012. /**
  131013. * Gets the current class name
  131014. * @returns the class name
  131015. */
  131016. getClassName(): string;
  131017. /**
  131018. * Gets the world position input component
  131019. */
  131020. get worldPosition(): NodeMaterialConnectionPoint;
  131021. /**
  131022. * Gets the world normal input component
  131023. */
  131024. get worldNormal(): NodeMaterialConnectionPoint;
  131025. /**
  131026. * Gets the camera (or eye) position component
  131027. */
  131028. get cameraPosition(): NodeMaterialConnectionPoint;
  131029. /**
  131030. * Gets the glossiness component
  131031. */
  131032. get glossiness(): NodeMaterialConnectionPoint;
  131033. /**
  131034. * Gets the glossinness power component
  131035. */
  131036. get glossPower(): NodeMaterialConnectionPoint;
  131037. /**
  131038. * Gets the diffuse color component
  131039. */
  131040. get diffuseColor(): NodeMaterialConnectionPoint;
  131041. /**
  131042. * Gets the specular color component
  131043. */
  131044. get specularColor(): NodeMaterialConnectionPoint;
  131045. /**
  131046. * Gets the diffuse output component
  131047. */
  131048. get diffuseOutput(): NodeMaterialConnectionPoint;
  131049. /**
  131050. * Gets the specular output component
  131051. */
  131052. get specularOutput(): NodeMaterialConnectionPoint;
  131053. /**
  131054. * Gets the shadow output component
  131055. */
  131056. get shadow(): NodeMaterialConnectionPoint;
  131057. autoConfigure(material: NodeMaterial): void;
  131058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131059. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131061. private _injectVertexCode;
  131062. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131063. serialize(): any;
  131064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131065. }
  131066. }
  131067. declare module BABYLON {
  131068. /**
  131069. * Block used to multiply 2 values
  131070. */
  131071. export class MultiplyBlock extends NodeMaterialBlock {
  131072. /**
  131073. * Creates a new MultiplyBlock
  131074. * @param name defines the block name
  131075. */
  131076. constructor(name: string);
  131077. /**
  131078. * Gets the current class name
  131079. * @returns the class name
  131080. */
  131081. getClassName(): string;
  131082. /**
  131083. * Gets the left operand input component
  131084. */
  131085. get left(): NodeMaterialConnectionPoint;
  131086. /**
  131087. * Gets the right operand input component
  131088. */
  131089. get right(): NodeMaterialConnectionPoint;
  131090. /**
  131091. * Gets the output component
  131092. */
  131093. get output(): NodeMaterialConnectionPoint;
  131094. protected _buildBlock(state: NodeMaterialBuildState): this;
  131095. }
  131096. }
  131097. declare module BABYLON {
  131098. /**
  131099. * Block used to add 2 vectors
  131100. */
  131101. export class AddBlock extends NodeMaterialBlock {
  131102. /**
  131103. * Creates a new AddBlock
  131104. * @param name defines the block name
  131105. */
  131106. constructor(name: string);
  131107. /**
  131108. * Gets the current class name
  131109. * @returns the class name
  131110. */
  131111. getClassName(): string;
  131112. /**
  131113. * Gets the left operand input component
  131114. */
  131115. get left(): NodeMaterialConnectionPoint;
  131116. /**
  131117. * Gets the right operand input component
  131118. */
  131119. get right(): NodeMaterialConnectionPoint;
  131120. /**
  131121. * Gets the output component
  131122. */
  131123. get output(): NodeMaterialConnectionPoint;
  131124. protected _buildBlock(state: NodeMaterialBuildState): this;
  131125. }
  131126. }
  131127. declare module BABYLON {
  131128. /**
  131129. * Block used to scale a vector by a float
  131130. */
  131131. export class ScaleBlock extends NodeMaterialBlock {
  131132. /**
  131133. * Creates a new ScaleBlock
  131134. * @param name defines the block name
  131135. */
  131136. constructor(name: string);
  131137. /**
  131138. * Gets the current class name
  131139. * @returns the class name
  131140. */
  131141. getClassName(): string;
  131142. /**
  131143. * Gets the input component
  131144. */
  131145. get input(): NodeMaterialConnectionPoint;
  131146. /**
  131147. * Gets the factor input component
  131148. */
  131149. get factor(): NodeMaterialConnectionPoint;
  131150. /**
  131151. * Gets the output component
  131152. */
  131153. get output(): NodeMaterialConnectionPoint;
  131154. protected _buildBlock(state: NodeMaterialBuildState): this;
  131155. }
  131156. }
  131157. declare module BABYLON {
  131158. /**
  131159. * Block used to clamp a float
  131160. */
  131161. export class ClampBlock extends NodeMaterialBlock {
  131162. /** Gets or sets the minimum range */
  131163. minimum: number;
  131164. /** Gets or sets the maximum range */
  131165. maximum: number;
  131166. /**
  131167. * Creates a new ClampBlock
  131168. * @param name defines the block name
  131169. */
  131170. constructor(name: string);
  131171. /**
  131172. * Gets the current class name
  131173. * @returns the class name
  131174. */
  131175. getClassName(): string;
  131176. /**
  131177. * Gets the value input component
  131178. */
  131179. get value(): NodeMaterialConnectionPoint;
  131180. /**
  131181. * Gets the output component
  131182. */
  131183. get output(): NodeMaterialConnectionPoint;
  131184. protected _buildBlock(state: NodeMaterialBuildState): this;
  131185. protected _dumpPropertiesCode(): string;
  131186. serialize(): any;
  131187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131188. }
  131189. }
  131190. declare module BABYLON {
  131191. /**
  131192. * Block used to apply a cross product between 2 vectors
  131193. */
  131194. export class CrossBlock extends NodeMaterialBlock {
  131195. /**
  131196. * Creates a new CrossBlock
  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 left operand input component
  131207. */
  131208. get left(): NodeMaterialConnectionPoint;
  131209. /**
  131210. * Gets the right operand input component
  131211. */
  131212. get right(): NodeMaterialConnectionPoint;
  131213. /**
  131214. * Gets the output component
  131215. */
  131216. get output(): NodeMaterialConnectionPoint;
  131217. protected _buildBlock(state: NodeMaterialBuildState): this;
  131218. }
  131219. }
  131220. declare module BABYLON {
  131221. /**
  131222. * Block used to apply a dot product between 2 vectors
  131223. */
  131224. export class DotBlock extends NodeMaterialBlock {
  131225. /**
  131226. * Creates a new DotBlock
  131227. * @param name defines the block name
  131228. */
  131229. constructor(name: string);
  131230. /**
  131231. * Gets the current class name
  131232. * @returns the class name
  131233. */
  131234. getClassName(): string;
  131235. /**
  131236. * Gets the left operand input component
  131237. */
  131238. get left(): NodeMaterialConnectionPoint;
  131239. /**
  131240. * Gets the right operand input component
  131241. */
  131242. get right(): NodeMaterialConnectionPoint;
  131243. /**
  131244. * Gets the output component
  131245. */
  131246. get output(): NodeMaterialConnectionPoint;
  131247. protected _buildBlock(state: NodeMaterialBuildState): this;
  131248. }
  131249. }
  131250. declare module BABYLON {
  131251. /**
  131252. * Block used to remap a float from a range to a new one
  131253. */
  131254. export class RemapBlock extends NodeMaterialBlock {
  131255. /**
  131256. * Gets or sets the source range
  131257. */
  131258. sourceRange: Vector2;
  131259. /**
  131260. * Gets or sets the target range
  131261. */
  131262. targetRange: Vector2;
  131263. /**
  131264. * Creates a new RemapBlock
  131265. * @param name defines the block name
  131266. */
  131267. constructor(name: string);
  131268. /**
  131269. * Gets the current class name
  131270. * @returns the class name
  131271. */
  131272. getClassName(): string;
  131273. /**
  131274. * Gets the input component
  131275. */
  131276. get input(): NodeMaterialConnectionPoint;
  131277. /**
  131278. * Gets the source min input component
  131279. */
  131280. get sourceMin(): NodeMaterialConnectionPoint;
  131281. /**
  131282. * Gets the source max input component
  131283. */
  131284. get sourceMax(): NodeMaterialConnectionPoint;
  131285. /**
  131286. * Gets the target min input component
  131287. */
  131288. get targetMin(): NodeMaterialConnectionPoint;
  131289. /**
  131290. * Gets the target max input component
  131291. */
  131292. get targetMax(): NodeMaterialConnectionPoint;
  131293. /**
  131294. * Gets the output component
  131295. */
  131296. get output(): NodeMaterialConnectionPoint;
  131297. protected _buildBlock(state: NodeMaterialBuildState): this;
  131298. protected _dumpPropertiesCode(): string;
  131299. serialize(): any;
  131300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131301. }
  131302. }
  131303. declare module BABYLON {
  131304. /**
  131305. * Block used to normalize a vector
  131306. */
  131307. export class NormalizeBlock extends NodeMaterialBlock {
  131308. /**
  131309. * Creates a new NormalizeBlock
  131310. * @param name defines the block name
  131311. */
  131312. constructor(name: string);
  131313. /**
  131314. * Gets the current class name
  131315. * @returns the class name
  131316. */
  131317. getClassName(): string;
  131318. /**
  131319. * Gets the input component
  131320. */
  131321. get input(): NodeMaterialConnectionPoint;
  131322. /**
  131323. * Gets the output component
  131324. */
  131325. get output(): NodeMaterialConnectionPoint;
  131326. protected _buildBlock(state: NodeMaterialBuildState): this;
  131327. }
  131328. }
  131329. declare module BABYLON {
  131330. /**
  131331. * Operations supported by the Trigonometry block
  131332. */
  131333. export enum TrigonometryBlockOperations {
  131334. /** Cos */
  131335. Cos = 0,
  131336. /** Sin */
  131337. Sin = 1,
  131338. /** Abs */
  131339. Abs = 2,
  131340. /** Exp */
  131341. Exp = 3,
  131342. /** Exp2 */
  131343. Exp2 = 4,
  131344. /** Round */
  131345. Round = 5,
  131346. /** Floor */
  131347. Floor = 6,
  131348. /** Ceiling */
  131349. Ceiling = 7,
  131350. /** Square root */
  131351. Sqrt = 8,
  131352. /** Log */
  131353. Log = 9,
  131354. /** Tangent */
  131355. Tan = 10,
  131356. /** Arc tangent */
  131357. ArcTan = 11,
  131358. /** Arc cosinus */
  131359. ArcCos = 12,
  131360. /** Arc sinus */
  131361. ArcSin = 13,
  131362. /** Fraction */
  131363. Fract = 14,
  131364. /** Sign */
  131365. Sign = 15,
  131366. /** To radians (from degrees) */
  131367. Radians = 16,
  131368. /** To degrees (from radians) */
  131369. Degrees = 17
  131370. }
  131371. /**
  131372. * Block used to apply trigonometry operation to floats
  131373. */
  131374. export class TrigonometryBlock extends NodeMaterialBlock {
  131375. /**
  131376. * Gets or sets the operation applied by the block
  131377. */
  131378. operation: TrigonometryBlockOperations;
  131379. /**
  131380. * Creates a new TrigonometryBlock
  131381. * @param name defines the block name
  131382. */
  131383. constructor(name: string);
  131384. /**
  131385. * Gets the current class name
  131386. * @returns the class name
  131387. */
  131388. getClassName(): string;
  131389. /**
  131390. * Gets the input component
  131391. */
  131392. get input(): NodeMaterialConnectionPoint;
  131393. /**
  131394. * Gets the output component
  131395. */
  131396. get output(): NodeMaterialConnectionPoint;
  131397. protected _buildBlock(state: NodeMaterialBuildState): this;
  131398. serialize(): any;
  131399. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131400. protected _dumpPropertiesCode(): string;
  131401. }
  131402. }
  131403. declare module BABYLON {
  131404. /**
  131405. * Block used to create a Color3/4 out of individual inputs (one for each component)
  131406. */
  131407. export class ColorMergerBlock extends NodeMaterialBlock {
  131408. /**
  131409. * Create a new ColorMergerBlock
  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 rgb component (input)
  131420. */
  131421. get rgbIn(): NodeMaterialConnectionPoint;
  131422. /**
  131423. * Gets the r component (input)
  131424. */
  131425. get r(): NodeMaterialConnectionPoint;
  131426. /**
  131427. * Gets the g component (input)
  131428. */
  131429. get g(): NodeMaterialConnectionPoint;
  131430. /**
  131431. * Gets the b component (input)
  131432. */
  131433. get b(): NodeMaterialConnectionPoint;
  131434. /**
  131435. * Gets the a component (input)
  131436. */
  131437. get a(): NodeMaterialConnectionPoint;
  131438. /**
  131439. * Gets the rgba component (output)
  131440. */
  131441. get rgba(): NodeMaterialConnectionPoint;
  131442. /**
  131443. * Gets the rgb component (output)
  131444. */
  131445. get rgbOut(): NodeMaterialConnectionPoint;
  131446. /**
  131447. * Gets the rgb component (output)
  131448. * @deprecated Please use rgbOut instead.
  131449. */
  131450. get rgb(): NodeMaterialConnectionPoint;
  131451. protected _buildBlock(state: NodeMaterialBuildState): this;
  131452. }
  131453. }
  131454. declare module BABYLON {
  131455. /**
  131456. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  131457. */
  131458. export class VectorMergerBlock extends NodeMaterialBlock {
  131459. /**
  131460. * Create a new VectorMergerBlock
  131461. * @param name defines the block name
  131462. */
  131463. constructor(name: string);
  131464. /**
  131465. * Gets the current class name
  131466. * @returns the class name
  131467. */
  131468. getClassName(): string;
  131469. /**
  131470. * Gets the xyz component (input)
  131471. */
  131472. get xyzIn(): NodeMaterialConnectionPoint;
  131473. /**
  131474. * Gets the xy component (input)
  131475. */
  131476. get xyIn(): NodeMaterialConnectionPoint;
  131477. /**
  131478. * Gets the x component (input)
  131479. */
  131480. get x(): NodeMaterialConnectionPoint;
  131481. /**
  131482. * Gets the y component (input)
  131483. */
  131484. get y(): NodeMaterialConnectionPoint;
  131485. /**
  131486. * Gets the z component (input)
  131487. */
  131488. get z(): NodeMaterialConnectionPoint;
  131489. /**
  131490. * Gets the w component (input)
  131491. */
  131492. get w(): NodeMaterialConnectionPoint;
  131493. /**
  131494. * Gets the xyzw component (output)
  131495. */
  131496. get xyzw(): NodeMaterialConnectionPoint;
  131497. /**
  131498. * Gets the xyz component (output)
  131499. */
  131500. get xyzOut(): NodeMaterialConnectionPoint;
  131501. /**
  131502. * Gets the xy component (output)
  131503. */
  131504. get xyOut(): NodeMaterialConnectionPoint;
  131505. /**
  131506. * Gets the xy component (output)
  131507. * @deprecated Please use xyOut instead.
  131508. */
  131509. get xy(): NodeMaterialConnectionPoint;
  131510. /**
  131511. * Gets the xyz component (output)
  131512. * @deprecated Please use xyzOut instead.
  131513. */
  131514. get xyz(): NodeMaterialConnectionPoint;
  131515. protected _buildBlock(state: NodeMaterialBuildState): this;
  131516. }
  131517. }
  131518. declare module BABYLON {
  131519. /**
  131520. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  131521. */
  131522. export class ColorSplitterBlock extends NodeMaterialBlock {
  131523. /**
  131524. * Create a new ColorSplitterBlock
  131525. * @param name defines the block name
  131526. */
  131527. constructor(name: string);
  131528. /**
  131529. * Gets the current class name
  131530. * @returns the class name
  131531. */
  131532. getClassName(): string;
  131533. /**
  131534. * Gets the rgba component (input)
  131535. */
  131536. get rgba(): NodeMaterialConnectionPoint;
  131537. /**
  131538. * Gets the rgb component (input)
  131539. */
  131540. get rgbIn(): NodeMaterialConnectionPoint;
  131541. /**
  131542. * Gets the rgb component (output)
  131543. */
  131544. get rgbOut(): NodeMaterialConnectionPoint;
  131545. /**
  131546. * Gets the r component (output)
  131547. */
  131548. get r(): NodeMaterialConnectionPoint;
  131549. /**
  131550. * Gets the g component (output)
  131551. */
  131552. get g(): NodeMaterialConnectionPoint;
  131553. /**
  131554. * Gets the b component (output)
  131555. */
  131556. get b(): NodeMaterialConnectionPoint;
  131557. /**
  131558. * Gets the a component (output)
  131559. */
  131560. get a(): NodeMaterialConnectionPoint;
  131561. protected _inputRename(name: string): string;
  131562. protected _outputRename(name: string): string;
  131563. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131564. }
  131565. }
  131566. declare module BABYLON {
  131567. /**
  131568. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  131569. */
  131570. export class VectorSplitterBlock extends NodeMaterialBlock {
  131571. /**
  131572. * Create a new VectorSplitterBlock
  131573. * @param name defines the block name
  131574. */
  131575. constructor(name: string);
  131576. /**
  131577. * Gets the current class name
  131578. * @returns the class name
  131579. */
  131580. getClassName(): string;
  131581. /**
  131582. * Gets the xyzw component (input)
  131583. */
  131584. get xyzw(): NodeMaterialConnectionPoint;
  131585. /**
  131586. * Gets the xyz component (input)
  131587. */
  131588. get xyzIn(): NodeMaterialConnectionPoint;
  131589. /**
  131590. * Gets the xy component (input)
  131591. */
  131592. get xyIn(): NodeMaterialConnectionPoint;
  131593. /**
  131594. * Gets the xyz component (output)
  131595. */
  131596. get xyzOut(): NodeMaterialConnectionPoint;
  131597. /**
  131598. * Gets the xy component (output)
  131599. */
  131600. get xyOut(): NodeMaterialConnectionPoint;
  131601. /**
  131602. * Gets the x component (output)
  131603. */
  131604. get x(): NodeMaterialConnectionPoint;
  131605. /**
  131606. * Gets the y component (output)
  131607. */
  131608. get y(): NodeMaterialConnectionPoint;
  131609. /**
  131610. * Gets the z component (output)
  131611. */
  131612. get z(): NodeMaterialConnectionPoint;
  131613. /**
  131614. * Gets the w component (output)
  131615. */
  131616. get w(): NodeMaterialConnectionPoint;
  131617. protected _inputRename(name: string): string;
  131618. protected _outputRename(name: string): string;
  131619. protected _buildBlock(state: NodeMaterialBuildState): this;
  131620. }
  131621. }
  131622. declare module BABYLON {
  131623. /**
  131624. * Block used to lerp between 2 values
  131625. */
  131626. export class LerpBlock extends NodeMaterialBlock {
  131627. /**
  131628. * Creates a new LerpBlock
  131629. * @param name defines the block name
  131630. */
  131631. constructor(name: string);
  131632. /**
  131633. * Gets the current class name
  131634. * @returns the class name
  131635. */
  131636. getClassName(): string;
  131637. /**
  131638. * Gets the left operand input component
  131639. */
  131640. get left(): NodeMaterialConnectionPoint;
  131641. /**
  131642. * Gets the right operand input component
  131643. */
  131644. get right(): NodeMaterialConnectionPoint;
  131645. /**
  131646. * Gets the gradient operand input component
  131647. */
  131648. get gradient(): NodeMaterialConnectionPoint;
  131649. /**
  131650. * Gets the output component
  131651. */
  131652. get output(): NodeMaterialConnectionPoint;
  131653. protected _buildBlock(state: NodeMaterialBuildState): this;
  131654. }
  131655. }
  131656. declare module BABYLON {
  131657. /**
  131658. * Block used to divide 2 vectors
  131659. */
  131660. export class DivideBlock extends NodeMaterialBlock {
  131661. /**
  131662. * Creates a new DivideBlock
  131663. * @param name defines the block name
  131664. */
  131665. constructor(name: string);
  131666. /**
  131667. * Gets the current class name
  131668. * @returns the class name
  131669. */
  131670. getClassName(): string;
  131671. /**
  131672. * Gets the left operand input component
  131673. */
  131674. get left(): NodeMaterialConnectionPoint;
  131675. /**
  131676. * Gets the right operand input component
  131677. */
  131678. get right(): NodeMaterialConnectionPoint;
  131679. /**
  131680. * Gets the output component
  131681. */
  131682. get output(): NodeMaterialConnectionPoint;
  131683. protected _buildBlock(state: NodeMaterialBuildState): this;
  131684. }
  131685. }
  131686. declare module BABYLON {
  131687. /**
  131688. * Block used to subtract 2 vectors
  131689. */
  131690. export class SubtractBlock extends NodeMaterialBlock {
  131691. /**
  131692. * Creates a new SubtractBlock
  131693. * @param name defines the block name
  131694. */
  131695. constructor(name: string);
  131696. /**
  131697. * Gets the current class name
  131698. * @returns the class name
  131699. */
  131700. getClassName(): string;
  131701. /**
  131702. * Gets the left operand input component
  131703. */
  131704. get left(): NodeMaterialConnectionPoint;
  131705. /**
  131706. * Gets the right operand input component
  131707. */
  131708. get right(): NodeMaterialConnectionPoint;
  131709. /**
  131710. * Gets the output component
  131711. */
  131712. get output(): NodeMaterialConnectionPoint;
  131713. protected _buildBlock(state: NodeMaterialBuildState): this;
  131714. }
  131715. }
  131716. declare module BABYLON {
  131717. /**
  131718. * Block used to step a value
  131719. */
  131720. export class StepBlock extends NodeMaterialBlock {
  131721. /**
  131722. * Creates a new StepBlock
  131723. * @param name defines the block name
  131724. */
  131725. constructor(name: string);
  131726. /**
  131727. * Gets the current class name
  131728. * @returns the class name
  131729. */
  131730. getClassName(): string;
  131731. /**
  131732. * Gets the value operand input component
  131733. */
  131734. get value(): NodeMaterialConnectionPoint;
  131735. /**
  131736. * Gets the edge operand input component
  131737. */
  131738. get edge(): NodeMaterialConnectionPoint;
  131739. /**
  131740. * Gets the output component
  131741. */
  131742. get output(): NodeMaterialConnectionPoint;
  131743. protected _buildBlock(state: NodeMaterialBuildState): this;
  131744. }
  131745. }
  131746. declare module BABYLON {
  131747. /**
  131748. * Block used to get the opposite (1 - x) of a value
  131749. */
  131750. export class OneMinusBlock extends NodeMaterialBlock {
  131751. /**
  131752. * Creates a new OneMinusBlock
  131753. * @param name defines the block name
  131754. */
  131755. constructor(name: string);
  131756. /**
  131757. * Gets the current class name
  131758. * @returns the class name
  131759. */
  131760. getClassName(): string;
  131761. /**
  131762. * Gets the input component
  131763. */
  131764. get input(): NodeMaterialConnectionPoint;
  131765. /**
  131766. * Gets the output component
  131767. */
  131768. get output(): NodeMaterialConnectionPoint;
  131769. protected _buildBlock(state: NodeMaterialBuildState): this;
  131770. }
  131771. }
  131772. declare module BABYLON {
  131773. /**
  131774. * Block used to get the view direction
  131775. */
  131776. export class ViewDirectionBlock extends NodeMaterialBlock {
  131777. /**
  131778. * Creates a new ViewDirectionBlock
  131779. * @param name defines the block name
  131780. */
  131781. constructor(name: string);
  131782. /**
  131783. * Gets the current class name
  131784. * @returns the class name
  131785. */
  131786. getClassName(): string;
  131787. /**
  131788. * Gets the world position component
  131789. */
  131790. get worldPosition(): NodeMaterialConnectionPoint;
  131791. /**
  131792. * Gets the camera position component
  131793. */
  131794. get cameraPosition(): NodeMaterialConnectionPoint;
  131795. /**
  131796. * Gets the output component
  131797. */
  131798. get output(): NodeMaterialConnectionPoint;
  131799. autoConfigure(material: NodeMaterial): void;
  131800. protected _buildBlock(state: NodeMaterialBuildState): this;
  131801. }
  131802. }
  131803. declare module BABYLON {
  131804. /**
  131805. * Block used to compute fresnel value
  131806. */
  131807. export class FresnelBlock extends NodeMaterialBlock {
  131808. /**
  131809. * Create a new FresnelBlock
  131810. * @param name defines the block name
  131811. */
  131812. constructor(name: string);
  131813. /**
  131814. * Gets the current class name
  131815. * @returns the class name
  131816. */
  131817. getClassName(): string;
  131818. /**
  131819. * Gets the world normal input component
  131820. */
  131821. get worldNormal(): NodeMaterialConnectionPoint;
  131822. /**
  131823. * Gets the view direction input component
  131824. */
  131825. get viewDirection(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the bias input component
  131828. */
  131829. get bias(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the camera (or eye) position component
  131832. */
  131833. get power(): NodeMaterialConnectionPoint;
  131834. /**
  131835. * Gets the fresnel output component
  131836. */
  131837. get fresnel(): NodeMaterialConnectionPoint;
  131838. autoConfigure(material: NodeMaterial): void;
  131839. protected _buildBlock(state: NodeMaterialBuildState): this;
  131840. }
  131841. }
  131842. declare module BABYLON {
  131843. /**
  131844. * Block used to get the max of 2 values
  131845. */
  131846. export class MaxBlock extends NodeMaterialBlock {
  131847. /**
  131848. * Creates a new MaxBlock
  131849. * @param name defines the block name
  131850. */
  131851. constructor(name: string);
  131852. /**
  131853. * Gets the current class name
  131854. * @returns the class name
  131855. */
  131856. getClassName(): string;
  131857. /**
  131858. * Gets the left operand input component
  131859. */
  131860. get left(): NodeMaterialConnectionPoint;
  131861. /**
  131862. * Gets the right operand input component
  131863. */
  131864. get right(): NodeMaterialConnectionPoint;
  131865. /**
  131866. * Gets the output component
  131867. */
  131868. get output(): NodeMaterialConnectionPoint;
  131869. protected _buildBlock(state: NodeMaterialBuildState): this;
  131870. }
  131871. }
  131872. declare module BABYLON {
  131873. /**
  131874. * Block used to get the min of 2 values
  131875. */
  131876. export class MinBlock extends NodeMaterialBlock {
  131877. /**
  131878. * Creates a new MinBlock
  131879. * @param name defines the block name
  131880. */
  131881. constructor(name: string);
  131882. /**
  131883. * Gets the current class name
  131884. * @returns the class name
  131885. */
  131886. getClassName(): string;
  131887. /**
  131888. * Gets the left operand input component
  131889. */
  131890. get left(): NodeMaterialConnectionPoint;
  131891. /**
  131892. * Gets the right operand input component
  131893. */
  131894. get right(): NodeMaterialConnectionPoint;
  131895. /**
  131896. * Gets the output component
  131897. */
  131898. get output(): NodeMaterialConnectionPoint;
  131899. protected _buildBlock(state: NodeMaterialBuildState): this;
  131900. }
  131901. }
  131902. declare module BABYLON {
  131903. /**
  131904. * Block used to get the distance between 2 values
  131905. */
  131906. export class DistanceBlock extends NodeMaterialBlock {
  131907. /**
  131908. * Creates a new DistanceBlock
  131909. * @param name defines the block name
  131910. */
  131911. constructor(name: string);
  131912. /**
  131913. * Gets the current class name
  131914. * @returns the class name
  131915. */
  131916. getClassName(): string;
  131917. /**
  131918. * Gets the left operand input component
  131919. */
  131920. get left(): NodeMaterialConnectionPoint;
  131921. /**
  131922. * Gets the right operand input component
  131923. */
  131924. get right(): NodeMaterialConnectionPoint;
  131925. /**
  131926. * Gets the output component
  131927. */
  131928. get output(): NodeMaterialConnectionPoint;
  131929. protected _buildBlock(state: NodeMaterialBuildState): this;
  131930. }
  131931. }
  131932. declare module BABYLON {
  131933. /**
  131934. * Block used to get the length of a vector
  131935. */
  131936. export class LengthBlock extends NodeMaterialBlock {
  131937. /**
  131938. * Creates a new LengthBlock
  131939. * @param name defines the block name
  131940. */
  131941. constructor(name: string);
  131942. /**
  131943. * Gets the current class name
  131944. * @returns the class name
  131945. */
  131946. getClassName(): string;
  131947. /**
  131948. * Gets the value input component
  131949. */
  131950. get value(): NodeMaterialConnectionPoint;
  131951. /**
  131952. * Gets the output component
  131953. */
  131954. get output(): NodeMaterialConnectionPoint;
  131955. protected _buildBlock(state: NodeMaterialBuildState): this;
  131956. }
  131957. }
  131958. declare module BABYLON {
  131959. /**
  131960. * Block used to get negative version of a value (i.e. x * -1)
  131961. */
  131962. export class NegateBlock extends NodeMaterialBlock {
  131963. /**
  131964. * Creates a new NegateBlock
  131965. * @param name defines the block name
  131966. */
  131967. constructor(name: string);
  131968. /**
  131969. * Gets the current class name
  131970. * @returns the class name
  131971. */
  131972. getClassName(): string;
  131973. /**
  131974. * Gets the value input component
  131975. */
  131976. get value(): NodeMaterialConnectionPoint;
  131977. /**
  131978. * Gets the output component
  131979. */
  131980. get output(): NodeMaterialConnectionPoint;
  131981. protected _buildBlock(state: NodeMaterialBuildState): this;
  131982. }
  131983. }
  131984. declare module BABYLON {
  131985. /**
  131986. * Block used to get the value of the first parameter raised to the power of the second
  131987. */
  131988. export class PowBlock extends NodeMaterialBlock {
  131989. /**
  131990. * Creates a new PowBlock
  131991. * @param name defines the block name
  131992. */
  131993. constructor(name: string);
  131994. /**
  131995. * Gets the current class name
  131996. * @returns the class name
  131997. */
  131998. getClassName(): string;
  131999. /**
  132000. * Gets the value operand input component
  132001. */
  132002. get value(): NodeMaterialConnectionPoint;
  132003. /**
  132004. * Gets the power operand input component
  132005. */
  132006. get power(): NodeMaterialConnectionPoint;
  132007. /**
  132008. * Gets the output component
  132009. */
  132010. get output(): NodeMaterialConnectionPoint;
  132011. protected _buildBlock(state: NodeMaterialBuildState): this;
  132012. }
  132013. }
  132014. declare module BABYLON {
  132015. /**
  132016. * Block used to get a random number
  132017. */
  132018. export class RandomNumberBlock extends NodeMaterialBlock {
  132019. /**
  132020. * Creates a new RandomNumberBlock
  132021. * @param name defines the block name
  132022. */
  132023. constructor(name: string);
  132024. /**
  132025. * Gets the current class name
  132026. * @returns the class name
  132027. */
  132028. getClassName(): string;
  132029. /**
  132030. * Gets the seed input component
  132031. */
  132032. get seed(): NodeMaterialConnectionPoint;
  132033. /**
  132034. * Gets the output component
  132035. */
  132036. get output(): NodeMaterialConnectionPoint;
  132037. protected _buildBlock(state: NodeMaterialBuildState): this;
  132038. }
  132039. }
  132040. declare module BABYLON {
  132041. /**
  132042. * Block used to compute arc tangent of 2 values
  132043. */
  132044. export class ArcTan2Block extends NodeMaterialBlock {
  132045. /**
  132046. * Creates a new ArcTan2Block
  132047. * @param name defines the block name
  132048. */
  132049. constructor(name: string);
  132050. /**
  132051. * Gets the current class name
  132052. * @returns the class name
  132053. */
  132054. getClassName(): string;
  132055. /**
  132056. * Gets the x operand input component
  132057. */
  132058. get x(): NodeMaterialConnectionPoint;
  132059. /**
  132060. * Gets the y operand input component
  132061. */
  132062. get y(): NodeMaterialConnectionPoint;
  132063. /**
  132064. * Gets the output component
  132065. */
  132066. get output(): NodeMaterialConnectionPoint;
  132067. protected _buildBlock(state: NodeMaterialBuildState): this;
  132068. }
  132069. }
  132070. declare module BABYLON {
  132071. /**
  132072. * Block used to smooth step a value
  132073. */
  132074. export class SmoothStepBlock extends NodeMaterialBlock {
  132075. /**
  132076. * Creates a new SmoothStepBlock
  132077. * @param name defines the block name
  132078. */
  132079. constructor(name: string);
  132080. /**
  132081. * Gets the current class name
  132082. * @returns the class name
  132083. */
  132084. getClassName(): string;
  132085. /**
  132086. * Gets the value operand input component
  132087. */
  132088. get value(): NodeMaterialConnectionPoint;
  132089. /**
  132090. * Gets the first edge operand input component
  132091. */
  132092. get edge0(): NodeMaterialConnectionPoint;
  132093. /**
  132094. * Gets the second edge operand input component
  132095. */
  132096. get edge1(): NodeMaterialConnectionPoint;
  132097. /**
  132098. * Gets the output component
  132099. */
  132100. get output(): NodeMaterialConnectionPoint;
  132101. protected _buildBlock(state: NodeMaterialBuildState): this;
  132102. }
  132103. }
  132104. declare module BABYLON {
  132105. /**
  132106. * Block used to get the reciprocal (1 / x) of a value
  132107. */
  132108. export class ReciprocalBlock extends NodeMaterialBlock {
  132109. /**
  132110. * Creates a new ReciprocalBlock
  132111. * @param name defines the block name
  132112. */
  132113. constructor(name: string);
  132114. /**
  132115. * Gets the current class name
  132116. * @returns the class name
  132117. */
  132118. getClassName(): string;
  132119. /**
  132120. * Gets the input component
  132121. */
  132122. get input(): NodeMaterialConnectionPoint;
  132123. /**
  132124. * Gets the output component
  132125. */
  132126. get output(): NodeMaterialConnectionPoint;
  132127. protected _buildBlock(state: NodeMaterialBuildState): this;
  132128. }
  132129. }
  132130. declare module BABYLON {
  132131. /**
  132132. * Block used to replace a color by another one
  132133. */
  132134. export class ReplaceColorBlock extends NodeMaterialBlock {
  132135. /**
  132136. * Creates a new ReplaceColorBlock
  132137. * @param name defines the block name
  132138. */
  132139. constructor(name: string);
  132140. /**
  132141. * Gets the current class name
  132142. * @returns the class name
  132143. */
  132144. getClassName(): string;
  132145. /**
  132146. * Gets the value input component
  132147. */
  132148. get value(): NodeMaterialConnectionPoint;
  132149. /**
  132150. * Gets the reference input component
  132151. */
  132152. get reference(): NodeMaterialConnectionPoint;
  132153. /**
  132154. * Gets the distance input component
  132155. */
  132156. get distance(): NodeMaterialConnectionPoint;
  132157. /**
  132158. * Gets the replacement input component
  132159. */
  132160. get replacement(): NodeMaterialConnectionPoint;
  132161. /**
  132162. * Gets the output component
  132163. */
  132164. get output(): NodeMaterialConnectionPoint;
  132165. protected _buildBlock(state: NodeMaterialBuildState): this;
  132166. }
  132167. }
  132168. declare module BABYLON {
  132169. /**
  132170. * Block used to posterize a value
  132171. * @see https://en.wikipedia.org/wiki/Posterization
  132172. */
  132173. export class PosterizeBlock extends NodeMaterialBlock {
  132174. /**
  132175. * Creates a new PosterizeBlock
  132176. * @param name defines the block name
  132177. */
  132178. constructor(name: string);
  132179. /**
  132180. * Gets the current class name
  132181. * @returns the class name
  132182. */
  132183. getClassName(): string;
  132184. /**
  132185. * Gets the value input component
  132186. */
  132187. get value(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the steps input component
  132190. */
  132191. get steps(): NodeMaterialConnectionPoint;
  132192. /**
  132193. * Gets the output component
  132194. */
  132195. get output(): NodeMaterialConnectionPoint;
  132196. protected _buildBlock(state: NodeMaterialBuildState): this;
  132197. }
  132198. }
  132199. declare module BABYLON {
  132200. /**
  132201. * Operations supported by the Wave block
  132202. */
  132203. export enum WaveBlockKind {
  132204. /** SawTooth */
  132205. SawTooth = 0,
  132206. /** Square */
  132207. Square = 1,
  132208. /** Triangle */
  132209. Triangle = 2
  132210. }
  132211. /**
  132212. * Block used to apply wave operation to floats
  132213. */
  132214. export class WaveBlock extends NodeMaterialBlock {
  132215. /**
  132216. * Gets or sets the kibnd of wave to be applied by the block
  132217. */
  132218. kind: WaveBlockKind;
  132219. /**
  132220. * Creates a new WaveBlock
  132221. * @param name defines the block name
  132222. */
  132223. constructor(name: string);
  132224. /**
  132225. * Gets the current class name
  132226. * @returns the class name
  132227. */
  132228. getClassName(): string;
  132229. /**
  132230. * Gets the input component
  132231. */
  132232. get input(): NodeMaterialConnectionPoint;
  132233. /**
  132234. * Gets the output component
  132235. */
  132236. get output(): NodeMaterialConnectionPoint;
  132237. protected _buildBlock(state: NodeMaterialBuildState): this;
  132238. serialize(): any;
  132239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132240. }
  132241. }
  132242. declare module BABYLON {
  132243. /**
  132244. * Class used to store a color step for the GradientBlock
  132245. */
  132246. export class GradientBlockColorStep {
  132247. /**
  132248. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132249. */
  132250. step: number;
  132251. /**
  132252. * Gets or sets the color associated with this step
  132253. */
  132254. color: Color3;
  132255. /**
  132256. * Creates a new GradientBlockColorStep
  132257. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132258. * @param color defines the color associated with this step
  132259. */
  132260. constructor(
  132261. /**
  132262. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132263. */
  132264. step: number,
  132265. /**
  132266. * Gets or sets the color associated with this step
  132267. */
  132268. color: Color3);
  132269. }
  132270. /**
  132271. * Block used to return a color from a gradient based on an input value between 0 and 1
  132272. */
  132273. export class GradientBlock extends NodeMaterialBlock {
  132274. /**
  132275. * Gets or sets the list of color steps
  132276. */
  132277. colorSteps: GradientBlockColorStep[];
  132278. /**
  132279. * Creates a new GradientBlock
  132280. * @param name defines the block name
  132281. */
  132282. constructor(name: string);
  132283. /**
  132284. * Gets the current class name
  132285. * @returns the class name
  132286. */
  132287. getClassName(): string;
  132288. /**
  132289. * Gets the gradient input component
  132290. */
  132291. get gradient(): NodeMaterialConnectionPoint;
  132292. /**
  132293. * Gets the output component
  132294. */
  132295. get output(): NodeMaterialConnectionPoint;
  132296. private _writeColorConstant;
  132297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132298. serialize(): any;
  132299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132300. protected _dumpPropertiesCode(): string;
  132301. }
  132302. }
  132303. declare module BABYLON {
  132304. /**
  132305. * Block used to normalize lerp between 2 values
  132306. */
  132307. export class NLerpBlock extends NodeMaterialBlock {
  132308. /**
  132309. * Creates a new NLerpBlock
  132310. * @param name defines the block name
  132311. */
  132312. constructor(name: string);
  132313. /**
  132314. * Gets the current class name
  132315. * @returns the class name
  132316. */
  132317. getClassName(): string;
  132318. /**
  132319. * Gets the left operand input component
  132320. */
  132321. get left(): NodeMaterialConnectionPoint;
  132322. /**
  132323. * Gets the right operand input component
  132324. */
  132325. get right(): NodeMaterialConnectionPoint;
  132326. /**
  132327. * Gets the gradient operand input component
  132328. */
  132329. get gradient(): NodeMaterialConnectionPoint;
  132330. /**
  132331. * Gets the output component
  132332. */
  132333. get output(): NodeMaterialConnectionPoint;
  132334. protected _buildBlock(state: NodeMaterialBuildState): this;
  132335. }
  132336. }
  132337. declare module BABYLON {
  132338. /**
  132339. * block used to Generate a Worley Noise 3D Noise Pattern
  132340. */
  132341. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  132342. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132343. manhattanDistance: boolean;
  132344. /**
  132345. * Creates a new WorleyNoise3DBlock
  132346. * @param name defines the block name
  132347. */
  132348. constructor(name: string);
  132349. /**
  132350. * Gets the current class name
  132351. * @returns the class name
  132352. */
  132353. getClassName(): string;
  132354. /**
  132355. * Gets the seed input component
  132356. */
  132357. get seed(): NodeMaterialConnectionPoint;
  132358. /**
  132359. * Gets the jitter input component
  132360. */
  132361. get jitter(): NodeMaterialConnectionPoint;
  132362. /**
  132363. * Gets the output component
  132364. */
  132365. get output(): NodeMaterialConnectionPoint;
  132366. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132367. /**
  132368. * Exposes the properties to the UI?
  132369. */
  132370. protected _dumpPropertiesCode(): string;
  132371. /**
  132372. * Exposes the properties to the Seralize?
  132373. */
  132374. serialize(): any;
  132375. /**
  132376. * Exposes the properties to the deseralize?
  132377. */
  132378. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132379. }
  132380. }
  132381. declare module BABYLON {
  132382. /**
  132383. * block used to Generate a Simplex Perlin 3d Noise Pattern
  132384. */
  132385. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  132386. /**
  132387. * Creates a new SimplexPerlin3DBlock
  132388. * @param name defines the block name
  132389. */
  132390. constructor(name: string);
  132391. /**
  132392. * Gets the current class name
  132393. * @returns the class name
  132394. */
  132395. getClassName(): string;
  132396. /**
  132397. * Gets the seed operand input component
  132398. */
  132399. get seed(): NodeMaterialConnectionPoint;
  132400. /**
  132401. * Gets the output component
  132402. */
  132403. get output(): NodeMaterialConnectionPoint;
  132404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132405. }
  132406. }
  132407. declare module BABYLON {
  132408. /**
  132409. * Block used to blend normals
  132410. */
  132411. export class NormalBlendBlock extends NodeMaterialBlock {
  132412. /**
  132413. * Creates a new NormalBlendBlock
  132414. * @param name defines the block name
  132415. */
  132416. constructor(name: string);
  132417. /**
  132418. * Gets the current class name
  132419. * @returns the class name
  132420. */
  132421. getClassName(): string;
  132422. /**
  132423. * Gets the first input component
  132424. */
  132425. get normalMap0(): NodeMaterialConnectionPoint;
  132426. /**
  132427. * Gets the second input component
  132428. */
  132429. get normalMap1(): NodeMaterialConnectionPoint;
  132430. /**
  132431. * Gets the output component
  132432. */
  132433. get output(): NodeMaterialConnectionPoint;
  132434. protected _buildBlock(state: NodeMaterialBuildState): this;
  132435. }
  132436. }
  132437. declare module BABYLON {
  132438. /**
  132439. * Block used to rotate a 2d vector by a given angle
  132440. */
  132441. export class Rotate2dBlock extends NodeMaterialBlock {
  132442. /**
  132443. * Creates a new Rotate2dBlock
  132444. * @param name defines the block name
  132445. */
  132446. constructor(name: string);
  132447. /**
  132448. * Gets the current class name
  132449. * @returns the class name
  132450. */
  132451. getClassName(): string;
  132452. /**
  132453. * Gets the input vector
  132454. */
  132455. get input(): NodeMaterialConnectionPoint;
  132456. /**
  132457. * Gets the input angle
  132458. */
  132459. get angle(): NodeMaterialConnectionPoint;
  132460. /**
  132461. * Gets the output component
  132462. */
  132463. get output(): NodeMaterialConnectionPoint;
  132464. autoConfigure(material: NodeMaterial): void;
  132465. protected _buildBlock(state: NodeMaterialBuildState): this;
  132466. }
  132467. }
  132468. declare module BABYLON {
  132469. /**
  132470. * Block used to get the reflected vector from a direction and a normal
  132471. */
  132472. export class ReflectBlock extends NodeMaterialBlock {
  132473. /**
  132474. * Creates a new ReflectBlock
  132475. * @param name defines the block name
  132476. */
  132477. constructor(name: string);
  132478. /**
  132479. * Gets the current class name
  132480. * @returns the class name
  132481. */
  132482. getClassName(): string;
  132483. /**
  132484. * Gets the incident component
  132485. */
  132486. get incident(): NodeMaterialConnectionPoint;
  132487. /**
  132488. * Gets the normal component
  132489. */
  132490. get normal(): NodeMaterialConnectionPoint;
  132491. /**
  132492. * Gets the output component
  132493. */
  132494. get output(): NodeMaterialConnectionPoint;
  132495. protected _buildBlock(state: NodeMaterialBuildState): this;
  132496. }
  132497. }
  132498. declare module BABYLON {
  132499. /**
  132500. * Block used to get the refracted vector from a direction and a normal
  132501. */
  132502. export class RefractBlock extends NodeMaterialBlock {
  132503. /**
  132504. * Creates a new RefractBlock
  132505. * @param name defines the block name
  132506. */
  132507. constructor(name: string);
  132508. /**
  132509. * Gets the current class name
  132510. * @returns the class name
  132511. */
  132512. getClassName(): string;
  132513. /**
  132514. * Gets the incident component
  132515. */
  132516. get incident(): NodeMaterialConnectionPoint;
  132517. /**
  132518. * Gets the normal component
  132519. */
  132520. get normal(): NodeMaterialConnectionPoint;
  132521. /**
  132522. * Gets the index of refraction component
  132523. */
  132524. get ior(): NodeMaterialConnectionPoint;
  132525. /**
  132526. * Gets the output component
  132527. */
  132528. get output(): NodeMaterialConnectionPoint;
  132529. protected _buildBlock(state: NodeMaterialBuildState): this;
  132530. }
  132531. }
  132532. declare module BABYLON {
  132533. /**
  132534. * Block used to desaturate a color
  132535. */
  132536. export class DesaturateBlock extends NodeMaterialBlock {
  132537. /**
  132538. * Creates a new DesaturateBlock
  132539. * @param name defines the block name
  132540. */
  132541. constructor(name: string);
  132542. /**
  132543. * Gets the current class name
  132544. * @returns the class name
  132545. */
  132546. getClassName(): string;
  132547. /**
  132548. * Gets the color operand input component
  132549. */
  132550. get color(): NodeMaterialConnectionPoint;
  132551. /**
  132552. * Gets the level operand input component
  132553. */
  132554. get level(): NodeMaterialConnectionPoint;
  132555. /**
  132556. * Gets the output component
  132557. */
  132558. get output(): NodeMaterialConnectionPoint;
  132559. protected _buildBlock(state: NodeMaterialBuildState): this;
  132560. }
  132561. }
  132562. declare module BABYLON {
  132563. /**
  132564. * Effect Render Options
  132565. */
  132566. export interface IEffectRendererOptions {
  132567. /**
  132568. * Defines the vertices positions.
  132569. */
  132570. positions?: number[];
  132571. /**
  132572. * Defines the indices.
  132573. */
  132574. indices?: number[];
  132575. }
  132576. /**
  132577. * Helper class to render one or more effects
  132578. */
  132579. export class EffectRenderer {
  132580. private engine;
  132581. private static _DefaultOptions;
  132582. private _vertexBuffers;
  132583. private _indexBuffer;
  132584. private _ringBufferIndex;
  132585. private _ringScreenBuffer;
  132586. private _fullscreenViewport;
  132587. private _getNextFrameBuffer;
  132588. /**
  132589. * Creates an effect renderer
  132590. * @param engine the engine to use for rendering
  132591. * @param options defines the options of the effect renderer
  132592. */
  132593. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  132594. /**
  132595. * Sets the current viewport in normalized coordinates 0-1
  132596. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  132597. */
  132598. setViewport(viewport?: Viewport): void;
  132599. /**
  132600. * Binds the embedded attributes buffer to the effect.
  132601. * @param effect Defines the effect to bind the attributes for
  132602. */
  132603. bindBuffers(effect: Effect): void;
  132604. /**
  132605. * Sets the current effect wrapper to use during draw.
  132606. * The effect needs to be ready before calling this api.
  132607. * This also sets the default full screen position attribute.
  132608. * @param effectWrapper Defines the effect to draw with
  132609. */
  132610. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  132611. /**
  132612. * Draws a full screen quad.
  132613. */
  132614. draw(): void;
  132615. /**
  132616. * renders one or more effects to a specified texture
  132617. * @param effectWrappers list of effects to renderer
  132618. * @param outputTexture texture to draw to, if null it will render to the screen
  132619. */
  132620. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  132621. /**
  132622. * Disposes of the effect renderer
  132623. */
  132624. dispose(): void;
  132625. }
  132626. /**
  132627. * Options to create an EffectWrapper
  132628. */
  132629. interface EffectWrapperCreationOptions {
  132630. /**
  132631. * Engine to use to create the effect
  132632. */
  132633. engine: ThinEngine;
  132634. /**
  132635. * Fragment shader for the effect
  132636. */
  132637. fragmentShader: string;
  132638. /**
  132639. * Vertex shader for the effect
  132640. */
  132641. vertexShader?: string;
  132642. /**
  132643. * Attributes to use in the shader
  132644. */
  132645. attributeNames?: Array<string>;
  132646. /**
  132647. * Uniforms to use in the shader
  132648. */
  132649. uniformNames?: Array<string>;
  132650. /**
  132651. * Texture sampler names to use in the shader
  132652. */
  132653. samplerNames?: Array<string>;
  132654. /**
  132655. * The friendly name of the effect displayed in Spector.
  132656. */
  132657. name?: string;
  132658. }
  132659. /**
  132660. * Wraps an effect to be used for rendering
  132661. */
  132662. export class EffectWrapper {
  132663. /**
  132664. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  132665. */
  132666. onApplyObservable: Observable<{}>;
  132667. /**
  132668. * The underlying effect
  132669. */
  132670. effect: Effect;
  132671. /**
  132672. * Creates an effect to be renderer
  132673. * @param creationOptions options to create the effect
  132674. */
  132675. constructor(creationOptions: EffectWrapperCreationOptions);
  132676. /**
  132677. * Disposes of the effect wrapper
  132678. */
  132679. dispose(): void;
  132680. }
  132681. }
  132682. declare module BABYLON {
  132683. /**
  132684. * Helper class to push actions to a pool of workers.
  132685. */
  132686. export class WorkerPool implements IDisposable {
  132687. private _workerInfos;
  132688. private _pendingActions;
  132689. /**
  132690. * Constructor
  132691. * @param workers Array of workers to use for actions
  132692. */
  132693. constructor(workers: Array<Worker>);
  132694. /**
  132695. * Terminates all workers and clears any pending actions.
  132696. */
  132697. dispose(): void;
  132698. /**
  132699. * Pushes an action to the worker pool. If all the workers are active, the action will be
  132700. * pended until a worker has completed its action.
  132701. * @param action The action to perform. Call onComplete when the action is complete.
  132702. */
  132703. push(action: (worker: Worker, onComplete: () => void) => void): void;
  132704. private _execute;
  132705. }
  132706. }
  132707. declare module BABYLON {
  132708. /**
  132709. * Configuration for Draco compression
  132710. */
  132711. export interface IDracoCompressionConfiguration {
  132712. /**
  132713. * Configuration for the decoder.
  132714. */
  132715. decoder: {
  132716. /**
  132717. * The url to the WebAssembly module.
  132718. */
  132719. wasmUrl?: string;
  132720. /**
  132721. * The url to the WebAssembly binary.
  132722. */
  132723. wasmBinaryUrl?: string;
  132724. /**
  132725. * The url to the fallback JavaScript module.
  132726. */
  132727. fallbackUrl?: string;
  132728. };
  132729. }
  132730. /**
  132731. * Draco compression (https://google.github.io/draco/)
  132732. *
  132733. * This class wraps the Draco module.
  132734. *
  132735. * **Encoder**
  132736. *
  132737. * The encoder is not currently implemented.
  132738. *
  132739. * **Decoder**
  132740. *
  132741. * 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.
  132742. *
  132743. * To update the configuration, use the following code:
  132744. * ```javascript
  132745. * DracoCompression.Configuration = {
  132746. * decoder: {
  132747. * wasmUrl: "<url to the WebAssembly library>",
  132748. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  132749. * fallbackUrl: "<url to the fallback JavaScript library>",
  132750. * }
  132751. * };
  132752. * ```
  132753. *
  132754. * 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.
  132755. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  132756. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  132757. *
  132758. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  132759. * ```javascript
  132760. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  132761. * ```
  132762. *
  132763. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  132764. */
  132765. export class DracoCompression implements IDisposable {
  132766. private _workerPoolPromise?;
  132767. private _decoderModulePromise?;
  132768. /**
  132769. * The configuration. Defaults to the following urls:
  132770. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  132771. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  132772. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  132773. */
  132774. static Configuration: IDracoCompressionConfiguration;
  132775. /**
  132776. * Returns true if the decoder configuration is available.
  132777. */
  132778. static get DecoderAvailable(): boolean;
  132779. /**
  132780. * Default number of workers to create when creating the draco compression object.
  132781. */
  132782. static DefaultNumWorkers: number;
  132783. private static GetDefaultNumWorkers;
  132784. private static _Default;
  132785. /**
  132786. * Default instance for the draco compression object.
  132787. */
  132788. static get Default(): DracoCompression;
  132789. /**
  132790. * Constructor
  132791. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  132792. */
  132793. constructor(numWorkers?: number);
  132794. /**
  132795. * Stop all async operations and release resources.
  132796. */
  132797. dispose(): void;
  132798. /**
  132799. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  132800. * @returns a promise that resolves when ready
  132801. */
  132802. whenReadyAsync(): Promise<void>;
  132803. /**
  132804. * Decode Draco compressed mesh data to vertex data.
  132805. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  132806. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  132807. * @returns A promise that resolves with the decoded vertex data
  132808. */
  132809. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  132810. [kind: string]: number;
  132811. }): Promise<VertexData>;
  132812. }
  132813. }
  132814. declare module BABYLON {
  132815. /**
  132816. * Class for building Constructive Solid Geometry
  132817. */
  132818. export class CSG {
  132819. private polygons;
  132820. /**
  132821. * The world matrix
  132822. */
  132823. matrix: Matrix;
  132824. /**
  132825. * Stores the position
  132826. */
  132827. position: Vector3;
  132828. /**
  132829. * Stores the rotation
  132830. */
  132831. rotation: Vector3;
  132832. /**
  132833. * Stores the rotation quaternion
  132834. */
  132835. rotationQuaternion: Nullable<Quaternion>;
  132836. /**
  132837. * Stores the scaling vector
  132838. */
  132839. scaling: Vector3;
  132840. /**
  132841. * Convert the Mesh to CSG
  132842. * @param mesh The Mesh to convert to CSG
  132843. * @returns A new CSG from the Mesh
  132844. */
  132845. static FromMesh(mesh: Mesh): CSG;
  132846. /**
  132847. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  132848. * @param polygons Polygons used to construct a CSG solid
  132849. */
  132850. private static FromPolygons;
  132851. /**
  132852. * Clones, or makes a deep copy, of the CSG
  132853. * @returns A new CSG
  132854. */
  132855. clone(): CSG;
  132856. /**
  132857. * Unions this CSG with another CSG
  132858. * @param csg The CSG to union against this CSG
  132859. * @returns The unioned CSG
  132860. */
  132861. union(csg: CSG): CSG;
  132862. /**
  132863. * Unions this CSG with another CSG in place
  132864. * @param csg The CSG to union against this CSG
  132865. */
  132866. unionInPlace(csg: CSG): void;
  132867. /**
  132868. * Subtracts this CSG with another CSG
  132869. * @param csg The CSG to subtract against this CSG
  132870. * @returns A new CSG
  132871. */
  132872. subtract(csg: CSG): CSG;
  132873. /**
  132874. * Subtracts this CSG with another CSG in place
  132875. * @param csg The CSG to subtact against this CSG
  132876. */
  132877. subtractInPlace(csg: CSG): void;
  132878. /**
  132879. * Intersect this CSG with another CSG
  132880. * @param csg The CSG to intersect against this CSG
  132881. * @returns A new CSG
  132882. */
  132883. intersect(csg: CSG): CSG;
  132884. /**
  132885. * Intersects this CSG with another CSG in place
  132886. * @param csg The CSG to intersect against this CSG
  132887. */
  132888. intersectInPlace(csg: CSG): void;
  132889. /**
  132890. * Return a new CSG solid with solid and empty space switched. This solid is
  132891. * not modified.
  132892. * @returns A new CSG solid with solid and empty space switched
  132893. */
  132894. inverse(): CSG;
  132895. /**
  132896. * Inverses the CSG in place
  132897. */
  132898. inverseInPlace(): void;
  132899. /**
  132900. * This is used to keep meshes transformations so they can be restored
  132901. * when we build back a Babylon Mesh
  132902. * NB : All CSG operations are performed in world coordinates
  132903. * @param csg The CSG to copy the transform attributes from
  132904. * @returns This CSG
  132905. */
  132906. copyTransformAttributes(csg: CSG): CSG;
  132907. /**
  132908. * Build Raw mesh from CSG
  132909. * Coordinates here are in world space
  132910. * @param name The name of the mesh geometry
  132911. * @param scene The Scene
  132912. * @param keepSubMeshes Specifies if the submeshes should be kept
  132913. * @returns A new Mesh
  132914. */
  132915. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132916. /**
  132917. * Build Mesh from CSG taking material and transforms into account
  132918. * @param name The name of the Mesh
  132919. * @param material The material of the Mesh
  132920. * @param scene The Scene
  132921. * @param keepSubMeshes Specifies if submeshes should be kept
  132922. * @returns The new Mesh
  132923. */
  132924. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132925. }
  132926. }
  132927. declare module BABYLON {
  132928. /**
  132929. * Class used to create a trail following a mesh
  132930. */
  132931. export class TrailMesh extends Mesh {
  132932. private _generator;
  132933. private _autoStart;
  132934. private _running;
  132935. private _diameter;
  132936. private _length;
  132937. private _sectionPolygonPointsCount;
  132938. private _sectionVectors;
  132939. private _sectionNormalVectors;
  132940. private _beforeRenderObserver;
  132941. /**
  132942. * @constructor
  132943. * @param name The value used by scene.getMeshByName() to do a lookup.
  132944. * @param generator The mesh or transform node to generate a trail.
  132945. * @param scene The scene to add this mesh to.
  132946. * @param diameter Diameter of trailing mesh. Default is 1.
  132947. * @param length Length of trailing mesh. Default is 60.
  132948. * @param autoStart Automatically start trailing mesh. Default true.
  132949. */
  132950. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  132951. /**
  132952. * "TrailMesh"
  132953. * @returns "TrailMesh"
  132954. */
  132955. getClassName(): string;
  132956. private _createMesh;
  132957. /**
  132958. * Start trailing mesh.
  132959. */
  132960. start(): void;
  132961. /**
  132962. * Stop trailing mesh.
  132963. */
  132964. stop(): void;
  132965. /**
  132966. * Update trailing mesh geometry.
  132967. */
  132968. update(): void;
  132969. /**
  132970. * Returns a new TrailMesh object.
  132971. * @param name is a string, the name given to the new mesh
  132972. * @param newGenerator use new generator object for cloned trail mesh
  132973. * @returns a new mesh
  132974. */
  132975. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  132976. /**
  132977. * Serializes this trail mesh
  132978. * @param serializationObject object to write serialization to
  132979. */
  132980. serialize(serializationObject: any): void;
  132981. /**
  132982. * Parses a serialized trail mesh
  132983. * @param parsedMesh the serialized mesh
  132984. * @param scene the scene to create the trail mesh in
  132985. * @returns the created trail mesh
  132986. */
  132987. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  132988. }
  132989. }
  132990. declare module BABYLON {
  132991. /**
  132992. * Class containing static functions to help procedurally build meshes
  132993. */
  132994. export class TiledBoxBuilder {
  132995. /**
  132996. * Creates a box mesh
  132997. * 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)
  132998. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  132999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133002. * @param name defines the name of the mesh
  133003. * @param options defines the options used to create the mesh
  133004. * @param scene defines the hosting scene
  133005. * @returns the box mesh
  133006. */
  133007. static CreateTiledBox(name: string, options: {
  133008. pattern?: number;
  133009. width?: number;
  133010. height?: number;
  133011. depth?: number;
  133012. tileSize?: number;
  133013. tileWidth?: number;
  133014. tileHeight?: number;
  133015. alignHorizontal?: number;
  133016. alignVertical?: number;
  133017. faceUV?: Vector4[];
  133018. faceColors?: Color4[];
  133019. sideOrientation?: number;
  133020. updatable?: boolean;
  133021. }, scene?: Nullable<Scene>): Mesh;
  133022. }
  133023. }
  133024. declare module BABYLON {
  133025. /**
  133026. * Class containing static functions to help procedurally build meshes
  133027. */
  133028. export class TorusKnotBuilder {
  133029. /**
  133030. * Creates a torus knot mesh
  133031. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133032. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133033. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133034. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133038. * @param name defines the name of the mesh
  133039. * @param options defines the options used to create the mesh
  133040. * @param scene defines the hosting scene
  133041. * @returns the torus knot mesh
  133042. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133043. */
  133044. static CreateTorusKnot(name: string, options: {
  133045. radius?: number;
  133046. tube?: number;
  133047. radialSegments?: number;
  133048. tubularSegments?: number;
  133049. p?: number;
  133050. q?: number;
  133051. updatable?: boolean;
  133052. sideOrientation?: number;
  133053. frontUVs?: Vector4;
  133054. backUVs?: Vector4;
  133055. }, scene: any): Mesh;
  133056. }
  133057. }
  133058. declare module BABYLON {
  133059. /**
  133060. * Polygon
  133061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133062. */
  133063. export class Polygon {
  133064. /**
  133065. * Creates a rectangle
  133066. * @param xmin bottom X coord
  133067. * @param ymin bottom Y coord
  133068. * @param xmax top X coord
  133069. * @param ymax top Y coord
  133070. * @returns points that make the resulting rectation
  133071. */
  133072. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133073. /**
  133074. * Creates a circle
  133075. * @param radius radius of circle
  133076. * @param cx scale in x
  133077. * @param cy scale in y
  133078. * @param numberOfSides number of sides that make up the circle
  133079. * @returns points that make the resulting circle
  133080. */
  133081. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133082. /**
  133083. * Creates a polygon from input string
  133084. * @param input Input polygon data
  133085. * @returns the parsed points
  133086. */
  133087. static Parse(input: string): Vector2[];
  133088. /**
  133089. * Starts building a polygon from x and y coordinates
  133090. * @param x x coordinate
  133091. * @param y y coordinate
  133092. * @returns the started path2
  133093. */
  133094. static StartingAt(x: number, y: number): Path2;
  133095. }
  133096. /**
  133097. * Builds a polygon
  133098. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133099. */
  133100. export class PolygonMeshBuilder {
  133101. private _points;
  133102. private _outlinepoints;
  133103. private _holes;
  133104. private _name;
  133105. private _scene;
  133106. private _epoints;
  133107. private _eholes;
  133108. private _addToepoint;
  133109. /**
  133110. * Babylon reference to the earcut plugin.
  133111. */
  133112. bjsEarcut: any;
  133113. /**
  133114. * Creates a PolygonMeshBuilder
  133115. * @param name name of the builder
  133116. * @param contours Path of the polygon
  133117. * @param scene scene to add to when creating the mesh
  133118. * @param earcutInjection can be used to inject your own earcut reference
  133119. */
  133120. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133121. /**
  133122. * Adds a whole within the polygon
  133123. * @param hole Array of points defining the hole
  133124. * @returns this
  133125. */
  133126. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133127. /**
  133128. * Creates the polygon
  133129. * @param updatable If the mesh should be updatable
  133130. * @param depth The depth of the mesh created
  133131. * @returns the created mesh
  133132. */
  133133. build(updatable?: boolean, depth?: number): Mesh;
  133134. /**
  133135. * Creates the polygon
  133136. * @param depth The depth of the mesh created
  133137. * @returns the created VertexData
  133138. */
  133139. buildVertexData(depth?: number): VertexData;
  133140. /**
  133141. * Adds a side to the polygon
  133142. * @param positions points that make the polygon
  133143. * @param normals normals of the polygon
  133144. * @param uvs uvs of the polygon
  133145. * @param indices indices of the polygon
  133146. * @param bounds bounds of the polygon
  133147. * @param points points of the polygon
  133148. * @param depth depth of the polygon
  133149. * @param flip flip of the polygon
  133150. */
  133151. private addSide;
  133152. }
  133153. }
  133154. declare module BABYLON {
  133155. /**
  133156. * Class containing static functions to help procedurally build meshes
  133157. */
  133158. export class PolygonBuilder {
  133159. /**
  133160. * Creates a polygon mesh
  133161. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133162. * * 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
  133163. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133166. * * Remember you can only change the shape positions, not their number when updating a polygon
  133167. * @param name defines the name of the mesh
  133168. * @param options defines the options used to create the mesh
  133169. * @param scene defines the hosting scene
  133170. * @param earcutInjection can be used to inject your own earcut reference
  133171. * @returns the polygon mesh
  133172. */
  133173. static CreatePolygon(name: string, options: {
  133174. shape: Vector3[];
  133175. holes?: Vector3[][];
  133176. depth?: number;
  133177. faceUV?: Vector4[];
  133178. faceColors?: Color4[];
  133179. updatable?: boolean;
  133180. sideOrientation?: number;
  133181. frontUVs?: Vector4;
  133182. backUVs?: Vector4;
  133183. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133184. /**
  133185. * Creates an extruded polygon mesh, with depth in the Y direction.
  133186. * * 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)
  133187. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133188. * @param name defines the name of the mesh
  133189. * @param options defines the options used to create the mesh
  133190. * @param scene defines the hosting scene
  133191. * @param earcutInjection can be used to inject your own earcut reference
  133192. * @returns the polygon mesh
  133193. */
  133194. static ExtrudePolygon(name: string, options: {
  133195. shape: Vector3[];
  133196. holes?: Vector3[][];
  133197. depth?: number;
  133198. faceUV?: Vector4[];
  133199. faceColors?: Color4[];
  133200. updatable?: boolean;
  133201. sideOrientation?: number;
  133202. frontUVs?: Vector4;
  133203. backUVs?: Vector4;
  133204. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133205. }
  133206. }
  133207. declare module BABYLON {
  133208. /**
  133209. * Class containing static functions to help procedurally build meshes
  133210. */
  133211. export class LatheBuilder {
  133212. /**
  133213. * Creates lathe mesh.
  133214. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133215. * * 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
  133216. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133217. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133218. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133219. * * 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
  133220. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133221. * * 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
  133222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133226. * @param name defines the name of the mesh
  133227. * @param options defines the options used to create the mesh
  133228. * @param scene defines the hosting scene
  133229. * @returns the lathe mesh
  133230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133231. */
  133232. static CreateLathe(name: string, options: {
  133233. shape: Vector3[];
  133234. radius?: number;
  133235. tessellation?: number;
  133236. clip?: number;
  133237. arc?: number;
  133238. closed?: boolean;
  133239. updatable?: boolean;
  133240. sideOrientation?: number;
  133241. frontUVs?: Vector4;
  133242. backUVs?: Vector4;
  133243. cap?: number;
  133244. invertUV?: boolean;
  133245. }, scene?: Nullable<Scene>): Mesh;
  133246. }
  133247. }
  133248. declare module BABYLON {
  133249. /**
  133250. * Class containing static functions to help procedurally build meshes
  133251. */
  133252. export class TiledPlaneBuilder {
  133253. /**
  133254. * Creates a tiled plane mesh
  133255. * * The parameter `pattern` will, depending on value, do nothing or
  133256. * * * flip (reflect about central vertical) alternate tiles across and up
  133257. * * * flip every tile on alternate rows
  133258. * * * rotate (180 degs) alternate tiles across and up
  133259. * * * rotate every tile on alternate rows
  133260. * * * flip and rotate alternate tiles across and up
  133261. * * * flip and rotate every tile on alternate rows
  133262. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133263. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133266. * * 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)
  133267. * * 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)
  133268. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133269. * @param name defines the name of the mesh
  133270. * @param options defines the options used to create the mesh
  133271. * @param scene defines the hosting scene
  133272. * @returns the box mesh
  133273. */
  133274. static CreateTiledPlane(name: string, options: {
  133275. pattern?: number;
  133276. tileSize?: number;
  133277. tileWidth?: number;
  133278. tileHeight?: number;
  133279. size?: number;
  133280. width?: number;
  133281. height?: number;
  133282. alignHorizontal?: number;
  133283. alignVertical?: number;
  133284. sideOrientation?: number;
  133285. frontUVs?: Vector4;
  133286. backUVs?: Vector4;
  133287. updatable?: boolean;
  133288. }, scene?: Nullable<Scene>): Mesh;
  133289. }
  133290. }
  133291. declare module BABYLON {
  133292. /**
  133293. * Class containing static functions to help procedurally build meshes
  133294. */
  133295. export class TubeBuilder {
  133296. /**
  133297. * Creates a tube mesh.
  133298. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133299. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133300. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133301. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133302. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133303. * * 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)
  133304. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133305. * * 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
  133306. * * 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
  133307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133311. * @param name defines the name of the mesh
  133312. * @param options defines the options used to create the mesh
  133313. * @param scene defines the hosting scene
  133314. * @returns the tube mesh
  133315. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133316. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133317. */
  133318. static CreateTube(name: string, options: {
  133319. path: Vector3[];
  133320. radius?: number;
  133321. tessellation?: number;
  133322. radiusFunction?: {
  133323. (i: number, distance: number): number;
  133324. };
  133325. cap?: number;
  133326. arc?: number;
  133327. updatable?: boolean;
  133328. sideOrientation?: number;
  133329. frontUVs?: Vector4;
  133330. backUVs?: Vector4;
  133331. instance?: Mesh;
  133332. invertUV?: boolean;
  133333. }, scene?: Nullable<Scene>): Mesh;
  133334. }
  133335. }
  133336. declare module BABYLON {
  133337. /**
  133338. * Class containing static functions to help procedurally build meshes
  133339. */
  133340. export class IcoSphereBuilder {
  133341. /**
  133342. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133343. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133344. * * 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`)
  133345. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133346. * * 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
  133347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133350. * @param name defines the name of the mesh
  133351. * @param options defines the options used to create the mesh
  133352. * @param scene defines the hosting scene
  133353. * @returns the icosahedron mesh
  133354. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133355. */
  133356. static CreateIcoSphere(name: string, options: {
  133357. radius?: number;
  133358. radiusX?: number;
  133359. radiusY?: number;
  133360. radiusZ?: number;
  133361. flat?: boolean;
  133362. subdivisions?: number;
  133363. sideOrientation?: number;
  133364. frontUVs?: Vector4;
  133365. backUVs?: Vector4;
  133366. updatable?: boolean;
  133367. }, scene?: Nullable<Scene>): Mesh;
  133368. }
  133369. }
  133370. declare module BABYLON {
  133371. /**
  133372. * Class containing static functions to help procedurally build meshes
  133373. */
  133374. export class DecalBuilder {
  133375. /**
  133376. * Creates a decal mesh.
  133377. * 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
  133378. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  133379. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  133380. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  133381. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  133382. * @param name defines the name of the mesh
  133383. * @param sourceMesh defines the mesh where the decal must be applied
  133384. * @param options defines the options used to create the mesh
  133385. * @param scene defines the hosting scene
  133386. * @returns the decal mesh
  133387. * @see https://doc.babylonjs.com/how_to/decals
  133388. */
  133389. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  133390. position?: Vector3;
  133391. normal?: Vector3;
  133392. size?: Vector3;
  133393. angle?: number;
  133394. }): Mesh;
  133395. }
  133396. }
  133397. declare module BABYLON {
  133398. /**
  133399. * Class containing static functions to help procedurally build meshes
  133400. */
  133401. export class MeshBuilder {
  133402. /**
  133403. * Creates a box mesh
  133404. * * The parameter `size` sets the size (float) of each box side (default 1)
  133405. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  133406. * * 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)
  133407. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133411. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133412. * @param name defines the name of the mesh
  133413. * @param options defines the options used to create the mesh
  133414. * @param scene defines the hosting scene
  133415. * @returns the box mesh
  133416. */
  133417. static CreateBox(name: string, options: {
  133418. size?: number;
  133419. width?: number;
  133420. height?: number;
  133421. depth?: number;
  133422. faceUV?: Vector4[];
  133423. faceColors?: Color4[];
  133424. sideOrientation?: number;
  133425. frontUVs?: Vector4;
  133426. backUVs?: Vector4;
  133427. updatable?: boolean;
  133428. }, scene?: Nullable<Scene>): Mesh;
  133429. /**
  133430. * Creates a tiled box mesh
  133431. * * faceTiles sets the pattern, tile size and number of tiles for a face
  133432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133433. * @param name defines the name of the mesh
  133434. * @param options defines the options used to create the mesh
  133435. * @param scene defines the hosting scene
  133436. * @returns the tiled box mesh
  133437. */
  133438. static CreateTiledBox(name: string, options: {
  133439. pattern?: number;
  133440. size?: number;
  133441. width?: number;
  133442. height?: number;
  133443. depth: number;
  133444. tileSize?: number;
  133445. tileWidth?: number;
  133446. tileHeight?: number;
  133447. faceUV?: Vector4[];
  133448. faceColors?: Color4[];
  133449. alignHorizontal?: number;
  133450. alignVertical?: number;
  133451. sideOrientation?: number;
  133452. updatable?: boolean;
  133453. }, scene?: Nullable<Scene>): Mesh;
  133454. /**
  133455. * Creates a sphere mesh
  133456. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133457. * * 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`)
  133458. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133459. * * 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
  133460. * * 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)
  133461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133464. * @param name defines the name of the mesh
  133465. * @param options defines the options used to create the mesh
  133466. * @param scene defines the hosting scene
  133467. * @returns the sphere mesh
  133468. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133469. */
  133470. static CreateSphere(name: string, options: {
  133471. segments?: number;
  133472. diameter?: number;
  133473. diameterX?: number;
  133474. diameterY?: number;
  133475. diameterZ?: number;
  133476. arc?: number;
  133477. slice?: number;
  133478. sideOrientation?: number;
  133479. frontUVs?: Vector4;
  133480. backUVs?: Vector4;
  133481. updatable?: boolean;
  133482. }, scene?: Nullable<Scene>): Mesh;
  133483. /**
  133484. * Creates a plane polygonal mesh. By default, this is a disc
  133485. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  133486. * * 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
  133487. * * 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
  133488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133491. * @param name defines the name of the mesh
  133492. * @param options defines the options used to create the mesh
  133493. * @param scene defines the hosting scene
  133494. * @returns the plane polygonal mesh
  133495. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  133496. */
  133497. static CreateDisc(name: string, options: {
  133498. radius?: number;
  133499. tessellation?: number;
  133500. arc?: number;
  133501. updatable?: boolean;
  133502. sideOrientation?: number;
  133503. frontUVs?: Vector4;
  133504. backUVs?: Vector4;
  133505. }, scene?: Nullable<Scene>): Mesh;
  133506. /**
  133507. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133508. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133509. * * 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`)
  133510. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133511. * * 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
  133512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133515. * @param name defines the name of the mesh
  133516. * @param options defines the options used to create the mesh
  133517. * @param scene defines the hosting scene
  133518. * @returns the icosahedron mesh
  133519. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133520. */
  133521. static CreateIcoSphere(name: string, options: {
  133522. radius?: number;
  133523. radiusX?: number;
  133524. radiusY?: number;
  133525. radiusZ?: number;
  133526. flat?: boolean;
  133527. subdivisions?: number;
  133528. sideOrientation?: number;
  133529. frontUVs?: Vector4;
  133530. backUVs?: Vector4;
  133531. updatable?: boolean;
  133532. }, scene?: Nullable<Scene>): Mesh;
  133533. /**
  133534. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133535. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  133536. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  133537. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  133538. * * 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
  133539. * * 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
  133540. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133544. * * 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
  133545. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  133546. * * 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
  133547. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  133548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133549. * @param name defines the name of the mesh
  133550. * @param options defines the options used to create the mesh
  133551. * @param scene defines the hosting scene
  133552. * @returns the ribbon mesh
  133553. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  133554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133555. */
  133556. static CreateRibbon(name: string, options: {
  133557. pathArray: Vector3[][];
  133558. closeArray?: boolean;
  133559. closePath?: boolean;
  133560. offset?: number;
  133561. updatable?: boolean;
  133562. sideOrientation?: number;
  133563. frontUVs?: Vector4;
  133564. backUVs?: Vector4;
  133565. instance?: Mesh;
  133566. invertUV?: boolean;
  133567. uvs?: Vector2[];
  133568. colors?: Color4[];
  133569. }, scene?: Nullable<Scene>): Mesh;
  133570. /**
  133571. * Creates a cylinder or a cone mesh
  133572. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  133573. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  133574. * * 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.
  133575. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  133576. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  133577. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  133578. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  133579. * * 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).
  133580. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  133581. * * 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).
  133582. * * 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
  133583. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  133584. * * 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
  133585. * * 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.
  133586. * * If `enclose` is false, a ring surface is one element.
  133587. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  133588. * * 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
  133589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133592. * @param name defines the name of the mesh
  133593. * @param options defines the options used to create the mesh
  133594. * @param scene defines the hosting scene
  133595. * @returns the cylinder mesh
  133596. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  133597. */
  133598. static CreateCylinder(name: string, options: {
  133599. height?: number;
  133600. diameterTop?: number;
  133601. diameterBottom?: number;
  133602. diameter?: number;
  133603. tessellation?: number;
  133604. subdivisions?: number;
  133605. arc?: number;
  133606. faceColors?: Color4[];
  133607. faceUV?: Vector4[];
  133608. updatable?: boolean;
  133609. hasRings?: boolean;
  133610. enclose?: boolean;
  133611. cap?: number;
  133612. sideOrientation?: number;
  133613. frontUVs?: Vector4;
  133614. backUVs?: Vector4;
  133615. }, scene?: Nullable<Scene>): Mesh;
  133616. /**
  133617. * Creates a torus mesh
  133618. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  133619. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  133620. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  133621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133624. * @param name defines the name of the mesh
  133625. * @param options defines the options used to create the mesh
  133626. * @param scene defines the hosting scene
  133627. * @returns the torus mesh
  133628. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  133629. */
  133630. static CreateTorus(name: string, options: {
  133631. diameter?: number;
  133632. thickness?: number;
  133633. tessellation?: number;
  133634. updatable?: boolean;
  133635. sideOrientation?: number;
  133636. frontUVs?: Vector4;
  133637. backUVs?: Vector4;
  133638. }, scene?: Nullable<Scene>): Mesh;
  133639. /**
  133640. * Creates a torus knot mesh
  133641. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133642. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133643. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133644. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133648. * @param name defines the name of the mesh
  133649. * @param options defines the options used to create the mesh
  133650. * @param scene defines the hosting scene
  133651. * @returns the torus knot mesh
  133652. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133653. */
  133654. static CreateTorusKnot(name: string, options: {
  133655. radius?: number;
  133656. tube?: number;
  133657. radialSegments?: number;
  133658. tubularSegments?: number;
  133659. p?: number;
  133660. q?: number;
  133661. updatable?: boolean;
  133662. sideOrientation?: number;
  133663. frontUVs?: Vector4;
  133664. backUVs?: Vector4;
  133665. }, scene?: Nullable<Scene>): Mesh;
  133666. /**
  133667. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133668. * * 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
  133669. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133670. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133671. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133672. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133673. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133674. * * 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
  133675. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133678. * @param name defines the name of the new line system
  133679. * @param options defines the options used to create the line system
  133680. * @param scene defines the hosting scene
  133681. * @returns a new line system mesh
  133682. */
  133683. static CreateLineSystem(name: string, options: {
  133684. lines: Vector3[][];
  133685. updatable?: boolean;
  133686. instance?: Nullable<LinesMesh>;
  133687. colors?: Nullable<Color4[][]>;
  133688. useVertexAlpha?: boolean;
  133689. }, scene: Nullable<Scene>): LinesMesh;
  133690. /**
  133691. * Creates a line mesh
  133692. * 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
  133693. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133694. * * The parameter `points` is an array successive Vector3
  133695. * * 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
  133696. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133697. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133698. * * When updating an instance, remember that only point positions can change, not the number of points
  133699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133701. * @param name defines the name of the new line system
  133702. * @param options defines the options used to create the line system
  133703. * @param scene defines the hosting scene
  133704. * @returns a new line mesh
  133705. */
  133706. static CreateLines(name: string, options: {
  133707. points: Vector3[];
  133708. updatable?: boolean;
  133709. instance?: Nullable<LinesMesh>;
  133710. colors?: Color4[];
  133711. useVertexAlpha?: boolean;
  133712. }, scene?: Nullable<Scene>): LinesMesh;
  133713. /**
  133714. * Creates a dashed line mesh
  133715. * * 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
  133716. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133717. * * The parameter `points` is an array successive Vector3
  133718. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133719. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133720. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133721. * * 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
  133722. * * When updating an instance, remember that only point positions can change, not the number of points
  133723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133724. * @param name defines the name of the mesh
  133725. * @param options defines the options used to create the mesh
  133726. * @param scene defines the hosting scene
  133727. * @returns the dashed line mesh
  133728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133729. */
  133730. static CreateDashedLines(name: string, options: {
  133731. points: Vector3[];
  133732. dashSize?: number;
  133733. gapSize?: number;
  133734. dashNb?: number;
  133735. updatable?: boolean;
  133736. instance?: LinesMesh;
  133737. }, scene?: Nullable<Scene>): LinesMesh;
  133738. /**
  133739. * 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.
  133740. * * 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.
  133741. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133742. * * 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.
  133743. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  133744. * * 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
  133745. * * 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
  133746. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  133747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  133750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133751. * @param name defines the name of the mesh
  133752. * @param options defines the options used to create the mesh
  133753. * @param scene defines the hosting scene
  133754. * @returns the extruded shape mesh
  133755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133757. */
  133758. static ExtrudeShape(name: string, options: {
  133759. shape: Vector3[];
  133760. path: Vector3[];
  133761. scale?: number;
  133762. rotation?: number;
  133763. cap?: number;
  133764. updatable?: boolean;
  133765. sideOrientation?: number;
  133766. frontUVs?: Vector4;
  133767. backUVs?: Vector4;
  133768. instance?: Mesh;
  133769. invertUV?: boolean;
  133770. }, scene?: Nullable<Scene>): Mesh;
  133771. /**
  133772. * Creates an custom extruded shape mesh.
  133773. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  133774. * * 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.
  133775. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133776. * * 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
  133777. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  133778. * * 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
  133779. * * It must returns a float value that will be the scale value applied to the shape on each path point
  133780. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  133781. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  133782. * * 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
  133783. * * 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
  133784. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  133785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133789. * @param name defines the name of the mesh
  133790. * @param options defines the options used to create the mesh
  133791. * @param scene defines the hosting scene
  133792. * @returns the custom extruded shape mesh
  133793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  133794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133796. */
  133797. static ExtrudeShapeCustom(name: string, options: {
  133798. shape: Vector3[];
  133799. path: Vector3[];
  133800. scaleFunction?: any;
  133801. rotationFunction?: any;
  133802. ribbonCloseArray?: boolean;
  133803. ribbonClosePath?: boolean;
  133804. cap?: number;
  133805. updatable?: boolean;
  133806. sideOrientation?: number;
  133807. frontUVs?: Vector4;
  133808. backUVs?: Vector4;
  133809. instance?: Mesh;
  133810. invertUV?: boolean;
  133811. }, scene?: Nullable<Scene>): Mesh;
  133812. /**
  133813. * Creates lathe mesh.
  133814. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133815. * * 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
  133816. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133817. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133818. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133819. * * 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
  133820. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133821. * * 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
  133822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133824. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133826. * @param name defines the name of the mesh
  133827. * @param options defines the options used to create the mesh
  133828. * @param scene defines the hosting scene
  133829. * @returns the lathe mesh
  133830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133831. */
  133832. static CreateLathe(name: string, options: {
  133833. shape: Vector3[];
  133834. radius?: number;
  133835. tessellation?: number;
  133836. clip?: number;
  133837. arc?: number;
  133838. closed?: boolean;
  133839. updatable?: boolean;
  133840. sideOrientation?: number;
  133841. frontUVs?: Vector4;
  133842. backUVs?: Vector4;
  133843. cap?: number;
  133844. invertUV?: boolean;
  133845. }, scene?: Nullable<Scene>): Mesh;
  133846. /**
  133847. * Creates a tiled plane mesh
  133848. * * You can set a limited pattern arrangement with the tiles
  133849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133852. * @param name defines the name of the mesh
  133853. * @param options defines the options used to create the mesh
  133854. * @param scene defines the hosting scene
  133855. * @returns the plane mesh
  133856. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133857. */
  133858. static CreateTiledPlane(name: string, options: {
  133859. pattern?: number;
  133860. tileSize?: number;
  133861. tileWidth?: number;
  133862. tileHeight?: number;
  133863. size?: number;
  133864. width?: number;
  133865. height?: number;
  133866. alignHorizontal?: number;
  133867. alignVertical?: number;
  133868. sideOrientation?: number;
  133869. frontUVs?: Vector4;
  133870. backUVs?: Vector4;
  133871. updatable?: boolean;
  133872. }, scene?: Nullable<Scene>): Mesh;
  133873. /**
  133874. * Creates a plane mesh
  133875. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  133876. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  133877. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  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 CreatePlane(name: string, options: {
  133888. size?: number;
  133889. width?: number;
  133890. height?: number;
  133891. sideOrientation?: number;
  133892. frontUVs?: Vector4;
  133893. backUVs?: Vector4;
  133894. updatable?: boolean;
  133895. sourcePlane?: Plane;
  133896. }, scene?: Nullable<Scene>): Mesh;
  133897. /**
  133898. * Creates a ground mesh
  133899. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  133900. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  133901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133902. * @param name defines the name of the mesh
  133903. * @param options defines the options used to create the mesh
  133904. * @param scene defines the hosting scene
  133905. * @returns the ground mesh
  133906. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  133907. */
  133908. static CreateGround(name: string, options: {
  133909. width?: number;
  133910. height?: number;
  133911. subdivisions?: number;
  133912. subdivisionsX?: number;
  133913. subdivisionsY?: number;
  133914. updatable?: boolean;
  133915. }, scene?: Nullable<Scene>): Mesh;
  133916. /**
  133917. * Creates a tiled ground mesh
  133918. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  133919. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  133920. * * 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
  133921. * * 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
  133922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133923. * @param name defines the name of the mesh
  133924. * @param options defines the options used to create the mesh
  133925. * @param scene defines the hosting scene
  133926. * @returns the tiled ground mesh
  133927. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  133928. */
  133929. static CreateTiledGround(name: string, options: {
  133930. xmin: number;
  133931. zmin: number;
  133932. xmax: number;
  133933. zmax: number;
  133934. subdivisions?: {
  133935. w: number;
  133936. h: number;
  133937. };
  133938. precision?: {
  133939. w: number;
  133940. h: number;
  133941. };
  133942. updatable?: boolean;
  133943. }, scene?: Nullable<Scene>): Mesh;
  133944. /**
  133945. * Creates a ground mesh from a height map
  133946. * * The parameter `url` sets the URL of the height map image resource.
  133947. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  133948. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  133949. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  133950. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  133951. * * 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.
  133952. * * 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).
  133953. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  133954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133955. * @param name defines the name of the mesh
  133956. * @param url defines the url to the height map
  133957. * @param options defines the options used to create the mesh
  133958. * @param scene defines the hosting scene
  133959. * @returns the ground mesh
  133960. * @see https://doc.babylonjs.com/babylon101/height_map
  133961. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  133962. */
  133963. static CreateGroundFromHeightMap(name: string, url: string, options: {
  133964. width?: number;
  133965. height?: number;
  133966. subdivisions?: number;
  133967. minHeight?: number;
  133968. maxHeight?: number;
  133969. colorFilter?: Color3;
  133970. alphaFilter?: number;
  133971. updatable?: boolean;
  133972. onReady?: (mesh: GroundMesh) => void;
  133973. }, scene?: Nullable<Scene>): GroundMesh;
  133974. /**
  133975. * Creates a polygon mesh
  133976. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133977. * * 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
  133978. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133981. * * Remember you can only change the shape positions, not their number when updating a polygon
  133982. * @param name defines the name of the mesh
  133983. * @param options defines the options used to create the mesh
  133984. * @param scene defines the hosting scene
  133985. * @param earcutInjection can be used to inject your own earcut reference
  133986. * @returns the polygon mesh
  133987. */
  133988. static CreatePolygon(name: string, options: {
  133989. shape: Vector3[];
  133990. holes?: Vector3[][];
  133991. depth?: number;
  133992. faceUV?: Vector4[];
  133993. faceColors?: Color4[];
  133994. updatable?: boolean;
  133995. sideOrientation?: number;
  133996. frontUVs?: Vector4;
  133997. backUVs?: Vector4;
  133998. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133999. /**
  134000. * Creates an extruded polygon mesh, with depth in the Y direction.
  134001. * * 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)
  134002. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134003. * @param name defines the name of the mesh
  134004. * @param options defines the options used to create the mesh
  134005. * @param scene defines the hosting scene
  134006. * @param earcutInjection can be used to inject your own earcut reference
  134007. * @returns the polygon mesh
  134008. */
  134009. static ExtrudePolygon(name: string, options: {
  134010. shape: Vector3[];
  134011. holes?: Vector3[][];
  134012. depth?: number;
  134013. faceUV?: Vector4[];
  134014. faceColors?: Color4[];
  134015. updatable?: boolean;
  134016. sideOrientation?: number;
  134017. frontUVs?: Vector4;
  134018. backUVs?: Vector4;
  134019. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134020. /**
  134021. * Creates a tube mesh.
  134022. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134023. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134024. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134025. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134026. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134027. * * 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)
  134028. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134029. * * 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
  134030. * * 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
  134031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134035. * @param name defines the name of the mesh
  134036. * @param options defines the options used to create the mesh
  134037. * @param scene defines the hosting scene
  134038. * @returns the tube mesh
  134039. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134040. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134041. */
  134042. static CreateTube(name: string, options: {
  134043. path: Vector3[];
  134044. radius?: number;
  134045. tessellation?: number;
  134046. radiusFunction?: {
  134047. (i: number, distance: number): number;
  134048. };
  134049. cap?: number;
  134050. arc?: number;
  134051. updatable?: boolean;
  134052. sideOrientation?: number;
  134053. frontUVs?: Vector4;
  134054. backUVs?: Vector4;
  134055. instance?: Mesh;
  134056. invertUV?: boolean;
  134057. }, scene?: Nullable<Scene>): Mesh;
  134058. /**
  134059. * Creates a polyhedron mesh
  134060. * * 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
  134061. * * The parameter `size` (positive float, default 1) sets the polygon size
  134062. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134063. * * 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`
  134064. * * 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
  134065. * * 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)`)
  134066. * * 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
  134067. * * 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
  134068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134071. * @param name defines the name of the mesh
  134072. * @param options defines the options used to create the mesh
  134073. * @param scene defines the hosting scene
  134074. * @returns the polyhedron mesh
  134075. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134076. */
  134077. static CreatePolyhedron(name: string, options: {
  134078. type?: number;
  134079. size?: number;
  134080. sizeX?: number;
  134081. sizeY?: number;
  134082. sizeZ?: number;
  134083. custom?: any;
  134084. faceUV?: Vector4[];
  134085. faceColors?: Color4[];
  134086. flat?: boolean;
  134087. updatable?: boolean;
  134088. sideOrientation?: number;
  134089. frontUVs?: Vector4;
  134090. backUVs?: Vector4;
  134091. }, scene?: Nullable<Scene>): Mesh;
  134092. /**
  134093. * Creates a decal mesh.
  134094. * 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
  134095. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134096. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134097. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134098. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134099. * @param name defines the name of the mesh
  134100. * @param sourceMesh defines the mesh where the decal must be applied
  134101. * @param options defines the options used to create the mesh
  134102. * @param scene defines the hosting scene
  134103. * @returns the decal mesh
  134104. * @see https://doc.babylonjs.com/how_to/decals
  134105. */
  134106. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134107. position?: Vector3;
  134108. normal?: Vector3;
  134109. size?: Vector3;
  134110. angle?: number;
  134111. }): Mesh;
  134112. }
  134113. }
  134114. declare module BABYLON {
  134115. /**
  134116. * A simplifier interface for future simplification implementations
  134117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134118. */
  134119. export interface ISimplifier {
  134120. /**
  134121. * Simplification of a given mesh according to the given settings.
  134122. * Since this requires computation, it is assumed that the function runs async.
  134123. * @param settings The settings of the simplification, including quality and distance
  134124. * @param successCallback A callback that will be called after the mesh was simplified.
  134125. * @param errorCallback in case of an error, this callback will be called. optional.
  134126. */
  134127. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134128. }
  134129. /**
  134130. * Expected simplification settings.
  134131. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134132. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134133. */
  134134. export interface ISimplificationSettings {
  134135. /**
  134136. * Gets or sets the expected quality
  134137. */
  134138. quality: number;
  134139. /**
  134140. * Gets or sets the distance when this optimized version should be used
  134141. */
  134142. distance: number;
  134143. /**
  134144. * Gets an already optimized mesh
  134145. */
  134146. optimizeMesh?: boolean;
  134147. }
  134148. /**
  134149. * Class used to specify simplification options
  134150. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134151. */
  134152. export class SimplificationSettings implements ISimplificationSettings {
  134153. /** expected quality */
  134154. quality: number;
  134155. /** distance when this optimized version should be used */
  134156. distance: number;
  134157. /** already optimized mesh */
  134158. optimizeMesh?: boolean | undefined;
  134159. /**
  134160. * Creates a SimplificationSettings
  134161. * @param quality expected quality
  134162. * @param distance distance when this optimized version should be used
  134163. * @param optimizeMesh already optimized mesh
  134164. */
  134165. constructor(
  134166. /** expected quality */
  134167. quality: number,
  134168. /** distance when this optimized version should be used */
  134169. distance: number,
  134170. /** already optimized mesh */
  134171. optimizeMesh?: boolean | undefined);
  134172. }
  134173. /**
  134174. * Interface used to define a simplification task
  134175. */
  134176. export interface ISimplificationTask {
  134177. /**
  134178. * Array of settings
  134179. */
  134180. settings: Array<ISimplificationSettings>;
  134181. /**
  134182. * Simplification type
  134183. */
  134184. simplificationType: SimplificationType;
  134185. /**
  134186. * Mesh to simplify
  134187. */
  134188. mesh: Mesh;
  134189. /**
  134190. * Callback called on success
  134191. */
  134192. successCallback?: () => void;
  134193. /**
  134194. * Defines if parallel processing can be used
  134195. */
  134196. parallelProcessing: boolean;
  134197. }
  134198. /**
  134199. * Queue used to order the simplification tasks
  134200. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134201. */
  134202. export class SimplificationQueue {
  134203. private _simplificationArray;
  134204. /**
  134205. * Gets a boolean indicating that the process is still running
  134206. */
  134207. running: boolean;
  134208. /**
  134209. * Creates a new queue
  134210. */
  134211. constructor();
  134212. /**
  134213. * Adds a new simplification task
  134214. * @param task defines a task to add
  134215. */
  134216. addTask(task: ISimplificationTask): void;
  134217. /**
  134218. * Execute next task
  134219. */
  134220. executeNext(): void;
  134221. /**
  134222. * Execute a simplification task
  134223. * @param task defines the task to run
  134224. */
  134225. runSimplification(task: ISimplificationTask): void;
  134226. private getSimplifier;
  134227. }
  134228. /**
  134229. * The implemented types of simplification
  134230. * At the moment only Quadratic Error Decimation is implemented
  134231. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134232. */
  134233. export enum SimplificationType {
  134234. /** Quadratic error decimation */
  134235. QUADRATIC = 0
  134236. }
  134237. }
  134238. declare module BABYLON {
  134239. interface Scene {
  134240. /** @hidden (Backing field) */
  134241. _simplificationQueue: SimplificationQueue;
  134242. /**
  134243. * Gets or sets the simplification queue attached to the scene
  134244. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134245. */
  134246. simplificationQueue: SimplificationQueue;
  134247. }
  134248. interface Mesh {
  134249. /**
  134250. * Simplify the mesh according to the given array of settings.
  134251. * Function will return immediately and will simplify async
  134252. * @param settings a collection of simplification settings
  134253. * @param parallelProcessing should all levels calculate parallel or one after the other
  134254. * @param simplificationType the type of simplification to run
  134255. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134256. * @returns the current mesh
  134257. */
  134258. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134259. }
  134260. /**
  134261. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134262. * created in a scene
  134263. */
  134264. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134265. /**
  134266. * The component name helpfull to identify the component in the list of scene components.
  134267. */
  134268. readonly name: string;
  134269. /**
  134270. * The scene the component belongs to.
  134271. */
  134272. scene: Scene;
  134273. /**
  134274. * Creates a new instance of the component for the given scene
  134275. * @param scene Defines the scene to register the component in
  134276. */
  134277. constructor(scene: Scene);
  134278. /**
  134279. * Registers the component in a given scene
  134280. */
  134281. register(): void;
  134282. /**
  134283. * Rebuilds the elements related to this component in case of
  134284. * context lost for instance.
  134285. */
  134286. rebuild(): void;
  134287. /**
  134288. * Disposes the component and the associated ressources
  134289. */
  134290. dispose(): void;
  134291. private _beforeCameraUpdate;
  134292. }
  134293. }
  134294. declare module BABYLON {
  134295. /**
  134296. * Navigation plugin interface to add navigation constrained by a navigation mesh
  134297. */
  134298. export interface INavigationEnginePlugin {
  134299. /**
  134300. * plugin name
  134301. */
  134302. name: string;
  134303. /**
  134304. * Creates a navigation mesh
  134305. * @param meshes array of all the geometry used to compute the navigatio mesh
  134306. * @param parameters bunch of parameters used to filter geometry
  134307. */
  134308. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134309. /**
  134310. * Create a navigation mesh debug mesh
  134311. * @param scene is where the mesh will be added
  134312. * @returns debug display mesh
  134313. */
  134314. createDebugNavMesh(scene: Scene): Mesh;
  134315. /**
  134316. * Get a navigation mesh constrained position, closest to the parameter position
  134317. * @param position world position
  134318. * @returns the closest point to position constrained by the navigation mesh
  134319. */
  134320. getClosestPoint(position: Vector3): Vector3;
  134321. /**
  134322. * Get a navigation mesh constrained position, within a particular radius
  134323. * @param position world position
  134324. * @param maxRadius the maximum distance to the constrained world position
  134325. * @returns the closest point to position constrained by the navigation mesh
  134326. */
  134327. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134328. /**
  134329. * Compute the final position from a segment made of destination-position
  134330. * @param position world position
  134331. * @param destination world position
  134332. * @returns the resulting point along the navmesh
  134333. */
  134334. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134335. /**
  134336. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134337. * @param start world position
  134338. * @param end world position
  134339. * @returns array containing world position composing the path
  134340. */
  134341. computePath(start: Vector3, end: Vector3): Vector3[];
  134342. /**
  134343. * If this plugin is supported
  134344. * @returns true if plugin is supported
  134345. */
  134346. isSupported(): boolean;
  134347. /**
  134348. * Create a new Crowd so you can add agents
  134349. * @param maxAgents the maximum agent count in the crowd
  134350. * @param maxAgentRadius the maximum radius an agent can have
  134351. * @param scene to attach the crowd to
  134352. * @returns the crowd you can add agents to
  134353. */
  134354. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134355. /**
  134356. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134357. * The queries will try to find a solution within those bounds
  134358. * default is (1,1,1)
  134359. * @param extent x,y,z value that define the extent around the queries point of reference
  134360. */
  134361. setDefaultQueryExtent(extent: Vector3): void;
  134362. /**
  134363. * Get the Bounding box extent specified by setDefaultQueryExtent
  134364. * @returns the box extent values
  134365. */
  134366. getDefaultQueryExtent(): Vector3;
  134367. /**
  134368. * Release all resources
  134369. */
  134370. dispose(): void;
  134371. }
  134372. /**
  134373. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  134374. */
  134375. export interface ICrowd {
  134376. /**
  134377. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134378. * You can attach anything to that node. The node position is updated in the scene update tick.
  134379. * @param pos world position that will be constrained by the navigation mesh
  134380. * @param parameters agent parameters
  134381. * @param transform hooked to the agent that will be update by the scene
  134382. * @returns agent index
  134383. */
  134384. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134385. /**
  134386. * Returns the agent position in world space
  134387. * @param index agent index returned by addAgent
  134388. * @returns world space position
  134389. */
  134390. getAgentPosition(index: number): Vector3;
  134391. /**
  134392. * Gets the agent velocity in world space
  134393. * @param index agent index returned by addAgent
  134394. * @returns world space velocity
  134395. */
  134396. getAgentVelocity(index: number): Vector3;
  134397. /**
  134398. * remove a particular agent previously created
  134399. * @param index agent index returned by addAgent
  134400. */
  134401. removeAgent(index: number): void;
  134402. /**
  134403. * get the list of all agents attached to this crowd
  134404. * @returns list of agent indices
  134405. */
  134406. getAgents(): number[];
  134407. /**
  134408. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134409. * @param deltaTime in seconds
  134410. */
  134411. update(deltaTime: number): void;
  134412. /**
  134413. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134414. * @param index agent index returned by addAgent
  134415. * @param destination targeted world position
  134416. */
  134417. agentGoto(index: number, destination: Vector3): void;
  134418. /**
  134419. * Teleport the agent to a new position
  134420. * @param index agent index returned by addAgent
  134421. * @param destination targeted world position
  134422. */
  134423. agentTeleport(index: number, destination: Vector3): void;
  134424. /**
  134425. * Update agent parameters
  134426. * @param index agent index returned by addAgent
  134427. * @param parameters agent parameters
  134428. */
  134429. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134430. /**
  134431. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134432. * The queries will try to find a solution within those bounds
  134433. * default is (1,1,1)
  134434. * @param extent x,y,z value that define the extent around the queries point of reference
  134435. */
  134436. setDefaultQueryExtent(extent: Vector3): void;
  134437. /**
  134438. * Get the Bounding box extent specified by setDefaultQueryExtent
  134439. * @returns the box extent values
  134440. */
  134441. getDefaultQueryExtent(): Vector3;
  134442. /**
  134443. * Release all resources
  134444. */
  134445. dispose(): void;
  134446. }
  134447. /**
  134448. * Configures an agent
  134449. */
  134450. export interface IAgentParameters {
  134451. /**
  134452. * Agent radius. [Limit: >= 0]
  134453. */
  134454. radius: number;
  134455. /**
  134456. * Agent height. [Limit: > 0]
  134457. */
  134458. height: number;
  134459. /**
  134460. * Maximum allowed acceleration. [Limit: >= 0]
  134461. */
  134462. maxAcceleration: number;
  134463. /**
  134464. * Maximum allowed speed. [Limit: >= 0]
  134465. */
  134466. maxSpeed: number;
  134467. /**
  134468. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  134469. */
  134470. collisionQueryRange: number;
  134471. /**
  134472. * The path visibility optimization range. [Limit: > 0]
  134473. */
  134474. pathOptimizationRange: number;
  134475. /**
  134476. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  134477. */
  134478. separationWeight: number;
  134479. }
  134480. /**
  134481. * Configures the navigation mesh creation
  134482. */
  134483. export interface INavMeshParameters {
  134484. /**
  134485. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  134486. */
  134487. cs: number;
  134488. /**
  134489. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  134490. */
  134491. ch: number;
  134492. /**
  134493. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  134494. */
  134495. walkableSlopeAngle: number;
  134496. /**
  134497. * Minimum floor to 'ceiling' height that will still allow the floor area to
  134498. * be considered walkable. [Limit: >= 3] [Units: vx]
  134499. */
  134500. walkableHeight: number;
  134501. /**
  134502. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  134503. */
  134504. walkableClimb: number;
  134505. /**
  134506. * The distance to erode/shrink the walkable area of the heightfield away from
  134507. * obstructions. [Limit: >=0] [Units: vx]
  134508. */
  134509. walkableRadius: number;
  134510. /**
  134511. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  134512. */
  134513. maxEdgeLen: number;
  134514. /**
  134515. * The maximum distance a simplfied contour's border edges should deviate
  134516. * the original raw contour. [Limit: >=0] [Units: vx]
  134517. */
  134518. maxSimplificationError: number;
  134519. /**
  134520. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  134521. */
  134522. minRegionArea: number;
  134523. /**
  134524. * Any regions with a span count smaller than this value will, if possible,
  134525. * be merged with larger regions. [Limit: >=0] [Units: vx]
  134526. */
  134527. mergeRegionArea: number;
  134528. /**
  134529. * The maximum number of vertices allowed for polygons generated during the
  134530. * contour to polygon conversion process. [Limit: >= 3]
  134531. */
  134532. maxVertsPerPoly: number;
  134533. /**
  134534. * Sets the sampling distance to use when generating the detail mesh.
  134535. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  134536. */
  134537. detailSampleDist: number;
  134538. /**
  134539. * The maximum distance the detail mesh surface should deviate from heightfield
  134540. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  134541. */
  134542. detailSampleMaxError: number;
  134543. }
  134544. }
  134545. declare module BABYLON {
  134546. /**
  134547. * RecastJS navigation plugin
  134548. */
  134549. export class RecastJSPlugin implements INavigationEnginePlugin {
  134550. /**
  134551. * Reference to the Recast library
  134552. */
  134553. bjsRECAST: any;
  134554. /**
  134555. * plugin name
  134556. */
  134557. name: string;
  134558. /**
  134559. * the first navmesh created. We might extend this to support multiple navmeshes
  134560. */
  134561. navMesh: any;
  134562. /**
  134563. * Initializes the recastJS plugin
  134564. * @param recastInjection can be used to inject your own recast reference
  134565. */
  134566. constructor(recastInjection?: any);
  134567. /**
  134568. * Creates a navigation mesh
  134569. * @param meshes array of all the geometry used to compute the navigatio mesh
  134570. * @param parameters bunch of parameters used to filter geometry
  134571. */
  134572. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134573. /**
  134574. * Create a navigation mesh debug mesh
  134575. * @param scene is where the mesh will be added
  134576. * @returns debug display mesh
  134577. */
  134578. createDebugNavMesh(scene: Scene): Mesh;
  134579. /**
  134580. * Get a navigation mesh constrained position, closest to the parameter position
  134581. * @param position world position
  134582. * @returns the closest point to position constrained by the navigation mesh
  134583. */
  134584. getClosestPoint(position: Vector3): Vector3;
  134585. /**
  134586. * Get a navigation mesh constrained position, within a particular radius
  134587. * @param position world position
  134588. * @param maxRadius the maximum distance to the constrained world position
  134589. * @returns the closest point to position constrained by the navigation mesh
  134590. */
  134591. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134592. /**
  134593. * Compute the final position from a segment made of destination-position
  134594. * @param position world position
  134595. * @param destination world position
  134596. * @returns the resulting point along the navmesh
  134597. */
  134598. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134599. /**
  134600. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134601. * @param start world position
  134602. * @param end world position
  134603. * @returns array containing world position composing the path
  134604. */
  134605. computePath(start: Vector3, end: Vector3): Vector3[];
  134606. /**
  134607. * Create a new Crowd so you can add agents
  134608. * @param maxAgents the maximum agent count in the crowd
  134609. * @param maxAgentRadius the maximum radius an agent can have
  134610. * @param scene to attach the crowd to
  134611. * @returns the crowd you can add agents to
  134612. */
  134613. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134614. /**
  134615. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134616. * The queries will try to find a solution within those bounds
  134617. * default is (1,1,1)
  134618. * @param extent x,y,z value that define the extent around the queries point of reference
  134619. */
  134620. setDefaultQueryExtent(extent: Vector3): void;
  134621. /**
  134622. * Get the Bounding box extent specified by setDefaultQueryExtent
  134623. * @returns the box extent values
  134624. */
  134625. getDefaultQueryExtent(): Vector3;
  134626. /**
  134627. * Disposes
  134628. */
  134629. dispose(): void;
  134630. /**
  134631. * If this plugin is supported
  134632. * @returns true if plugin is supported
  134633. */
  134634. isSupported(): boolean;
  134635. }
  134636. /**
  134637. * Recast detour crowd implementation
  134638. */
  134639. export class RecastJSCrowd implements ICrowd {
  134640. /**
  134641. * Recast/detour plugin
  134642. */
  134643. bjsRECASTPlugin: RecastJSPlugin;
  134644. /**
  134645. * Link to the detour crowd
  134646. */
  134647. recastCrowd: any;
  134648. /**
  134649. * One transform per agent
  134650. */
  134651. transforms: TransformNode[];
  134652. /**
  134653. * All agents created
  134654. */
  134655. agents: number[];
  134656. /**
  134657. * Link to the scene is kept to unregister the crowd from the scene
  134658. */
  134659. private _scene;
  134660. /**
  134661. * Observer for crowd updates
  134662. */
  134663. private _onBeforeAnimationsObserver;
  134664. /**
  134665. * Constructor
  134666. * @param plugin recastJS plugin
  134667. * @param maxAgents the maximum agent count in the crowd
  134668. * @param maxAgentRadius the maximum radius an agent can have
  134669. * @param scene to attach the crowd to
  134670. * @returns the crowd you can add agents to
  134671. */
  134672. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  134673. /**
  134674. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134675. * You can attach anything to that node. The node position is updated in the scene update tick.
  134676. * @param pos world position that will be constrained by the navigation mesh
  134677. * @param parameters agent parameters
  134678. * @param transform hooked to the agent that will be update by the scene
  134679. * @returns agent index
  134680. */
  134681. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134682. /**
  134683. * Returns the agent position in world space
  134684. * @param index agent index returned by addAgent
  134685. * @returns world space position
  134686. */
  134687. getAgentPosition(index: number): Vector3;
  134688. /**
  134689. * Returns the agent velocity in world space
  134690. * @param index agent index returned by addAgent
  134691. * @returns world space velocity
  134692. */
  134693. getAgentVelocity(index: number): Vector3;
  134694. /**
  134695. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134696. * @param index agent index returned by addAgent
  134697. * @param destination targeted world position
  134698. */
  134699. agentGoto(index: number, destination: Vector3): void;
  134700. /**
  134701. * Teleport the agent to a new position
  134702. * @param index agent index returned by addAgent
  134703. * @param destination targeted world position
  134704. */
  134705. agentTeleport(index: number, destination: Vector3): void;
  134706. /**
  134707. * Update agent parameters
  134708. * @param index agent index returned by addAgent
  134709. * @param parameters agent parameters
  134710. */
  134711. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134712. /**
  134713. * remove a particular agent previously created
  134714. * @param index agent index returned by addAgent
  134715. */
  134716. removeAgent(index: number): void;
  134717. /**
  134718. * get the list of all agents attached to this crowd
  134719. * @returns list of agent indices
  134720. */
  134721. getAgents(): number[];
  134722. /**
  134723. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134724. * @param deltaTime in seconds
  134725. */
  134726. update(deltaTime: number): void;
  134727. /**
  134728. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134729. * The queries will try to find a solution within those bounds
  134730. * default is (1,1,1)
  134731. * @param extent x,y,z value that define the extent around the queries point of reference
  134732. */
  134733. setDefaultQueryExtent(extent: Vector3): void;
  134734. /**
  134735. * Get the Bounding box extent specified by setDefaultQueryExtent
  134736. * @returns the box extent values
  134737. */
  134738. getDefaultQueryExtent(): Vector3;
  134739. /**
  134740. * Release all resources
  134741. */
  134742. dispose(): void;
  134743. }
  134744. }
  134745. declare module BABYLON {
  134746. /**
  134747. * Class used to enable access to IndexedDB
  134748. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  134749. */
  134750. export class Database implements IOfflineProvider {
  134751. private _callbackManifestChecked;
  134752. private _currentSceneUrl;
  134753. private _db;
  134754. private _enableSceneOffline;
  134755. private _enableTexturesOffline;
  134756. private _manifestVersionFound;
  134757. private _mustUpdateRessources;
  134758. private _hasReachedQuota;
  134759. private _isSupported;
  134760. private _idbFactory;
  134761. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  134762. private static IsUASupportingBlobStorage;
  134763. /**
  134764. * Gets a boolean indicating if Database storate is enabled (off by default)
  134765. */
  134766. static IDBStorageEnabled: boolean;
  134767. /**
  134768. * Gets a boolean indicating if scene must be saved in the database
  134769. */
  134770. get enableSceneOffline(): boolean;
  134771. /**
  134772. * Gets a boolean indicating if textures must be saved in the database
  134773. */
  134774. get enableTexturesOffline(): boolean;
  134775. /**
  134776. * Creates a new Database
  134777. * @param urlToScene defines the url to load the scene
  134778. * @param callbackManifestChecked defines the callback to use when manifest is checked
  134779. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  134780. */
  134781. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  134782. private static _ParseURL;
  134783. private static _ReturnFullUrlLocation;
  134784. private _checkManifestFile;
  134785. /**
  134786. * Open the database and make it available
  134787. * @param successCallback defines the callback to call on success
  134788. * @param errorCallback defines the callback to call on error
  134789. */
  134790. open(successCallback: () => void, errorCallback: () => void): void;
  134791. /**
  134792. * Loads an image from the database
  134793. * @param url defines the url to load from
  134794. * @param image defines the target DOM image
  134795. */
  134796. loadImage(url: string, image: HTMLImageElement): void;
  134797. private _loadImageFromDBAsync;
  134798. private _saveImageIntoDBAsync;
  134799. private _checkVersionFromDB;
  134800. private _loadVersionFromDBAsync;
  134801. private _saveVersionIntoDBAsync;
  134802. /**
  134803. * Loads a file from database
  134804. * @param url defines the URL to load from
  134805. * @param sceneLoaded defines a callback to call on success
  134806. * @param progressCallBack defines a callback to call when progress changed
  134807. * @param errorCallback defines a callback to call on error
  134808. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  134809. */
  134810. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  134811. private _loadFileAsync;
  134812. private _saveFileAsync;
  134813. /**
  134814. * Validates if xhr data is correct
  134815. * @param xhr defines the request to validate
  134816. * @param dataType defines the expected data type
  134817. * @returns true if data is correct
  134818. */
  134819. private static _ValidateXHRData;
  134820. }
  134821. }
  134822. declare module BABYLON {
  134823. /** @hidden */
  134824. export var gpuUpdateParticlesPixelShader: {
  134825. name: string;
  134826. shader: string;
  134827. };
  134828. }
  134829. declare module BABYLON {
  134830. /** @hidden */
  134831. export var gpuUpdateParticlesVertexShader: {
  134832. name: string;
  134833. shader: string;
  134834. };
  134835. }
  134836. declare module BABYLON {
  134837. /** @hidden */
  134838. export var clipPlaneFragmentDeclaration2: {
  134839. name: string;
  134840. shader: string;
  134841. };
  134842. }
  134843. declare module BABYLON {
  134844. /** @hidden */
  134845. export var gpuRenderParticlesPixelShader: {
  134846. name: string;
  134847. shader: string;
  134848. };
  134849. }
  134850. declare module BABYLON {
  134851. /** @hidden */
  134852. export var clipPlaneVertexDeclaration2: {
  134853. name: string;
  134854. shader: string;
  134855. };
  134856. }
  134857. declare module BABYLON {
  134858. /** @hidden */
  134859. export var gpuRenderParticlesVertexShader: {
  134860. name: string;
  134861. shader: string;
  134862. };
  134863. }
  134864. declare module BABYLON {
  134865. /**
  134866. * This represents a GPU particle system in Babylon
  134867. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  134868. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  134869. */
  134870. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  134871. /**
  134872. * The layer mask we are rendering the particles through.
  134873. */
  134874. layerMask: number;
  134875. private _capacity;
  134876. private _activeCount;
  134877. private _currentActiveCount;
  134878. private _accumulatedCount;
  134879. private _renderEffect;
  134880. private _updateEffect;
  134881. private _buffer0;
  134882. private _buffer1;
  134883. private _spriteBuffer;
  134884. private _updateVAO;
  134885. private _renderVAO;
  134886. private _targetIndex;
  134887. private _sourceBuffer;
  134888. private _targetBuffer;
  134889. private _engine;
  134890. private _currentRenderId;
  134891. private _started;
  134892. private _stopped;
  134893. private _timeDelta;
  134894. private _randomTexture;
  134895. private _randomTexture2;
  134896. private _attributesStrideSize;
  134897. private _updateEffectOptions;
  134898. private _randomTextureSize;
  134899. private _actualFrame;
  134900. private readonly _rawTextureWidth;
  134901. /**
  134902. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  134903. */
  134904. static get IsSupported(): boolean;
  134905. /**
  134906. * An event triggered when the system is disposed.
  134907. */
  134908. onDisposeObservable: Observable<GPUParticleSystem>;
  134909. /**
  134910. * Gets the maximum number of particles active at the same time.
  134911. * @returns The max number of active particles.
  134912. */
  134913. getCapacity(): number;
  134914. /**
  134915. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  134916. * to override the particles.
  134917. */
  134918. forceDepthWrite: boolean;
  134919. /**
  134920. * Gets or set the number of active particles
  134921. */
  134922. get activeParticleCount(): number;
  134923. set activeParticleCount(value: number);
  134924. private _preWarmDone;
  134925. /**
  134926. * Is this system ready to be used/rendered
  134927. * @return true if the system is ready
  134928. */
  134929. isReady(): boolean;
  134930. /**
  134931. * Gets if the system has been started. (Note: this will still be true after stop is called)
  134932. * @returns True if it has been started, otherwise false.
  134933. */
  134934. isStarted(): boolean;
  134935. /**
  134936. * Starts the particle system and begins to emit
  134937. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  134938. */
  134939. start(delay?: number): void;
  134940. /**
  134941. * Stops the particle system.
  134942. */
  134943. stop(): void;
  134944. /**
  134945. * Remove all active particles
  134946. */
  134947. reset(): void;
  134948. /**
  134949. * Returns the string "GPUParticleSystem"
  134950. * @returns a string containing the class name
  134951. */
  134952. getClassName(): string;
  134953. private _colorGradientsTexture;
  134954. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  134955. /**
  134956. * Adds a new color gradient
  134957. * @param gradient defines the gradient to use (between 0 and 1)
  134958. * @param color1 defines the color to affect to the specified gradient
  134959. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  134960. * @returns the current particle system
  134961. */
  134962. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  134963. /**
  134964. * Remove a specific color gradient
  134965. * @param gradient defines the gradient to remove
  134966. * @returns the current particle system
  134967. */
  134968. removeColorGradient(gradient: number): GPUParticleSystem;
  134969. private _angularSpeedGradientsTexture;
  134970. private _sizeGradientsTexture;
  134971. private _velocityGradientsTexture;
  134972. private _limitVelocityGradientsTexture;
  134973. private _dragGradientsTexture;
  134974. private _addFactorGradient;
  134975. /**
  134976. * Adds a new size gradient
  134977. * @param gradient defines the gradient to use (between 0 and 1)
  134978. * @param factor defines the size factor to affect to the specified gradient
  134979. * @returns the current particle system
  134980. */
  134981. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  134982. /**
  134983. * Remove a specific size gradient
  134984. * @param gradient defines the gradient to remove
  134985. * @returns the current particle system
  134986. */
  134987. removeSizeGradient(gradient: number): GPUParticleSystem;
  134988. /**
  134989. * Adds a new angular speed gradient
  134990. * @param gradient defines the gradient to use (between 0 and 1)
  134991. * @param factor defines the angular speed to affect to the specified gradient
  134992. * @returns the current particle system
  134993. */
  134994. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  134995. /**
  134996. * Remove a specific angular speed gradient
  134997. * @param gradient defines the gradient to remove
  134998. * @returns the current particle system
  134999. */
  135000. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135001. /**
  135002. * Adds a new velocity gradient
  135003. * @param gradient defines the gradient to use (between 0 and 1)
  135004. * @param factor defines the velocity to affect to the specified gradient
  135005. * @returns the current particle system
  135006. */
  135007. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135008. /**
  135009. * Remove a specific velocity gradient
  135010. * @param gradient defines the gradient to remove
  135011. * @returns the current particle system
  135012. */
  135013. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135014. /**
  135015. * Adds a new limit velocity gradient
  135016. * @param gradient defines the gradient to use (between 0 and 1)
  135017. * @param factor defines the limit velocity value to affect to the specified gradient
  135018. * @returns the current particle system
  135019. */
  135020. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135021. /**
  135022. * Remove a specific limit velocity gradient
  135023. * @param gradient defines the gradient to remove
  135024. * @returns the current particle system
  135025. */
  135026. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135027. /**
  135028. * Adds a new drag gradient
  135029. * @param gradient defines the gradient to use (between 0 and 1)
  135030. * @param factor defines the drag value to affect to the specified gradient
  135031. * @returns the current particle system
  135032. */
  135033. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135034. /**
  135035. * Remove a specific drag gradient
  135036. * @param gradient defines the gradient to remove
  135037. * @returns the current particle system
  135038. */
  135039. removeDragGradient(gradient: number): GPUParticleSystem;
  135040. /**
  135041. * Not supported by GPUParticleSystem
  135042. * @param gradient defines the gradient to use (between 0 and 1)
  135043. * @param factor defines the emit rate value to affect to the specified gradient
  135044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135045. * @returns the current particle system
  135046. */
  135047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135048. /**
  135049. * Not supported by GPUParticleSystem
  135050. * @param gradient defines the gradient to remove
  135051. * @returns the current particle system
  135052. */
  135053. removeEmitRateGradient(gradient: number): IParticleSystem;
  135054. /**
  135055. * Not supported by GPUParticleSystem
  135056. * @param gradient defines the gradient to use (between 0 and 1)
  135057. * @param factor defines the start size value to affect to the specified gradient
  135058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135059. * @returns the current particle system
  135060. */
  135061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135062. /**
  135063. * Not supported by GPUParticleSystem
  135064. * @param gradient defines the gradient to remove
  135065. * @returns the current particle system
  135066. */
  135067. removeStartSizeGradient(gradient: number): IParticleSystem;
  135068. /**
  135069. * Not supported by GPUParticleSystem
  135070. * @param gradient defines the gradient to use (between 0 and 1)
  135071. * @param min defines the color remap minimal range
  135072. * @param max defines the color remap maximal range
  135073. * @returns the current particle system
  135074. */
  135075. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135076. /**
  135077. * Not supported by GPUParticleSystem
  135078. * @param gradient defines the gradient to remove
  135079. * @returns the current particle system
  135080. */
  135081. removeColorRemapGradient(): IParticleSystem;
  135082. /**
  135083. * Not supported by GPUParticleSystem
  135084. * @param gradient defines the gradient to use (between 0 and 1)
  135085. * @param min defines the alpha remap minimal range
  135086. * @param max defines the alpha remap maximal range
  135087. * @returns the current particle system
  135088. */
  135089. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135090. /**
  135091. * Not supported by GPUParticleSystem
  135092. * @param gradient defines the gradient to remove
  135093. * @returns the current particle system
  135094. */
  135095. removeAlphaRemapGradient(): IParticleSystem;
  135096. /**
  135097. * Not supported by GPUParticleSystem
  135098. * @param gradient defines the gradient to use (between 0 and 1)
  135099. * @param color defines the color to affect to the specified gradient
  135100. * @returns the current particle system
  135101. */
  135102. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135103. /**
  135104. * Not supported by GPUParticleSystem
  135105. * @param gradient defines the gradient to remove
  135106. * @returns the current particle system
  135107. */
  135108. removeRampGradient(): IParticleSystem;
  135109. /**
  135110. * Not supported by GPUParticleSystem
  135111. * @returns the list of ramp gradients
  135112. */
  135113. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135114. /**
  135115. * Not supported by GPUParticleSystem
  135116. * Gets or sets a boolean indicating that ramp gradients must be used
  135117. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135118. */
  135119. get useRampGradients(): boolean;
  135120. set useRampGradients(value: boolean);
  135121. /**
  135122. * Not supported by GPUParticleSystem
  135123. * @param gradient defines the gradient to use (between 0 and 1)
  135124. * @param factor defines the life time factor to affect to the specified gradient
  135125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135126. * @returns the current particle system
  135127. */
  135128. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135129. /**
  135130. * Not supported by GPUParticleSystem
  135131. * @param gradient defines the gradient to remove
  135132. * @returns the current particle system
  135133. */
  135134. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135135. /**
  135136. * Instantiates a GPU particle system.
  135137. * 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.
  135138. * @param name The name of the particle system
  135139. * @param options The options used to create the system
  135140. * @param scene The scene the particle system belongs to
  135141. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135142. */
  135143. constructor(name: string, options: Partial<{
  135144. capacity: number;
  135145. randomTextureSize: number;
  135146. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135147. protected _reset(): void;
  135148. private _createUpdateVAO;
  135149. private _createRenderVAO;
  135150. private _initialize;
  135151. /** @hidden */
  135152. _recreateUpdateEffect(): void;
  135153. /** @hidden */
  135154. _recreateRenderEffect(): void;
  135155. /**
  135156. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135157. * @param preWarm defines if we are in the pre-warmimg phase
  135158. */
  135159. animate(preWarm?: boolean): void;
  135160. private _createFactorGradientTexture;
  135161. private _createSizeGradientTexture;
  135162. private _createAngularSpeedGradientTexture;
  135163. private _createVelocityGradientTexture;
  135164. private _createLimitVelocityGradientTexture;
  135165. private _createDragGradientTexture;
  135166. private _createColorGradientTexture;
  135167. /**
  135168. * Renders the particle system in its current state
  135169. * @param preWarm defines if the system should only update the particles but not render them
  135170. * @returns the current number of particles
  135171. */
  135172. render(preWarm?: boolean): number;
  135173. /**
  135174. * Rebuilds the particle system
  135175. */
  135176. rebuild(): void;
  135177. private _releaseBuffers;
  135178. private _releaseVAOs;
  135179. /**
  135180. * Disposes the particle system and free the associated resources
  135181. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135182. */
  135183. dispose(disposeTexture?: boolean): void;
  135184. /**
  135185. * Clones the particle system.
  135186. * @param name The name of the cloned object
  135187. * @param newEmitter The new emitter to use
  135188. * @returns the cloned particle system
  135189. */
  135190. clone(name: string, newEmitter: any): GPUParticleSystem;
  135191. /**
  135192. * Serializes the particle system to a JSON object.
  135193. * @returns the JSON object
  135194. */
  135195. serialize(): any;
  135196. /**
  135197. * Parses a JSON object to create a GPU particle system.
  135198. * @param parsedParticleSystem The JSON object to parse
  135199. * @param scene The scene to create the particle system in
  135200. * @param rootUrl The root url to use to load external dependencies like texture
  135201. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135202. * @returns the parsed GPU particle system
  135203. */
  135204. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135205. }
  135206. }
  135207. declare module BABYLON {
  135208. /**
  135209. * Represents a set of particle systems working together to create a specific effect
  135210. */
  135211. export class ParticleSystemSet implements IDisposable {
  135212. /**
  135213. * Gets or sets base Assets URL
  135214. */
  135215. static BaseAssetsUrl: string;
  135216. private _emitterCreationOptions;
  135217. private _emitterNode;
  135218. /**
  135219. * Gets the particle system list
  135220. */
  135221. systems: IParticleSystem[];
  135222. /**
  135223. * Gets the emitter node used with this set
  135224. */
  135225. get emitterNode(): Nullable<TransformNode>;
  135226. /**
  135227. * Creates a new emitter mesh as a sphere
  135228. * @param options defines the options used to create the sphere
  135229. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135230. * @param scene defines the hosting scene
  135231. */
  135232. setEmitterAsSphere(options: {
  135233. diameter: number;
  135234. segments: number;
  135235. color: Color3;
  135236. }, renderingGroupId: number, scene: Scene): void;
  135237. /**
  135238. * Starts all particle systems of the set
  135239. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135240. */
  135241. start(emitter?: AbstractMesh): void;
  135242. /**
  135243. * Release all associated resources
  135244. */
  135245. dispose(): void;
  135246. /**
  135247. * Serialize the set into a JSON compatible object
  135248. * @returns a JSON compatible representation of the set
  135249. */
  135250. serialize(): any;
  135251. /**
  135252. * Parse a new ParticleSystemSet from a serialized source
  135253. * @param data defines a JSON compatible representation of the set
  135254. * @param scene defines the hosting scene
  135255. * @param gpu defines if we want GPU particles or CPU particles
  135256. * @returns a new ParticleSystemSet
  135257. */
  135258. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135259. }
  135260. }
  135261. declare module BABYLON {
  135262. /**
  135263. * This class is made for on one-liner static method to help creating particle system set.
  135264. */
  135265. export class ParticleHelper {
  135266. /**
  135267. * Gets or sets base Assets URL
  135268. */
  135269. static BaseAssetsUrl: string;
  135270. /**
  135271. * Create a default particle system that you can tweak
  135272. * @param emitter defines the emitter to use
  135273. * @param capacity defines the system capacity (default is 500 particles)
  135274. * @param scene defines the hosting scene
  135275. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135276. * @returns the new Particle system
  135277. */
  135278. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135279. /**
  135280. * This is the main static method (one-liner) of this helper to create different particle systems
  135281. * @param type This string represents the type to the particle system to create
  135282. * @param scene The scene where the particle system should live
  135283. * @param gpu If the system will use gpu
  135284. * @returns the ParticleSystemSet created
  135285. */
  135286. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135287. /**
  135288. * Static function used to export a particle system to a ParticleSystemSet variable.
  135289. * Please note that the emitter shape is not exported
  135290. * @param systems defines the particle systems to export
  135291. * @returns the created particle system set
  135292. */
  135293. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  135294. }
  135295. }
  135296. declare module BABYLON {
  135297. interface Engine {
  135298. /**
  135299. * Create an effect to use with particle systems.
  135300. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  135301. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  135302. * @param uniformsNames defines a list of attribute names
  135303. * @param samplers defines an array of string used to represent textures
  135304. * @param defines defines the string containing the defines to use to compile the shaders
  135305. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  135306. * @param onCompiled defines a function to call when the effect creation is successful
  135307. * @param onError defines a function to call when the effect creation has failed
  135308. * @returns the new Effect
  135309. */
  135310. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  135311. }
  135312. interface Mesh {
  135313. /**
  135314. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  135315. * @returns an array of IParticleSystem
  135316. */
  135317. getEmittedParticleSystems(): IParticleSystem[];
  135318. /**
  135319. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  135320. * @returns an array of IParticleSystem
  135321. */
  135322. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  135323. }
  135324. /**
  135325. * @hidden
  135326. */
  135327. export var _IDoNeedToBeInTheBuild: number;
  135328. }
  135329. declare module BABYLON {
  135330. /** Defines the 4 color options */
  135331. export enum PointColor {
  135332. /** color value */
  135333. Color = 2,
  135334. /** uv value */
  135335. UV = 1,
  135336. /** random value */
  135337. Random = 0,
  135338. /** stated value */
  135339. Stated = 3
  135340. }
  135341. /**
  135342. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  135343. * 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.
  135344. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  135345. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  135346. *
  135347. * Full documentation here : TO BE ENTERED
  135348. */
  135349. export class PointsCloudSystem implements IDisposable {
  135350. /**
  135351. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  135352. * Example : var p = SPS.particles[i];
  135353. */
  135354. particles: CloudPoint[];
  135355. /**
  135356. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  135357. */
  135358. nbParticles: number;
  135359. /**
  135360. * This a counter for your own usage. It's not set by any SPS functions.
  135361. */
  135362. counter: number;
  135363. /**
  135364. * The PCS name. This name is also given to the underlying mesh.
  135365. */
  135366. name: string;
  135367. /**
  135368. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  135369. */
  135370. mesh: Mesh;
  135371. /**
  135372. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  135373. * Please read :
  135374. */
  135375. vars: any;
  135376. /**
  135377. * @hidden
  135378. */
  135379. _size: number;
  135380. private _scene;
  135381. private _promises;
  135382. private _positions;
  135383. private _indices;
  135384. private _normals;
  135385. private _colors;
  135386. private _uvs;
  135387. private _indices32;
  135388. private _positions32;
  135389. private _colors32;
  135390. private _uvs32;
  135391. private _updatable;
  135392. private _isVisibilityBoxLocked;
  135393. private _alwaysVisible;
  135394. private _groups;
  135395. private _groupCounter;
  135396. private _computeParticleColor;
  135397. private _computeParticleTexture;
  135398. private _computeParticleRotation;
  135399. private _computeBoundingBox;
  135400. private _isReady;
  135401. /**
  135402. * Creates a PCS (Points Cloud System) object
  135403. * @param name (String) is the PCS name, this will be the underlying mesh name
  135404. * @param pointSize (number) is the size for each point
  135405. * @param scene (Scene) is the scene in which the PCS is added
  135406. * @param options defines the options of the PCS e.g.
  135407. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  135408. */
  135409. constructor(name: string, pointSize: number, scene: Scene, options?: {
  135410. updatable?: boolean;
  135411. });
  135412. /**
  135413. * Builds the PCS underlying mesh. Returns a standard Mesh.
  135414. * If no points were added to the PCS, the returned mesh is just a single point.
  135415. * @returns a promise for the created mesh
  135416. */
  135417. buildMeshAsync(): Promise<Mesh>;
  135418. /**
  135419. * @hidden
  135420. */
  135421. private _buildMesh;
  135422. private _addParticle;
  135423. private _randomUnitVector;
  135424. private _getColorIndicesForCoord;
  135425. private _setPointsColorOrUV;
  135426. private _colorFromTexture;
  135427. private _calculateDensity;
  135428. /**
  135429. * Adds points to the PCS in random positions within a unit sphere
  135430. * @param nb (positive integer) the number of particles to be created from this model
  135431. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  135432. * @returns the number of groups in the system
  135433. */
  135434. addPoints(nb: number, pointFunction?: any): number;
  135435. /**
  135436. * Adds points to the PCS from the surface of the model shape
  135437. * @param mesh is any Mesh object that will be used as a surface model for the points
  135438. * @param nb (positive integer) the number of particles to be created from this model
  135439. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135440. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135441. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135442. * @returns the number of groups in the system
  135443. */
  135444. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135445. /**
  135446. * Adds points to the PCS inside the model shape
  135447. * @param mesh is any Mesh object that will be used as a surface model for the points
  135448. * @param nb (positive integer) the number of particles to be created from this model
  135449. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135450. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135451. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135452. * @returns the number of groups in the system
  135453. */
  135454. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135455. /**
  135456. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  135457. * This method calls `updateParticle()` for each particle of the SPS.
  135458. * For an animated SPS, it is usually called within the render loop.
  135459. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  135460. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  135461. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  135462. * @returns the PCS.
  135463. */
  135464. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  135465. /**
  135466. * Disposes the PCS.
  135467. */
  135468. dispose(): void;
  135469. /**
  135470. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  135471. * doc :
  135472. * @returns the PCS.
  135473. */
  135474. refreshVisibleSize(): PointsCloudSystem;
  135475. /**
  135476. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  135477. * @param size the size (float) of the visibility box
  135478. * note : this doesn't lock the PCS mesh bounding box.
  135479. * doc :
  135480. */
  135481. setVisibilityBox(size: number): void;
  135482. /**
  135483. * Gets whether the PCS is always visible or not
  135484. * doc :
  135485. */
  135486. get isAlwaysVisible(): boolean;
  135487. /**
  135488. * Sets the PCS as always visible or not
  135489. * doc :
  135490. */
  135491. set isAlwaysVisible(val: boolean);
  135492. /**
  135493. * Tells to `setParticles()` to compute the particle rotations or not
  135494. * Default value : false. The PCS is faster when it's set to false
  135495. * Note : particle rotations are only applied to parent particles
  135496. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  135497. */
  135498. set computeParticleRotation(val: boolean);
  135499. /**
  135500. * Tells to `setParticles()` to compute the particle colors or not.
  135501. * Default value : true. The PCS is faster when it's set to false.
  135502. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135503. */
  135504. set computeParticleColor(val: boolean);
  135505. set computeParticleTexture(val: boolean);
  135506. /**
  135507. * Gets if `setParticles()` computes the particle colors or not.
  135508. * Default value : false. The PCS is faster when it's set to false.
  135509. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135510. */
  135511. get computeParticleColor(): boolean;
  135512. /**
  135513. * Gets if `setParticles()` computes the particle textures or not.
  135514. * Default value : false. The PCS is faster when it's set to false.
  135515. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  135516. */
  135517. get computeParticleTexture(): boolean;
  135518. /**
  135519. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  135520. */
  135521. set computeBoundingBox(val: boolean);
  135522. /**
  135523. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  135524. */
  135525. get computeBoundingBox(): boolean;
  135526. /**
  135527. * This function does nothing. It may be overwritten to set all the particle first values.
  135528. * The PCS doesn't call this function, you may have to call it by your own.
  135529. * doc :
  135530. */
  135531. initParticles(): void;
  135532. /**
  135533. * This function does nothing. It may be overwritten to recycle a particle
  135534. * The PCS doesn't call this function, you can to call it
  135535. * doc :
  135536. * @param particle The particle to recycle
  135537. * @returns the recycled particle
  135538. */
  135539. recycleParticle(particle: CloudPoint): CloudPoint;
  135540. /**
  135541. * Updates a particle : this function should be overwritten by the user.
  135542. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  135543. * doc :
  135544. * @example : just set a particle position or velocity and recycle conditions
  135545. * @param particle The particle to update
  135546. * @returns the updated particle
  135547. */
  135548. updateParticle(particle: CloudPoint): CloudPoint;
  135549. /**
  135550. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  135551. * This does nothing and may be overwritten by the user.
  135552. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135553. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135554. * @param update the boolean update value actually passed to setParticles()
  135555. */
  135556. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135557. /**
  135558. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  135559. * This will be passed three parameters.
  135560. * This does nothing and may be overwritten by the user.
  135561. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135562. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135563. * @param update the boolean update value actually passed to setParticles()
  135564. */
  135565. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135566. }
  135567. }
  135568. declare module BABYLON {
  135569. /**
  135570. * Represents one particle of a points cloud system.
  135571. */
  135572. export class CloudPoint {
  135573. /**
  135574. * particle global index
  135575. */
  135576. idx: number;
  135577. /**
  135578. * The color of the particle
  135579. */
  135580. color: Nullable<Color4>;
  135581. /**
  135582. * The world space position of the particle.
  135583. */
  135584. position: Vector3;
  135585. /**
  135586. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  135587. */
  135588. rotation: Vector3;
  135589. /**
  135590. * The world space rotation quaternion of the particle.
  135591. */
  135592. rotationQuaternion: Nullable<Quaternion>;
  135593. /**
  135594. * The uv of the particle.
  135595. */
  135596. uv: Nullable<Vector2>;
  135597. /**
  135598. * The current speed of the particle.
  135599. */
  135600. velocity: Vector3;
  135601. /**
  135602. * The pivot point in the particle local space.
  135603. */
  135604. pivot: Vector3;
  135605. /**
  135606. * Must the particle be translated from its pivot point in its local space ?
  135607. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  135608. * Default : false
  135609. */
  135610. translateFromPivot: boolean;
  135611. /**
  135612. * Index of this particle in the global "positions" array (Internal use)
  135613. * @hidden
  135614. */
  135615. _pos: number;
  135616. /**
  135617. * @hidden Index of this particle in the global "indices" array (Internal use)
  135618. */
  135619. _ind: number;
  135620. /**
  135621. * Group this particle belongs to
  135622. */
  135623. _group: PointsGroup;
  135624. /**
  135625. * Group id of this particle
  135626. */
  135627. groupId: number;
  135628. /**
  135629. * Index of the particle in its group id (Internal use)
  135630. */
  135631. idxInGroup: number;
  135632. /**
  135633. * @hidden Particle BoundingInfo object (Internal use)
  135634. */
  135635. _boundingInfo: BoundingInfo;
  135636. /**
  135637. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  135638. */
  135639. _pcs: PointsCloudSystem;
  135640. /**
  135641. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  135642. */
  135643. _stillInvisible: boolean;
  135644. /**
  135645. * @hidden Last computed particle rotation matrix
  135646. */
  135647. _rotationMatrix: number[];
  135648. /**
  135649. * Parent particle Id, if any.
  135650. * Default null.
  135651. */
  135652. parentId: Nullable<number>;
  135653. /**
  135654. * @hidden Internal global position in the PCS.
  135655. */
  135656. _globalPosition: Vector3;
  135657. /**
  135658. * Creates a Point Cloud object.
  135659. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  135660. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  135661. * @param group (PointsGroup) is the group the particle belongs to
  135662. * @param groupId (integer) is the group identifier in the PCS.
  135663. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  135664. * @param pcs defines the PCS it is associated to
  135665. */
  135666. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  135667. /**
  135668. * get point size
  135669. */
  135670. get size(): Vector3;
  135671. /**
  135672. * Set point size
  135673. */
  135674. set size(scale: Vector3);
  135675. /**
  135676. * Legacy support, changed quaternion to rotationQuaternion
  135677. */
  135678. get quaternion(): Nullable<Quaternion>;
  135679. /**
  135680. * Legacy support, changed quaternion to rotationQuaternion
  135681. */
  135682. set quaternion(q: Nullable<Quaternion>);
  135683. /**
  135684. * Returns a boolean. True if the particle intersects a mesh, else false
  135685. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  135686. * @param target is the object (point or mesh) what the intersection is computed against
  135687. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  135688. * @returns true if it intersects
  135689. */
  135690. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  135691. /**
  135692. * get the rotation matrix of the particle
  135693. * @hidden
  135694. */
  135695. getRotationMatrix(m: Matrix): void;
  135696. }
  135697. /**
  135698. * Represents a group of points in a points cloud system
  135699. * * PCS internal tool, don't use it manually.
  135700. */
  135701. export class PointsGroup {
  135702. /**
  135703. * The group id
  135704. * @hidden
  135705. */
  135706. groupID: number;
  135707. /**
  135708. * image data for group (internal use)
  135709. * @hidden
  135710. */
  135711. _groupImageData: Nullable<ArrayBufferView>;
  135712. /**
  135713. * Image Width (internal use)
  135714. * @hidden
  135715. */
  135716. _groupImgWidth: number;
  135717. /**
  135718. * Image Height (internal use)
  135719. * @hidden
  135720. */
  135721. _groupImgHeight: number;
  135722. /**
  135723. * Custom position function (internal use)
  135724. * @hidden
  135725. */
  135726. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  135727. /**
  135728. * density per facet for surface points
  135729. * @hidden
  135730. */
  135731. _groupDensity: number[];
  135732. /**
  135733. * Only when points are colored by texture carries pointer to texture list array
  135734. * @hidden
  135735. */
  135736. _textureNb: number;
  135737. /**
  135738. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  135739. * PCS internal tool, don't use it manually.
  135740. * @hidden
  135741. */
  135742. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  135743. }
  135744. }
  135745. declare module BABYLON {
  135746. interface Scene {
  135747. /** @hidden (Backing field) */
  135748. _physicsEngine: Nullable<IPhysicsEngine>;
  135749. /** @hidden */
  135750. _physicsTimeAccumulator: number;
  135751. /**
  135752. * Gets the current physics engine
  135753. * @returns a IPhysicsEngine or null if none attached
  135754. */
  135755. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  135756. /**
  135757. * Enables physics to the current scene
  135758. * @param gravity defines the scene's gravity for the physics engine
  135759. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  135760. * @return a boolean indicating if the physics engine was initialized
  135761. */
  135762. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  135763. /**
  135764. * Disables and disposes the physics engine associated with the scene
  135765. */
  135766. disablePhysicsEngine(): void;
  135767. /**
  135768. * Gets a boolean indicating if there is an active physics engine
  135769. * @returns a boolean indicating if there is an active physics engine
  135770. */
  135771. isPhysicsEnabled(): boolean;
  135772. /**
  135773. * Deletes a physics compound impostor
  135774. * @param compound defines the compound to delete
  135775. */
  135776. deleteCompoundImpostor(compound: any): void;
  135777. /**
  135778. * An event triggered when physic simulation is about to be run
  135779. */
  135780. onBeforePhysicsObservable: Observable<Scene>;
  135781. /**
  135782. * An event triggered when physic simulation has been done
  135783. */
  135784. onAfterPhysicsObservable: Observable<Scene>;
  135785. }
  135786. interface AbstractMesh {
  135787. /** @hidden */
  135788. _physicsImpostor: Nullable<PhysicsImpostor>;
  135789. /**
  135790. * Gets or sets impostor used for physic simulation
  135791. * @see http://doc.babylonjs.com/features/physics_engine
  135792. */
  135793. physicsImpostor: Nullable<PhysicsImpostor>;
  135794. /**
  135795. * Gets the current physics impostor
  135796. * @see http://doc.babylonjs.com/features/physics_engine
  135797. * @returns a physics impostor or null
  135798. */
  135799. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  135800. /** Apply a physic impulse to the mesh
  135801. * @param force defines the force to apply
  135802. * @param contactPoint defines where to apply the force
  135803. * @returns the current mesh
  135804. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135805. */
  135806. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  135807. /**
  135808. * Creates a physic joint between two meshes
  135809. * @param otherMesh defines the other mesh to use
  135810. * @param pivot1 defines the pivot to use on this mesh
  135811. * @param pivot2 defines the pivot to use on the other mesh
  135812. * @param options defines additional options (can be plugin dependent)
  135813. * @returns the current mesh
  135814. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  135815. */
  135816. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  135817. /** @hidden */
  135818. _disposePhysicsObserver: Nullable<Observer<Node>>;
  135819. }
  135820. /**
  135821. * Defines the physics engine scene component responsible to manage a physics engine
  135822. */
  135823. export class PhysicsEngineSceneComponent implements ISceneComponent {
  135824. /**
  135825. * The component name helpful to identify the component in the list of scene components.
  135826. */
  135827. readonly name: string;
  135828. /**
  135829. * The scene the component belongs to.
  135830. */
  135831. scene: Scene;
  135832. /**
  135833. * Creates a new instance of the component for the given scene
  135834. * @param scene Defines the scene to register the component in
  135835. */
  135836. constructor(scene: Scene);
  135837. /**
  135838. * Registers the component in a given scene
  135839. */
  135840. register(): void;
  135841. /**
  135842. * Rebuilds the elements related to this component in case of
  135843. * context lost for instance.
  135844. */
  135845. rebuild(): void;
  135846. /**
  135847. * Disposes the component and the associated ressources
  135848. */
  135849. dispose(): void;
  135850. }
  135851. }
  135852. declare module BABYLON {
  135853. /**
  135854. * A helper for physics simulations
  135855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  135856. */
  135857. export class PhysicsHelper {
  135858. private _scene;
  135859. private _physicsEngine;
  135860. /**
  135861. * Initializes the Physics helper
  135862. * @param scene Babylon.js scene
  135863. */
  135864. constructor(scene: Scene);
  135865. /**
  135866. * Applies a radial explosion impulse
  135867. * @param origin the origin of the explosion
  135868. * @param radiusOrEventOptions the radius or the options of radial explosion
  135869. * @param strength the explosion strength
  135870. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135871. * @returns A physics radial explosion event, or null
  135872. */
  135873. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135874. /**
  135875. * Applies a radial explosion force
  135876. * @param origin the origin of the explosion
  135877. * @param radiusOrEventOptions the radius or the options of radial explosion
  135878. * @param strength the explosion strength
  135879. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135880. * @returns A physics radial explosion event, or null
  135881. */
  135882. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135883. /**
  135884. * Creates a gravitational field
  135885. * @param origin the origin of the explosion
  135886. * @param radiusOrEventOptions the radius or the options of radial explosion
  135887. * @param strength the explosion strength
  135888. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135889. * @returns A physics gravitational field event, or null
  135890. */
  135891. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  135892. /**
  135893. * Creates a physics updraft event
  135894. * @param origin the origin of the updraft
  135895. * @param radiusOrEventOptions the radius or the options of the updraft
  135896. * @param strength the strength of the updraft
  135897. * @param height the height of the updraft
  135898. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  135899. * @returns A physics updraft event, or null
  135900. */
  135901. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  135902. /**
  135903. * Creates a physics vortex event
  135904. * @param origin the of the vortex
  135905. * @param radiusOrEventOptions the radius or the options of the vortex
  135906. * @param strength the strength of the vortex
  135907. * @param height the height of the vortex
  135908. * @returns a Physics vortex event, or null
  135909. * A physics vortex event or null
  135910. */
  135911. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  135912. }
  135913. /**
  135914. * Represents a physics radial explosion event
  135915. */
  135916. class PhysicsRadialExplosionEvent {
  135917. private _scene;
  135918. private _options;
  135919. private _sphere;
  135920. private _dataFetched;
  135921. /**
  135922. * Initializes a radial explosioin event
  135923. * @param _scene BabylonJS scene
  135924. * @param _options The options for the vortex event
  135925. */
  135926. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  135927. /**
  135928. * Returns the data related to the radial explosion event (sphere).
  135929. * @returns The radial explosion event data
  135930. */
  135931. getData(): PhysicsRadialExplosionEventData;
  135932. /**
  135933. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  135934. * @param impostor A physics imposter
  135935. * @param origin the origin of the explosion
  135936. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  135937. */
  135938. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  135939. /**
  135940. * Triggers affecterd impostors callbacks
  135941. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  135942. */
  135943. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  135944. /**
  135945. * Disposes the sphere.
  135946. * @param force Specifies if the sphere should be disposed by force
  135947. */
  135948. dispose(force?: boolean): void;
  135949. /*** Helpers ***/
  135950. private _prepareSphere;
  135951. private _intersectsWithSphere;
  135952. }
  135953. /**
  135954. * Represents a gravitational field event
  135955. */
  135956. class PhysicsGravitationalFieldEvent {
  135957. private _physicsHelper;
  135958. private _scene;
  135959. private _origin;
  135960. private _options;
  135961. private _tickCallback;
  135962. private _sphere;
  135963. private _dataFetched;
  135964. /**
  135965. * Initializes the physics gravitational field event
  135966. * @param _physicsHelper A physics helper
  135967. * @param _scene BabylonJS scene
  135968. * @param _origin The origin position of the gravitational field event
  135969. * @param _options The options for the vortex event
  135970. */
  135971. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  135972. /**
  135973. * Returns the data related to the gravitational field event (sphere).
  135974. * @returns A gravitational field event
  135975. */
  135976. getData(): PhysicsGravitationalFieldEventData;
  135977. /**
  135978. * Enables the gravitational field.
  135979. */
  135980. enable(): void;
  135981. /**
  135982. * Disables the gravitational field.
  135983. */
  135984. disable(): void;
  135985. /**
  135986. * Disposes the sphere.
  135987. * @param force The force to dispose from the gravitational field event
  135988. */
  135989. dispose(force?: boolean): void;
  135990. private _tick;
  135991. }
  135992. /**
  135993. * Represents a physics updraft event
  135994. */
  135995. class PhysicsUpdraftEvent {
  135996. private _scene;
  135997. private _origin;
  135998. private _options;
  135999. private _physicsEngine;
  136000. private _originTop;
  136001. private _originDirection;
  136002. private _tickCallback;
  136003. private _cylinder;
  136004. private _cylinderPosition;
  136005. private _dataFetched;
  136006. /**
  136007. * Initializes the physics updraft event
  136008. * @param _scene BabylonJS scene
  136009. * @param _origin The origin position of the updraft
  136010. * @param _options The options for the updraft event
  136011. */
  136012. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136013. /**
  136014. * Returns the data related to the updraft event (cylinder).
  136015. * @returns A physics updraft event
  136016. */
  136017. getData(): PhysicsUpdraftEventData;
  136018. /**
  136019. * Enables the updraft.
  136020. */
  136021. enable(): void;
  136022. /**
  136023. * Disables the updraft.
  136024. */
  136025. disable(): void;
  136026. /**
  136027. * Disposes the cylinder.
  136028. * @param force Specifies if the updraft should be disposed by force
  136029. */
  136030. dispose(force?: boolean): void;
  136031. private getImpostorHitData;
  136032. private _tick;
  136033. /*** Helpers ***/
  136034. private _prepareCylinder;
  136035. private _intersectsWithCylinder;
  136036. }
  136037. /**
  136038. * Represents a physics vortex event
  136039. */
  136040. class PhysicsVortexEvent {
  136041. private _scene;
  136042. private _origin;
  136043. private _options;
  136044. private _physicsEngine;
  136045. private _originTop;
  136046. private _tickCallback;
  136047. private _cylinder;
  136048. private _cylinderPosition;
  136049. private _dataFetched;
  136050. /**
  136051. * Initializes the physics vortex event
  136052. * @param _scene The BabylonJS scene
  136053. * @param _origin The origin position of the vortex
  136054. * @param _options The options for the vortex event
  136055. */
  136056. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136057. /**
  136058. * Returns the data related to the vortex event (cylinder).
  136059. * @returns The physics vortex event data
  136060. */
  136061. getData(): PhysicsVortexEventData;
  136062. /**
  136063. * Enables the vortex.
  136064. */
  136065. enable(): void;
  136066. /**
  136067. * Disables the cortex.
  136068. */
  136069. disable(): void;
  136070. /**
  136071. * Disposes the sphere.
  136072. * @param force
  136073. */
  136074. dispose(force?: boolean): void;
  136075. private getImpostorHitData;
  136076. private _tick;
  136077. /*** Helpers ***/
  136078. private _prepareCylinder;
  136079. private _intersectsWithCylinder;
  136080. }
  136081. /**
  136082. * Options fot the radial explosion event
  136083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136084. */
  136085. export class PhysicsRadialExplosionEventOptions {
  136086. /**
  136087. * The radius of the sphere for the radial explosion.
  136088. */
  136089. radius: number;
  136090. /**
  136091. * The strenth of the explosion.
  136092. */
  136093. strength: number;
  136094. /**
  136095. * The strenght of the force in correspondence to the distance of the affected object
  136096. */
  136097. falloff: PhysicsRadialImpulseFalloff;
  136098. /**
  136099. * Sphere options for the radial explosion.
  136100. */
  136101. sphere: {
  136102. segments: number;
  136103. diameter: number;
  136104. };
  136105. /**
  136106. * Sphere options for the radial explosion.
  136107. */
  136108. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136109. }
  136110. /**
  136111. * Options fot the updraft event
  136112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136113. */
  136114. export class PhysicsUpdraftEventOptions {
  136115. /**
  136116. * The radius of the cylinder for the vortex
  136117. */
  136118. radius: number;
  136119. /**
  136120. * The strenth of the updraft.
  136121. */
  136122. strength: number;
  136123. /**
  136124. * The height of the cylinder for the updraft.
  136125. */
  136126. height: number;
  136127. /**
  136128. * The mode for the the updraft.
  136129. */
  136130. updraftMode: PhysicsUpdraftMode;
  136131. }
  136132. /**
  136133. * Options fot the vortex event
  136134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136135. */
  136136. export class PhysicsVortexEventOptions {
  136137. /**
  136138. * The radius of the cylinder for the vortex
  136139. */
  136140. radius: number;
  136141. /**
  136142. * The strenth of the vortex.
  136143. */
  136144. strength: number;
  136145. /**
  136146. * The height of the cylinder for the vortex.
  136147. */
  136148. height: number;
  136149. /**
  136150. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136151. */
  136152. centripetalForceThreshold: number;
  136153. /**
  136154. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136155. */
  136156. centripetalForceMultiplier: number;
  136157. /**
  136158. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136159. */
  136160. centrifugalForceMultiplier: number;
  136161. /**
  136162. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136163. */
  136164. updraftForceMultiplier: number;
  136165. }
  136166. /**
  136167. * The strenght of the force in correspondence to the distance of the affected object
  136168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136169. */
  136170. export enum PhysicsRadialImpulseFalloff {
  136171. /** Defines that impulse is constant in strength across it's whole radius */
  136172. Constant = 0,
  136173. /** Defines that impulse gets weaker if it's further from the origin */
  136174. Linear = 1
  136175. }
  136176. /**
  136177. * The strength of the force in correspondence to the distance of the affected object
  136178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136179. */
  136180. export enum PhysicsUpdraftMode {
  136181. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136182. Center = 0,
  136183. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136184. Perpendicular = 1
  136185. }
  136186. /**
  136187. * Interface for a physics hit data
  136188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136189. */
  136190. export interface PhysicsHitData {
  136191. /**
  136192. * The force applied at the contact point
  136193. */
  136194. force: Vector3;
  136195. /**
  136196. * The contact point
  136197. */
  136198. contactPoint: Vector3;
  136199. /**
  136200. * The distance from the origin to the contact point
  136201. */
  136202. distanceFromOrigin: number;
  136203. }
  136204. /**
  136205. * Interface for radial explosion event data
  136206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136207. */
  136208. export interface PhysicsRadialExplosionEventData {
  136209. /**
  136210. * A sphere used for the radial explosion event
  136211. */
  136212. sphere: Mesh;
  136213. }
  136214. /**
  136215. * Interface for gravitational field event data
  136216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136217. */
  136218. export interface PhysicsGravitationalFieldEventData {
  136219. /**
  136220. * A sphere mesh used for the gravitational field event
  136221. */
  136222. sphere: Mesh;
  136223. }
  136224. /**
  136225. * Interface for updraft event data
  136226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136227. */
  136228. export interface PhysicsUpdraftEventData {
  136229. /**
  136230. * A cylinder used for the updraft event
  136231. */
  136232. cylinder: Mesh;
  136233. }
  136234. /**
  136235. * Interface for vortex event data
  136236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136237. */
  136238. export interface PhysicsVortexEventData {
  136239. /**
  136240. * A cylinder used for the vortex event
  136241. */
  136242. cylinder: Mesh;
  136243. }
  136244. /**
  136245. * Interface for an affected physics impostor
  136246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136247. */
  136248. export interface PhysicsAffectedImpostorWithData {
  136249. /**
  136250. * The impostor affected by the effect
  136251. */
  136252. impostor: PhysicsImpostor;
  136253. /**
  136254. * The data about the hit/horce from the explosion
  136255. */
  136256. hitData: PhysicsHitData;
  136257. }
  136258. }
  136259. declare module BABYLON {
  136260. /** @hidden */
  136261. export var blackAndWhitePixelShader: {
  136262. name: string;
  136263. shader: string;
  136264. };
  136265. }
  136266. declare module BABYLON {
  136267. /**
  136268. * Post process used to render in black and white
  136269. */
  136270. export class BlackAndWhitePostProcess extends PostProcess {
  136271. /**
  136272. * Linear about to convert he result to black and white (default: 1)
  136273. */
  136274. degree: number;
  136275. /**
  136276. * Creates a black and white post process
  136277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136278. * @param name The name of the effect.
  136279. * @param options The required width/height ratio to downsize to before computing the render pass.
  136280. * @param camera The camera to apply the render pass to.
  136281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136282. * @param engine The engine which the post process will be applied. (default: current engine)
  136283. * @param reusable If the post process can be reused on the same frame. (default: false)
  136284. */
  136285. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136286. }
  136287. }
  136288. declare module BABYLON {
  136289. /**
  136290. * This represents a set of one or more post processes in Babylon.
  136291. * A post process can be used to apply a shader to a texture after it is rendered.
  136292. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  136293. */
  136294. export class PostProcessRenderEffect {
  136295. private _postProcesses;
  136296. private _getPostProcesses;
  136297. private _singleInstance;
  136298. private _cameras;
  136299. private _indicesForCamera;
  136300. /**
  136301. * Name of the effect
  136302. * @hidden
  136303. */
  136304. _name: string;
  136305. /**
  136306. * Instantiates a post process render effect.
  136307. * A post process can be used to apply a shader to a texture after it is rendered.
  136308. * @param engine The engine the effect is tied to
  136309. * @param name The name of the effect
  136310. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  136311. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  136312. */
  136313. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  136314. /**
  136315. * Checks if all the post processes in the effect are supported.
  136316. */
  136317. get isSupported(): boolean;
  136318. /**
  136319. * Updates the current state of the effect
  136320. * @hidden
  136321. */
  136322. _update(): void;
  136323. /**
  136324. * Attaches the effect on cameras
  136325. * @param cameras The camera to attach to.
  136326. * @hidden
  136327. */
  136328. _attachCameras(cameras: Camera): void;
  136329. /**
  136330. * Attaches the effect on cameras
  136331. * @param cameras The camera to attach to.
  136332. * @hidden
  136333. */
  136334. _attachCameras(cameras: Camera[]): void;
  136335. /**
  136336. * Detaches the effect on cameras
  136337. * @param cameras The camera to detatch from.
  136338. * @hidden
  136339. */
  136340. _detachCameras(cameras: Camera): void;
  136341. /**
  136342. * Detatches the effect on cameras
  136343. * @param cameras The camera to detatch from.
  136344. * @hidden
  136345. */
  136346. _detachCameras(cameras: Camera[]): void;
  136347. /**
  136348. * Enables the effect on given cameras
  136349. * @param cameras The camera to enable.
  136350. * @hidden
  136351. */
  136352. _enable(cameras: Camera): void;
  136353. /**
  136354. * Enables the effect on given cameras
  136355. * @param cameras The camera to enable.
  136356. * @hidden
  136357. */
  136358. _enable(cameras: Nullable<Camera[]>): void;
  136359. /**
  136360. * Disables the effect on the given cameras
  136361. * @param cameras The camera to disable.
  136362. * @hidden
  136363. */
  136364. _disable(cameras: Camera): void;
  136365. /**
  136366. * Disables the effect on the given cameras
  136367. * @param cameras The camera to disable.
  136368. * @hidden
  136369. */
  136370. _disable(cameras: Nullable<Camera[]>): void;
  136371. /**
  136372. * Gets a list of the post processes contained in the effect.
  136373. * @param camera The camera to get the post processes on.
  136374. * @returns The list of the post processes in the effect.
  136375. */
  136376. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  136377. }
  136378. }
  136379. declare module BABYLON {
  136380. /** @hidden */
  136381. export var extractHighlightsPixelShader: {
  136382. name: string;
  136383. shader: string;
  136384. };
  136385. }
  136386. declare module BABYLON {
  136387. /**
  136388. * 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.
  136389. */
  136390. export class ExtractHighlightsPostProcess extends PostProcess {
  136391. /**
  136392. * The luminance threshold, pixels below this value will be set to black.
  136393. */
  136394. threshold: number;
  136395. /** @hidden */
  136396. _exposure: number;
  136397. /**
  136398. * Post process which has the input texture to be used when performing highlight extraction
  136399. * @hidden
  136400. */
  136401. _inputPostProcess: Nullable<PostProcess>;
  136402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136403. }
  136404. }
  136405. declare module BABYLON {
  136406. /** @hidden */
  136407. export var bloomMergePixelShader: {
  136408. name: string;
  136409. shader: string;
  136410. };
  136411. }
  136412. declare module BABYLON {
  136413. /**
  136414. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136415. */
  136416. export class BloomMergePostProcess extends PostProcess {
  136417. /** Weight of the bloom to be added to the original input. */
  136418. weight: number;
  136419. /**
  136420. * Creates a new instance of @see BloomMergePostProcess
  136421. * @param name The name of the effect.
  136422. * @param originalFromInput Post process which's input will be used for the merge.
  136423. * @param blurred Blurred highlights post process which's output will be used.
  136424. * @param weight Weight of the bloom to be added to the original input.
  136425. * @param options The required width/height ratio to downsize to before computing the render pass.
  136426. * @param camera The camera to apply the render pass to.
  136427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136428. * @param engine The engine which the post process will be applied. (default: current engine)
  136429. * @param reusable If the post process can be reused on the same frame. (default: false)
  136430. * @param textureType Type of textures used when performing the post process. (default: 0)
  136431. * @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)
  136432. */
  136433. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  136434. /** Weight of the bloom to be added to the original input. */
  136435. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136436. }
  136437. }
  136438. declare module BABYLON {
  136439. /**
  136440. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  136441. */
  136442. export class BloomEffect extends PostProcessRenderEffect {
  136443. private bloomScale;
  136444. /**
  136445. * @hidden Internal
  136446. */
  136447. _effects: Array<PostProcess>;
  136448. /**
  136449. * @hidden Internal
  136450. */
  136451. _downscale: ExtractHighlightsPostProcess;
  136452. private _blurX;
  136453. private _blurY;
  136454. private _merge;
  136455. /**
  136456. * The luminance threshold to find bright areas of the image to bloom.
  136457. */
  136458. get threshold(): number;
  136459. set threshold(value: number);
  136460. /**
  136461. * The strength of the bloom.
  136462. */
  136463. get weight(): number;
  136464. set weight(value: number);
  136465. /**
  136466. * Specifies the size of the bloom blur kernel, relative to the final output size
  136467. */
  136468. get kernel(): number;
  136469. set kernel(value: number);
  136470. /**
  136471. * Creates a new instance of @see BloomEffect
  136472. * @param scene The scene the effect belongs to.
  136473. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  136474. * @param bloomKernel The size of the kernel to be used when applying the blur.
  136475. * @param bloomWeight The the strength of bloom.
  136476. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136477. * @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)
  136478. */
  136479. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  136480. /**
  136481. * Disposes each of the internal effects for a given camera.
  136482. * @param camera The camera to dispose the effect on.
  136483. */
  136484. disposeEffects(camera: Camera): void;
  136485. /**
  136486. * @hidden Internal
  136487. */
  136488. _updateEffects(): void;
  136489. /**
  136490. * Internal
  136491. * @returns if all the contained post processes are ready.
  136492. * @hidden
  136493. */
  136494. _isReady(): boolean;
  136495. }
  136496. }
  136497. declare module BABYLON {
  136498. /** @hidden */
  136499. export var chromaticAberrationPixelShader: {
  136500. name: string;
  136501. shader: string;
  136502. };
  136503. }
  136504. declare module BABYLON {
  136505. /**
  136506. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  136507. */
  136508. export class ChromaticAberrationPostProcess extends PostProcess {
  136509. /**
  136510. * The amount of seperation of rgb channels (default: 30)
  136511. */
  136512. aberrationAmount: number;
  136513. /**
  136514. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  136515. */
  136516. radialIntensity: number;
  136517. /**
  136518. * 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))
  136519. */
  136520. direction: Vector2;
  136521. /**
  136522. * 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))
  136523. */
  136524. centerPosition: Vector2;
  136525. /**
  136526. * Creates a new instance ChromaticAberrationPostProcess
  136527. * @param name The name of the effect.
  136528. * @param screenWidth The width of the screen to apply the effect on.
  136529. * @param screenHeight The height of the screen to apply the effect on.
  136530. * @param options The required width/height ratio to downsize to before computing the render pass.
  136531. * @param camera The camera to apply the render pass to.
  136532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136533. * @param engine The engine which the post process will be applied. (default: current engine)
  136534. * @param reusable If the post process can be reused on the same frame. (default: false)
  136535. * @param textureType Type of textures used when performing the post process. (default: 0)
  136536. * @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)
  136537. */
  136538. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136539. }
  136540. }
  136541. declare module BABYLON {
  136542. /** @hidden */
  136543. export var circleOfConfusionPixelShader: {
  136544. name: string;
  136545. shader: string;
  136546. };
  136547. }
  136548. declare module BABYLON {
  136549. /**
  136550. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  136551. */
  136552. export class CircleOfConfusionPostProcess extends PostProcess {
  136553. /**
  136554. * 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.
  136555. */
  136556. lensSize: number;
  136557. /**
  136558. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136559. */
  136560. fStop: number;
  136561. /**
  136562. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136563. */
  136564. focusDistance: number;
  136565. /**
  136566. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  136567. */
  136568. focalLength: number;
  136569. private _depthTexture;
  136570. /**
  136571. * Creates a new instance CircleOfConfusionPostProcess
  136572. * @param name The name of the effect.
  136573. * @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.
  136574. * @param options The required width/height ratio to downsize to before computing the render pass.
  136575. * @param camera The camera to apply the render pass to.
  136576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136577. * @param engine The engine which the post process will be applied. (default: current engine)
  136578. * @param reusable If the post process can be reused on the same frame. (default: false)
  136579. * @param textureType Type of textures used when performing the post process. (default: 0)
  136580. * @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)
  136581. */
  136582. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136583. /**
  136584. * 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.
  136585. */
  136586. set depthTexture(value: RenderTargetTexture);
  136587. }
  136588. }
  136589. declare module BABYLON {
  136590. /** @hidden */
  136591. export var colorCorrectionPixelShader: {
  136592. name: string;
  136593. shader: string;
  136594. };
  136595. }
  136596. declare module BABYLON {
  136597. /**
  136598. *
  136599. * This post-process allows the modification of rendered colors by using
  136600. * a 'look-up table' (LUT). This effect is also called Color Grading.
  136601. *
  136602. * The object needs to be provided an url to a texture containing the color
  136603. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  136604. * Use an image editing software to tweak the LUT to match your needs.
  136605. *
  136606. * For an example of a color LUT, see here:
  136607. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  136608. * For explanations on color grading, see here:
  136609. * @see http://udn.epicgames.com/Three/ColorGrading.html
  136610. *
  136611. */
  136612. export class ColorCorrectionPostProcess extends PostProcess {
  136613. private _colorTableTexture;
  136614. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136615. }
  136616. }
  136617. declare module BABYLON {
  136618. /** @hidden */
  136619. export var convolutionPixelShader: {
  136620. name: string;
  136621. shader: string;
  136622. };
  136623. }
  136624. declare module BABYLON {
  136625. /**
  136626. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  136627. * input texture to perform effects such as edge detection or sharpening
  136628. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  136629. */
  136630. export class ConvolutionPostProcess extends PostProcess {
  136631. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136632. kernel: number[];
  136633. /**
  136634. * Creates a new instance ConvolutionPostProcess
  136635. * @param name The name of the effect.
  136636. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  136637. * @param options The required width/height ratio to downsize to before computing the render pass.
  136638. * @param camera The camera to apply the render pass to.
  136639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136640. * @param engine The engine which the post process will be applied. (default: current engine)
  136641. * @param reusable If the post process can be reused on the same frame. (default: false)
  136642. * @param textureType Type of textures used when performing the post process. (default: 0)
  136643. */
  136644. constructor(name: string,
  136645. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136646. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136647. /**
  136648. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136649. */
  136650. static EdgeDetect0Kernel: number[];
  136651. /**
  136652. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136653. */
  136654. static EdgeDetect1Kernel: number[];
  136655. /**
  136656. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136657. */
  136658. static EdgeDetect2Kernel: number[];
  136659. /**
  136660. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136661. */
  136662. static SharpenKernel: number[];
  136663. /**
  136664. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136665. */
  136666. static EmbossKernel: number[];
  136667. /**
  136668. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136669. */
  136670. static GaussianKernel: number[];
  136671. }
  136672. }
  136673. declare module BABYLON {
  136674. /**
  136675. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  136676. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  136677. * based on samples that have a large difference in distance than the center pixel.
  136678. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  136679. */
  136680. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  136681. direction: Vector2;
  136682. /**
  136683. * Creates a new instance CircleOfConfusionPostProcess
  136684. * @param name The name of the effect.
  136685. * @param scene The scene the effect belongs to.
  136686. * @param direction The direction the blur should be applied.
  136687. * @param kernel The size of the kernel used to blur.
  136688. * @param options The required width/height ratio to downsize to before computing the render pass.
  136689. * @param camera The camera to apply the render pass to.
  136690. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  136691. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  136692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136693. * @param engine The engine which the post process will be applied. (default: current engine)
  136694. * @param reusable If the post process can be reused on the same frame. (default: false)
  136695. * @param textureType Type of textures used when performing the post process. (default: 0)
  136696. * @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)
  136697. */
  136698. 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);
  136699. }
  136700. }
  136701. declare module BABYLON {
  136702. /** @hidden */
  136703. export var depthOfFieldMergePixelShader: {
  136704. name: string;
  136705. shader: string;
  136706. };
  136707. }
  136708. declare module BABYLON {
  136709. /**
  136710. * Options to be set when merging outputs from the default pipeline.
  136711. */
  136712. export class DepthOfFieldMergePostProcessOptions {
  136713. /**
  136714. * The original image to merge on top of
  136715. */
  136716. originalFromInput: PostProcess;
  136717. /**
  136718. * Parameters to perform the merge of the depth of field effect
  136719. */
  136720. depthOfField?: {
  136721. circleOfConfusion: PostProcess;
  136722. blurSteps: Array<PostProcess>;
  136723. };
  136724. /**
  136725. * Parameters to perform the merge of bloom effect
  136726. */
  136727. bloom?: {
  136728. blurred: PostProcess;
  136729. weight: number;
  136730. };
  136731. }
  136732. /**
  136733. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136734. */
  136735. export class DepthOfFieldMergePostProcess extends PostProcess {
  136736. private blurSteps;
  136737. /**
  136738. * Creates a new instance of DepthOfFieldMergePostProcess
  136739. * @param name The name of the effect.
  136740. * @param originalFromInput Post process which's input will be used for the merge.
  136741. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  136742. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  136743. * @param options The required width/height ratio to downsize to before computing the render pass.
  136744. * @param camera The camera to apply the render pass to.
  136745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136746. * @param engine The engine which the post process will be applied. (default: current engine)
  136747. * @param reusable If the post process can be reused on the same frame. (default: false)
  136748. * @param textureType Type of textures used when performing the post process. (default: 0)
  136749. * @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)
  136750. */
  136751. 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);
  136752. /**
  136753. * Updates the effect with the current post process compile time values and recompiles the shader.
  136754. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  136755. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  136756. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  136757. * @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
  136758. * @param onCompiled Called when the shader has been compiled.
  136759. * @param onError Called if there is an error when compiling a shader.
  136760. */
  136761. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  136762. }
  136763. }
  136764. declare module BABYLON {
  136765. /**
  136766. * Specifies the level of max blur that should be applied when using the depth of field effect
  136767. */
  136768. export enum DepthOfFieldEffectBlurLevel {
  136769. /**
  136770. * Subtle blur
  136771. */
  136772. Low = 0,
  136773. /**
  136774. * Medium blur
  136775. */
  136776. Medium = 1,
  136777. /**
  136778. * Large blur
  136779. */
  136780. High = 2
  136781. }
  136782. /**
  136783. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  136784. */
  136785. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  136786. private _circleOfConfusion;
  136787. /**
  136788. * @hidden Internal, blurs from high to low
  136789. */
  136790. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  136791. private _depthOfFieldBlurY;
  136792. private _dofMerge;
  136793. /**
  136794. * @hidden Internal post processes in depth of field effect
  136795. */
  136796. _effects: Array<PostProcess>;
  136797. /**
  136798. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  136799. */
  136800. set focalLength(value: number);
  136801. get focalLength(): number;
  136802. /**
  136803. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136804. */
  136805. set fStop(value: number);
  136806. get fStop(): number;
  136807. /**
  136808. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136809. */
  136810. set focusDistance(value: number);
  136811. get focusDistance(): number;
  136812. /**
  136813. * 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.
  136814. */
  136815. set lensSize(value: number);
  136816. get lensSize(): number;
  136817. /**
  136818. * Creates a new instance DepthOfFieldEffect
  136819. * @param scene The scene the effect belongs to.
  136820. * @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.
  136821. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136822. * @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)
  136823. */
  136824. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  136825. /**
  136826. * Get the current class name of the current effet
  136827. * @returns "DepthOfFieldEffect"
  136828. */
  136829. getClassName(): string;
  136830. /**
  136831. * 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.
  136832. */
  136833. set depthTexture(value: RenderTargetTexture);
  136834. /**
  136835. * Disposes each of the internal effects for a given camera.
  136836. * @param camera The camera to dispose the effect on.
  136837. */
  136838. disposeEffects(camera: Camera): void;
  136839. /**
  136840. * @hidden Internal
  136841. */
  136842. _updateEffects(): void;
  136843. /**
  136844. * Internal
  136845. * @returns if all the contained post processes are ready.
  136846. * @hidden
  136847. */
  136848. _isReady(): boolean;
  136849. }
  136850. }
  136851. declare module BABYLON {
  136852. /** @hidden */
  136853. export var displayPassPixelShader: {
  136854. name: string;
  136855. shader: string;
  136856. };
  136857. }
  136858. declare module BABYLON {
  136859. /**
  136860. * DisplayPassPostProcess which produces an output the same as it's input
  136861. */
  136862. export class DisplayPassPostProcess extends PostProcess {
  136863. /**
  136864. * Creates the DisplayPassPostProcess
  136865. * @param name The name of the effect.
  136866. * @param options The required width/height ratio to downsize to before computing the render pass.
  136867. * @param camera The camera to apply the render pass to.
  136868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136869. * @param engine The engine which the post process will be applied. (default: current engine)
  136870. * @param reusable If the post process can be reused on the same frame. (default: false)
  136871. */
  136872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136873. }
  136874. }
  136875. declare module BABYLON {
  136876. /** @hidden */
  136877. export var filterPixelShader: {
  136878. name: string;
  136879. shader: string;
  136880. };
  136881. }
  136882. declare module BABYLON {
  136883. /**
  136884. * Applies a kernel filter to the image
  136885. */
  136886. export class FilterPostProcess extends PostProcess {
  136887. /** The matrix to be applied to the image */
  136888. kernelMatrix: Matrix;
  136889. /**
  136890. *
  136891. * @param name The name of the effect.
  136892. * @param kernelMatrix The matrix to be applied to the image
  136893. * @param options The required width/height ratio to downsize to before computing the render pass.
  136894. * @param camera The camera to apply the render pass to.
  136895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136896. * @param engine The engine which the post process will be applied. (default: current engine)
  136897. * @param reusable If the post process can be reused on the same frame. (default: false)
  136898. */
  136899. constructor(name: string,
  136900. /** The matrix to be applied to the image */
  136901. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136902. }
  136903. }
  136904. declare module BABYLON {
  136905. /** @hidden */
  136906. export var fxaaPixelShader: {
  136907. name: string;
  136908. shader: string;
  136909. };
  136910. }
  136911. declare module BABYLON {
  136912. /** @hidden */
  136913. export var fxaaVertexShader: {
  136914. name: string;
  136915. shader: string;
  136916. };
  136917. }
  136918. declare module BABYLON {
  136919. /**
  136920. * Fxaa post process
  136921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  136922. */
  136923. export class FxaaPostProcess extends PostProcess {
  136924. /** @hidden */
  136925. texelWidth: number;
  136926. /** @hidden */
  136927. texelHeight: number;
  136928. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136929. private _getDefines;
  136930. }
  136931. }
  136932. declare module BABYLON {
  136933. /** @hidden */
  136934. export var grainPixelShader: {
  136935. name: string;
  136936. shader: string;
  136937. };
  136938. }
  136939. declare module BABYLON {
  136940. /**
  136941. * The GrainPostProcess adds noise to the image at mid luminance levels
  136942. */
  136943. export class GrainPostProcess extends PostProcess {
  136944. /**
  136945. * The intensity of the grain added (default: 30)
  136946. */
  136947. intensity: number;
  136948. /**
  136949. * If the grain should be randomized on every frame
  136950. */
  136951. animated: boolean;
  136952. /**
  136953. * Creates a new instance of @see GrainPostProcess
  136954. * @param name The name of the effect.
  136955. * @param options The required width/height ratio to downsize to before computing the render pass.
  136956. * @param camera The camera to apply the render pass to.
  136957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136958. * @param engine The engine which the post process will be applied. (default: current engine)
  136959. * @param reusable If the post process can be reused on the same frame. (default: false)
  136960. * @param textureType Type of textures used when performing the post process. (default: 0)
  136961. * @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)
  136962. */
  136963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136964. }
  136965. }
  136966. declare module BABYLON {
  136967. /** @hidden */
  136968. export var highlightsPixelShader: {
  136969. name: string;
  136970. shader: string;
  136971. };
  136972. }
  136973. declare module BABYLON {
  136974. /**
  136975. * Extracts highlights from the image
  136976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136977. */
  136978. export class HighlightsPostProcess extends PostProcess {
  136979. /**
  136980. * Extracts highlights from the image
  136981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136982. * @param name The name of the effect.
  136983. * @param options The required width/height ratio to downsize to before computing the render pass.
  136984. * @param camera The camera to apply the render pass to.
  136985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136986. * @param engine The engine which the post process will be applied. (default: current engine)
  136987. * @param reusable If the post process can be reused on the same frame. (default: false)
  136988. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  136989. */
  136990. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136991. }
  136992. }
  136993. declare module BABYLON {
  136994. /** @hidden */
  136995. export var mrtFragmentDeclaration: {
  136996. name: string;
  136997. shader: string;
  136998. };
  136999. }
  137000. declare module BABYLON {
  137001. /** @hidden */
  137002. export var geometryPixelShader: {
  137003. name: string;
  137004. shader: string;
  137005. };
  137006. }
  137007. declare module BABYLON {
  137008. /** @hidden */
  137009. export var geometryVertexShader: {
  137010. name: string;
  137011. shader: string;
  137012. };
  137013. }
  137014. declare module BABYLON {
  137015. /** @hidden */
  137016. interface ISavedTransformationMatrix {
  137017. world: Matrix;
  137018. viewProjection: Matrix;
  137019. }
  137020. /**
  137021. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137022. */
  137023. export class GeometryBufferRenderer {
  137024. /**
  137025. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137026. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137027. */
  137028. static readonly POSITION_TEXTURE_TYPE: number;
  137029. /**
  137030. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137031. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137032. */
  137033. static readonly VELOCITY_TEXTURE_TYPE: number;
  137034. /**
  137035. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137036. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137037. */
  137038. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137039. /**
  137040. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137041. * in order to compute objects velocities when enableVelocity is set to "true"
  137042. * @hidden
  137043. */
  137044. _previousTransformationMatrices: {
  137045. [index: number]: ISavedTransformationMatrix;
  137046. };
  137047. /**
  137048. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137049. * in order to compute objects velocities when enableVelocity is set to "true"
  137050. * @hidden
  137051. */
  137052. _previousBonesTransformationMatrices: {
  137053. [index: number]: Float32Array;
  137054. };
  137055. /**
  137056. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137057. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137058. */
  137059. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137060. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137061. renderTransparentMeshes: boolean;
  137062. private _scene;
  137063. private _multiRenderTarget;
  137064. private _ratio;
  137065. private _enablePosition;
  137066. private _enableVelocity;
  137067. private _enableReflectivity;
  137068. private _positionIndex;
  137069. private _velocityIndex;
  137070. private _reflectivityIndex;
  137071. protected _effect: Effect;
  137072. protected _cachedDefines: string;
  137073. /**
  137074. * Set the render list (meshes to be rendered) used in the G buffer.
  137075. */
  137076. set renderList(meshes: Mesh[]);
  137077. /**
  137078. * Gets wether or not G buffer are supported by the running hardware.
  137079. * This requires draw buffer supports
  137080. */
  137081. get isSupported(): boolean;
  137082. /**
  137083. * Returns the index of the given texture type in the G-Buffer textures array
  137084. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137085. * @returns the index of the given texture type in the G-Buffer textures array
  137086. */
  137087. getTextureIndex(textureType: number): number;
  137088. /**
  137089. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137090. */
  137091. get enablePosition(): boolean;
  137092. /**
  137093. * Sets whether or not objects positions are enabled for the G buffer.
  137094. */
  137095. set enablePosition(enable: boolean);
  137096. /**
  137097. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137098. */
  137099. get enableVelocity(): boolean;
  137100. /**
  137101. * Sets wether or not objects velocities are enabled for the G buffer.
  137102. */
  137103. set enableVelocity(enable: boolean);
  137104. /**
  137105. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137106. */
  137107. get enableReflectivity(): boolean;
  137108. /**
  137109. * Sets wether or not objects roughness are enabled for the G buffer.
  137110. */
  137111. set enableReflectivity(enable: boolean);
  137112. /**
  137113. * Gets the scene associated with the buffer.
  137114. */
  137115. get scene(): Scene;
  137116. /**
  137117. * Gets the ratio used by the buffer during its creation.
  137118. * How big is the buffer related to the main canvas.
  137119. */
  137120. get ratio(): number;
  137121. /** @hidden */
  137122. static _SceneComponentInitialization: (scene: Scene) => void;
  137123. /**
  137124. * Creates a new G Buffer for the scene
  137125. * @param scene The scene the buffer belongs to
  137126. * @param ratio How big is the buffer related to the main canvas.
  137127. */
  137128. constructor(scene: Scene, ratio?: number);
  137129. /**
  137130. * Checks wether everything is ready to render a submesh to the G buffer.
  137131. * @param subMesh the submesh to check readiness for
  137132. * @param useInstances is the mesh drawn using instance or not
  137133. * @returns true if ready otherwise false
  137134. */
  137135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137136. /**
  137137. * Gets the current underlying G Buffer.
  137138. * @returns the buffer
  137139. */
  137140. getGBuffer(): MultiRenderTarget;
  137141. /**
  137142. * Gets the number of samples used to render the buffer (anti aliasing).
  137143. */
  137144. get samples(): number;
  137145. /**
  137146. * Sets the number of samples used to render the buffer (anti aliasing).
  137147. */
  137148. set samples(value: number);
  137149. /**
  137150. * Disposes the renderer and frees up associated resources.
  137151. */
  137152. dispose(): void;
  137153. protected _createRenderTargets(): void;
  137154. private _copyBonesTransformationMatrices;
  137155. }
  137156. }
  137157. declare module BABYLON {
  137158. interface Scene {
  137159. /** @hidden (Backing field) */
  137160. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137161. /**
  137162. * Gets or Sets the current geometry buffer associated to the scene.
  137163. */
  137164. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137165. /**
  137166. * Enables a GeometryBufferRender and associates it with the scene
  137167. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137168. * @returns the GeometryBufferRenderer
  137169. */
  137170. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137171. /**
  137172. * Disables the GeometryBufferRender associated with the scene
  137173. */
  137174. disableGeometryBufferRenderer(): void;
  137175. }
  137176. /**
  137177. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137178. * in several rendering techniques.
  137179. */
  137180. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137181. /**
  137182. * The component name helpful to identify the component in the list of scene components.
  137183. */
  137184. readonly name: string;
  137185. /**
  137186. * The scene the component belongs to.
  137187. */
  137188. scene: Scene;
  137189. /**
  137190. * Creates a new instance of the component for the given scene
  137191. * @param scene Defines the scene to register the component in
  137192. */
  137193. constructor(scene: Scene);
  137194. /**
  137195. * Registers the component in a given scene
  137196. */
  137197. register(): void;
  137198. /**
  137199. * Rebuilds the elements related to this component in case of
  137200. * context lost for instance.
  137201. */
  137202. rebuild(): void;
  137203. /**
  137204. * Disposes the component and the associated ressources
  137205. */
  137206. dispose(): void;
  137207. private _gatherRenderTargets;
  137208. }
  137209. }
  137210. declare module BABYLON {
  137211. /** @hidden */
  137212. export var motionBlurPixelShader: {
  137213. name: string;
  137214. shader: string;
  137215. };
  137216. }
  137217. declare module BABYLON {
  137218. /**
  137219. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137220. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137221. * As an example, all you have to do is to create the post-process:
  137222. * var mb = new BABYLON.MotionBlurPostProcess(
  137223. * 'mb', // The name of the effect.
  137224. * scene, // The scene containing the objects to blur according to their velocity.
  137225. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137226. * camera // The camera to apply the render pass to.
  137227. * );
  137228. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137229. */
  137230. export class MotionBlurPostProcess extends PostProcess {
  137231. /**
  137232. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137233. */
  137234. motionStrength: number;
  137235. /**
  137236. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137237. */
  137238. get motionBlurSamples(): number;
  137239. /**
  137240. * Sets the number of iterations to be used for motion blur quality
  137241. */
  137242. set motionBlurSamples(samples: number);
  137243. private _motionBlurSamples;
  137244. private _geometryBufferRenderer;
  137245. /**
  137246. * Creates a new instance MotionBlurPostProcess
  137247. * @param name The name of the effect.
  137248. * @param scene The scene containing the objects to blur according to their velocity.
  137249. * @param options The required width/height ratio to downsize to before computing the render pass.
  137250. * @param camera The camera to apply the render pass to.
  137251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137252. * @param engine The engine which the post process will be applied. (default: current engine)
  137253. * @param reusable If the post process can be reused on the same frame. (default: false)
  137254. * @param textureType Type of textures used when performing the post process. (default: 0)
  137255. * @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)
  137256. */
  137257. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137258. /**
  137259. * Excludes the given skinned mesh from computing bones velocities.
  137260. * 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.
  137261. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137262. */
  137263. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137264. /**
  137265. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137266. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137267. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137268. */
  137269. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137270. /**
  137271. * Disposes the post process.
  137272. * @param camera The camera to dispose the post process on.
  137273. */
  137274. dispose(camera?: Camera): void;
  137275. }
  137276. }
  137277. declare module BABYLON {
  137278. /** @hidden */
  137279. export var refractionPixelShader: {
  137280. name: string;
  137281. shader: string;
  137282. };
  137283. }
  137284. declare module BABYLON {
  137285. /**
  137286. * Post process which applies a refractin texture
  137287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137288. */
  137289. export class RefractionPostProcess extends PostProcess {
  137290. /** the base color of the refraction (used to taint the rendering) */
  137291. color: Color3;
  137292. /** simulated refraction depth */
  137293. depth: number;
  137294. /** the coefficient of the base color (0 to remove base color tainting) */
  137295. colorLevel: number;
  137296. private _refTexture;
  137297. private _ownRefractionTexture;
  137298. /**
  137299. * Gets or sets the refraction texture
  137300. * Please note that you are responsible for disposing the texture if you set it manually
  137301. */
  137302. get refractionTexture(): Texture;
  137303. set refractionTexture(value: Texture);
  137304. /**
  137305. * Initializes the RefractionPostProcess
  137306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137307. * @param name The name of the effect.
  137308. * @param refractionTextureUrl Url of the refraction texture to use
  137309. * @param color the base color of the refraction (used to taint the rendering)
  137310. * @param depth simulated refraction depth
  137311. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137312. * @param camera The camera to apply the render pass to.
  137313. * @param options The required width/height ratio to downsize to before computing the render pass.
  137314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137315. * @param engine The engine which the post process will be applied. (default: current engine)
  137316. * @param reusable If the post process can be reused on the same frame. (default: false)
  137317. */
  137318. constructor(name: string, refractionTextureUrl: string,
  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, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137325. /**
  137326. * Disposes of the post process
  137327. * @param camera Camera to dispose post process on
  137328. */
  137329. dispose(camera: Camera): void;
  137330. }
  137331. }
  137332. declare module BABYLON {
  137333. /** @hidden */
  137334. export var sharpenPixelShader: {
  137335. name: string;
  137336. shader: string;
  137337. };
  137338. }
  137339. declare module BABYLON {
  137340. /**
  137341. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137342. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137343. */
  137344. export class SharpenPostProcess extends PostProcess {
  137345. /**
  137346. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137347. */
  137348. colorAmount: number;
  137349. /**
  137350. * How much sharpness should be applied (default: 0.3)
  137351. */
  137352. edgeAmount: number;
  137353. /**
  137354. * Creates a new instance ConvolutionPostProcess
  137355. * @param name The name of the effect.
  137356. * @param options The required width/height ratio to downsize to before computing the render pass.
  137357. * @param camera The camera to apply the render pass to.
  137358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137359. * @param engine The engine which the post process will be applied. (default: current engine)
  137360. * @param reusable If the post process can be reused on the same frame. (default: false)
  137361. * @param textureType Type of textures used when performing the post process. (default: 0)
  137362. * @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)
  137363. */
  137364. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137365. }
  137366. }
  137367. declare module BABYLON {
  137368. /**
  137369. * PostProcessRenderPipeline
  137370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137371. */
  137372. export class PostProcessRenderPipeline {
  137373. private engine;
  137374. private _renderEffects;
  137375. private _renderEffectsForIsolatedPass;
  137376. /**
  137377. * List of inspectable custom properties (used by the Inspector)
  137378. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  137379. */
  137380. inspectableCustomProperties: IInspectable[];
  137381. /**
  137382. * @hidden
  137383. */
  137384. protected _cameras: Camera[];
  137385. /** @hidden */
  137386. _name: string;
  137387. /**
  137388. * Gets pipeline name
  137389. */
  137390. get name(): string;
  137391. /** Gets the list of attached cameras */
  137392. get cameras(): Camera[];
  137393. /**
  137394. * Initializes a PostProcessRenderPipeline
  137395. * @param engine engine to add the pipeline to
  137396. * @param name name of the pipeline
  137397. */
  137398. constructor(engine: Engine, name: string);
  137399. /**
  137400. * Gets the class name
  137401. * @returns "PostProcessRenderPipeline"
  137402. */
  137403. getClassName(): string;
  137404. /**
  137405. * If all the render effects in the pipeline are supported
  137406. */
  137407. get isSupported(): boolean;
  137408. /**
  137409. * Adds an effect to the pipeline
  137410. * @param renderEffect the effect to add
  137411. */
  137412. addEffect(renderEffect: PostProcessRenderEffect): void;
  137413. /** @hidden */
  137414. _rebuild(): void;
  137415. /** @hidden */
  137416. _enableEffect(renderEffectName: string, cameras: Camera): void;
  137417. /** @hidden */
  137418. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  137419. /** @hidden */
  137420. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137421. /** @hidden */
  137422. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137423. /** @hidden */
  137424. _attachCameras(cameras: Camera, unique: boolean): void;
  137425. /** @hidden */
  137426. _attachCameras(cameras: Camera[], unique: boolean): void;
  137427. /** @hidden */
  137428. _detachCameras(cameras: Camera): void;
  137429. /** @hidden */
  137430. _detachCameras(cameras: Nullable<Camera[]>): void;
  137431. /** @hidden */
  137432. _update(): void;
  137433. /** @hidden */
  137434. _reset(): void;
  137435. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  137436. /**
  137437. * Disposes of the pipeline
  137438. */
  137439. dispose(): void;
  137440. }
  137441. }
  137442. declare module BABYLON {
  137443. /**
  137444. * PostProcessRenderPipelineManager class
  137445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137446. */
  137447. export class PostProcessRenderPipelineManager {
  137448. private _renderPipelines;
  137449. /**
  137450. * Initializes a PostProcessRenderPipelineManager
  137451. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137452. */
  137453. constructor();
  137454. /**
  137455. * Gets the list of supported render pipelines
  137456. */
  137457. get supportedPipelines(): PostProcessRenderPipeline[];
  137458. /**
  137459. * Adds a pipeline to the manager
  137460. * @param renderPipeline The pipeline to add
  137461. */
  137462. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  137463. /**
  137464. * Attaches a camera to the pipeline
  137465. * @param renderPipelineName The name of the pipeline to attach to
  137466. * @param cameras the camera to attach
  137467. * @param unique if the camera can be attached multiple times to the pipeline
  137468. */
  137469. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  137470. /**
  137471. * Detaches a camera from the pipeline
  137472. * @param renderPipelineName The name of the pipeline to detach from
  137473. * @param cameras the camera to detach
  137474. */
  137475. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  137476. /**
  137477. * Enables an effect by name on a pipeline
  137478. * @param renderPipelineName the name of the pipeline to enable the effect in
  137479. * @param renderEffectName the name of the effect to enable
  137480. * @param cameras the cameras that the effect should be enabled on
  137481. */
  137482. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137483. /**
  137484. * Disables an effect by name on a pipeline
  137485. * @param renderPipelineName the name of the pipeline to disable the effect in
  137486. * @param renderEffectName the name of the effect to disable
  137487. * @param cameras the cameras that the effect should be disabled on
  137488. */
  137489. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137490. /**
  137491. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  137492. */
  137493. update(): void;
  137494. /** @hidden */
  137495. _rebuild(): void;
  137496. /**
  137497. * Disposes of the manager and pipelines
  137498. */
  137499. dispose(): void;
  137500. }
  137501. }
  137502. declare module BABYLON {
  137503. interface Scene {
  137504. /** @hidden (Backing field) */
  137505. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137506. /**
  137507. * Gets the postprocess render pipeline manager
  137508. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137509. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137510. */
  137511. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137512. }
  137513. /**
  137514. * Defines the Render Pipeline scene component responsible to rendering pipelines
  137515. */
  137516. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  137517. /**
  137518. * The component name helpfull to identify the component in the list of scene components.
  137519. */
  137520. readonly name: string;
  137521. /**
  137522. * The scene the component belongs to.
  137523. */
  137524. scene: Scene;
  137525. /**
  137526. * Creates a new instance of the component for the given scene
  137527. * @param scene Defines the scene to register the component in
  137528. */
  137529. constructor(scene: Scene);
  137530. /**
  137531. * Registers the component in a given scene
  137532. */
  137533. register(): void;
  137534. /**
  137535. * Rebuilds the elements related to this component in case of
  137536. * context lost for instance.
  137537. */
  137538. rebuild(): void;
  137539. /**
  137540. * Disposes the component and the associated ressources
  137541. */
  137542. dispose(): void;
  137543. private _gatherRenderTargets;
  137544. }
  137545. }
  137546. declare module BABYLON {
  137547. /**
  137548. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  137549. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137550. */
  137551. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  137552. private _scene;
  137553. private _camerasToBeAttached;
  137554. /**
  137555. * ID of the sharpen post process,
  137556. */
  137557. private readonly SharpenPostProcessId;
  137558. /**
  137559. * @ignore
  137560. * ID of the image processing post process;
  137561. */
  137562. readonly ImageProcessingPostProcessId: string;
  137563. /**
  137564. * @ignore
  137565. * ID of the Fast Approximate Anti-Aliasing post process;
  137566. */
  137567. readonly FxaaPostProcessId: string;
  137568. /**
  137569. * ID of the chromatic aberration post process,
  137570. */
  137571. private readonly ChromaticAberrationPostProcessId;
  137572. /**
  137573. * ID of the grain post process
  137574. */
  137575. private readonly GrainPostProcessId;
  137576. /**
  137577. * Sharpen post process which will apply a sharpen convolution to enhance edges
  137578. */
  137579. sharpen: SharpenPostProcess;
  137580. private _sharpenEffect;
  137581. private bloom;
  137582. /**
  137583. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  137584. */
  137585. depthOfField: DepthOfFieldEffect;
  137586. /**
  137587. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  137588. */
  137589. fxaa: FxaaPostProcess;
  137590. /**
  137591. * Image post processing pass used to perform operations such as tone mapping or color grading.
  137592. */
  137593. imageProcessing: ImageProcessingPostProcess;
  137594. /**
  137595. * Chromatic aberration post process which will shift rgb colors in the image
  137596. */
  137597. chromaticAberration: ChromaticAberrationPostProcess;
  137598. private _chromaticAberrationEffect;
  137599. /**
  137600. * Grain post process which add noise to the image
  137601. */
  137602. grain: GrainPostProcess;
  137603. private _grainEffect;
  137604. /**
  137605. * Glow post process which adds a glow to emissive areas of the image
  137606. */
  137607. private _glowLayer;
  137608. /**
  137609. * Animations which can be used to tweak settings over a period of time
  137610. */
  137611. animations: Animation[];
  137612. private _imageProcessingConfigurationObserver;
  137613. private _sharpenEnabled;
  137614. private _bloomEnabled;
  137615. private _depthOfFieldEnabled;
  137616. private _depthOfFieldBlurLevel;
  137617. private _fxaaEnabled;
  137618. private _imageProcessingEnabled;
  137619. private _defaultPipelineTextureType;
  137620. private _bloomScale;
  137621. private _chromaticAberrationEnabled;
  137622. private _grainEnabled;
  137623. private _buildAllowed;
  137624. /**
  137625. * Gets active scene
  137626. */
  137627. get scene(): Scene;
  137628. /**
  137629. * Enable or disable the sharpen process from the pipeline
  137630. */
  137631. set sharpenEnabled(enabled: boolean);
  137632. get sharpenEnabled(): boolean;
  137633. private _resizeObserver;
  137634. private _hardwareScaleLevel;
  137635. private _bloomKernel;
  137636. /**
  137637. * Specifies the size of the bloom blur kernel, relative to the final output size
  137638. */
  137639. get bloomKernel(): number;
  137640. set bloomKernel(value: number);
  137641. /**
  137642. * Specifies the weight of the bloom in the final rendering
  137643. */
  137644. private _bloomWeight;
  137645. /**
  137646. * Specifies the luma threshold for the area that will be blurred by the bloom
  137647. */
  137648. private _bloomThreshold;
  137649. private _hdr;
  137650. /**
  137651. * The strength of the bloom.
  137652. */
  137653. set bloomWeight(value: number);
  137654. get bloomWeight(): number;
  137655. /**
  137656. * The strength of the bloom.
  137657. */
  137658. set bloomThreshold(value: number);
  137659. get bloomThreshold(): number;
  137660. /**
  137661. * The scale of the bloom, lower value will provide better performance.
  137662. */
  137663. set bloomScale(value: number);
  137664. get bloomScale(): number;
  137665. /**
  137666. * Enable or disable the bloom from the pipeline
  137667. */
  137668. set bloomEnabled(enabled: boolean);
  137669. get bloomEnabled(): boolean;
  137670. private _rebuildBloom;
  137671. /**
  137672. * If the depth of field is enabled.
  137673. */
  137674. get depthOfFieldEnabled(): boolean;
  137675. set depthOfFieldEnabled(enabled: boolean);
  137676. /**
  137677. * Blur level of the depth of field effect. (Higher blur will effect performance)
  137678. */
  137679. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  137680. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  137681. /**
  137682. * If the anti aliasing is enabled.
  137683. */
  137684. set fxaaEnabled(enabled: boolean);
  137685. get fxaaEnabled(): boolean;
  137686. private _samples;
  137687. /**
  137688. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  137689. */
  137690. set samples(sampleCount: number);
  137691. get samples(): number;
  137692. /**
  137693. * If image processing is enabled.
  137694. */
  137695. set imageProcessingEnabled(enabled: boolean);
  137696. get imageProcessingEnabled(): boolean;
  137697. /**
  137698. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  137699. */
  137700. set glowLayerEnabled(enabled: boolean);
  137701. get glowLayerEnabled(): boolean;
  137702. /**
  137703. * Gets the glow layer (or null if not defined)
  137704. */
  137705. get glowLayer(): Nullable<GlowLayer>;
  137706. /**
  137707. * Enable or disable the chromaticAberration process from the pipeline
  137708. */
  137709. set chromaticAberrationEnabled(enabled: boolean);
  137710. get chromaticAberrationEnabled(): boolean;
  137711. /**
  137712. * Enable or disable the grain process from the pipeline
  137713. */
  137714. set grainEnabled(enabled: boolean);
  137715. get grainEnabled(): boolean;
  137716. /**
  137717. * @constructor
  137718. * @param name - The rendering pipeline name (default: "")
  137719. * @param hdr - If high dynamic range textures should be used (default: true)
  137720. * @param scene - The scene linked to this pipeline (default: the last created scene)
  137721. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  137722. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  137723. */
  137724. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  137725. /**
  137726. * Get the class name
  137727. * @returns "DefaultRenderingPipeline"
  137728. */
  137729. getClassName(): string;
  137730. /**
  137731. * Force the compilation of the entire pipeline.
  137732. */
  137733. prepare(): void;
  137734. private _hasCleared;
  137735. private _prevPostProcess;
  137736. private _prevPrevPostProcess;
  137737. private _setAutoClearAndTextureSharing;
  137738. private _depthOfFieldSceneObserver;
  137739. private _buildPipeline;
  137740. private _disposePostProcesses;
  137741. /**
  137742. * Adds a camera to the pipeline
  137743. * @param camera the camera to be added
  137744. */
  137745. addCamera(camera: Camera): void;
  137746. /**
  137747. * Removes a camera from the pipeline
  137748. * @param camera the camera to remove
  137749. */
  137750. removeCamera(camera: Camera): void;
  137751. /**
  137752. * Dispose of the pipeline and stop all post processes
  137753. */
  137754. dispose(): void;
  137755. /**
  137756. * Serialize the rendering pipeline (Used when exporting)
  137757. * @returns the serialized object
  137758. */
  137759. serialize(): any;
  137760. /**
  137761. * Parse the serialized pipeline
  137762. * @param source Source pipeline.
  137763. * @param scene The scene to load the pipeline to.
  137764. * @param rootUrl The URL of the serialized pipeline.
  137765. * @returns An instantiated pipeline from the serialized object.
  137766. */
  137767. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  137768. }
  137769. }
  137770. declare module BABYLON {
  137771. /** @hidden */
  137772. export var lensHighlightsPixelShader: {
  137773. name: string;
  137774. shader: string;
  137775. };
  137776. }
  137777. declare module BABYLON {
  137778. /** @hidden */
  137779. export var depthOfFieldPixelShader: {
  137780. name: string;
  137781. shader: string;
  137782. };
  137783. }
  137784. declare module BABYLON {
  137785. /**
  137786. * BABYLON.JS Chromatic Aberration GLSL Shader
  137787. * Author: Olivier Guyot
  137788. * Separates very slightly R, G and B colors on the edges of the screen
  137789. * Inspired by Francois Tarlier & Martins Upitis
  137790. */
  137791. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  137792. /**
  137793. * @ignore
  137794. * The chromatic aberration PostProcess id in the pipeline
  137795. */
  137796. LensChromaticAberrationEffect: string;
  137797. /**
  137798. * @ignore
  137799. * The highlights enhancing PostProcess id in the pipeline
  137800. */
  137801. HighlightsEnhancingEffect: string;
  137802. /**
  137803. * @ignore
  137804. * The depth-of-field PostProcess id in the pipeline
  137805. */
  137806. LensDepthOfFieldEffect: string;
  137807. private _scene;
  137808. private _depthTexture;
  137809. private _grainTexture;
  137810. private _chromaticAberrationPostProcess;
  137811. private _highlightsPostProcess;
  137812. private _depthOfFieldPostProcess;
  137813. private _edgeBlur;
  137814. private _grainAmount;
  137815. private _chromaticAberration;
  137816. private _distortion;
  137817. private _highlightsGain;
  137818. private _highlightsThreshold;
  137819. private _dofDistance;
  137820. private _dofAperture;
  137821. private _dofDarken;
  137822. private _dofPentagon;
  137823. private _blurNoise;
  137824. /**
  137825. * @constructor
  137826. *
  137827. * Effect parameters are as follow:
  137828. * {
  137829. * chromatic_aberration: number; // from 0 to x (1 for realism)
  137830. * edge_blur: number; // from 0 to x (1 for realism)
  137831. * distortion: number; // from 0 to x (1 for realism)
  137832. * grain_amount: number; // from 0 to 1
  137833. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  137834. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  137835. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  137836. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  137837. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  137838. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  137839. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  137840. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  137841. * }
  137842. * Note: if an effect parameter is unset, effect is disabled
  137843. *
  137844. * @param name The rendering pipeline name
  137845. * @param parameters - An object containing all parameters (see above)
  137846. * @param scene The scene linked to this pipeline
  137847. * @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)
  137848. * @param cameras The array of cameras that the rendering pipeline will be attached to
  137849. */
  137850. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  137851. /**
  137852. * Get the class name
  137853. * @returns "LensRenderingPipeline"
  137854. */
  137855. getClassName(): string;
  137856. /**
  137857. * Gets associated scene
  137858. */
  137859. get scene(): Scene;
  137860. /**
  137861. * Gets or sets the edge blur
  137862. */
  137863. get edgeBlur(): number;
  137864. set edgeBlur(value: number);
  137865. /**
  137866. * Gets or sets the grain amount
  137867. */
  137868. get grainAmount(): number;
  137869. set grainAmount(value: number);
  137870. /**
  137871. * Gets or sets the chromatic aberration amount
  137872. */
  137873. get chromaticAberration(): number;
  137874. set chromaticAberration(value: number);
  137875. /**
  137876. * Gets or sets the depth of field aperture
  137877. */
  137878. get dofAperture(): number;
  137879. set dofAperture(value: number);
  137880. /**
  137881. * Gets or sets the edge distortion
  137882. */
  137883. get edgeDistortion(): number;
  137884. set edgeDistortion(value: number);
  137885. /**
  137886. * Gets or sets the depth of field distortion
  137887. */
  137888. get dofDistortion(): number;
  137889. set dofDistortion(value: number);
  137890. /**
  137891. * Gets or sets the darken out of focus amount
  137892. */
  137893. get darkenOutOfFocus(): number;
  137894. set darkenOutOfFocus(value: number);
  137895. /**
  137896. * Gets or sets a boolean indicating if blur noise is enabled
  137897. */
  137898. get blurNoise(): boolean;
  137899. set blurNoise(value: boolean);
  137900. /**
  137901. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  137902. */
  137903. get pentagonBokeh(): boolean;
  137904. set pentagonBokeh(value: boolean);
  137905. /**
  137906. * Gets or sets the highlight grain amount
  137907. */
  137908. get highlightsGain(): number;
  137909. set highlightsGain(value: number);
  137910. /**
  137911. * Gets or sets the highlight threshold
  137912. */
  137913. get highlightsThreshold(): number;
  137914. set highlightsThreshold(value: number);
  137915. /**
  137916. * Sets the amount of blur at the edges
  137917. * @param amount blur amount
  137918. */
  137919. setEdgeBlur(amount: number): void;
  137920. /**
  137921. * Sets edge blur to 0
  137922. */
  137923. disableEdgeBlur(): void;
  137924. /**
  137925. * Sets the amout of grain
  137926. * @param amount Amount of grain
  137927. */
  137928. setGrainAmount(amount: number): void;
  137929. /**
  137930. * Set grain amount to 0
  137931. */
  137932. disableGrain(): void;
  137933. /**
  137934. * Sets the chromatic aberration amount
  137935. * @param amount amount of chromatic aberration
  137936. */
  137937. setChromaticAberration(amount: number): void;
  137938. /**
  137939. * Sets chromatic aberration amount to 0
  137940. */
  137941. disableChromaticAberration(): void;
  137942. /**
  137943. * Sets the EdgeDistortion amount
  137944. * @param amount amount of EdgeDistortion
  137945. */
  137946. setEdgeDistortion(amount: number): void;
  137947. /**
  137948. * Sets edge distortion to 0
  137949. */
  137950. disableEdgeDistortion(): void;
  137951. /**
  137952. * Sets the FocusDistance amount
  137953. * @param amount amount of FocusDistance
  137954. */
  137955. setFocusDistance(amount: number): void;
  137956. /**
  137957. * Disables depth of field
  137958. */
  137959. disableDepthOfField(): void;
  137960. /**
  137961. * Sets the Aperture amount
  137962. * @param amount amount of Aperture
  137963. */
  137964. setAperture(amount: number): void;
  137965. /**
  137966. * Sets the DarkenOutOfFocus amount
  137967. * @param amount amount of DarkenOutOfFocus
  137968. */
  137969. setDarkenOutOfFocus(amount: number): void;
  137970. private _pentagonBokehIsEnabled;
  137971. /**
  137972. * Creates a pentagon bokeh effect
  137973. */
  137974. enablePentagonBokeh(): void;
  137975. /**
  137976. * Disables the pentagon bokeh effect
  137977. */
  137978. disablePentagonBokeh(): void;
  137979. /**
  137980. * Enables noise blur
  137981. */
  137982. enableNoiseBlur(): void;
  137983. /**
  137984. * Disables noise blur
  137985. */
  137986. disableNoiseBlur(): void;
  137987. /**
  137988. * Sets the HighlightsGain amount
  137989. * @param amount amount of HighlightsGain
  137990. */
  137991. setHighlightsGain(amount: number): void;
  137992. /**
  137993. * Sets the HighlightsThreshold amount
  137994. * @param amount amount of HighlightsThreshold
  137995. */
  137996. setHighlightsThreshold(amount: number): void;
  137997. /**
  137998. * Disables highlights
  137999. */
  138000. disableHighlights(): void;
  138001. /**
  138002. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138003. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138004. */
  138005. dispose(disableDepthRender?: boolean): void;
  138006. private _createChromaticAberrationPostProcess;
  138007. private _createHighlightsPostProcess;
  138008. private _createDepthOfFieldPostProcess;
  138009. private _createGrainTexture;
  138010. }
  138011. }
  138012. declare module BABYLON {
  138013. /** @hidden */
  138014. export var ssao2PixelShader: {
  138015. name: string;
  138016. shader: string;
  138017. };
  138018. }
  138019. declare module BABYLON {
  138020. /** @hidden */
  138021. export var ssaoCombinePixelShader: {
  138022. name: string;
  138023. shader: string;
  138024. };
  138025. }
  138026. declare module BABYLON {
  138027. /**
  138028. * Render pipeline to produce ssao effect
  138029. */
  138030. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138031. /**
  138032. * @ignore
  138033. * The PassPostProcess id in the pipeline that contains the original scene color
  138034. */
  138035. SSAOOriginalSceneColorEffect: string;
  138036. /**
  138037. * @ignore
  138038. * The SSAO PostProcess id in the pipeline
  138039. */
  138040. SSAORenderEffect: string;
  138041. /**
  138042. * @ignore
  138043. * The horizontal blur PostProcess id in the pipeline
  138044. */
  138045. SSAOBlurHRenderEffect: string;
  138046. /**
  138047. * @ignore
  138048. * The vertical blur PostProcess id in the pipeline
  138049. */
  138050. SSAOBlurVRenderEffect: string;
  138051. /**
  138052. * @ignore
  138053. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138054. */
  138055. SSAOCombineRenderEffect: string;
  138056. /**
  138057. * The output strength of the SSAO post-process. Default value is 1.0.
  138058. */
  138059. totalStrength: number;
  138060. /**
  138061. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138062. */
  138063. maxZ: number;
  138064. /**
  138065. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138066. */
  138067. minZAspect: number;
  138068. private _samples;
  138069. /**
  138070. * Number of samples used for the SSAO calculations. Default value is 8
  138071. */
  138072. set samples(n: number);
  138073. get samples(): number;
  138074. private _textureSamples;
  138075. /**
  138076. * Number of samples to use for antialiasing
  138077. */
  138078. set textureSamples(n: number);
  138079. get textureSamples(): number;
  138080. /**
  138081. * Ratio object used for SSAO ratio and blur ratio
  138082. */
  138083. private _ratio;
  138084. /**
  138085. * Dynamically generated sphere sampler.
  138086. */
  138087. private _sampleSphere;
  138088. /**
  138089. * Blur filter offsets
  138090. */
  138091. private _samplerOffsets;
  138092. private _expensiveBlur;
  138093. /**
  138094. * If bilateral blur should be used
  138095. */
  138096. set expensiveBlur(b: boolean);
  138097. get expensiveBlur(): boolean;
  138098. /**
  138099. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138100. */
  138101. radius: number;
  138102. /**
  138103. * The base color of the SSAO post-process
  138104. * The final result is "base + ssao" between [0, 1]
  138105. */
  138106. base: number;
  138107. /**
  138108. * Support test.
  138109. */
  138110. static get IsSupported(): boolean;
  138111. private _scene;
  138112. private _depthTexture;
  138113. private _normalTexture;
  138114. private _randomTexture;
  138115. private _originalColorPostProcess;
  138116. private _ssaoPostProcess;
  138117. private _blurHPostProcess;
  138118. private _blurVPostProcess;
  138119. private _ssaoCombinePostProcess;
  138120. /**
  138121. * Gets active scene
  138122. */
  138123. get scene(): Scene;
  138124. /**
  138125. * @constructor
  138126. * @param name The rendering pipeline name
  138127. * @param scene The scene linked to this pipeline
  138128. * @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 }
  138129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138130. */
  138131. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138132. /**
  138133. * Get the class name
  138134. * @returns "SSAO2RenderingPipeline"
  138135. */
  138136. getClassName(): string;
  138137. /**
  138138. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138139. */
  138140. dispose(disableGeometryBufferRenderer?: boolean): void;
  138141. private _createBlurPostProcess;
  138142. /** @hidden */
  138143. _rebuild(): void;
  138144. private _bits;
  138145. private _radicalInverse_VdC;
  138146. private _hammersley;
  138147. private _hemisphereSample_uniform;
  138148. private _generateHemisphere;
  138149. private _createSSAOPostProcess;
  138150. private _createSSAOCombinePostProcess;
  138151. private _createRandomTexture;
  138152. /**
  138153. * Serialize the rendering pipeline (Used when exporting)
  138154. * @returns the serialized object
  138155. */
  138156. serialize(): any;
  138157. /**
  138158. * Parse the serialized pipeline
  138159. * @param source Source pipeline.
  138160. * @param scene The scene to load the pipeline to.
  138161. * @param rootUrl The URL of the serialized pipeline.
  138162. * @returns An instantiated pipeline from the serialized object.
  138163. */
  138164. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138165. }
  138166. }
  138167. declare module BABYLON {
  138168. /** @hidden */
  138169. export var ssaoPixelShader: {
  138170. name: string;
  138171. shader: string;
  138172. };
  138173. }
  138174. declare module BABYLON {
  138175. /**
  138176. * Render pipeline to produce ssao effect
  138177. */
  138178. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138179. /**
  138180. * @ignore
  138181. * The PassPostProcess id in the pipeline that contains the original scene color
  138182. */
  138183. SSAOOriginalSceneColorEffect: string;
  138184. /**
  138185. * @ignore
  138186. * The SSAO PostProcess id in the pipeline
  138187. */
  138188. SSAORenderEffect: string;
  138189. /**
  138190. * @ignore
  138191. * The horizontal blur PostProcess id in the pipeline
  138192. */
  138193. SSAOBlurHRenderEffect: string;
  138194. /**
  138195. * @ignore
  138196. * The vertical blur PostProcess id in the pipeline
  138197. */
  138198. SSAOBlurVRenderEffect: string;
  138199. /**
  138200. * @ignore
  138201. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138202. */
  138203. SSAOCombineRenderEffect: string;
  138204. /**
  138205. * The output strength of the SSAO post-process. Default value is 1.0.
  138206. */
  138207. totalStrength: number;
  138208. /**
  138209. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138210. */
  138211. radius: number;
  138212. /**
  138213. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138214. * Must not be equal to fallOff and superior to fallOff.
  138215. * Default value is 0.0075
  138216. */
  138217. area: number;
  138218. /**
  138219. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138220. * Must not be equal to area and inferior to area.
  138221. * Default value is 0.000001
  138222. */
  138223. fallOff: number;
  138224. /**
  138225. * The base color of the SSAO post-process
  138226. * The final result is "base + ssao" between [0, 1]
  138227. */
  138228. base: number;
  138229. private _scene;
  138230. private _depthTexture;
  138231. private _randomTexture;
  138232. private _originalColorPostProcess;
  138233. private _ssaoPostProcess;
  138234. private _blurHPostProcess;
  138235. private _blurVPostProcess;
  138236. private _ssaoCombinePostProcess;
  138237. private _firstUpdate;
  138238. /**
  138239. * Gets active scene
  138240. */
  138241. get scene(): Scene;
  138242. /**
  138243. * @constructor
  138244. * @param name - The rendering pipeline name
  138245. * @param scene - The scene linked to this pipeline
  138246. * @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 }
  138247. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138248. */
  138249. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138250. /**
  138251. * Get the class name
  138252. * @returns "SSAORenderingPipeline"
  138253. */
  138254. getClassName(): string;
  138255. /**
  138256. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138257. */
  138258. dispose(disableDepthRender?: boolean): void;
  138259. private _createBlurPostProcess;
  138260. /** @hidden */
  138261. _rebuild(): void;
  138262. private _createSSAOPostProcess;
  138263. private _createSSAOCombinePostProcess;
  138264. private _createRandomTexture;
  138265. }
  138266. }
  138267. declare module BABYLON {
  138268. /** @hidden */
  138269. export var screenSpaceReflectionPixelShader: {
  138270. name: string;
  138271. shader: string;
  138272. };
  138273. }
  138274. declare module BABYLON {
  138275. /**
  138276. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138277. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138278. */
  138279. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138280. /**
  138281. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138282. */
  138283. threshold: number;
  138284. /**
  138285. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138286. */
  138287. strength: number;
  138288. /**
  138289. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  138290. */
  138291. reflectionSpecularFalloffExponent: number;
  138292. /**
  138293. * 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]
  138294. */
  138295. step: number;
  138296. /**
  138297. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  138298. */
  138299. roughnessFactor: number;
  138300. private _geometryBufferRenderer;
  138301. private _enableSmoothReflections;
  138302. private _reflectionSamples;
  138303. private _smoothSteps;
  138304. /**
  138305. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  138306. * @param name The name of the effect.
  138307. * @param scene The scene containing the objects to calculate reflections.
  138308. * @param options The required width/height ratio to downsize to before computing the render pass.
  138309. * @param camera The camera to apply the render pass to.
  138310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138311. * @param engine The engine which the post process will be applied. (default: current engine)
  138312. * @param reusable If the post process can be reused on the same frame. (default: false)
  138313. * @param textureType Type of textures used when performing the post process. (default: 0)
  138314. * @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)
  138315. */
  138316. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138317. /**
  138318. * Gets wether or not smoothing reflections is enabled.
  138319. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138320. */
  138321. get enableSmoothReflections(): boolean;
  138322. /**
  138323. * Sets wether or not smoothing reflections is enabled.
  138324. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138325. */
  138326. set enableSmoothReflections(enabled: boolean);
  138327. /**
  138328. * Gets the number of samples taken while computing reflections. More samples count is high,
  138329. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138330. */
  138331. get reflectionSamples(): number;
  138332. /**
  138333. * Sets the number of samples taken while computing reflections. More samples count is high,
  138334. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138335. */
  138336. set reflectionSamples(samples: number);
  138337. /**
  138338. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  138339. * more the post-process will require GPU power and can generate a drop in FPS.
  138340. * Default value (5.0) work pretty well in all cases but can be adjusted.
  138341. */
  138342. get smoothSteps(): number;
  138343. set smoothSteps(steps: number);
  138344. private _updateEffectDefines;
  138345. }
  138346. }
  138347. declare module BABYLON {
  138348. /** @hidden */
  138349. export var standardPixelShader: {
  138350. name: string;
  138351. shader: string;
  138352. };
  138353. }
  138354. declare module BABYLON {
  138355. /**
  138356. * Standard rendering pipeline
  138357. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138358. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  138359. */
  138360. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138361. /**
  138362. * Public members
  138363. */
  138364. /**
  138365. * Post-process which contains the original scene color before the pipeline applies all the effects
  138366. */
  138367. originalPostProcess: Nullable<PostProcess>;
  138368. /**
  138369. * Post-process used to down scale an image x4
  138370. */
  138371. downSampleX4PostProcess: Nullable<PostProcess>;
  138372. /**
  138373. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  138374. */
  138375. brightPassPostProcess: Nullable<PostProcess>;
  138376. /**
  138377. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  138378. */
  138379. blurHPostProcesses: PostProcess[];
  138380. /**
  138381. * Post-process array storing all the vertical blur post-processes used by the pipeline
  138382. */
  138383. blurVPostProcesses: PostProcess[];
  138384. /**
  138385. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  138386. */
  138387. textureAdderPostProcess: Nullable<PostProcess>;
  138388. /**
  138389. * Post-process used to create volumetric lighting effect
  138390. */
  138391. volumetricLightPostProcess: Nullable<PostProcess>;
  138392. /**
  138393. * Post-process used to smooth the previous volumetric light post-process on the X axis
  138394. */
  138395. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  138396. /**
  138397. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  138398. */
  138399. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  138400. /**
  138401. * Post-process used to merge the volumetric light effect and the real scene color
  138402. */
  138403. volumetricLightMergePostProces: Nullable<PostProcess>;
  138404. /**
  138405. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  138406. */
  138407. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  138408. /**
  138409. * Base post-process used to calculate the average luminance of the final image for HDR
  138410. */
  138411. luminancePostProcess: Nullable<PostProcess>;
  138412. /**
  138413. * Post-processes used to create down sample post-processes in order to get
  138414. * the average luminance of the final image for HDR
  138415. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  138416. */
  138417. luminanceDownSamplePostProcesses: PostProcess[];
  138418. /**
  138419. * Post-process used to create a HDR effect (light adaptation)
  138420. */
  138421. hdrPostProcess: Nullable<PostProcess>;
  138422. /**
  138423. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  138424. */
  138425. textureAdderFinalPostProcess: Nullable<PostProcess>;
  138426. /**
  138427. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  138428. */
  138429. lensFlareFinalPostProcess: Nullable<PostProcess>;
  138430. /**
  138431. * Post-process used to merge the final HDR post-process and the real scene color
  138432. */
  138433. hdrFinalPostProcess: Nullable<PostProcess>;
  138434. /**
  138435. * Post-process used to create a lens flare effect
  138436. */
  138437. lensFlarePostProcess: Nullable<PostProcess>;
  138438. /**
  138439. * Post-process that merges the result of the lens flare post-process and the real scene color
  138440. */
  138441. lensFlareComposePostProcess: Nullable<PostProcess>;
  138442. /**
  138443. * Post-process used to create a motion blur effect
  138444. */
  138445. motionBlurPostProcess: Nullable<PostProcess>;
  138446. /**
  138447. * Post-process used to create a depth of field effect
  138448. */
  138449. depthOfFieldPostProcess: Nullable<PostProcess>;
  138450. /**
  138451. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138452. */
  138453. fxaaPostProcess: Nullable<FxaaPostProcess>;
  138454. /**
  138455. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  138456. */
  138457. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  138458. /**
  138459. * Represents the brightness threshold in order to configure the illuminated surfaces
  138460. */
  138461. brightThreshold: number;
  138462. /**
  138463. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  138464. */
  138465. blurWidth: number;
  138466. /**
  138467. * Sets if the blur for highlighted surfaces must be only horizontal
  138468. */
  138469. horizontalBlur: boolean;
  138470. /**
  138471. * Gets the overall exposure used by the pipeline
  138472. */
  138473. get exposure(): number;
  138474. /**
  138475. * Sets the overall exposure used by the pipeline
  138476. */
  138477. set exposure(value: number);
  138478. /**
  138479. * Texture used typically to simulate "dirty" on camera lens
  138480. */
  138481. lensTexture: Nullable<Texture>;
  138482. /**
  138483. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  138484. */
  138485. volumetricLightCoefficient: number;
  138486. /**
  138487. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  138488. */
  138489. volumetricLightPower: number;
  138490. /**
  138491. * Used the set the blur intensity to smooth the volumetric lights
  138492. */
  138493. volumetricLightBlurScale: number;
  138494. /**
  138495. * Light (spot or directional) used to generate the volumetric lights rays
  138496. * The source light must have a shadow generate so the pipeline can get its
  138497. * depth map
  138498. */
  138499. sourceLight: Nullable<SpotLight | DirectionalLight>;
  138500. /**
  138501. * For eye adaptation, represents the minimum luminance the eye can see
  138502. */
  138503. hdrMinimumLuminance: number;
  138504. /**
  138505. * For eye adaptation, represents the decrease luminance speed
  138506. */
  138507. hdrDecreaseRate: number;
  138508. /**
  138509. * For eye adaptation, represents the increase luminance speed
  138510. */
  138511. hdrIncreaseRate: number;
  138512. /**
  138513. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138514. */
  138515. get hdrAutoExposure(): boolean;
  138516. /**
  138517. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138518. */
  138519. set hdrAutoExposure(value: boolean);
  138520. /**
  138521. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  138522. */
  138523. lensColorTexture: Nullable<Texture>;
  138524. /**
  138525. * The overall strengh for the lens flare effect
  138526. */
  138527. lensFlareStrength: number;
  138528. /**
  138529. * Dispersion coefficient for lens flare ghosts
  138530. */
  138531. lensFlareGhostDispersal: number;
  138532. /**
  138533. * Main lens flare halo width
  138534. */
  138535. lensFlareHaloWidth: number;
  138536. /**
  138537. * Based on the lens distortion effect, defines how much the lens flare result
  138538. * is distorted
  138539. */
  138540. lensFlareDistortionStrength: number;
  138541. /**
  138542. * Configures the blur intensity used for for lens flare (halo)
  138543. */
  138544. lensFlareBlurWidth: number;
  138545. /**
  138546. * Lens star texture must be used to simulate rays on the flares and is available
  138547. * in the documentation
  138548. */
  138549. lensStarTexture: Nullable<Texture>;
  138550. /**
  138551. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  138552. * flare effect by taking account of the dirt texture
  138553. */
  138554. lensFlareDirtTexture: Nullable<Texture>;
  138555. /**
  138556. * Represents the focal length for the depth of field effect
  138557. */
  138558. depthOfFieldDistance: number;
  138559. /**
  138560. * Represents the blur intensity for the blurred part of the depth of field effect
  138561. */
  138562. depthOfFieldBlurWidth: number;
  138563. /**
  138564. * Gets how much the image is blurred by the movement while using the motion blur post-process
  138565. */
  138566. get motionStrength(): number;
  138567. /**
  138568. * Sets how much the image is blurred by the movement while using the motion blur post-process
  138569. */
  138570. set motionStrength(strength: number);
  138571. /**
  138572. * Gets wether or not the motion blur post-process is object based or screen based.
  138573. */
  138574. get objectBasedMotionBlur(): boolean;
  138575. /**
  138576. * Sets wether or not the motion blur post-process should be object based or screen based
  138577. */
  138578. set objectBasedMotionBlur(value: boolean);
  138579. /**
  138580. * List of animations for the pipeline (IAnimatable implementation)
  138581. */
  138582. animations: Animation[];
  138583. /**
  138584. * Private members
  138585. */
  138586. private _scene;
  138587. private _currentDepthOfFieldSource;
  138588. private _basePostProcess;
  138589. private _fixedExposure;
  138590. private _currentExposure;
  138591. private _hdrAutoExposure;
  138592. private _hdrCurrentLuminance;
  138593. private _motionStrength;
  138594. private _isObjectBasedMotionBlur;
  138595. private _floatTextureType;
  138596. private _camerasToBeAttached;
  138597. private _ratio;
  138598. private _bloomEnabled;
  138599. private _depthOfFieldEnabled;
  138600. private _vlsEnabled;
  138601. private _lensFlareEnabled;
  138602. private _hdrEnabled;
  138603. private _motionBlurEnabled;
  138604. private _fxaaEnabled;
  138605. private _screenSpaceReflectionsEnabled;
  138606. private _motionBlurSamples;
  138607. private _volumetricLightStepsCount;
  138608. private _samples;
  138609. /**
  138610. * @ignore
  138611. * Specifies if the bloom pipeline is enabled
  138612. */
  138613. get BloomEnabled(): boolean;
  138614. set BloomEnabled(enabled: boolean);
  138615. /**
  138616. * @ignore
  138617. * Specifies if the depth of field pipeline is enabed
  138618. */
  138619. get DepthOfFieldEnabled(): boolean;
  138620. set DepthOfFieldEnabled(enabled: boolean);
  138621. /**
  138622. * @ignore
  138623. * Specifies if the lens flare pipeline is enabed
  138624. */
  138625. get LensFlareEnabled(): boolean;
  138626. set LensFlareEnabled(enabled: boolean);
  138627. /**
  138628. * @ignore
  138629. * Specifies if the HDR pipeline is enabled
  138630. */
  138631. get HDREnabled(): boolean;
  138632. set HDREnabled(enabled: boolean);
  138633. /**
  138634. * @ignore
  138635. * Specifies if the volumetric lights scattering effect is enabled
  138636. */
  138637. get VLSEnabled(): boolean;
  138638. set VLSEnabled(enabled: boolean);
  138639. /**
  138640. * @ignore
  138641. * Specifies if the motion blur effect is enabled
  138642. */
  138643. get MotionBlurEnabled(): boolean;
  138644. set MotionBlurEnabled(enabled: boolean);
  138645. /**
  138646. * Specifies if anti-aliasing is enabled
  138647. */
  138648. get fxaaEnabled(): boolean;
  138649. set fxaaEnabled(enabled: boolean);
  138650. /**
  138651. * Specifies if screen space reflections are enabled.
  138652. */
  138653. get screenSpaceReflectionsEnabled(): boolean;
  138654. set screenSpaceReflectionsEnabled(enabled: boolean);
  138655. /**
  138656. * Specifies the number of steps used to calculate the volumetric lights
  138657. * Typically in interval [50, 200]
  138658. */
  138659. get volumetricLightStepsCount(): number;
  138660. set volumetricLightStepsCount(count: number);
  138661. /**
  138662. * Specifies the number of samples used for the motion blur effect
  138663. * Typically in interval [16, 64]
  138664. */
  138665. get motionBlurSamples(): number;
  138666. set motionBlurSamples(samples: number);
  138667. /**
  138668. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138669. */
  138670. get samples(): number;
  138671. set samples(sampleCount: number);
  138672. /**
  138673. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138674. * @constructor
  138675. * @param name The rendering pipeline name
  138676. * @param scene The scene linked to this pipeline
  138677. * @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)
  138678. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  138679. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138680. */
  138681. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  138682. private _buildPipeline;
  138683. private _createDownSampleX4PostProcess;
  138684. private _createBrightPassPostProcess;
  138685. private _createBlurPostProcesses;
  138686. private _createTextureAdderPostProcess;
  138687. private _createVolumetricLightPostProcess;
  138688. private _createLuminancePostProcesses;
  138689. private _createHdrPostProcess;
  138690. private _createLensFlarePostProcess;
  138691. private _createDepthOfFieldPostProcess;
  138692. private _createMotionBlurPostProcess;
  138693. private _getDepthTexture;
  138694. private _disposePostProcesses;
  138695. /**
  138696. * Dispose of the pipeline and stop all post processes
  138697. */
  138698. dispose(): void;
  138699. /**
  138700. * Serialize the rendering pipeline (Used when exporting)
  138701. * @returns the serialized object
  138702. */
  138703. serialize(): any;
  138704. /**
  138705. * Parse the serialized pipeline
  138706. * @param source Source pipeline.
  138707. * @param scene The scene to load the pipeline to.
  138708. * @param rootUrl The URL of the serialized pipeline.
  138709. * @returns An instantiated pipeline from the serialized object.
  138710. */
  138711. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  138712. /**
  138713. * Luminance steps
  138714. */
  138715. static LuminanceSteps: number;
  138716. }
  138717. }
  138718. declare module BABYLON {
  138719. /** @hidden */
  138720. export var tonemapPixelShader: {
  138721. name: string;
  138722. shader: string;
  138723. };
  138724. }
  138725. declare module BABYLON {
  138726. /** Defines operator used for tonemapping */
  138727. export enum TonemappingOperator {
  138728. /** Hable */
  138729. Hable = 0,
  138730. /** Reinhard */
  138731. Reinhard = 1,
  138732. /** HejiDawson */
  138733. HejiDawson = 2,
  138734. /** Photographic */
  138735. Photographic = 3
  138736. }
  138737. /**
  138738. * Defines a post process to apply tone mapping
  138739. */
  138740. export class TonemapPostProcess extends PostProcess {
  138741. private _operator;
  138742. /** Defines the required exposure adjustement */
  138743. exposureAdjustment: number;
  138744. /**
  138745. * Creates a new TonemapPostProcess
  138746. * @param name defines the name of the postprocess
  138747. * @param _operator defines the operator to use
  138748. * @param exposureAdjustment defines the required exposure adjustement
  138749. * @param camera defines the camera to use (can be null)
  138750. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  138751. * @param engine defines the hosting engine (can be ignore if camera is set)
  138752. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138753. */
  138754. constructor(name: string, _operator: TonemappingOperator,
  138755. /** Defines the required exposure adjustement */
  138756. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  138757. }
  138758. }
  138759. declare module BABYLON {
  138760. /** @hidden */
  138761. export var volumetricLightScatteringPixelShader: {
  138762. name: string;
  138763. shader: string;
  138764. };
  138765. }
  138766. declare module BABYLON {
  138767. /** @hidden */
  138768. export var volumetricLightScatteringPassVertexShader: {
  138769. name: string;
  138770. shader: string;
  138771. };
  138772. }
  138773. declare module BABYLON {
  138774. /** @hidden */
  138775. export var volumetricLightScatteringPassPixelShader: {
  138776. name: string;
  138777. shader: string;
  138778. };
  138779. }
  138780. declare module BABYLON {
  138781. /**
  138782. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  138783. */
  138784. export class VolumetricLightScatteringPostProcess extends PostProcess {
  138785. private _volumetricLightScatteringPass;
  138786. private _volumetricLightScatteringRTT;
  138787. private _viewPort;
  138788. private _screenCoordinates;
  138789. private _cachedDefines;
  138790. /**
  138791. * If not undefined, the mesh position is computed from the attached node position
  138792. */
  138793. attachedNode: {
  138794. position: Vector3;
  138795. };
  138796. /**
  138797. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  138798. */
  138799. customMeshPosition: Vector3;
  138800. /**
  138801. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  138802. */
  138803. useCustomMeshPosition: boolean;
  138804. /**
  138805. * If the post-process should inverse the light scattering direction
  138806. */
  138807. invert: boolean;
  138808. /**
  138809. * The internal mesh used by the post-process
  138810. */
  138811. mesh: Mesh;
  138812. /**
  138813. * @hidden
  138814. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  138815. */
  138816. get useDiffuseColor(): boolean;
  138817. set useDiffuseColor(useDiffuseColor: boolean);
  138818. /**
  138819. * Array containing the excluded meshes not rendered in the internal pass
  138820. */
  138821. excludedMeshes: AbstractMesh[];
  138822. /**
  138823. * Controls the overall intensity of the post-process
  138824. */
  138825. exposure: number;
  138826. /**
  138827. * Dissipates each sample's contribution in range [0, 1]
  138828. */
  138829. decay: number;
  138830. /**
  138831. * Controls the overall intensity of each sample
  138832. */
  138833. weight: number;
  138834. /**
  138835. * Controls the density of each sample
  138836. */
  138837. density: number;
  138838. /**
  138839. * @constructor
  138840. * @param name The post-process name
  138841. * @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)
  138842. * @param camera The camera that the post-process will be attached to
  138843. * @param mesh The mesh used to create the light scattering
  138844. * @param samples The post-process quality, default 100
  138845. * @param samplingModeThe post-process filtering mode
  138846. * @param engine The babylon engine
  138847. * @param reusable If the post-process is reusable
  138848. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  138849. */
  138850. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  138851. /**
  138852. * Returns the string "VolumetricLightScatteringPostProcess"
  138853. * @returns "VolumetricLightScatteringPostProcess"
  138854. */
  138855. getClassName(): string;
  138856. private _isReady;
  138857. /**
  138858. * Sets the new light position for light scattering effect
  138859. * @param position The new custom light position
  138860. */
  138861. setCustomMeshPosition(position: Vector3): void;
  138862. /**
  138863. * Returns the light position for light scattering effect
  138864. * @return Vector3 The custom light position
  138865. */
  138866. getCustomMeshPosition(): Vector3;
  138867. /**
  138868. * Disposes the internal assets and detaches the post-process from the camera
  138869. */
  138870. dispose(camera: Camera): void;
  138871. /**
  138872. * Returns the render target texture used by the post-process
  138873. * @return the render target texture used by the post-process
  138874. */
  138875. getPass(): RenderTargetTexture;
  138876. private _meshExcluded;
  138877. private _createPass;
  138878. private _updateMeshScreenCoordinates;
  138879. /**
  138880. * Creates a default mesh for the Volumeric Light Scattering post-process
  138881. * @param name The mesh name
  138882. * @param scene The scene where to create the mesh
  138883. * @return the default mesh
  138884. */
  138885. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  138886. }
  138887. }
  138888. declare module BABYLON {
  138889. interface Scene {
  138890. /** @hidden (Backing field) */
  138891. _boundingBoxRenderer: BoundingBoxRenderer;
  138892. /** @hidden (Backing field) */
  138893. _forceShowBoundingBoxes: boolean;
  138894. /**
  138895. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  138896. */
  138897. forceShowBoundingBoxes: boolean;
  138898. /**
  138899. * Gets the bounding box renderer associated with the scene
  138900. * @returns a BoundingBoxRenderer
  138901. */
  138902. getBoundingBoxRenderer(): BoundingBoxRenderer;
  138903. }
  138904. interface AbstractMesh {
  138905. /** @hidden (Backing field) */
  138906. _showBoundingBox: boolean;
  138907. /**
  138908. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  138909. */
  138910. showBoundingBox: boolean;
  138911. }
  138912. /**
  138913. * Component responsible of rendering the bounding box of the meshes in a scene.
  138914. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  138915. */
  138916. export class BoundingBoxRenderer implements ISceneComponent {
  138917. /**
  138918. * The component name helpfull to identify the component in the list of scene components.
  138919. */
  138920. readonly name: string;
  138921. /**
  138922. * The scene the component belongs to.
  138923. */
  138924. scene: Scene;
  138925. /**
  138926. * Color of the bounding box lines placed in front of an object
  138927. */
  138928. frontColor: Color3;
  138929. /**
  138930. * Color of the bounding box lines placed behind an object
  138931. */
  138932. backColor: Color3;
  138933. /**
  138934. * Defines if the renderer should show the back lines or not
  138935. */
  138936. showBackLines: boolean;
  138937. /**
  138938. * @hidden
  138939. */
  138940. renderList: SmartArray<BoundingBox>;
  138941. private _colorShader;
  138942. private _vertexBuffers;
  138943. private _indexBuffer;
  138944. private _fillIndexBuffer;
  138945. private _fillIndexData;
  138946. /**
  138947. * Instantiates a new bounding box renderer in a scene.
  138948. * @param scene the scene the renderer renders in
  138949. */
  138950. constructor(scene: Scene);
  138951. /**
  138952. * Registers the component in a given scene
  138953. */
  138954. register(): void;
  138955. private _evaluateSubMesh;
  138956. private _activeMesh;
  138957. private _prepareRessources;
  138958. private _createIndexBuffer;
  138959. /**
  138960. * Rebuilds the elements related to this component in case of
  138961. * context lost for instance.
  138962. */
  138963. rebuild(): void;
  138964. /**
  138965. * @hidden
  138966. */
  138967. reset(): void;
  138968. /**
  138969. * Render the bounding boxes of a specific rendering group
  138970. * @param renderingGroupId defines the rendering group to render
  138971. */
  138972. render(renderingGroupId: number): void;
  138973. /**
  138974. * In case of occlusion queries, we can render the occlusion bounding box through this method
  138975. * @param mesh Define the mesh to render the occlusion bounding box for
  138976. */
  138977. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  138978. /**
  138979. * Dispose and release the resources attached to this renderer.
  138980. */
  138981. dispose(): void;
  138982. }
  138983. }
  138984. declare module BABYLON {
  138985. interface Scene {
  138986. /** @hidden (Backing field) */
  138987. _depthRenderer: {
  138988. [id: string]: DepthRenderer;
  138989. };
  138990. /**
  138991. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  138992. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  138993. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138994. * @returns the created depth renderer
  138995. */
  138996. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  138997. /**
  138998. * Disables a depth renderer for a given camera
  138999. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139000. */
  139001. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139002. }
  139003. /**
  139004. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139005. * in several rendering techniques.
  139006. */
  139007. export class DepthRendererSceneComponent implements ISceneComponent {
  139008. /**
  139009. * The component name helpfull to identify the component in the list of scene components.
  139010. */
  139011. readonly name: string;
  139012. /**
  139013. * The scene the component belongs to.
  139014. */
  139015. scene: Scene;
  139016. /**
  139017. * Creates a new instance of the component for the given scene
  139018. * @param scene Defines the scene to register the component in
  139019. */
  139020. constructor(scene: Scene);
  139021. /**
  139022. * Registers the component in a given scene
  139023. */
  139024. register(): void;
  139025. /**
  139026. * Rebuilds the elements related to this component in case of
  139027. * context lost for instance.
  139028. */
  139029. rebuild(): void;
  139030. /**
  139031. * Disposes the component and the associated ressources
  139032. */
  139033. dispose(): void;
  139034. private _gatherRenderTargets;
  139035. private _gatherActiveCameraRenderTargets;
  139036. }
  139037. }
  139038. declare module BABYLON {
  139039. /** @hidden */
  139040. export var outlinePixelShader: {
  139041. name: string;
  139042. shader: string;
  139043. };
  139044. }
  139045. declare module BABYLON {
  139046. /** @hidden */
  139047. export var outlineVertexShader: {
  139048. name: string;
  139049. shader: string;
  139050. };
  139051. }
  139052. declare module BABYLON {
  139053. interface Scene {
  139054. /** @hidden */
  139055. _outlineRenderer: OutlineRenderer;
  139056. /**
  139057. * Gets the outline renderer associated with the scene
  139058. * @returns a OutlineRenderer
  139059. */
  139060. getOutlineRenderer(): OutlineRenderer;
  139061. }
  139062. interface AbstractMesh {
  139063. /** @hidden (Backing field) */
  139064. _renderOutline: boolean;
  139065. /**
  139066. * Gets or sets a boolean indicating if the outline must be rendered as well
  139067. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139068. */
  139069. renderOutline: boolean;
  139070. /** @hidden (Backing field) */
  139071. _renderOverlay: boolean;
  139072. /**
  139073. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139074. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139075. */
  139076. renderOverlay: boolean;
  139077. }
  139078. /**
  139079. * This class is responsible to draw bothe outline/overlay of meshes.
  139080. * It should not be used directly but through the available method on mesh.
  139081. */
  139082. export class OutlineRenderer implements ISceneComponent {
  139083. /**
  139084. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139085. */
  139086. private static _StencilReference;
  139087. /**
  139088. * The name of the component. Each component must have a unique name.
  139089. */
  139090. name: string;
  139091. /**
  139092. * The scene the component belongs to.
  139093. */
  139094. scene: Scene;
  139095. /**
  139096. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139097. */
  139098. zOffset: number;
  139099. private _engine;
  139100. private _effect;
  139101. private _cachedDefines;
  139102. private _savedDepthWrite;
  139103. /**
  139104. * Instantiates a new outline renderer. (There could be only one per scene).
  139105. * @param scene Defines the scene it belongs to
  139106. */
  139107. constructor(scene: Scene);
  139108. /**
  139109. * Register the component to one instance of a scene.
  139110. */
  139111. register(): void;
  139112. /**
  139113. * Rebuilds the elements related to this component in case of
  139114. * context lost for instance.
  139115. */
  139116. rebuild(): void;
  139117. /**
  139118. * Disposes the component and the associated ressources.
  139119. */
  139120. dispose(): void;
  139121. /**
  139122. * Renders the outline in the canvas.
  139123. * @param subMesh Defines the sumesh to render
  139124. * @param batch Defines the batch of meshes in case of instances
  139125. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139126. */
  139127. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139128. /**
  139129. * Returns whether or not the outline renderer is ready for a given submesh.
  139130. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139131. * @param subMesh Defines the submesh to check readyness for
  139132. * @param useInstances Defines wheter wee are trying to render instances or not
  139133. * @returns true if ready otherwise false
  139134. */
  139135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139136. private _beforeRenderingMesh;
  139137. private _afterRenderingMesh;
  139138. }
  139139. }
  139140. declare module BABYLON {
  139141. /**
  139142. * Defines the basic options interface of a Sprite Frame Source Size.
  139143. */
  139144. export interface ISpriteJSONSpriteSourceSize {
  139145. /**
  139146. * number of the original width of the Frame
  139147. */
  139148. w: number;
  139149. /**
  139150. * number of the original height of the Frame
  139151. */
  139152. h: number;
  139153. }
  139154. /**
  139155. * Defines the basic options interface of a Sprite Frame Data.
  139156. */
  139157. export interface ISpriteJSONSpriteFrameData {
  139158. /**
  139159. * number of the x offset of the Frame
  139160. */
  139161. x: number;
  139162. /**
  139163. * number of the y offset of the Frame
  139164. */
  139165. y: number;
  139166. /**
  139167. * number of the width of the Frame
  139168. */
  139169. w: number;
  139170. /**
  139171. * number of the height of the Frame
  139172. */
  139173. h: number;
  139174. }
  139175. /**
  139176. * Defines the basic options interface of a JSON Sprite.
  139177. */
  139178. export interface ISpriteJSONSprite {
  139179. /**
  139180. * string name of the Frame
  139181. */
  139182. filename: string;
  139183. /**
  139184. * ISpriteJSONSpriteFrame basic object of the frame data
  139185. */
  139186. frame: ISpriteJSONSpriteFrameData;
  139187. /**
  139188. * boolean to flag is the frame was rotated.
  139189. */
  139190. rotated: boolean;
  139191. /**
  139192. * boolean to flag is the frame was trimmed.
  139193. */
  139194. trimmed: boolean;
  139195. /**
  139196. * ISpriteJSONSpriteFrame basic object of the source data
  139197. */
  139198. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139199. /**
  139200. * ISpriteJSONSpriteFrame basic object of the source data
  139201. */
  139202. sourceSize: ISpriteJSONSpriteSourceSize;
  139203. }
  139204. /**
  139205. * Defines the basic options interface of a JSON atlas.
  139206. */
  139207. export interface ISpriteJSONAtlas {
  139208. /**
  139209. * Array of objects that contain the frame data.
  139210. */
  139211. frames: Array<ISpriteJSONSprite>;
  139212. /**
  139213. * object basic object containing the sprite meta data.
  139214. */
  139215. meta?: object;
  139216. }
  139217. }
  139218. declare module BABYLON {
  139219. /** @hidden */
  139220. export var spriteMapPixelShader: {
  139221. name: string;
  139222. shader: string;
  139223. };
  139224. }
  139225. declare module BABYLON {
  139226. /** @hidden */
  139227. export var spriteMapVertexShader: {
  139228. name: string;
  139229. shader: string;
  139230. };
  139231. }
  139232. declare module BABYLON {
  139233. /**
  139234. * Defines the basic options interface of a SpriteMap
  139235. */
  139236. export interface ISpriteMapOptions {
  139237. /**
  139238. * Vector2 of the number of cells in the grid.
  139239. */
  139240. stageSize?: Vector2;
  139241. /**
  139242. * Vector2 of the size of the output plane in World Units.
  139243. */
  139244. outputSize?: Vector2;
  139245. /**
  139246. * Vector3 of the position of the output plane in World Units.
  139247. */
  139248. outputPosition?: Vector3;
  139249. /**
  139250. * Vector3 of the rotation of the output plane.
  139251. */
  139252. outputRotation?: Vector3;
  139253. /**
  139254. * number of layers that the system will reserve in resources.
  139255. */
  139256. layerCount?: number;
  139257. /**
  139258. * number of max animation frames a single cell will reserve in resources.
  139259. */
  139260. maxAnimationFrames?: number;
  139261. /**
  139262. * number cell index of the base tile when the system compiles.
  139263. */
  139264. baseTile?: number;
  139265. /**
  139266. * boolean flip the sprite after its been repositioned by the framing data.
  139267. */
  139268. flipU?: boolean;
  139269. /**
  139270. * Vector3 scalar of the global RGB values of the SpriteMap.
  139271. */
  139272. colorMultiply?: Vector3;
  139273. }
  139274. /**
  139275. * Defines the IDisposable interface in order to be cleanable from resources.
  139276. */
  139277. export interface ISpriteMap extends IDisposable {
  139278. /**
  139279. * String name of the SpriteMap.
  139280. */
  139281. name: string;
  139282. /**
  139283. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139284. */
  139285. atlasJSON: ISpriteJSONAtlas;
  139286. /**
  139287. * Texture of the SpriteMap.
  139288. */
  139289. spriteSheet: Texture;
  139290. /**
  139291. * The parameters to initialize the SpriteMap with.
  139292. */
  139293. options: ISpriteMapOptions;
  139294. }
  139295. /**
  139296. * Class used to manage a grid restricted sprite deployment on an Output plane.
  139297. */
  139298. export class SpriteMap implements ISpriteMap {
  139299. /** The Name of the spriteMap */
  139300. name: string;
  139301. /** The JSON file with the frame and meta data */
  139302. atlasJSON: ISpriteJSONAtlas;
  139303. /** The systems Sprite Sheet Texture */
  139304. spriteSheet: Texture;
  139305. /** Arguments passed with the Constructor */
  139306. options: ISpriteMapOptions;
  139307. /** Public Sprite Storage array, parsed from atlasJSON */
  139308. sprites: Array<ISpriteJSONSprite>;
  139309. /** Returns the Number of Sprites in the System */
  139310. get spriteCount(): number;
  139311. /** Returns the Position of Output Plane*/
  139312. get position(): Vector3;
  139313. /** Returns the Position of Output Plane*/
  139314. set position(v: Vector3);
  139315. /** Returns the Rotation of Output Plane*/
  139316. get rotation(): Vector3;
  139317. /** Returns the Rotation of Output Plane*/
  139318. set rotation(v: Vector3);
  139319. /** Sets the AnimationMap*/
  139320. get animationMap(): RawTexture;
  139321. /** Sets the AnimationMap*/
  139322. set animationMap(v: RawTexture);
  139323. /** Scene that the SpriteMap was created in */
  139324. private _scene;
  139325. /** Texture Buffer of Float32 that holds tile frame data*/
  139326. private _frameMap;
  139327. /** Texture Buffers of Float32 that holds tileMap data*/
  139328. private _tileMaps;
  139329. /** Texture Buffer of Float32 that holds Animation Data*/
  139330. private _animationMap;
  139331. /** Custom ShaderMaterial Central to the System*/
  139332. private _material;
  139333. /** Custom ShaderMaterial Central to the System*/
  139334. private _output;
  139335. /** Systems Time Ticker*/
  139336. private _time;
  139337. /**
  139338. * Creates a new SpriteMap
  139339. * @param name defines the SpriteMaps Name
  139340. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  139341. * @param spriteSheet is the Texture that the Sprites are on.
  139342. * @param options a basic deployment configuration
  139343. * @param scene The Scene that the map is deployed on
  139344. */
  139345. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  139346. /**
  139347. * Returns tileID location
  139348. * @returns Vector2 the cell position ID
  139349. */
  139350. getTileID(): Vector2;
  139351. /**
  139352. * Gets the UV location of the mouse over the SpriteMap.
  139353. * @returns Vector2 the UV position of the mouse interaction
  139354. */
  139355. getMousePosition(): Vector2;
  139356. /**
  139357. * Creates the "frame" texture Buffer
  139358. * -------------------------------------
  139359. * Structure of frames
  139360. * "filename": "Falling-Water-2.png",
  139361. * "frame": {"x":69,"y":103,"w":24,"h":32},
  139362. * "rotated": true,
  139363. * "trimmed": true,
  139364. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  139365. * "sourceSize": {"w":32,"h":32}
  139366. * @returns RawTexture of the frameMap
  139367. */
  139368. private _createFrameBuffer;
  139369. /**
  139370. * Creates the tileMap texture Buffer
  139371. * @param buffer normally and array of numbers, or a false to generate from scratch
  139372. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  139373. * @returns RawTexture of the tileMap
  139374. */
  139375. private _createTileBuffer;
  139376. /**
  139377. * Modifies the data of the tileMaps
  139378. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  139379. * @param pos is the iVector2 Coordinates of the Tile
  139380. * @param tile The SpriteIndex of the new Tile
  139381. */
  139382. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  139383. /**
  139384. * Creates the animationMap texture Buffer
  139385. * @param buffer normally and array of numbers, or a false to generate from scratch
  139386. * @returns RawTexture of the animationMap
  139387. */
  139388. private _createTileAnimationBuffer;
  139389. /**
  139390. * Modifies the data of the animationMap
  139391. * @param cellID is the Index of the Sprite
  139392. * @param _frame is the target Animation frame
  139393. * @param toCell is the Target Index of the next frame of the animation
  139394. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  139395. * @param speed is a global scalar of the time variable on the map.
  139396. */
  139397. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  139398. /**
  139399. * Exports the .tilemaps file
  139400. */
  139401. saveTileMaps(): void;
  139402. /**
  139403. * Imports the .tilemaps file
  139404. * @param url of the .tilemaps file
  139405. */
  139406. loadTileMaps(url: string): void;
  139407. /**
  139408. * Release associated resources
  139409. */
  139410. dispose(): void;
  139411. }
  139412. }
  139413. declare module BABYLON {
  139414. /**
  139415. * Class used to manage multiple sprites of different sizes on the same spritesheet
  139416. * @see http://doc.babylonjs.com/babylon101/sprites
  139417. */
  139418. export class SpritePackedManager extends SpriteManager {
  139419. /** defines the packed manager's name */
  139420. name: string;
  139421. /**
  139422. * Creates a new sprite manager from a packed sprite sheet
  139423. * @param name defines the manager's name
  139424. * @param imgUrl defines the sprite sheet url
  139425. * @param capacity defines the maximum allowed number of sprites
  139426. * @param scene defines the hosting scene
  139427. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  139428. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  139429. * @param samplingMode defines the smapling mode to use with spritesheet
  139430. * @param fromPacked set to true; do not alter
  139431. */
  139432. constructor(
  139433. /** defines the packed manager's name */
  139434. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  139435. }
  139436. }
  139437. declare module BABYLON {
  139438. /**
  139439. * Defines the list of states available for a task inside a AssetsManager
  139440. */
  139441. export enum AssetTaskState {
  139442. /**
  139443. * Initialization
  139444. */
  139445. INIT = 0,
  139446. /**
  139447. * Running
  139448. */
  139449. RUNNING = 1,
  139450. /**
  139451. * Done
  139452. */
  139453. DONE = 2,
  139454. /**
  139455. * Error
  139456. */
  139457. ERROR = 3
  139458. }
  139459. /**
  139460. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  139461. */
  139462. export abstract class AbstractAssetTask {
  139463. /**
  139464. * Task name
  139465. */ name: string;
  139466. /**
  139467. * Callback called when the task is successful
  139468. */
  139469. onSuccess: (task: any) => void;
  139470. /**
  139471. * Callback called when the task is not successful
  139472. */
  139473. onError: (task: any, message?: string, exception?: any) => void;
  139474. /**
  139475. * Creates a new AssetsManager
  139476. * @param name defines the name of the task
  139477. */
  139478. constructor(
  139479. /**
  139480. * Task name
  139481. */ name: string);
  139482. private _isCompleted;
  139483. private _taskState;
  139484. private _errorObject;
  139485. /**
  139486. * Get if the task is completed
  139487. */
  139488. get isCompleted(): boolean;
  139489. /**
  139490. * Gets the current state of the task
  139491. */
  139492. get taskState(): AssetTaskState;
  139493. /**
  139494. * Gets the current error object (if task is in error)
  139495. */
  139496. get errorObject(): {
  139497. message?: string;
  139498. exception?: any;
  139499. };
  139500. /**
  139501. * Internal only
  139502. * @hidden
  139503. */
  139504. _setErrorObject(message?: string, exception?: any): void;
  139505. /**
  139506. * Execute the current task
  139507. * @param scene defines the scene where you want your assets to be loaded
  139508. * @param onSuccess is a callback called when the task is successfully executed
  139509. * @param onError is a callback called if an error occurs
  139510. */
  139511. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139512. /**
  139513. * Execute the current task
  139514. * @param scene defines the scene where you want your assets to be loaded
  139515. * @param onSuccess is a callback called when the task is successfully executed
  139516. * @param onError is a callback called if an error occurs
  139517. */
  139518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139519. /**
  139520. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  139521. * This can be used with failed tasks that have the reason for failure fixed.
  139522. */
  139523. reset(): void;
  139524. private onErrorCallback;
  139525. private onDoneCallback;
  139526. }
  139527. /**
  139528. * Define the interface used by progress events raised during assets loading
  139529. */
  139530. export interface IAssetsProgressEvent {
  139531. /**
  139532. * Defines the number of remaining tasks to process
  139533. */
  139534. remainingCount: number;
  139535. /**
  139536. * Defines the total number of tasks
  139537. */
  139538. totalCount: number;
  139539. /**
  139540. * Defines the task that was just processed
  139541. */
  139542. task: AbstractAssetTask;
  139543. }
  139544. /**
  139545. * Class used to share progress information about assets loading
  139546. */
  139547. export class AssetsProgressEvent implements IAssetsProgressEvent {
  139548. /**
  139549. * Defines the number of remaining tasks to process
  139550. */
  139551. remainingCount: number;
  139552. /**
  139553. * Defines the total number of tasks
  139554. */
  139555. totalCount: number;
  139556. /**
  139557. * Defines the task that was just processed
  139558. */
  139559. task: AbstractAssetTask;
  139560. /**
  139561. * Creates a AssetsProgressEvent
  139562. * @param remainingCount defines the number of remaining tasks to process
  139563. * @param totalCount defines the total number of tasks
  139564. * @param task defines the task that was just processed
  139565. */
  139566. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  139567. }
  139568. /**
  139569. * Define a task used by AssetsManager to load meshes
  139570. */
  139571. export class MeshAssetTask extends AbstractAssetTask {
  139572. /**
  139573. * Defines the name of the task
  139574. */
  139575. name: string;
  139576. /**
  139577. * Defines the list of mesh's names you want to load
  139578. */
  139579. meshesNames: any;
  139580. /**
  139581. * Defines the root url to use as a base to load your meshes and associated resources
  139582. */
  139583. rootUrl: string;
  139584. /**
  139585. * Defines the filename of the scene to load from
  139586. */
  139587. sceneFilename: string;
  139588. /**
  139589. * Gets the list of loaded meshes
  139590. */
  139591. loadedMeshes: Array<AbstractMesh>;
  139592. /**
  139593. * Gets the list of loaded particle systems
  139594. */
  139595. loadedParticleSystems: Array<IParticleSystem>;
  139596. /**
  139597. * Gets the list of loaded skeletons
  139598. */
  139599. loadedSkeletons: Array<Skeleton>;
  139600. /**
  139601. * Gets the list of loaded animation groups
  139602. */
  139603. loadedAnimationGroups: Array<AnimationGroup>;
  139604. /**
  139605. * Callback called when the task is successful
  139606. */
  139607. onSuccess: (task: MeshAssetTask) => void;
  139608. /**
  139609. * Callback called when the task is successful
  139610. */
  139611. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  139612. /**
  139613. * Creates a new MeshAssetTask
  139614. * @param name defines the name of the task
  139615. * @param meshesNames defines the list of mesh's names you want to load
  139616. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  139617. * @param sceneFilename defines the filename of the scene to load from
  139618. */
  139619. constructor(
  139620. /**
  139621. * Defines the name of the task
  139622. */
  139623. name: string,
  139624. /**
  139625. * Defines the list of mesh's names you want to load
  139626. */
  139627. meshesNames: any,
  139628. /**
  139629. * Defines the root url to use as a base to load your meshes and associated resources
  139630. */
  139631. rootUrl: string,
  139632. /**
  139633. * Defines the filename of the scene to load from
  139634. */
  139635. sceneFilename: string);
  139636. /**
  139637. * Execute the current task
  139638. * @param scene defines the scene where you want your assets to be loaded
  139639. * @param onSuccess is a callback called when the task is successfully executed
  139640. * @param onError is a callback called if an error occurs
  139641. */
  139642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139643. }
  139644. /**
  139645. * Define a task used by AssetsManager to load text content
  139646. */
  139647. export class TextFileAssetTask extends AbstractAssetTask {
  139648. /**
  139649. * Defines the name of the task
  139650. */
  139651. name: string;
  139652. /**
  139653. * Defines the location of the file to load
  139654. */
  139655. url: string;
  139656. /**
  139657. * Gets the loaded text string
  139658. */
  139659. text: string;
  139660. /**
  139661. * Callback called when the task is successful
  139662. */
  139663. onSuccess: (task: TextFileAssetTask) => void;
  139664. /**
  139665. * Callback called when the task is successful
  139666. */
  139667. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  139668. /**
  139669. * Creates a new TextFileAssetTask object
  139670. * @param name defines the name of the task
  139671. * @param url defines the location of the file to load
  139672. */
  139673. constructor(
  139674. /**
  139675. * Defines the name of the task
  139676. */
  139677. name: string,
  139678. /**
  139679. * Defines the location of the file to load
  139680. */
  139681. url: string);
  139682. /**
  139683. * Execute the current task
  139684. * @param scene defines the scene where you want your assets to be loaded
  139685. * @param onSuccess is a callback called when the task is successfully executed
  139686. * @param onError is a callback called if an error occurs
  139687. */
  139688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139689. }
  139690. /**
  139691. * Define a task used by AssetsManager to load binary data
  139692. */
  139693. export class BinaryFileAssetTask extends AbstractAssetTask {
  139694. /**
  139695. * Defines the name of the task
  139696. */
  139697. name: string;
  139698. /**
  139699. * Defines the location of the file to load
  139700. */
  139701. url: string;
  139702. /**
  139703. * Gets the lodaded data (as an array buffer)
  139704. */
  139705. data: ArrayBuffer;
  139706. /**
  139707. * Callback called when the task is successful
  139708. */
  139709. onSuccess: (task: BinaryFileAssetTask) => void;
  139710. /**
  139711. * Callback called when the task is successful
  139712. */
  139713. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  139714. /**
  139715. * Creates a new BinaryFileAssetTask object
  139716. * @param name defines the name of the new task
  139717. * @param url defines the location of the file to load
  139718. */
  139719. constructor(
  139720. /**
  139721. * Defines the name of the task
  139722. */
  139723. name: string,
  139724. /**
  139725. * Defines the location of the file to load
  139726. */
  139727. url: string);
  139728. /**
  139729. * Execute the current task
  139730. * @param scene defines the scene where you want your assets to be loaded
  139731. * @param onSuccess is a callback called when the task is successfully executed
  139732. * @param onError is a callback called if an error occurs
  139733. */
  139734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139735. }
  139736. /**
  139737. * Define a task used by AssetsManager to load images
  139738. */
  139739. export class ImageAssetTask extends AbstractAssetTask {
  139740. /**
  139741. * Defines the name of the task
  139742. */
  139743. name: string;
  139744. /**
  139745. * Defines the location of the image to load
  139746. */
  139747. url: string;
  139748. /**
  139749. * Gets the loaded images
  139750. */
  139751. image: HTMLImageElement;
  139752. /**
  139753. * Callback called when the task is successful
  139754. */
  139755. onSuccess: (task: ImageAssetTask) => void;
  139756. /**
  139757. * Callback called when the task is successful
  139758. */
  139759. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  139760. /**
  139761. * Creates a new ImageAssetTask
  139762. * @param name defines the name of the task
  139763. * @param url defines the location of the image to load
  139764. */
  139765. constructor(
  139766. /**
  139767. * Defines the name of the task
  139768. */
  139769. name: string,
  139770. /**
  139771. * Defines the location of the image to load
  139772. */
  139773. url: string);
  139774. /**
  139775. * Execute the current task
  139776. * @param scene defines the scene where you want your assets to be loaded
  139777. * @param onSuccess is a callback called when the task is successfully executed
  139778. * @param onError is a callback called if an error occurs
  139779. */
  139780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139781. }
  139782. /**
  139783. * Defines the interface used by texture loading tasks
  139784. */
  139785. export interface ITextureAssetTask<TEX extends BaseTexture> {
  139786. /**
  139787. * Gets the loaded texture
  139788. */
  139789. texture: TEX;
  139790. }
  139791. /**
  139792. * Define a task used by AssetsManager to load 2D textures
  139793. */
  139794. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  139795. /**
  139796. * Defines the name of the task
  139797. */
  139798. name: string;
  139799. /**
  139800. * Defines the location of the file to load
  139801. */
  139802. url: string;
  139803. /**
  139804. * Defines if mipmap should not be generated (default is false)
  139805. */
  139806. noMipmap?: boolean | undefined;
  139807. /**
  139808. * Defines if texture must be inverted on Y axis (default is false)
  139809. */
  139810. invertY?: boolean | undefined;
  139811. /**
  139812. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139813. */
  139814. samplingMode: number;
  139815. /**
  139816. * Gets the loaded texture
  139817. */
  139818. texture: Texture;
  139819. /**
  139820. * Callback called when the task is successful
  139821. */
  139822. onSuccess: (task: TextureAssetTask) => void;
  139823. /**
  139824. * Callback called when the task is successful
  139825. */
  139826. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  139827. /**
  139828. * Creates a new TextureAssetTask object
  139829. * @param name defines the name of the task
  139830. * @param url defines the location of the file to load
  139831. * @param noMipmap defines if mipmap should not be generated (default is false)
  139832. * @param invertY defines if texture must be inverted on Y axis (default is false)
  139833. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139834. */
  139835. constructor(
  139836. /**
  139837. * Defines the name of the task
  139838. */
  139839. name: string,
  139840. /**
  139841. * Defines the location of the file to load
  139842. */
  139843. url: string,
  139844. /**
  139845. * Defines if mipmap should not be generated (default is false)
  139846. */
  139847. noMipmap?: boolean | undefined,
  139848. /**
  139849. * Defines if texture must be inverted on Y axis (default is false)
  139850. */
  139851. invertY?: boolean | undefined,
  139852. /**
  139853. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139854. */
  139855. samplingMode?: number);
  139856. /**
  139857. * Execute the current task
  139858. * @param scene defines the scene where you want your assets to be loaded
  139859. * @param onSuccess is a callback called when the task is successfully executed
  139860. * @param onError is a callback called if an error occurs
  139861. */
  139862. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139863. }
  139864. /**
  139865. * Define a task used by AssetsManager to load cube textures
  139866. */
  139867. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  139868. /**
  139869. * Defines the name of the task
  139870. */
  139871. name: string;
  139872. /**
  139873. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139874. */
  139875. url: string;
  139876. /**
  139877. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139878. */
  139879. extensions?: string[] | undefined;
  139880. /**
  139881. * Defines if mipmaps should not be generated (default is false)
  139882. */
  139883. noMipmap?: boolean | undefined;
  139884. /**
  139885. * Defines the explicit list of files (undefined by default)
  139886. */
  139887. files?: string[] | undefined;
  139888. /**
  139889. * Gets the loaded texture
  139890. */
  139891. texture: CubeTexture;
  139892. /**
  139893. * Callback called when the task is successful
  139894. */
  139895. onSuccess: (task: CubeTextureAssetTask) => void;
  139896. /**
  139897. * Callback called when the task is successful
  139898. */
  139899. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  139900. /**
  139901. * Creates a new CubeTextureAssetTask
  139902. * @param name defines the name of the task
  139903. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139904. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139905. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139906. * @param files defines the explicit list of files (undefined by default)
  139907. */
  139908. constructor(
  139909. /**
  139910. * Defines the name of the task
  139911. */
  139912. name: string,
  139913. /**
  139914. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139915. */
  139916. url: string,
  139917. /**
  139918. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139919. */
  139920. extensions?: string[] | undefined,
  139921. /**
  139922. * Defines if mipmaps should not be generated (default is false)
  139923. */
  139924. noMipmap?: boolean | undefined,
  139925. /**
  139926. * Defines the explicit list of files (undefined by default)
  139927. */
  139928. files?: string[] | undefined);
  139929. /**
  139930. * Execute the current task
  139931. * @param scene defines the scene where you want your assets to be loaded
  139932. * @param onSuccess is a callback called when the task is successfully executed
  139933. * @param onError is a callback called if an error occurs
  139934. */
  139935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139936. }
  139937. /**
  139938. * Define a task used by AssetsManager to load HDR cube textures
  139939. */
  139940. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  139941. /**
  139942. * Defines the name of the task
  139943. */
  139944. name: string;
  139945. /**
  139946. * Defines the location of the file to load
  139947. */
  139948. url: string;
  139949. /**
  139950. * Defines the desired size (the more it increases the longer the generation will be)
  139951. */
  139952. size: number;
  139953. /**
  139954. * Defines if mipmaps should not be generated (default is false)
  139955. */
  139956. noMipmap: boolean;
  139957. /**
  139958. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139959. */
  139960. generateHarmonics: boolean;
  139961. /**
  139962. * 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)
  139963. */
  139964. gammaSpace: boolean;
  139965. /**
  139966. * Internal Use Only
  139967. */
  139968. reserved: boolean;
  139969. /**
  139970. * Gets the loaded texture
  139971. */
  139972. texture: HDRCubeTexture;
  139973. /**
  139974. * Callback called when the task is successful
  139975. */
  139976. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  139977. /**
  139978. * Callback called when the task is successful
  139979. */
  139980. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  139981. /**
  139982. * Creates a new HDRCubeTextureAssetTask object
  139983. * @param name defines the name of the task
  139984. * @param url defines the location of the file to load
  139985. * @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.
  139986. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139987. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139988. * @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)
  139989. * @param reserved Internal use only
  139990. */
  139991. constructor(
  139992. /**
  139993. * Defines the name of the task
  139994. */
  139995. name: string,
  139996. /**
  139997. * Defines the location of the file to load
  139998. */
  139999. url: string,
  140000. /**
  140001. * Defines the desired size (the more it increases the longer the generation will be)
  140002. */
  140003. size: number,
  140004. /**
  140005. * Defines if mipmaps should not be generated (default is false)
  140006. */
  140007. noMipmap?: boolean,
  140008. /**
  140009. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140010. */
  140011. generateHarmonics?: boolean,
  140012. /**
  140013. * 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)
  140014. */
  140015. gammaSpace?: boolean,
  140016. /**
  140017. * Internal Use Only
  140018. */
  140019. reserved?: boolean);
  140020. /**
  140021. * Execute the current task
  140022. * @param scene defines the scene where you want your assets to be loaded
  140023. * @param onSuccess is a callback called when the task is successfully executed
  140024. * @param onError is a callback called if an error occurs
  140025. */
  140026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140027. }
  140028. /**
  140029. * Define a task used by AssetsManager to load Equirectangular cube textures
  140030. */
  140031. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140032. /**
  140033. * Defines the name of the task
  140034. */
  140035. name: string;
  140036. /**
  140037. * Defines the location of the file to load
  140038. */
  140039. url: string;
  140040. /**
  140041. * Defines the desired size (the more it increases the longer the generation will be)
  140042. */
  140043. size: number;
  140044. /**
  140045. * Defines if mipmaps should not be generated (default is false)
  140046. */
  140047. noMipmap: boolean;
  140048. /**
  140049. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140050. * but the standard material would require them in Gamma space) (default is true)
  140051. */
  140052. gammaSpace: boolean;
  140053. /**
  140054. * Gets the loaded texture
  140055. */
  140056. texture: EquiRectangularCubeTexture;
  140057. /**
  140058. * Callback called when the task is successful
  140059. */
  140060. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140061. /**
  140062. * Callback called when the task is successful
  140063. */
  140064. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140065. /**
  140066. * Creates a new EquiRectangularCubeTextureAssetTask object
  140067. * @param name defines the name of the task
  140068. * @param url defines the location of the file to load
  140069. * @param size defines the desired size (the more it increases the longer the generation will be)
  140070. * If the size is omitted this implies you are using a preprocessed cubemap.
  140071. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140072. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140073. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140074. * (default is true)
  140075. */
  140076. constructor(
  140077. /**
  140078. * Defines the name of the task
  140079. */
  140080. name: string,
  140081. /**
  140082. * Defines the location of the file to load
  140083. */
  140084. url: string,
  140085. /**
  140086. * Defines the desired size (the more it increases the longer the generation will be)
  140087. */
  140088. size: number,
  140089. /**
  140090. * Defines if mipmaps should not be generated (default is false)
  140091. */
  140092. noMipmap?: boolean,
  140093. /**
  140094. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140095. * but the standard material would require them in Gamma space) (default is true)
  140096. */
  140097. gammaSpace?: boolean);
  140098. /**
  140099. * Execute the current task
  140100. * @param scene defines the scene where you want your assets to be loaded
  140101. * @param onSuccess is a callback called when the task is successfully executed
  140102. * @param onError is a callback called if an error occurs
  140103. */
  140104. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140105. }
  140106. /**
  140107. * This class can be used to easily import assets into a scene
  140108. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140109. */
  140110. export class AssetsManager {
  140111. private _scene;
  140112. private _isLoading;
  140113. protected _tasks: AbstractAssetTask[];
  140114. protected _waitingTasksCount: number;
  140115. protected _totalTasksCount: number;
  140116. /**
  140117. * Callback called when all tasks are processed
  140118. */
  140119. onFinish: (tasks: AbstractAssetTask[]) => void;
  140120. /**
  140121. * Callback called when a task is successful
  140122. */
  140123. onTaskSuccess: (task: AbstractAssetTask) => void;
  140124. /**
  140125. * Callback called when a task had an error
  140126. */
  140127. onTaskError: (task: AbstractAssetTask) => void;
  140128. /**
  140129. * Callback called when a task is done (whatever the result is)
  140130. */
  140131. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140132. /**
  140133. * Observable called when all tasks are processed
  140134. */
  140135. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140136. /**
  140137. * Observable called when a task had an error
  140138. */
  140139. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140140. /**
  140141. * Observable called when all tasks were executed
  140142. */
  140143. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140144. /**
  140145. * Observable called when a task is done (whatever the result is)
  140146. */
  140147. onProgressObservable: Observable<IAssetsProgressEvent>;
  140148. /**
  140149. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140151. */
  140152. useDefaultLoadingScreen: boolean;
  140153. /**
  140154. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140155. * when all assets have been downloaded.
  140156. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140157. */
  140158. autoHideLoadingUI: boolean;
  140159. /**
  140160. * Creates a new AssetsManager
  140161. * @param scene defines the scene to work on
  140162. */
  140163. constructor(scene: Scene);
  140164. /**
  140165. * Add a MeshAssetTask to the list of active tasks
  140166. * @param taskName defines the name of the new task
  140167. * @param meshesNames defines the name of meshes to load
  140168. * @param rootUrl defines the root url to use to locate files
  140169. * @param sceneFilename defines the filename of the scene file
  140170. * @returns a new MeshAssetTask object
  140171. */
  140172. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140173. /**
  140174. * Add a TextFileAssetTask to the list of active tasks
  140175. * @param taskName defines the name of the new task
  140176. * @param url defines the url of the file to load
  140177. * @returns a new TextFileAssetTask object
  140178. */
  140179. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140180. /**
  140181. * Add a BinaryFileAssetTask to the list of active tasks
  140182. * @param taskName defines the name of the new task
  140183. * @param url defines the url of the file to load
  140184. * @returns a new BinaryFileAssetTask object
  140185. */
  140186. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140187. /**
  140188. * Add a ImageAssetTask to the list of active tasks
  140189. * @param taskName defines the name of the new task
  140190. * @param url defines the url of the file to load
  140191. * @returns a new ImageAssetTask object
  140192. */
  140193. addImageTask(taskName: string, url: string): ImageAssetTask;
  140194. /**
  140195. * Add a TextureAssetTask to the list of active tasks
  140196. * @param taskName defines the name of the new task
  140197. * @param url defines the url of the file to load
  140198. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140199. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140200. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140201. * @returns a new TextureAssetTask object
  140202. */
  140203. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140204. /**
  140205. * Add a CubeTextureAssetTask to the list of active tasks
  140206. * @param taskName defines the name of the new task
  140207. * @param url defines the url of the file to load
  140208. * @param extensions defines the extension to use to load the cube map (can be null)
  140209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140210. * @param files defines the list of files to load (can be null)
  140211. * @returns a new CubeTextureAssetTask object
  140212. */
  140213. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140214. /**
  140215. *
  140216. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140217. * @param taskName defines the name of the new task
  140218. * @param url defines the url of the file to load
  140219. * @param size defines the size you want for the cubemap (can be null)
  140220. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140221. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140222. * @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)
  140223. * @param reserved Internal use only
  140224. * @returns a new HDRCubeTextureAssetTask object
  140225. */
  140226. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140227. /**
  140228. *
  140229. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140230. * @param taskName defines the name of the new task
  140231. * @param url defines the url of the file to load
  140232. * @param size defines the size you want for the cubemap (can be null)
  140233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140234. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140235. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140236. * @returns a new EquiRectangularCubeTextureAssetTask object
  140237. */
  140238. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140239. /**
  140240. * Remove a task from the assets manager.
  140241. * @param task the task to remove
  140242. */
  140243. removeTask(task: AbstractAssetTask): void;
  140244. private _decreaseWaitingTasksCount;
  140245. private _runTask;
  140246. /**
  140247. * Reset the AssetsManager and remove all tasks
  140248. * @return the current instance of the AssetsManager
  140249. */
  140250. reset(): AssetsManager;
  140251. /**
  140252. * Start the loading process
  140253. * @return the current instance of the AssetsManager
  140254. */
  140255. load(): AssetsManager;
  140256. /**
  140257. * Start the loading process as an async operation
  140258. * @return a promise returning the list of failed tasks
  140259. */
  140260. loadAsync(): Promise<void>;
  140261. }
  140262. }
  140263. declare module BABYLON {
  140264. /**
  140265. * Wrapper class for promise with external resolve and reject.
  140266. */
  140267. export class Deferred<T> {
  140268. /**
  140269. * The promise associated with this deferred object.
  140270. */
  140271. readonly promise: Promise<T>;
  140272. private _resolve;
  140273. private _reject;
  140274. /**
  140275. * The resolve method of the promise associated with this deferred object.
  140276. */
  140277. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140278. /**
  140279. * The reject method of the promise associated with this deferred object.
  140280. */
  140281. get reject(): (reason?: any) => void;
  140282. /**
  140283. * Constructor for this deferred object.
  140284. */
  140285. constructor();
  140286. }
  140287. }
  140288. declare module BABYLON {
  140289. /**
  140290. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140291. */
  140292. export class MeshExploder {
  140293. private _centerMesh;
  140294. private _meshes;
  140295. private _meshesOrigins;
  140296. private _toCenterVectors;
  140297. private _scaledDirection;
  140298. private _newPosition;
  140299. private _centerPosition;
  140300. /**
  140301. * Explodes meshes from a center mesh.
  140302. * @param meshes The meshes to explode.
  140303. * @param centerMesh The mesh to be center of explosion.
  140304. */
  140305. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  140306. private _setCenterMesh;
  140307. /**
  140308. * Get class name
  140309. * @returns "MeshExploder"
  140310. */
  140311. getClassName(): string;
  140312. /**
  140313. * "Exploded meshes"
  140314. * @returns Array of meshes with the centerMesh at index 0.
  140315. */
  140316. getMeshes(): Array<Mesh>;
  140317. /**
  140318. * Explodes meshes giving a specific direction
  140319. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  140320. */
  140321. explode(direction?: number): void;
  140322. }
  140323. }
  140324. declare module BABYLON {
  140325. /**
  140326. * Class used to help managing file picking and drag'n'drop
  140327. */
  140328. export class FilesInput {
  140329. /**
  140330. * List of files ready to be loaded
  140331. */
  140332. static get FilesToLoad(): {
  140333. [key: string]: File;
  140334. };
  140335. /**
  140336. * Callback called when a file is processed
  140337. */
  140338. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  140339. private _engine;
  140340. private _currentScene;
  140341. private _sceneLoadedCallback;
  140342. private _progressCallback;
  140343. private _additionalRenderLoopLogicCallback;
  140344. private _textureLoadingCallback;
  140345. private _startingProcessingFilesCallback;
  140346. private _onReloadCallback;
  140347. private _errorCallback;
  140348. private _elementToMonitor;
  140349. private _sceneFileToLoad;
  140350. private _filesToLoad;
  140351. /**
  140352. * Creates a new FilesInput
  140353. * @param engine defines the rendering engine
  140354. * @param scene defines the hosting scene
  140355. * @param sceneLoadedCallback callback called when scene is loaded
  140356. * @param progressCallback callback called to track progress
  140357. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  140358. * @param textureLoadingCallback callback called when a texture is loading
  140359. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  140360. * @param onReloadCallback callback called when a reload is requested
  140361. * @param errorCallback callback call if an error occurs
  140362. */
  140363. 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);
  140364. private _dragEnterHandler;
  140365. private _dragOverHandler;
  140366. private _dropHandler;
  140367. /**
  140368. * Calls this function to listen to drag'n'drop events on a specific DOM element
  140369. * @param elementToMonitor defines the DOM element to track
  140370. */
  140371. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  140372. /**
  140373. * Release all associated resources
  140374. */
  140375. dispose(): void;
  140376. private renderFunction;
  140377. private drag;
  140378. private drop;
  140379. private _traverseFolder;
  140380. private _processFiles;
  140381. /**
  140382. * Load files from a drop event
  140383. * @param event defines the drop event to use as source
  140384. */
  140385. loadFiles(event: any): void;
  140386. private _processReload;
  140387. /**
  140388. * Reload the current scene from the loaded files
  140389. */
  140390. reload(): void;
  140391. }
  140392. }
  140393. declare module BABYLON {
  140394. /**
  140395. * Defines the root class used to create scene optimization to use with SceneOptimizer
  140396. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140397. */
  140398. export class SceneOptimization {
  140399. /**
  140400. * Defines the priority of this optimization (0 by default which means first in the list)
  140401. */
  140402. priority: number;
  140403. /**
  140404. * Gets a string describing the action executed by the current optimization
  140405. * @returns description string
  140406. */
  140407. getDescription(): string;
  140408. /**
  140409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140410. * @param scene defines the current scene where to apply this optimization
  140411. * @param optimizer defines the current optimizer
  140412. * @returns true if everything that can be done was applied
  140413. */
  140414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140415. /**
  140416. * Creates the SceneOptimization object
  140417. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140418. * @param desc defines the description associated with the optimization
  140419. */
  140420. constructor(
  140421. /**
  140422. * Defines the priority of this optimization (0 by default which means first in the list)
  140423. */
  140424. priority?: number);
  140425. }
  140426. /**
  140427. * Defines an optimization used to reduce the size of render target textures
  140428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140429. */
  140430. export class TextureOptimization extends SceneOptimization {
  140431. /**
  140432. * Defines the priority of this optimization (0 by default which means first in the list)
  140433. */
  140434. priority: number;
  140435. /**
  140436. * 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
  140437. */
  140438. maximumSize: number;
  140439. /**
  140440. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140441. */
  140442. step: number;
  140443. /**
  140444. * Gets a string describing the action executed by the current optimization
  140445. * @returns description string
  140446. */
  140447. getDescription(): string;
  140448. /**
  140449. * Creates the TextureOptimization object
  140450. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140451. * @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
  140452. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140453. */
  140454. constructor(
  140455. /**
  140456. * Defines the priority of this optimization (0 by default which means first in the list)
  140457. */
  140458. priority?: number,
  140459. /**
  140460. * 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
  140461. */
  140462. maximumSize?: number,
  140463. /**
  140464. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140465. */
  140466. step?: number);
  140467. /**
  140468. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140469. * @param scene defines the current scene where to apply this optimization
  140470. * @param optimizer defines the current optimizer
  140471. * @returns true if everything that can be done was applied
  140472. */
  140473. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140474. }
  140475. /**
  140476. * Defines an optimization used to increase or decrease the rendering resolution
  140477. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140478. */
  140479. export class HardwareScalingOptimization extends SceneOptimization {
  140480. /**
  140481. * Defines the priority of this optimization (0 by default which means first in the list)
  140482. */
  140483. priority: number;
  140484. /**
  140485. * Defines the maximum scale to use (2 by default)
  140486. */
  140487. maximumScale: number;
  140488. /**
  140489. * Defines the step to use between two passes (0.5 by default)
  140490. */
  140491. step: number;
  140492. private _currentScale;
  140493. private _directionOffset;
  140494. /**
  140495. * Gets a string describing the action executed by the current optimization
  140496. * @return description string
  140497. */
  140498. getDescription(): string;
  140499. /**
  140500. * Creates the HardwareScalingOptimization object
  140501. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140502. * @param maximumScale defines the maximum scale to use (2 by default)
  140503. * @param step defines the step to use between two passes (0.5 by default)
  140504. */
  140505. constructor(
  140506. /**
  140507. * Defines the priority of this optimization (0 by default which means first in the list)
  140508. */
  140509. priority?: number,
  140510. /**
  140511. * Defines the maximum scale to use (2 by default)
  140512. */
  140513. maximumScale?: number,
  140514. /**
  140515. * Defines the step to use between two passes (0.5 by default)
  140516. */
  140517. step?: number);
  140518. /**
  140519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140520. * @param scene defines the current scene where to apply this optimization
  140521. * @param optimizer defines the current optimizer
  140522. * @returns true if everything that can be done was applied
  140523. */
  140524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140525. }
  140526. /**
  140527. * Defines an optimization used to remove shadows
  140528. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140529. */
  140530. export class ShadowsOptimization extends SceneOptimization {
  140531. /**
  140532. * Gets a string describing the action executed by the current optimization
  140533. * @return description string
  140534. */
  140535. getDescription(): string;
  140536. /**
  140537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140538. * @param scene defines the current scene where to apply this optimization
  140539. * @param optimizer defines the current optimizer
  140540. * @returns true if everything that can be done was applied
  140541. */
  140542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140543. }
  140544. /**
  140545. * Defines an optimization used to turn post-processes off
  140546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140547. */
  140548. export class PostProcessesOptimization extends SceneOptimization {
  140549. /**
  140550. * Gets a string describing the action executed by the current optimization
  140551. * @return description string
  140552. */
  140553. getDescription(): string;
  140554. /**
  140555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140556. * @param scene defines the current scene where to apply this optimization
  140557. * @param optimizer defines the current optimizer
  140558. * @returns true if everything that can be done was applied
  140559. */
  140560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140561. }
  140562. /**
  140563. * Defines an optimization used to turn lens flares off
  140564. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140565. */
  140566. export class LensFlaresOptimization extends SceneOptimization {
  140567. /**
  140568. * Gets a string describing the action executed by the current optimization
  140569. * @return description string
  140570. */
  140571. getDescription(): string;
  140572. /**
  140573. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140574. * @param scene defines the current scene where to apply this optimization
  140575. * @param optimizer defines the current optimizer
  140576. * @returns true if everything that can be done was applied
  140577. */
  140578. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140579. }
  140580. /**
  140581. * Defines an optimization based on user defined callback.
  140582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140583. */
  140584. export class CustomOptimization extends SceneOptimization {
  140585. /**
  140586. * Callback called to apply the custom optimization.
  140587. */
  140588. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  140589. /**
  140590. * Callback called to get custom description
  140591. */
  140592. onGetDescription: () => string;
  140593. /**
  140594. * Gets a string describing the action executed by the current optimization
  140595. * @returns description string
  140596. */
  140597. getDescription(): string;
  140598. /**
  140599. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140600. * @param scene defines the current scene where to apply this optimization
  140601. * @param optimizer defines the current optimizer
  140602. * @returns true if everything that can be done was applied
  140603. */
  140604. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140605. }
  140606. /**
  140607. * Defines an optimization used to turn particles off
  140608. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140609. */
  140610. export class ParticlesOptimization extends SceneOptimization {
  140611. /**
  140612. * Gets a string describing the action executed by the current optimization
  140613. * @return description string
  140614. */
  140615. getDescription(): string;
  140616. /**
  140617. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140618. * @param scene defines the current scene where to apply this optimization
  140619. * @param optimizer defines the current optimizer
  140620. * @returns true if everything that can be done was applied
  140621. */
  140622. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140623. }
  140624. /**
  140625. * Defines an optimization used to turn render targets off
  140626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140627. */
  140628. export class RenderTargetsOptimization extends SceneOptimization {
  140629. /**
  140630. * Gets a string describing the action executed by the current optimization
  140631. * @return description string
  140632. */
  140633. getDescription(): string;
  140634. /**
  140635. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140636. * @param scene defines the current scene where to apply this optimization
  140637. * @param optimizer defines the current optimizer
  140638. * @returns true if everything that can be done was applied
  140639. */
  140640. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140641. }
  140642. /**
  140643. * Defines an optimization used to merge meshes with compatible materials
  140644. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140645. */
  140646. export class MergeMeshesOptimization extends SceneOptimization {
  140647. private static _UpdateSelectionTree;
  140648. /**
  140649. * Gets or sets a boolean which defines if optimization octree has to be updated
  140650. */
  140651. static get UpdateSelectionTree(): boolean;
  140652. /**
  140653. * Gets or sets a boolean which defines if optimization octree has to be updated
  140654. */
  140655. static set UpdateSelectionTree(value: boolean);
  140656. /**
  140657. * Gets a string describing the action executed by the current optimization
  140658. * @return description string
  140659. */
  140660. getDescription(): string;
  140661. private _canBeMerged;
  140662. /**
  140663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140664. * @param scene defines the current scene where to apply this optimization
  140665. * @param optimizer defines the current optimizer
  140666. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  140667. * @returns true if everything that can be done was applied
  140668. */
  140669. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  140670. }
  140671. /**
  140672. * Defines a list of options used by SceneOptimizer
  140673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140674. */
  140675. export class SceneOptimizerOptions {
  140676. /**
  140677. * Defines the target frame rate to reach (60 by default)
  140678. */
  140679. targetFrameRate: number;
  140680. /**
  140681. * Defines the interval between two checkes (2000ms by default)
  140682. */
  140683. trackerDuration: number;
  140684. /**
  140685. * Gets the list of optimizations to apply
  140686. */
  140687. optimizations: SceneOptimization[];
  140688. /**
  140689. * Creates a new list of options used by SceneOptimizer
  140690. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  140691. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  140692. */
  140693. constructor(
  140694. /**
  140695. * Defines the target frame rate to reach (60 by default)
  140696. */
  140697. targetFrameRate?: number,
  140698. /**
  140699. * Defines the interval between two checkes (2000ms by default)
  140700. */
  140701. trackerDuration?: number);
  140702. /**
  140703. * Add a new optimization
  140704. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  140705. * @returns the current SceneOptimizerOptions
  140706. */
  140707. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  140708. /**
  140709. * Add a new custom optimization
  140710. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  140711. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  140712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140713. * @returns the current SceneOptimizerOptions
  140714. */
  140715. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  140716. /**
  140717. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  140718. * @param targetFrameRate defines the target frame rate (60 by default)
  140719. * @returns a SceneOptimizerOptions object
  140720. */
  140721. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140722. /**
  140723. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  140724. * @param targetFrameRate defines the target frame rate (60 by default)
  140725. * @returns a SceneOptimizerOptions object
  140726. */
  140727. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140728. /**
  140729. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  140730. * @param targetFrameRate defines the target frame rate (60 by default)
  140731. * @returns a SceneOptimizerOptions object
  140732. */
  140733. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140734. }
  140735. /**
  140736. * Class used to run optimizations in order to reach a target frame rate
  140737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140738. */
  140739. export class SceneOptimizer implements IDisposable {
  140740. private _isRunning;
  140741. private _options;
  140742. private _scene;
  140743. private _currentPriorityLevel;
  140744. private _targetFrameRate;
  140745. private _trackerDuration;
  140746. private _currentFrameRate;
  140747. private _sceneDisposeObserver;
  140748. private _improvementMode;
  140749. /**
  140750. * Defines an observable called when the optimizer reaches the target frame rate
  140751. */
  140752. onSuccessObservable: Observable<SceneOptimizer>;
  140753. /**
  140754. * Defines an observable called when the optimizer enables an optimization
  140755. */
  140756. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  140757. /**
  140758. * Defines an observable called when the optimizer is not able to reach the target frame rate
  140759. */
  140760. onFailureObservable: Observable<SceneOptimizer>;
  140761. /**
  140762. * Gets a boolean indicating if the optimizer is in improvement mode
  140763. */
  140764. get isInImprovementMode(): boolean;
  140765. /**
  140766. * Gets the current priority level (0 at start)
  140767. */
  140768. get currentPriorityLevel(): number;
  140769. /**
  140770. * Gets the current frame rate checked by the SceneOptimizer
  140771. */
  140772. get currentFrameRate(): number;
  140773. /**
  140774. * Gets or sets the current target frame rate (60 by default)
  140775. */
  140776. get targetFrameRate(): number;
  140777. /**
  140778. * Gets or sets the current target frame rate (60 by default)
  140779. */
  140780. set targetFrameRate(value: number);
  140781. /**
  140782. * Gets or sets the current interval between two checks (every 2000ms by default)
  140783. */
  140784. get trackerDuration(): number;
  140785. /**
  140786. * Gets or sets the current interval between two checks (every 2000ms by default)
  140787. */
  140788. set trackerDuration(value: number);
  140789. /**
  140790. * Gets the list of active optimizations
  140791. */
  140792. get optimizations(): SceneOptimization[];
  140793. /**
  140794. * Creates a new SceneOptimizer
  140795. * @param scene defines the scene to work on
  140796. * @param options defines the options to use with the SceneOptimizer
  140797. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  140798. * @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)
  140799. */
  140800. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  140801. /**
  140802. * Stops the current optimizer
  140803. */
  140804. stop(): void;
  140805. /**
  140806. * Reset the optimizer to initial step (current priority level = 0)
  140807. */
  140808. reset(): void;
  140809. /**
  140810. * Start the optimizer. By default it will try to reach a specific framerate
  140811. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  140812. */
  140813. start(): void;
  140814. private _checkCurrentState;
  140815. /**
  140816. * Release all resources
  140817. */
  140818. dispose(): void;
  140819. /**
  140820. * Helper function to create a SceneOptimizer with one single line of code
  140821. * @param scene defines the scene to work on
  140822. * @param options defines the options to use with the SceneOptimizer
  140823. * @param onSuccess defines a callback to call on success
  140824. * @param onFailure defines a callback to call on failure
  140825. * @returns the new SceneOptimizer object
  140826. */
  140827. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  140828. }
  140829. }
  140830. declare module BABYLON {
  140831. /**
  140832. * Class used to serialize a scene into a string
  140833. */
  140834. export class SceneSerializer {
  140835. /**
  140836. * Clear cache used by a previous serialization
  140837. */
  140838. static ClearCache(): void;
  140839. /**
  140840. * Serialize a scene into a JSON compatible object
  140841. * @param scene defines the scene to serialize
  140842. * @returns a JSON compatible object
  140843. */
  140844. static Serialize(scene: Scene): any;
  140845. /**
  140846. * Serialize a mesh into a JSON compatible object
  140847. * @param toSerialize defines the mesh to serialize
  140848. * @param withParents defines if parents must be serialized as well
  140849. * @param withChildren defines if children must be serialized as well
  140850. * @returns a JSON compatible object
  140851. */
  140852. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  140853. }
  140854. }
  140855. declare module BABYLON {
  140856. /**
  140857. * Class used to host texture specific utilities
  140858. */
  140859. export class TextureTools {
  140860. /**
  140861. * Uses the GPU to create a copy texture rescaled at a given size
  140862. * @param texture Texture to copy from
  140863. * @param width defines the desired width
  140864. * @param height defines the desired height
  140865. * @param useBilinearMode defines if bilinear mode has to be used
  140866. * @return the generated texture
  140867. */
  140868. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  140869. }
  140870. }
  140871. declare module BABYLON {
  140872. /**
  140873. * This represents the different options available for the video capture.
  140874. */
  140875. export interface VideoRecorderOptions {
  140876. /** Defines the mime type of the video. */
  140877. mimeType: string;
  140878. /** Defines the FPS the video should be recorded at. */
  140879. fps: number;
  140880. /** Defines the chunk size for the recording data. */
  140881. recordChunckSize: number;
  140882. /** The audio tracks to attach to the recording. */
  140883. audioTracks?: MediaStreamTrack[];
  140884. }
  140885. /**
  140886. * This can help with recording videos from BabylonJS.
  140887. * This is based on the available WebRTC functionalities of the browser.
  140888. *
  140889. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  140890. */
  140891. export class VideoRecorder {
  140892. private static readonly _defaultOptions;
  140893. /**
  140894. * Returns whether or not the VideoRecorder is available in your browser.
  140895. * @param engine Defines the Babylon Engine.
  140896. * @returns true if supported otherwise false.
  140897. */
  140898. static IsSupported(engine: Engine): boolean;
  140899. private readonly _options;
  140900. private _canvas;
  140901. private _mediaRecorder;
  140902. private _recordedChunks;
  140903. private _fileName;
  140904. private _resolve;
  140905. private _reject;
  140906. /**
  140907. * True when a recording is already in progress.
  140908. */
  140909. get isRecording(): boolean;
  140910. /**
  140911. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  140912. * @param engine Defines the BabylonJS Engine you wish to record.
  140913. * @param options Defines options that can be used to customize the capture.
  140914. */
  140915. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  140916. /**
  140917. * Stops the current recording before the default capture timeout passed in the startRecording function.
  140918. */
  140919. stopRecording(): void;
  140920. /**
  140921. * Starts recording the canvas for a max duration specified in parameters.
  140922. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  140923. * If null no automatic download will start and you can rely on the promise to get the data back.
  140924. * @param maxDuration Defines the maximum recording time in seconds.
  140925. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  140926. * @return A promise callback at the end of the recording with the video data in Blob.
  140927. */
  140928. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  140929. /**
  140930. * Releases internal resources used during the recording.
  140931. */
  140932. dispose(): void;
  140933. private _handleDataAvailable;
  140934. private _handleError;
  140935. private _handleStop;
  140936. }
  140937. }
  140938. declare module BABYLON {
  140939. /**
  140940. * Class containing a set of static utilities functions for screenshots
  140941. */
  140942. export class ScreenshotTools {
  140943. /**
  140944. * Captures a screenshot of the current rendering
  140945. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140946. * @param engine defines the rendering engine
  140947. * @param camera defines the source camera
  140948. * @param size This parameter can be set to a single number or to an object with the
  140949. * following (optional) properties: precision, width, height. If a single number is passed,
  140950. * it will be used for both width and height. If an object is passed, the screenshot size
  140951. * will be derived from the parameters. The precision property is a multiplier allowing
  140952. * rendering at a higher or lower resolution
  140953. * @param successCallback defines the callback receives a single parameter which contains the
  140954. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140955. * src parameter of an <img> to display it
  140956. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140957. * Check your browser for supported MIME types
  140958. */
  140959. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  140960. /**
  140961. * Captures a screenshot of the current rendering
  140962. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140963. * @param engine defines the rendering engine
  140964. * @param camera defines the source camera
  140965. * @param size This parameter can be set to a single number or to an object with the
  140966. * following (optional) properties: precision, width, height. If a single number is passed,
  140967. * it will be used for both width and height. If an object is passed, the screenshot size
  140968. * will be derived from the parameters. The precision property is a multiplier allowing
  140969. * rendering at a higher or lower resolution
  140970. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140971. * Check your browser for supported MIME types
  140972. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  140973. * to the src parameter of an <img> to display it
  140974. */
  140975. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  140976. /**
  140977. * Generates an image screenshot from the specified camera.
  140978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140979. * @param engine The engine to use for rendering
  140980. * @param camera The camera to use for rendering
  140981. * @param size This parameter can be set to a single number or to an object with the
  140982. * following (optional) properties: precision, width, height. If a single number is passed,
  140983. * it will be used for both width and height. If an object is passed, the screenshot size
  140984. * will be derived from the parameters. The precision property is a multiplier allowing
  140985. * rendering at a higher or lower resolution
  140986. * @param successCallback The callback receives a single parameter which contains the
  140987. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140988. * src parameter of an <img> to display it
  140989. * @param mimeType The MIME type of the screenshot image (default: image/png).
  140990. * Check your browser for supported MIME types
  140991. * @param samples Texture samples (default: 1)
  140992. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  140993. * @param fileName A name for for the downloaded file.
  140994. */
  140995. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  140996. /**
  140997. * Generates an image screenshot from the specified camera.
  140998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140999. * @param engine The engine to use for rendering
  141000. * @param camera The camera to use for rendering
  141001. * @param size This parameter can be set to a single number or to an object with the
  141002. * following (optional) properties: precision, width, height. If a single number is passed,
  141003. * it will be used for both width and height. If an object is passed, the screenshot size
  141004. * will be derived from the parameters. The precision property is a multiplier allowing
  141005. * rendering at a higher or lower resolution
  141006. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141007. * Check your browser for supported MIME types
  141008. * @param samples Texture samples (default: 1)
  141009. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141010. * @param fileName A name for for the downloaded file.
  141011. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141012. * to the src parameter of an <img> to display it
  141013. */
  141014. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141015. /**
  141016. * Gets height and width for screenshot size
  141017. * @private
  141018. */
  141019. private static _getScreenshotSize;
  141020. }
  141021. }
  141022. declare module BABYLON {
  141023. /**
  141024. * Interface for a data buffer
  141025. */
  141026. export interface IDataBuffer {
  141027. /**
  141028. * Reads bytes from the data buffer.
  141029. * @param byteOffset The byte offset to read
  141030. * @param byteLength The byte length to read
  141031. * @returns A promise that resolves when the bytes are read
  141032. */
  141033. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141034. /**
  141035. * The byte length of the buffer.
  141036. */
  141037. readonly byteLength: number;
  141038. }
  141039. /**
  141040. * Utility class for reading from a data buffer
  141041. */
  141042. export class DataReader {
  141043. /**
  141044. * The data buffer associated with this data reader.
  141045. */
  141046. readonly buffer: IDataBuffer;
  141047. /**
  141048. * The current byte offset from the beginning of the data buffer.
  141049. */
  141050. byteOffset: number;
  141051. private _dataView;
  141052. private _dataByteOffset;
  141053. /**
  141054. * Constructor
  141055. * @param buffer The buffer to read
  141056. */
  141057. constructor(buffer: IDataBuffer);
  141058. /**
  141059. * Loads the given byte length.
  141060. * @param byteLength The byte length to load
  141061. * @returns A promise that resolves when the load is complete
  141062. */
  141063. loadAsync(byteLength: number): Promise<void>;
  141064. /**
  141065. * Read a unsigned 32-bit integer from the currently loaded data range.
  141066. * @returns The 32-bit integer read
  141067. */
  141068. readUint32(): number;
  141069. /**
  141070. * Read a byte array from the currently loaded data range.
  141071. * @param byteLength The byte length to read
  141072. * @returns The byte array read
  141073. */
  141074. readUint8Array(byteLength: number): Uint8Array;
  141075. /**
  141076. * Read a string from the currently loaded data range.
  141077. * @param byteLength The byte length to read
  141078. * @returns The string read
  141079. */
  141080. readString(byteLength: number): string;
  141081. /**
  141082. * Skips the given byte length the currently loaded data range.
  141083. * @param byteLength The byte length to skip
  141084. */
  141085. skipBytes(byteLength: number): void;
  141086. }
  141087. }
  141088. declare module BABYLON {
  141089. /**
  141090. * A cursor which tracks a point on a path
  141091. */
  141092. export class PathCursor {
  141093. private path;
  141094. /**
  141095. * Stores path cursor callbacks for when an onchange event is triggered
  141096. */
  141097. private _onchange;
  141098. /**
  141099. * The value of the path cursor
  141100. */
  141101. value: number;
  141102. /**
  141103. * The animation array of the path cursor
  141104. */
  141105. animations: Animation[];
  141106. /**
  141107. * Initializes the path cursor
  141108. * @param path The path to track
  141109. */
  141110. constructor(path: Path2);
  141111. /**
  141112. * Gets the cursor point on the path
  141113. * @returns A point on the path cursor at the cursor location
  141114. */
  141115. getPoint(): Vector3;
  141116. /**
  141117. * Moves the cursor ahead by the step amount
  141118. * @param step The amount to move the cursor forward
  141119. * @returns This path cursor
  141120. */
  141121. moveAhead(step?: number): PathCursor;
  141122. /**
  141123. * Moves the cursor behind by the step amount
  141124. * @param step The amount to move the cursor back
  141125. * @returns This path cursor
  141126. */
  141127. moveBack(step?: number): PathCursor;
  141128. /**
  141129. * Moves the cursor by the step amount
  141130. * If the step amount is greater than one, an exception is thrown
  141131. * @param step The amount to move the cursor
  141132. * @returns This path cursor
  141133. */
  141134. move(step: number): PathCursor;
  141135. /**
  141136. * Ensures that the value is limited between zero and one
  141137. * @returns This path cursor
  141138. */
  141139. private ensureLimits;
  141140. /**
  141141. * Runs onchange callbacks on change (used by the animation engine)
  141142. * @returns This path cursor
  141143. */
  141144. private raiseOnChange;
  141145. /**
  141146. * Executes a function on change
  141147. * @param f A path cursor onchange callback
  141148. * @returns This path cursor
  141149. */
  141150. onchange(f: (cursor: PathCursor) => void): PathCursor;
  141151. }
  141152. }
  141153. declare module BABYLON {
  141154. /** @hidden */
  141155. export var blurPixelShader: {
  141156. name: string;
  141157. shader: string;
  141158. };
  141159. }
  141160. declare module BABYLON {
  141161. /** @hidden */
  141162. export var pointCloudVertexDeclaration: {
  141163. name: string;
  141164. shader: string;
  141165. };
  141166. }
  141167. // Mixins
  141168. interface Window {
  141169. mozIndexedDB: IDBFactory;
  141170. webkitIndexedDB: IDBFactory;
  141171. msIndexedDB: IDBFactory;
  141172. webkitURL: typeof URL;
  141173. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  141174. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  141175. WebGLRenderingContext: WebGLRenderingContext;
  141176. MSGesture: MSGesture;
  141177. CANNON: any;
  141178. AudioContext: AudioContext;
  141179. webkitAudioContext: AudioContext;
  141180. PointerEvent: any;
  141181. Math: Math;
  141182. Uint8Array: Uint8ArrayConstructor;
  141183. Float32Array: Float32ArrayConstructor;
  141184. mozURL: typeof URL;
  141185. msURL: typeof URL;
  141186. VRFrameData: any; // WebVR, from specs 1.1
  141187. DracoDecoderModule: any;
  141188. setImmediate(handler: (...args: any[]) => void): number;
  141189. }
  141190. interface HTMLCanvasElement {
  141191. requestPointerLock(): void;
  141192. msRequestPointerLock?(): void;
  141193. mozRequestPointerLock?(): void;
  141194. webkitRequestPointerLock?(): void;
  141195. /** Track wether a record is in progress */
  141196. isRecording: boolean;
  141197. /** Capture Stream method defined by some browsers */
  141198. captureStream(fps?: number): MediaStream;
  141199. }
  141200. interface CanvasRenderingContext2D {
  141201. msImageSmoothingEnabled: boolean;
  141202. }
  141203. interface MouseEvent {
  141204. mozMovementX: number;
  141205. mozMovementY: number;
  141206. webkitMovementX: number;
  141207. webkitMovementY: number;
  141208. msMovementX: number;
  141209. msMovementY: number;
  141210. }
  141211. interface Navigator {
  141212. mozGetVRDevices: (any: any) => any;
  141213. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141214. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141215. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141216. webkitGetGamepads(): Gamepad[];
  141217. msGetGamepads(): Gamepad[];
  141218. webkitGamepads(): Gamepad[];
  141219. }
  141220. interface HTMLVideoElement {
  141221. mozSrcObject: any;
  141222. }
  141223. interface Math {
  141224. fround(x: number): number;
  141225. imul(a: number, b: number): number;
  141226. }
  141227. interface WebGLRenderingContext {
  141228. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  141229. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  141230. vertexAttribDivisor(index: number, divisor: number): void;
  141231. createVertexArray(): any;
  141232. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  141233. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  141234. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  141235. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  141236. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  141237. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  141238. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  141239. // Queries
  141240. createQuery(): WebGLQuery;
  141241. deleteQuery(query: WebGLQuery): void;
  141242. beginQuery(target: number, query: WebGLQuery): void;
  141243. endQuery(target: number): void;
  141244. getQueryParameter(query: WebGLQuery, pname: number): any;
  141245. getQuery(target: number, pname: number): any;
  141246. MAX_SAMPLES: number;
  141247. RGBA8: number;
  141248. READ_FRAMEBUFFER: number;
  141249. DRAW_FRAMEBUFFER: number;
  141250. UNIFORM_BUFFER: number;
  141251. HALF_FLOAT_OES: number;
  141252. RGBA16F: number;
  141253. RGBA32F: number;
  141254. R32F: number;
  141255. RG32F: number;
  141256. RGB32F: number;
  141257. R16F: number;
  141258. RG16F: number;
  141259. RGB16F: number;
  141260. RED: number;
  141261. RG: number;
  141262. R8: number;
  141263. RG8: number;
  141264. UNSIGNED_INT_24_8: number;
  141265. DEPTH24_STENCIL8: number;
  141266. MIN: number;
  141267. MAX: number;
  141268. /* Multiple Render Targets */
  141269. drawBuffers(buffers: number[]): void;
  141270. readBuffer(src: number): void;
  141271. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  141272. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  141273. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  141274. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  141275. // Occlusion Query
  141276. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  141277. ANY_SAMPLES_PASSED: number;
  141278. QUERY_RESULT_AVAILABLE: number;
  141279. QUERY_RESULT: number;
  141280. }
  141281. interface WebGLProgram {
  141282. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  141283. }
  141284. interface EXT_disjoint_timer_query {
  141285. QUERY_COUNTER_BITS_EXT: number;
  141286. TIME_ELAPSED_EXT: number;
  141287. TIMESTAMP_EXT: number;
  141288. GPU_DISJOINT_EXT: number;
  141289. QUERY_RESULT_EXT: number;
  141290. QUERY_RESULT_AVAILABLE_EXT: number;
  141291. queryCounterEXT(query: WebGLQuery, target: number): void;
  141292. createQueryEXT(): WebGLQuery;
  141293. beginQueryEXT(target: number, query: WebGLQuery): void;
  141294. endQueryEXT(target: number): void;
  141295. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  141296. deleteQueryEXT(query: WebGLQuery): void;
  141297. }
  141298. interface WebGLUniformLocation {
  141299. _currentState: any;
  141300. }
  141301. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  141302. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  141303. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  141304. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141305. interface WebGLRenderingContext {
  141306. readonly RASTERIZER_DISCARD: number;
  141307. readonly DEPTH_COMPONENT24: number;
  141308. readonly TEXTURE_3D: number;
  141309. readonly TEXTURE_2D_ARRAY: number;
  141310. readonly TEXTURE_COMPARE_FUNC: number;
  141311. readonly TEXTURE_COMPARE_MODE: number;
  141312. readonly COMPARE_REF_TO_TEXTURE: number;
  141313. readonly TEXTURE_WRAP_R: number;
  141314. readonly HALF_FLOAT: number;
  141315. readonly RGB8: number;
  141316. readonly RED_INTEGER: number;
  141317. readonly RG_INTEGER: number;
  141318. readonly RGB_INTEGER: number;
  141319. readonly RGBA_INTEGER: number;
  141320. readonly R8_SNORM: number;
  141321. readonly RG8_SNORM: number;
  141322. readonly RGB8_SNORM: number;
  141323. readonly RGBA8_SNORM: number;
  141324. readonly R8I: number;
  141325. readonly RG8I: number;
  141326. readonly RGB8I: number;
  141327. readonly RGBA8I: number;
  141328. readonly R8UI: number;
  141329. readonly RG8UI: number;
  141330. readonly RGB8UI: number;
  141331. readonly RGBA8UI: number;
  141332. readonly R16I: number;
  141333. readonly RG16I: number;
  141334. readonly RGB16I: number;
  141335. readonly RGBA16I: number;
  141336. readonly R16UI: number;
  141337. readonly RG16UI: number;
  141338. readonly RGB16UI: number;
  141339. readonly RGBA16UI: number;
  141340. readonly R32I: number;
  141341. readonly RG32I: number;
  141342. readonly RGB32I: number;
  141343. readonly RGBA32I: number;
  141344. readonly R32UI: number;
  141345. readonly RG32UI: number;
  141346. readonly RGB32UI: number;
  141347. readonly RGBA32UI: number;
  141348. readonly RGB10_A2UI: number;
  141349. readonly R11F_G11F_B10F: number;
  141350. readonly RGB9_E5: number;
  141351. readonly RGB10_A2: number;
  141352. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  141353. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  141354. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  141355. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  141356. readonly DEPTH_COMPONENT32F: number;
  141357. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  141358. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  141359. 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;
  141360. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  141361. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  141362. readonly TRANSFORM_FEEDBACK: number;
  141363. readonly INTERLEAVED_ATTRIBS: number;
  141364. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  141365. createTransformFeedback(): WebGLTransformFeedback;
  141366. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  141367. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  141368. beginTransformFeedback(primitiveMode: number): void;
  141369. endTransformFeedback(): void;
  141370. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  141371. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141372. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141373. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141374. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  141375. }
  141376. interface ImageBitmap {
  141377. readonly width: number;
  141378. readonly height: number;
  141379. close(): void;
  141380. }
  141381. interface WebGLQuery extends WebGLObject {
  141382. }
  141383. declare var WebGLQuery: {
  141384. prototype: WebGLQuery;
  141385. new(): WebGLQuery;
  141386. };
  141387. interface WebGLSampler extends WebGLObject {
  141388. }
  141389. declare var WebGLSampler: {
  141390. prototype: WebGLSampler;
  141391. new(): WebGLSampler;
  141392. };
  141393. interface WebGLSync extends WebGLObject {
  141394. }
  141395. declare var WebGLSync: {
  141396. prototype: WebGLSync;
  141397. new(): WebGLSync;
  141398. };
  141399. interface WebGLTransformFeedback extends WebGLObject {
  141400. }
  141401. declare var WebGLTransformFeedback: {
  141402. prototype: WebGLTransformFeedback;
  141403. new(): WebGLTransformFeedback;
  141404. };
  141405. interface WebGLVertexArrayObject extends WebGLObject {
  141406. }
  141407. declare var WebGLVertexArrayObject: {
  141408. prototype: WebGLVertexArrayObject;
  141409. new(): WebGLVertexArrayObject;
  141410. };
  141411. // Type definitions for WebVR API
  141412. // Project: https://w3c.github.io/webvr/
  141413. // Definitions by: six a <https://github.com/lostfictions>
  141414. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141415. interface VRDisplay extends EventTarget {
  141416. /**
  141417. * Dictionary of capabilities describing the VRDisplay.
  141418. */
  141419. readonly capabilities: VRDisplayCapabilities;
  141420. /**
  141421. * z-depth defining the far plane of the eye view frustum
  141422. * enables mapping of values in the render target depth
  141423. * attachment to scene coordinates. Initially set to 10000.0.
  141424. */
  141425. depthFar: number;
  141426. /**
  141427. * z-depth defining the near plane of the eye view frustum
  141428. * enables mapping of values in the render target depth
  141429. * attachment to scene coordinates. Initially set to 0.01.
  141430. */
  141431. depthNear: number;
  141432. /**
  141433. * An identifier for this distinct VRDisplay. Used as an
  141434. * association point in the Gamepad API.
  141435. */
  141436. readonly displayId: number;
  141437. /**
  141438. * A display name, a user-readable name identifying it.
  141439. */
  141440. readonly displayName: string;
  141441. readonly isConnected: boolean;
  141442. readonly isPresenting: boolean;
  141443. /**
  141444. * If this VRDisplay supports room-scale experiences, the optional
  141445. * stage attribute contains details on the room-scale parameters.
  141446. */
  141447. readonly stageParameters: VRStageParameters | null;
  141448. /**
  141449. * Passing the value returned by `requestAnimationFrame` to
  141450. * `cancelAnimationFrame` will unregister the callback.
  141451. * @param handle Define the hanle of the request to cancel
  141452. */
  141453. cancelAnimationFrame(handle: number): void;
  141454. /**
  141455. * Stops presenting to the VRDisplay.
  141456. * @returns a promise to know when it stopped
  141457. */
  141458. exitPresent(): Promise<void>;
  141459. /**
  141460. * Return the current VREyeParameters for the given eye.
  141461. * @param whichEye Define the eye we want the parameter for
  141462. * @returns the eye parameters
  141463. */
  141464. getEyeParameters(whichEye: string): VREyeParameters;
  141465. /**
  141466. * Populates the passed VRFrameData with the information required to render
  141467. * the current frame.
  141468. * @param frameData Define the data structure to populate
  141469. * @returns true if ok otherwise false
  141470. */
  141471. getFrameData(frameData: VRFrameData): boolean;
  141472. /**
  141473. * Get the layers currently being presented.
  141474. * @returns the list of VR layers
  141475. */
  141476. getLayers(): VRLayer[];
  141477. /**
  141478. * Return a VRPose containing the future predicted pose of the VRDisplay
  141479. * when the current frame will be presented. The value returned will not
  141480. * change until JavaScript has returned control to the browser.
  141481. *
  141482. * The VRPose will contain the position, orientation, velocity,
  141483. * and acceleration of each of these properties.
  141484. * @returns the pose object
  141485. */
  141486. getPose(): VRPose;
  141487. /**
  141488. * Return the current instantaneous pose of the VRDisplay, with no
  141489. * prediction applied.
  141490. * @returns the current instantaneous pose
  141491. */
  141492. getImmediatePose(): VRPose;
  141493. /**
  141494. * The callback passed to `requestAnimationFrame` will be called
  141495. * any time a new frame should be rendered. When the VRDisplay is
  141496. * presenting the callback will be called at the native refresh
  141497. * rate of the HMD. When not presenting this function acts
  141498. * identically to how window.requestAnimationFrame acts. Content should
  141499. * make no assumptions of frame rate or vsync behavior as the HMD runs
  141500. * asynchronously from other displays and at differing refresh rates.
  141501. * @param callback Define the eaction to run next frame
  141502. * @returns the request handle it
  141503. */
  141504. requestAnimationFrame(callback: FrameRequestCallback): number;
  141505. /**
  141506. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  141507. * Repeat calls while already presenting will update the VRLayers being displayed.
  141508. * @param layers Define the list of layer to present
  141509. * @returns a promise to know when the request has been fulfilled
  141510. */
  141511. requestPresent(layers: VRLayer[]): Promise<void>;
  141512. /**
  141513. * Reset the pose for this display, treating its current position and
  141514. * orientation as the "origin/zero" values. VRPose.position,
  141515. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  141516. * updated when calling resetPose(). This should be called in only
  141517. * sitting-space experiences.
  141518. */
  141519. resetPose(): void;
  141520. /**
  141521. * The VRLayer provided to the VRDisplay will be captured and presented
  141522. * in the HMD. Calling this function has the same effect on the source
  141523. * canvas as any other operation that uses its source image, and canvases
  141524. * created without preserveDrawingBuffer set to true will be cleared.
  141525. * @param pose Define the pose to submit
  141526. */
  141527. submitFrame(pose?: VRPose): void;
  141528. }
  141529. declare var VRDisplay: {
  141530. prototype: VRDisplay;
  141531. new(): VRDisplay;
  141532. };
  141533. interface VRLayer {
  141534. leftBounds?: number[] | Float32Array | null;
  141535. rightBounds?: number[] | Float32Array | null;
  141536. source?: HTMLCanvasElement | null;
  141537. }
  141538. interface VRDisplayCapabilities {
  141539. readonly canPresent: boolean;
  141540. readonly hasExternalDisplay: boolean;
  141541. readonly hasOrientation: boolean;
  141542. readonly hasPosition: boolean;
  141543. readonly maxLayers: number;
  141544. }
  141545. interface VREyeParameters {
  141546. /** @deprecated */
  141547. readonly fieldOfView: VRFieldOfView;
  141548. readonly offset: Float32Array;
  141549. readonly renderHeight: number;
  141550. readonly renderWidth: number;
  141551. }
  141552. interface VRFieldOfView {
  141553. readonly downDegrees: number;
  141554. readonly leftDegrees: number;
  141555. readonly rightDegrees: number;
  141556. readonly upDegrees: number;
  141557. }
  141558. interface VRFrameData {
  141559. readonly leftProjectionMatrix: Float32Array;
  141560. readonly leftViewMatrix: Float32Array;
  141561. readonly pose: VRPose;
  141562. readonly rightProjectionMatrix: Float32Array;
  141563. readonly rightViewMatrix: Float32Array;
  141564. readonly timestamp: number;
  141565. }
  141566. interface VRPose {
  141567. readonly angularAcceleration: Float32Array | null;
  141568. readonly angularVelocity: Float32Array | null;
  141569. readonly linearAcceleration: Float32Array | null;
  141570. readonly linearVelocity: Float32Array | null;
  141571. readonly orientation: Float32Array | null;
  141572. readonly position: Float32Array | null;
  141573. readonly timestamp: number;
  141574. }
  141575. interface VRStageParameters {
  141576. sittingToStandingTransform?: Float32Array;
  141577. sizeX?: number;
  141578. sizeY?: number;
  141579. }
  141580. interface Navigator {
  141581. getVRDisplays(): Promise<VRDisplay[]>;
  141582. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  141583. }
  141584. interface Window {
  141585. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  141586. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  141587. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  141588. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141589. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141590. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  141591. }
  141592. interface Gamepad {
  141593. readonly displayId: number;
  141594. }
  141595. type XRSessionMode =
  141596. | "inline"
  141597. | "immersive-vr"
  141598. | "immersive-ar";
  141599. type XRReferenceSpaceType =
  141600. | "viewer"
  141601. | "local"
  141602. | "local-floor"
  141603. | "bounded-floor"
  141604. | "unbounded";
  141605. type XREnvironmentBlendMode =
  141606. | "opaque"
  141607. | "additive"
  141608. | "alpha-blend";
  141609. type XRVisibilityState =
  141610. | "visible"
  141611. | "visible-blurred"
  141612. | "hidden";
  141613. type XRHandedness =
  141614. | "none"
  141615. | "left"
  141616. | "right";
  141617. type XRTargetRayMode =
  141618. | "gaze"
  141619. | "tracked-pointer"
  141620. | "screen";
  141621. type XREye =
  141622. | "none"
  141623. | "left"
  141624. | "right";
  141625. interface XRSpace extends EventTarget {
  141626. }
  141627. interface XRRenderState {
  141628. depthNear?: number;
  141629. depthFar?: number;
  141630. inlineVerticalFieldOfView?: number;
  141631. baseLayer?: XRWebGLLayer;
  141632. }
  141633. interface XRInputSource {
  141634. handedness: XRHandedness;
  141635. targetRayMode: XRTargetRayMode;
  141636. targetRaySpace: XRSpace;
  141637. gripSpace: XRSpace | undefined;
  141638. gamepad: Gamepad | undefined;
  141639. profiles: Array<string>;
  141640. }
  141641. interface XRSessionInit {
  141642. optionalFeatures?: XRReferenceSpaceType[];
  141643. requiredFeatures?: XRReferenceSpaceType[];
  141644. }
  141645. interface XRSession extends XRAnchorCreator {
  141646. addEventListener: Function;
  141647. removeEventListener: Function;
  141648. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  141649. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  141650. requestAnimationFrame: Function;
  141651. end(): Promise<void>;
  141652. renderState: XRRenderState;
  141653. inputSources: Array<XRInputSource>;
  141654. // AR hit test
  141655. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141656. updateWorldTrackingState(options: {
  141657. planeDetectionState?: { enabled: boolean; }
  141658. }): void;
  141659. }
  141660. interface XRReferenceSpace extends XRSpace {
  141661. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  141662. onreset: any;
  141663. }
  141664. type XRPlaneSet = Set<XRPlane>;
  141665. type XRAnchorSet = Set<XRAnchor>;
  141666. interface XRFrame {
  141667. session: XRSession;
  141668. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  141669. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  141670. // Anchors
  141671. trackedAnchors?: XRAnchorSet;
  141672. // Planes
  141673. worldInformation: {
  141674. detectedPlanes?: XRPlaneSet;
  141675. };
  141676. }
  141677. interface XRViewerPose extends XRPose {
  141678. views: Array<XRView>;
  141679. }
  141680. interface XRPose {
  141681. transform: XRRigidTransform;
  141682. emulatedPosition: boolean;
  141683. }
  141684. interface XRWebGLLayerOptions {
  141685. antialias?: boolean;
  141686. depth?: boolean;
  141687. stencil?: boolean;
  141688. alpha?: boolean;
  141689. multiview?: boolean;
  141690. framebufferScaleFactor?: number;
  141691. }
  141692. declare var XRWebGLLayer: {
  141693. prototype: XRWebGLLayer;
  141694. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  141695. };
  141696. interface XRWebGLLayer {
  141697. framebuffer: WebGLFramebuffer;
  141698. framebufferWidth: number;
  141699. framebufferHeight: number;
  141700. getViewport: Function;
  141701. }
  141702. declare class XRRigidTransform {
  141703. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  141704. position: DOMPointReadOnly;
  141705. orientation: DOMPointReadOnly;
  141706. matrix: Float32Array;
  141707. inverse: XRRigidTransform;
  141708. }
  141709. interface XRView {
  141710. eye: XREye;
  141711. projectionMatrix: Float32Array;
  141712. transform: XRRigidTransform;
  141713. }
  141714. interface XRInputSourceChangeEvent {
  141715. session: XRSession;
  141716. removed: Array<XRInputSource>;
  141717. added: Array<XRInputSource>;
  141718. }
  141719. interface XRInputSourceEvent extends Event {
  141720. readonly frame: XRFrame;
  141721. readonly inputSource: XRInputSource;
  141722. }
  141723. // Experimental(er) features
  141724. declare class XRRay {
  141725. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  141726. origin: DOMPointReadOnly;
  141727. direction: DOMPointReadOnly;
  141728. matrix: Float32Array;
  141729. }
  141730. interface XRHitResult {
  141731. hitMatrix: Float32Array;
  141732. }
  141733. interface XRAnchor {
  141734. // remove?
  141735. id?: string;
  141736. anchorSpace: XRSpace;
  141737. lastChangedTime: number;
  141738. detach(): void;
  141739. }
  141740. interface XRPlane extends XRAnchorCreator {
  141741. orientation: "Horizontal" | "Vertical";
  141742. planeSpace: XRSpace;
  141743. polygon: Array<DOMPointReadOnly>;
  141744. lastChangedTime: number;
  141745. }
  141746. interface XRAnchorCreator {
  141747. // AR Anchors
  141748. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  141749. }